Switch the project language to English
CI / test (push) Has been cancelled

Comments, doc comments, test names, error and log messages, CLI help, README,
Makefile, CI step names and the design document are now all in English.
No behaviour changes; the full suite passes under the race detector.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
ilkerandClaude Opus 5 committed 2026-09-16 01:15:21 +02:00
1 parent b7417e1a69
commit 28029eb43b
21 files changed
+910 -869

No files matched your search

+16 -16
View File
@@ -9,14 +9,14 @@ import (
"time"
)
// Server, Engine'i OpenAI uyumlu bir HTTP yüzeyiyle sarar.
// Server wraps an Engine in an OpenAI-compatible HTTP surface.
type Server struct {
eng *Engine
log *slog.Logger
mux *http.ServeMux
}
// NewServer, engine için HTTP yüzeyini kurar.
// NewServer builds the HTTP surface for an engine.
func NewServer(eng *Engine, log *slog.Logger) *Server {
if log == nil {
log = slog.Default()
@@ -32,7 +32,7 @@ func NewServer(eng *Engine, log *slog.Logger) *Server {
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { s.mux.ServeHTTP(w, r) }
// --- istek/yanıt tipleri (yalnızca gereken alanlar) ---
// --- request/response types (only the fields we need) ---
type streamOptions struct {
IncludeUsage bool `json:"include_usage"`
@@ -64,15 +64,15 @@ type usage struct {
PromptTokens int `json:"prompt_tokens"`
CompletionTokens int `json:"completion_tokens"`
TotalTokens int `json:"total_tokens"`
// OpenAI uyumlu cache raporlaması; prefix cache etkisini istemciye gösterir.
// OpenAI-compatible cache reporting; surfaces the prefix cache to clients.
PromptTokensDetails struct {
CachedTokens int `json:"cached_tokens"`
} `json:"prompt_tokens_details"`
}
// text, mesaj içeriğini düz metne indirger.
// İçerik string ya da parça dizisi olabilir; sim için ikisini de kaba şekilde
// metne çeviriyoruz, çünkü tek ihtiyacımız deterministik bir token sayısı.
// text reduces a message's content to plain text.
// Content may be a string or an array of parts; the simulation coerces both
// crudely, since all it needs is a deterministic token count.
func (m chatMessage) text() string {
var s string
if err := json.Unmarshal(m.Content, &s); err == nil {
@@ -92,7 +92,7 @@ func promptFromMessages(msgs []chatMessage) string {
return b.String()
}
// --- handler'lar ---
// --- handlers ---
func (s *Server) handleChat(w http.ResponseWriter, r *http.Request) {
var req chatRequest
@@ -168,7 +168,7 @@ func (s *Server) handleMetrics(w http.ResponseWriter, _ *http.Request) {
s.eng.WriteMetrics(w)
}
// --- ortak akış ---
// --- shared request flow ---
type servePlan struct {
prompt Prompt
@@ -241,7 +241,7 @@ func (s *Server) bufferedResponse(w http.ResponseWriter, ch <-chan Event, p serv
func (s *Server) streamResponse(w http.ResponseWriter, r *http.Request, ch <-chan Event, p servePlan, id string, created int64) {
flusher, ok := w.(http.Flusher)
if !ok {
writeError(w, http.StatusInternalServerError, "server_error", "streaming desteklenmiyor")
writeError(w, http.StatusInternalServerError, "server_error", "streaming not supported")
return
}
h := w.Header()
@@ -256,7 +256,7 @@ func (s *Server) streamResponse(w http.ResponseWriter, r *http.Request, ch <-cha
for {
select {
case <-r.Context().Done():
// İstemci koptu. Engine reap() ile isteği batch'ten düşürecek.
// Client disconnected; the engine's reap() drops it from the batch.
return
case ev, open := <-ch:
if !open {
@@ -291,7 +291,7 @@ func (s *Server) streamResponse(w http.ResponseWriter, r *http.Request, ch <-cha
func (s *Server) writeChunk(w http.ResponseWriter, v any) {
b, err := json.Marshal(v)
if err != nil {
s.log.Error("chunk serileştirilemedi", "err", err)
s.log.Error("failed to marshal chunk", "err", err)
return
}
fmt.Fprintf(w, "data: %s\n\n", b)
@@ -319,7 +319,7 @@ func chunk(id string, p servePlan, created int64, text *string, finish string, u
out := map[string]any{
"id": id, "object": p.chunkObject, "created": created, "model": p.model,
}
// Usage chunk'ında choices boş dizi olur (OpenAI davranışı).
// The usage chunk carries an empty choices array (OpenAI behaviour).
if u != nil {
out["choices"] = []map[string]any{}
out["usage"] = u
@@ -329,9 +329,9 @@ func chunk(id string, p servePlan, created int64, text *string, finish string, u
return out
}
// usage, mümkünse engine'in raporladığı gerçek sayıları kullanır.
// res nil olabilir (istek iptal edildiyse veya hata aldıysa); o durumda
// prompt token sayısı metinden hesaplanır ve cached_tokens bilinmez.
// usage prefers the counts the engine reported. res may be nil (cancelled or
// failed request), in which case prompt tokens are derived from the text and
// cached_tokens is unknown.
func (s *Server) usage(p Prompt, completion int, res *Result) usage {
var u usage
u.PromptTokens = CountTokens(p.Text)