Merge features-c2: the docs portal and its links in English and Turkish
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
commit
e8a62b23b7
201 files changed
+26276
-630
No files matched your search
@@ -546,7 +546,7 @@ func describeServe(l *Lang, m catalog.Model) string {
|
||||
return ""
|
||||
}
|
||||
p := m.Profiles[0]
|
||||
engine := map[string]string{"llamacpp": "llama.cpp", "vllm": "vLLM", "sglang": "SGLang"}[p.Engine]
|
||||
engine := map[string]string{"llamacpp": "llama.cpp", "vllm": "vLLM", "sglang": "SGLang", "trtllm": "TensorRT-LLM"}[p.Engine]
|
||||
if engine == "" {
|
||||
engine = p.Engine
|
||||
}
|
||||
|
||||
@@ -0,0 +1,258 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"html/template"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"path"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/yuin/goldmark"
|
||||
"github.com/yuin/goldmark/ast"
|
||||
"github.com/yuin/goldmark/extension"
|
||||
"github.com/yuin/goldmark/parser"
|
||||
"github.com/yuin/goldmark/text"
|
||||
"github.com/yuin/goldmark/util"
|
||||
|
||||
llmgw "gitea.mynodes.xyz/ilker/llmgw"
|
||||
)
|
||||
|
||||
// The docs portal: the manual the binary carries, the pages `llmgw docs` and
|
||||
// the console show, rendered as a website at /docs on the client port.
|
||||
//
|
||||
// Public by default, like the landing page and for the same reason: the
|
||||
// person who needs the client guide is the one who does not have an account
|
||||
// yet. The operator documents describe how llmgw is deployed in general, not
|
||||
// this deployment — no address, no model, no key — so publishing them tells a
|
||||
// stranger what the project's own repository already does. A site that would
|
||||
// rather not say even that sets landing.docs_sign_in.
|
||||
//
|
||||
// Only the embedded documents are rendered, never anything a visitor sent, and
|
||||
// in goldmark's safe mode all the same: raw HTML in a document is dropped
|
||||
// rather than trusted, so a page here can never carry a script for the
|
||||
// Content-Security-Policy to have to refuse.
|
||||
|
||||
// docLink is one entry of the portal's sidebar.
|
||||
type docLink struct{ Key, Title string }
|
||||
|
||||
// docSection is a second-level heading, offered under the open document.
|
||||
type docSection struct{ ID, Title string }
|
||||
|
||||
// renderedDoc is a document turned into HTML once, when first asked for.
|
||||
type renderedDoc struct {
|
||||
docLink
|
||||
Sections []docSection
|
||||
Body template.HTML
|
||||
}
|
||||
|
||||
// docsData is what the docs template is rendered with.
|
||||
type docsData struct {
|
||||
Version string
|
||||
// Doc is the open document; nil on the index.
|
||||
Doc *renderedDoc
|
||||
Docs []docLink
|
||||
// Clients is the client developer's guide, which the index leads with.
|
||||
Clients *docLink
|
||||
// Nav is the menu of whoever is signed in, and SignedIn whether anyone is.
|
||||
Nav Nav
|
||||
SignedIn bool
|
||||
// SignIn offers a sign-in link to someone who is not.
|
||||
SignIn bool
|
||||
}
|
||||
|
||||
// manualOnce renders every document the first time the portal is opened:
|
||||
// the configuration reference alone is two thousand lines, and rendering it
|
||||
// again on every request would be work for nothing — the documents change
|
||||
// only when the binary does.
|
||||
var (
|
||||
manualOnce sync.Once
|
||||
manualDocs []renderedDoc
|
||||
)
|
||||
|
||||
func manual() []renderedDoc {
|
||||
manualOnce.Do(func() {
|
||||
docs := llmgw.Manual()
|
||||
paths := map[string]string{}
|
||||
for _, d := range docs {
|
||||
paths[d.Path] = d.Key
|
||||
}
|
||||
for _, d := range docs {
|
||||
body, sections := renderDoc(d.Source(), d.Path, paths)
|
||||
manualDocs = append(manualDocs, renderedDoc{
|
||||
docLink: docLink{Key: d.Key, Title: d.Title}, Sections: sections, Body: body,
|
||||
})
|
||||
}
|
||||
})
|
||||
return manualDocs
|
||||
}
|
||||
|
||||
// renderDoc turns one embedded document into HTML. from is its path in the
|
||||
// embed, which its relative links are resolved against; paths are the paths
|
||||
// of every document the portal has, by key.
|
||||
func renderDoc(src, from string, paths map[string]string) (template.HTML, []docSection) {
|
||||
t := &docTransform{from: from, paths: paths}
|
||||
md := goldmark.New(
|
||||
goldmark.WithExtensions(extension.GFM),
|
||||
goldmark.WithParserOptions(
|
||||
// The same ids GitHub gives headings, which is what the documents'
|
||||
// own #links were written against.
|
||||
parser.WithAutoHeadingID(),
|
||||
parser.WithASTTransformers(util.Prioritized(t, 100))),
|
||||
)
|
||||
var out bytes.Buffer
|
||||
if err := md.Convert([]byte(src), &out); err != nil {
|
||||
return template.HTML("<p>This document could not be rendered.</p>"), nil
|
||||
}
|
||||
// goldmark in its default, safe mode over documents compiled into the
|
||||
// binary, with links rewritten below: not something to escape again.
|
||||
return template.HTML(out.String()), t.sections //nolint:gosec
|
||||
}
|
||||
|
||||
// docTransform rewrites a document's links for the portal, gives every
|
||||
// heading a link to itself, and collects the sections for the sidebar.
|
||||
type docTransform struct {
|
||||
from string
|
||||
paths map[string]string
|
||||
sections []docSection
|
||||
}
|
||||
|
||||
func (t *docTransform) Transform(doc *ast.Document, reader text.Reader, _ parser.Context) {
|
||||
src := reader.Source()
|
||||
var headings []*ast.Heading
|
||||
_ = ast.Walk(doc, func(n ast.Node, entering bool) (ast.WalkStatus, error) {
|
||||
if !entering {
|
||||
return ast.WalkContinue, nil
|
||||
}
|
||||
switch n := n.(type) {
|
||||
case *ast.Link:
|
||||
n.Destination = []byte(t.rewrite(string(n.Destination)))
|
||||
case *ast.Heading:
|
||||
headings = append(headings, n)
|
||||
}
|
||||
return ast.WalkContinue, nil
|
||||
})
|
||||
// After the walk, so the links added here are not themselves rewritten.
|
||||
for _, h := range headings {
|
||||
id, ok := h.AttributeString("id")
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
idStr := string(id.([]byte))
|
||||
if h.Level == 2 {
|
||||
t.sections = append(t.sections, docSection{ID: idStr, Title: plainText(h, src)})
|
||||
}
|
||||
a := ast.NewLink()
|
||||
a.Destination = []byte("#" + idStr)
|
||||
a.Title = []byte("Link to this section")
|
||||
a.SetAttributeString("class", []byte("anchor"))
|
||||
a.AppendChild(a, ast.NewString([]byte("#")))
|
||||
h.AppendChild(h, a)
|
||||
}
|
||||
}
|
||||
|
||||
// rewrite points a link at where its target is served from.
|
||||
//
|
||||
// A link to another document becomes its page under /docs, keeping the
|
||||
// section it names. A link to anything else in the repository — deploy/,
|
||||
// the backlog, the design plan — is not in the binary, so it goes to the
|
||||
// repository itself rather than to a 404 here. Absolute links and links
|
||||
// within the page are left alone.
|
||||
func (t *docTransform) rewrite(dest string) string {
|
||||
u, err := url.Parse(dest)
|
||||
if err != nil || u.Scheme != "" || u.Host != "" || u.Path == "" || strings.HasPrefix(u.Path, "/") {
|
||||
return dest
|
||||
}
|
||||
target := path.Clean(path.Join(path.Dir(t.from), u.Path))
|
||||
frag := ""
|
||||
if u.Fragment != "" {
|
||||
frag = "#" + u.EscapedFragment()
|
||||
}
|
||||
if key, ok := t.paths[target]; ok {
|
||||
return "/docs/" + key + frag
|
||||
}
|
||||
if strings.HasPrefix(target, "../") {
|
||||
return dest // outside the repository: nothing better to point it at
|
||||
}
|
||||
if strings.HasSuffix(u.Path, "/") {
|
||||
target += "/"
|
||||
}
|
||||
return repoURL + "/src/branch/main/" + target + frag
|
||||
}
|
||||
|
||||
// plainText is a heading's words without their markup: "`name`" is "name".
|
||||
func plainText(n ast.Node, src []byte) string {
|
||||
var b strings.Builder
|
||||
_ = ast.Walk(n, func(c ast.Node, entering bool) (ast.WalkStatus, error) {
|
||||
if !entering {
|
||||
return ast.WalkContinue, nil
|
||||
}
|
||||
switch c := c.(type) {
|
||||
case *ast.Text:
|
||||
b.Write(c.Segment.Value(src))
|
||||
if c.SoftLineBreak() {
|
||||
b.WriteByte(' ')
|
||||
}
|
||||
case *ast.String:
|
||||
b.Write(c.Value)
|
||||
}
|
||||
return ast.WalkContinue, nil
|
||||
})
|
||||
return b.String()
|
||||
}
|
||||
|
||||
// Docs serves the portal: the index at /docs and a document at
|
||||
// /docs/{doc}. signIn is whether this gateway has accounts to sign in to,
|
||||
// which decides whether the page offers it.
|
||||
func Docs(version string, signIn bool) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
docs := manual()
|
||||
d := docsData{Version: version, SignIn: signIn}
|
||||
if n, ok := r.Context().Value(navKey{}).(Nav); ok {
|
||||
n.Current = "docs"
|
||||
d.Nav, d.SignedIn = n, true
|
||||
}
|
||||
for i := range docs {
|
||||
d.Docs = append(d.Docs, docs[i].docLink)
|
||||
if docs[i].Key == "clients" {
|
||||
d.Clients = &docs[i].docLink
|
||||
}
|
||||
}
|
||||
key := strings.TrimSuffix(strings.ToLower(r.PathValue("doc")), ".md")
|
||||
if key == "" {
|
||||
render(w, r, "docs", d)
|
||||
return
|
||||
}
|
||||
for i := range docs {
|
||||
if docs[i].Key == key {
|
||||
d.Doc = &docs[i]
|
||||
render(w, r, "docs", d)
|
||||
return
|
||||
}
|
||||
}
|
||||
http.NotFound(w, r)
|
||||
}
|
||||
}
|
||||
|
||||
// DocsPage serves the docs portal with the menu of whoever is signed in and,
|
||||
// when required is set, to nobody else: someone not signed in is sent to sign
|
||||
// in, as every other page that needs a session does.
|
||||
func (p *AccountPages) DocsPage(docs http.HandlerFunc, required bool) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
_, user, ok := p.session(r)
|
||||
if !ok {
|
||||
if required {
|
||||
noStore(w)
|
||||
http.Redirect(w, r, "/login", http.StatusSeeOther)
|
||||
return
|
||||
}
|
||||
docs(w, r)
|
||||
return
|
||||
}
|
||||
// The page carries this person's menu, so no cache may keep it for
|
||||
// the next.
|
||||
noStore(w)
|
||||
docs(w, p.withNav(r, user))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"io"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
llmgw "gitea.mynodes.xyz/ilker/llmgw"
|
||||
"gitea.mynodes.xyz/ilker/llmgw/internal/store"
|
||||
)
|
||||
|
||||
// docsMux mounts the portal the way the router does.
|
||||
func docsMux(h http.HandlerFunc) *http.ServeMux {
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("GET /docs", h)
|
||||
mux.HandleFunc("GET /docs/{doc}", h)
|
||||
return mux
|
||||
}
|
||||
|
||||
func TestTheDocsPortalRendersADocumentWithItsHeadingsAndCode(t *testing.T) {
|
||||
code, body := get(t, docsMux(Docs("v1", false)), "/docs/clients", nil)
|
||||
if code != http.StatusOK {
|
||||
t.Fatalf("status %d", code)
|
||||
}
|
||||
for _, want := range []string{
|
||||
`<h1 id="using-llmgw-from-code">Using llmgw from code`,
|
||||
// A heading links to itself, for someone sending a section to someone.
|
||||
`<h2 id="streaming">Streaming<a href="#streaming"`,
|
||||
// Fenced code keeps its language, and its text is escaped, not markup.
|
||||
`<pre><code class="language-python">`,
|
||||
`client.chat.completions.create(`,
|
||||
// Tables are GitHub's.
|
||||
`<table>`,
|
||||
// The sidebar offers every document and marks the open one.
|
||||
`<a href="/docs/clients" aria-current="page">Using llmgw from code</a>`,
|
||||
`<a href="/docs/reference">`,
|
||||
// And this document's sections beneath it.
|
||||
`<a href="#the-anthropic-sdk">The Anthropic SDK</a>`,
|
||||
} {
|
||||
if !strings.Contains(body, want) {
|
||||
t.Errorf("the page lacks %q", want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestEveryDocumentInTheManualIsAPage(t *testing.T) {
|
||||
h := docsMux(Docs("v1", false))
|
||||
for _, d := range llmgw.Manual() {
|
||||
if code, _ := get(t, h, "/docs/"+d.Key, nil); code != http.StatusOK {
|
||||
t.Errorf("/docs/%s: %d", d.Key, code)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestTheIndexLeadsWithTheClientGuide(t *testing.T) {
|
||||
code, body := get(t, docsMux(Docs("v1", true)), "/docs", nil)
|
||||
if code != http.StatusOK {
|
||||
t.Fatalf("status %d", code)
|
||||
}
|
||||
lead := strings.Index(body, `<a href="/docs/clients">Using llmgw from code</a> shows`)
|
||||
every := strings.Index(body, "Every document")
|
||||
if lead < 0 || every < 0 || lead > every {
|
||||
t.Errorf("the client guide is not offered first:\n%s", body)
|
||||
}
|
||||
if !strings.Contains(body, `<a href="/login">Sign in</a>`) {
|
||||
t.Error("a gateway with accounts does not offer to sign in")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLinksBetweenDocumentsStayInThePortal(t *testing.T) {
|
||||
paths := map[string]string{"docs/install.md": "install", "docs/guardrails.md": "guardrails",
|
||||
"README.md": "readme", "CHANGELOG.md": "changes"}
|
||||
src := "See [install](install.md), [a section](install.md#2-the-control-plane), " +
|
||||
"[here](#local), [the readme](../README.md), [proxies](../deploy/proxy/), " +
|
||||
"[the plan](llmgw-plan.md) and [elsewhere](https://example.com/x.md).\n"
|
||||
body, _ := renderDoc(src, "docs/guardrails.md", paths)
|
||||
for _, want := range []string{
|
||||
`href="/docs/install"`,
|
||||
`href="/docs/install#2-the-control-plane"`,
|
||||
`href="#local"`,
|
||||
`href="/docs/readme"`,
|
||||
// Not in the binary: the repository has it.
|
||||
`href="` + repoURL + `/src/branch/main/deploy/proxy/"`,
|
||||
`href="` + repoURL + `/src/branch/main/docs/llmgw-plan.md"`,
|
||||
`href="https://example.com/x.md"`,
|
||||
} {
|
||||
if !strings.Contains(string(body), want) {
|
||||
t.Errorf("rendered without %s:\n%s", want, body)
|
||||
}
|
||||
}
|
||||
// The README links into docs/ from the repository's root.
|
||||
body, _ = renderDoc("[guardrails](docs/guardrails.md)\n", "README.md", paths)
|
||||
if !strings.Contains(string(body), `href="/docs/guardrails"`) {
|
||||
t.Errorf("a link from the README: %s", body)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNoEmbeddedDocumentLinksToAPageThePortalLacks(t *testing.T) {
|
||||
// Every link a document makes into /docs/ must land on a page, or the
|
||||
// portal ships its own 404s.
|
||||
keys := map[string]bool{}
|
||||
for _, d := range manual() {
|
||||
keys[d.Key] = true
|
||||
}
|
||||
for _, d := range manual() {
|
||||
for _, part := range strings.Split(string(d.Body), `href="/docs/`)[1:] {
|
||||
key := part[:strings.IndexAny(part, `"#`)]
|
||||
if !keys[key] {
|
||||
t.Errorf("%s links to /docs/%s, which is not a page", d.Key, key)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestAnUnknownDocumentIsNotFound(t *testing.T) {
|
||||
h := docsMux(Docs("v1", false))
|
||||
for _, path := range []string{"/docs/no-such-doc", "/docs/..%2fgo.mod", "/docs/BACKLOG"} {
|
||||
if code, _ := get(t, h, path, nil); code != http.StatusNotFound {
|
||||
t.Errorf("%s: %d, want 404", path, code)
|
||||
}
|
||||
}
|
||||
// The file name works as well as the key: it is what the documents say.
|
||||
if code, _ := get(t, h, "/docs/install.md", nil); code != http.StatusOK {
|
||||
t.Errorf("/docs/install.md: %d", code)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTheDocsCarryThePolicyAndNoScript(t *testing.T) {
|
||||
for _, path := range []string{"/docs", "/docs/clients", "/docs/reference", "/docs/readme"} {
|
||||
rec := httptest.NewRecorder()
|
||||
docsMux(Docs("v1", false)).ServeHTTP(rec, httptest.NewRequest("GET", path, nil))
|
||||
csp := rec.Header().Get("Content-Security-Policy")
|
||||
if !strings.Contains(csp, "script-src 'self';") || strings.Contains(csp, "sha256-") {
|
||||
t.Errorf("%s: policy %q, want this server's scripts and no inline one", path, csp)
|
||||
}
|
||||
if strings.Contains(strings.ToLower(rec.Body.String()), "<script") {
|
||||
t.Errorf("%s emits a script", path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestTheDocsCanRequireSigningIn(t *testing.T) {
|
||||
a := fakeAccounts{user: store.User{ID: "u1", Email: "a@example.com"}}
|
||||
p := NewAccountPages(a, nil, nil, "v0", slog.New(slog.NewTextHandler(io.Discard, nil)))
|
||||
|
||||
required := docsMux(p.DocsPage(Docs("v0", true), true))
|
||||
rec := httptest.NewRecorder()
|
||||
required.ServeHTTP(rec, httptest.NewRequest("GET", "/docs/install", nil))
|
||||
if rec.Code != http.StatusSeeOther || rec.Header().Get("Location") != "/login" {
|
||||
t.Errorf("without a session: %d to %q, want a redirect to /login", rec.Code, rec.Header().Get("Location"))
|
||||
}
|
||||
signedIn := mirrorGet(t, required, "/docs/install")
|
||||
if signedIn.Code != http.StatusOK {
|
||||
t.Fatalf("signed in: %d", signedIn.Code)
|
||||
}
|
||||
// Signed in, the page draws the portal's menu with Docs marked.
|
||||
if menu := menuRe.FindString(signedIn.Body.String()); !strings.Contains(menu, `aria-current="page">Docs<`) ||
|
||||
!strings.Contains(menu, `"/logout"`) {
|
||||
t.Errorf("the signed-in menu:\n%s", menu)
|
||||
}
|
||||
if !strings.Contains(signedIn.Header().Get("Cache-Control"), "no-store") {
|
||||
t.Error("a page with someone's menu on it may be cached")
|
||||
}
|
||||
|
||||
public := docsMux(p.DocsPage(Docs("v0", true), false))
|
||||
rec = httptest.NewRecorder()
|
||||
public.ServeHTTP(rec, httptest.NewRequest("GET", "/docs/install", nil))
|
||||
if rec.Code != http.StatusOK || strings.Contains(rec.Body.String(), `"/logout"`) {
|
||||
t.Errorf("public, without a session: %d", rec.Code)
|
||||
}
|
||||
}
|
||||
@@ -457,3 +457,24 @@ func TestACatalogueWithAKeyTwiceIsRefused(t *testing.T) {
|
||||
t.Errorf("%v %v", m, err)
|
||||
}
|
||||
}
|
||||
|
||||
// The docs portal's own pages are translated; the documents themselves are
|
||||
// English, and a Turkish reader is told so rather than left to find out.
|
||||
func TestTheDocsPortalSpeaksTurkishAroundEnglishDocuments(t *testing.T) {
|
||||
r := httptest.NewRequest(http.MethodGet, "/docs", nil)
|
||||
r.Header.Set("Accept-Language", "tr")
|
||||
w := httptest.NewRecorder()
|
||||
Docs("v1", true)(w, r)
|
||||
body := w.Body.String()
|
||||
for _, want := range []string{`<html lang="tr">`, "llmgw belgeleri", "Tüm belgeler", "yalnızca İngilizcedir", `href="/_lang/en"`} {
|
||||
if !strings.Contains(body, want) {
|
||||
t.Errorf("the Turkish docs index lacks %q", want)
|
||||
}
|
||||
}
|
||||
r = httptest.NewRequest(http.MethodGet, "/docs", nil)
|
||||
w = httptest.NewRecorder()
|
||||
Docs("v1", true)(w, r)
|
||||
if strings.Contains(w.Body.String(), "İngilizce") || !strings.Contains(w.Body.String(), "Every document") {
|
||||
t.Error("the English docs index is not as it was")
|
||||
}
|
||||
}
|
||||
@@ -147,5 +147,6 @@
|
||||
"profile.err.try_again": "something went wrong; try again",
|
||||
"profile.err.not_member": "you are not a member of that project",
|
||||
"profile.err.wrong_password": "that is not your current password",
|
||||
"profile.err.same_password": "that is the password you already have"
|
||||
"profile.err.same_password": "that is the password you already have",
|
||||
"connect.own_code": "From your own code: the official OpenAI and Anthropic SDKs work as they are —\nthe <a href=\"/docs/clients\">client guide</a> shows how, in Python, TypeScript, Go and curl."
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"docs.title": "llmgw docs",
|
||||
"docs.description": "How to use and run llmgw: the client guide, installation, operation and the configuration reference.",
|
||||
"docs.this_gateway": "This gateway",
|
||||
"docs.about": "About llmgw",
|
||||
"docs.documents": "Documents",
|
||||
"docs.sub": "The manual this gateway's software carries — the same pages\n<code>llmgw docs</code> prints and the console's Manual shows.",
|
||||
"docs.from_code": "Using the gateway from code",
|
||||
"docs.from_code_text": "The official OpenAI and Anthropic SDKs work as they are: only the base URL\n and the key change. <a href=\"/docs/%s\">%s</a> shows Python,\n TypeScript, Go and curl for chat, streaming, tools, embeddings, the Responses\n API, batches, and what llmgw adds — stored conversations, tags, sessions and\n memory notes.",
|
||||
"docs.every": "Every document",
|
||||
"docs.general": "The documents describe llmgw in general, not this installation:\nthey name no address, model or key of it.",
|
||||
"docs.english_only": "",
|
||||
"docs.footer": "docs"
|
||||
}
|
||||
@@ -30,5 +30,6 @@
|
||||
"landing.anything_works": "Anything that speaks the chat-completions API works, whether or not it\nis listed here — there is nothing llmgw-specific to install.",
|
||||
"landing.once_you_have_key": "Once you have a key",
|
||||
"landing.models_endpoint": "what your key may use",
|
||||
"landing.me_endpoint": "its limits, and what it has spent"
|
||||
"landing.me_endpoint": "its limits, and what it has spent",
|
||||
"landing.client_guide": "The <a href=\"/docs/clients\">client guide</a> has more: streaming, tools, embeddings and the Anthropic SDK."
|
||||
}
|
||||
@@ -9,5 +9,6 @@
|
||||
"nav.guard": "Guardrails",
|
||||
"nav.chat": "Chat",
|
||||
"nav.account": "Account",
|
||||
"nav.sign_out": "Sign out"
|
||||
"nav.sign_out": "Sign out",
|
||||
"nav.docs": "Docs"
|
||||
}
|
||||
@@ -147,5 +147,6 @@
|
||||
"profile.err.try_again": "bir sorun oluştu; yeniden deneyin",
|
||||
"profile.err.not_member": "o projenin üyesi değilsiniz",
|
||||
"profile.err.wrong_password": "mevcut parolanız bu değil",
|
||||
"profile.err.same_password": "bu zaten kullandığınız parola"
|
||||
"profile.err.same_password": "bu zaten kullandığınız parola",
|
||||
"connect.own_code": "Kendi kodunuzdan: resmî OpenAI ve Anthropic SDK'ları olduğu gibi çalışır;\nnasıl yapılacağını <a href=\"/docs/clients\">istemci kılavuzu</a> Python, TypeScript, Go ve curl ile gösteriyor."
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"docs.title": "llmgw belgeleri",
|
||||
"docs.description": "llmgw'nin kullanımı ve işletimi: istemci kılavuzu, kurulum, işletim ve yapılandırma başvurusu.",
|
||||
"docs.this_gateway": "Bu ağ geçidi",
|
||||
"docs.about": "llmgw hakkında",
|
||||
"docs.documents": "Belgeler",
|
||||
"docs.sub": "Bu ağ geçidinin yazılımıyla birlikte gelen kılavuz: <code>llmgw docs</code> komutunun yazdırdığı\nve konsoldaki Kılavuz ekranının gösterdiği sayfaların aynısı.",
|
||||
"docs.from_code": "Ağ geçidini koddan kullanmak",
|
||||
"docs.from_code_text": "Resmî OpenAI ve Anthropic SDK'ları olduğu gibi çalışır: yalnızca temel URL ile anahtar değişir.\n <a href=\"/docs/%s\">%s</a>; sohbet, akış, araçlar, gömmeler, Responses API'si, toplu işler ve\n llmgw'nin eklediklerini (saklanan sohbetler, etiketler, oturumlar ve bellek notları)\n Python, TypeScript, Go ve curl örnekleriyle gösterir.",
|
||||
"docs.every": "Tüm belgeler",
|
||||
"docs.general": "Belgeler bu kurulumu değil, genel olarak llmgw'yi anlatır:\nbu kuruluma ait hiçbir adres, model ya da anahtar içermez.",
|
||||
"docs.english_only": "Belgelerin kendisi yalnızca İngilizcedir.",
|
||||
"docs.footer": "belgeler"
|
||||
}
|
||||
@@ -30,5 +30,6 @@
|
||||
"landing.anything_works": "Chat completions API'sini konuşan her şey çalışır, burada listelenmiş olsun ya da olmasın;\nllmgw'ye özel kurulacak hiçbir şey yoktur.",
|
||||
"landing.once_you_have_key": "Anahtarınızı aldıktan sonra",
|
||||
"landing.models_endpoint": "anahtarınızın kullanabildikleri",
|
||||
"landing.me_endpoint": "sınırları ve şimdiye kadarki harcaması"
|
||||
"landing.me_endpoint": "sınırları ve şimdiye kadarki harcaması",
|
||||
"landing.client_guide": "Daha fazlası <a href=\"/docs/clients\">istemci kılavuzunda</a>: akış, araçlar, gömmeler (embeddings) ve Anthropic SDK."
|
||||
}
|
||||
@@ -9,5 +9,6 @@
|
||||
"nav.guard": "Koruma kuralları",
|
||||
"nav.chat": "Sohbet",
|
||||
"nav.account": "Hesap",
|
||||
"nav.sign_out": "Çıkış yap"
|
||||
"nav.sign_out": "Çıkış yap",
|
||||
"nav.docs": "Belgeler"
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/* The docs portal, over base.css: a sidebar of the documents beside the one
|
||||
being read. Its own file so the pages that have no use for it do not carry
|
||||
it. */
|
||||
.docs-head { margin-bottom: 1.5rem; }
|
||||
.docs-brand { margin: 0; font-weight: 600; font-size: 1.05rem; }
|
||||
.docs-brand a { color: var(--fg); text-decoration: none; }
|
||||
|
||||
.docs { display: grid; grid-template-columns: 15rem minmax(0, 1fr); gap: 2.5rem; align-items: start; }
|
||||
.docs-side { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow-y: auto;
|
||||
font-size: .88rem; padding-right: .25rem; }
|
||||
.docs-side ul { list-style: none; padding: 0; margin: 0; }
|
||||
.docs-side li { margin: 0; }
|
||||
.docs-side a { display: block; padding: .22rem .55rem; border-radius: 5px;
|
||||
color: var(--muted); text-decoration: none; }
|
||||
.docs-side a:hover { color: var(--fg); }
|
||||
.docs-side a[aria-current="page"] { color: var(--fg); background: var(--card);
|
||||
font-weight: 600; border: 1px solid var(--line); }
|
||||
.docs-side .sections { margin: .25rem 0 .6rem .7rem; padding-left: .3rem;
|
||||
border-left: 1px solid var(--line); font-size: .82rem; }
|
||||
.docs-side .sections a { padding: .12rem .45rem; }
|
||||
|
||||
.doc { line-height: 1.65; min-width: 0; }
|
||||
.doc h1 { font-size: 1.7rem; margin: 0 0 1rem; }
|
||||
.doc h2 { font-size: 1.2rem; margin: 2.6rem 0 .8rem; padding-top: 1rem; border-top: 1px solid var(--line); }
|
||||
.doc h3 { font-size: 1rem; margin: 1.8rem 0 .5rem; }
|
||||
.doc h4 { font-size: .93rem; margin: 1.4rem 0 .4rem; }
|
||||
.doc :is(h1, h2, h3, h4) { scroll-margin-top: 1rem; }
|
||||
.doc .anchor { margin-left: .4rem; color: var(--muted); text-decoration: none;
|
||||
font-weight: 400; opacity: 0; }
|
||||
.doc :is(h1, h2, h3, h4):hover .anchor, .doc .anchor:focus-visible { opacity: 1; }
|
||||
.doc pre { line-height: 1.45; }
|
||||
.doc :not(pre) > code { background: var(--card); border: 1px solid var(--line);
|
||||
border-radius: 4px; padding: .05rem .3rem; }
|
||||
.doc table { display: block; overflow-x: auto; margin: .8rem 0 1.4rem; width: auto; max-width: 100%; }
|
||||
.doc th { text-transform: none; letter-spacing: 0; font-size: .82rem; }
|
||||
.doc blockquote { margin: 1rem 0; padding: .2rem 1rem; border-left: 3px solid var(--accent);
|
||||
background: var(--card); border-radius: 0 6px 6px 0; }
|
||||
.doc img { max-width: 100%; }
|
||||
.doc li > p { margin: .2rem 0; }
|
||||
|
||||
.docs-lead { background: var(--card); border: 1px solid var(--line); border-radius: 8px;
|
||||
padding: .2rem 1.1rem .9rem; margin: 1.5rem 0; }
|
||||
.docs-lead h2 { border-top: none; padding-top: 0; margin-top: 1rem; }
|
||||
.docs-index { columns: 2 16rem; }
|
||||
|
||||
@media (max-width: 760px) {
|
||||
.docs { grid-template-columns: 1fr; gap: 1rem; }
|
||||
.docs-side { position: static; max-height: none; border-bottom: 1px solid var(--line);
|
||||
padding-bottom: 1rem; }
|
||||
}
|
||||
@@ -99,6 +99,7 @@
|
||||
|
||||
<h2>{{t "connect.heading"}}</h2>
|
||||
<p class="note">{{t "connect.intro"}}</p>
|
||||
<p class="note">{{th "connect.own_code"}}</p>
|
||||
<form method="post" action="/profile/connect#connected" class="connect-form">
|
||||
<input type="hidden" name="csrf" value="{{.CSRF}}">
|
||||
<div class="field-row">
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
{{/* The docs portal: the manual the binary carries, as a website. No script
|
||||
at all — a sidebar of links and a rendered document need none, and the
|
||||
policy then has nothing to allow. */}}
|
||||
{{define "docs"}}<!doctype html>
|
||||
<html lang="{{lang}}"><head>
|
||||
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>{{if .Doc}}{{.Doc.Title}} · {{end}}{{t "docs.title"}}</title>
|
||||
<meta name="description" content="{{t "docs.description"}}">
|
||||
<link rel="stylesheet" href="{{stylesheet}}">
|
||||
<link rel="stylesheet" href="{{asset "docs.css"}}">
|
||||
</head><body><div class="wrap">
|
||||
<header class="docs-head">
|
||||
<p class="docs-brand"><a href="/docs">{{t "docs.title"}}</a></p>
|
||||
{{if .SignedIn}}{{template "nav" .Nav}}{{else}}
|
||||
<nav class="menu" aria-label="{{t "nav.aria"}}">
|
||||
<a href="/">{{t "docs.this_gateway"}}</a>
|
||||
<a href="/docs"{{if not .Doc}} aria-current="page"{{end}}>{{t "nav.docs"}}</a>
|
||||
<a href="/about">{{t "docs.about"}}</a>
|
||||
{{if .SignIn}}<a href="/login">{{t "landing.sign_in"}}</a>{{end}}
|
||||
</nav>{{end}}
|
||||
</header>
|
||||
|
||||
<div class="docs">
|
||||
<aside class="docs-side" aria-label="{{t "docs.documents"}}">
|
||||
<ul>
|
||||
{{range .Docs}}
|
||||
<li><a href="/docs/{{.Key}}"{{if and $.Doc (eq $.Doc.Key .Key)}} aria-current="page"{{end}}>{{.Title}}</a>
|
||||
{{- if and $.Doc (eq $.Doc.Key .Key) $.Doc.Sections}}
|
||||
<ul class="sections">{{range $.Doc.Sections}}
|
||||
<li><a href="#{{.ID}}">{{.Title}}</a></li>{{end}}
|
||||
</ul>
|
||||
{{- end}}</li>
|
||||
{{end}}
|
||||
</ul>
|
||||
</aside>
|
||||
|
||||
<main class="doc">
|
||||
{{if .Doc}}
|
||||
{{.Doc.Body}}
|
||||
{{else}}
|
||||
<h1>{{t "docs.title"}}</h1>
|
||||
<p class="sub">{{th "docs.sub"}}</p>
|
||||
|
||||
{{with .Clients}}
|
||||
<section class="docs-lead">
|
||||
<h2>{{t "docs.from_code"}}</h2>
|
||||
<p>{{th "docs.from_code_text" .Key .Title}}</p>
|
||||
</section>
|
||||
{{end}}
|
||||
|
||||
<h2>{{t "docs.every"}}</h2>
|
||||
<ul class="docs-index">
|
||||
{{range .Docs}} <li><a href="/docs/{{.Key}}">{{.Title}}</a></li>
|
||||
{{end}}</ul>
|
||||
<p class="note">{{t "docs.general"}}</p>
|
||||
{{with t "docs.english_only"}}<p class="note">{{.}}</p>{{end}}
|
||||
{{end}}
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<footer><span><a href="/about">llmgw {{.Version}}</a></span><span><a href="/docs">{{t "docs.footer"}}</a></span>{{template "langs"}}</footer>
|
||||
</div></body></html>{{end}}
|
||||
@@ -163,7 +163,7 @@ print(reply.choices[0].message.content)</code></pre>
|
||||
}</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<p class="note">{{t "landing.anything_works"}}</p>
|
||||
<p class="note">{{t "landing.anything_works"}} {{th "landing.client_guide"}}</p>
|
||||
|
||||
<h2>{{t "landing.once_you_have_key"}}</h2>
|
||||
<ul class="endpoints">
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
{{- end}}
|
||||
<a href="/chat"{{if eq .Current "chat"}} aria-current="page"{{end}}>{{t "nav.chat"}}</a>
|
||||
<a href="/profile"{{if eq .Current "keys"}} aria-current="page"{{end}}>{{t "nav.account"}}</a>
|
||||
<a href="/docs"{{if eq .Current "docs"}} aria-current="page"{{end}}>{{t "nav.docs"}}</a>
|
||||
<form method="post" action="/logout" class="inline">
|
||||
<input type="hidden" name="csrf" value="{{.CSRF}}">
|
||||
<button type="submit" class="link">{{t "nav.sign_out"}}</button>
|
||||
|
||||
Reference in new issue
Block a user