Plan v0.2'nin Faz 0 çıktısı. Yazılan sıraya göre:
- cobra tabanlı CLI iskeleti; server/agent/ctl komutları henüz stub.
- internal/sim: OpenAI uyumlu sahte inference engine. Router'ı GPU olmadan
gerçekçi koşullarda test edebilmek için gerçek bir engine'in router
açısından önemli davranışlarını modeller:
* continuous batching ve KV blok muhasebesi (head-of-line blocking dahil)
* zincirlenmiş blok hash'leri + LRU ile otomatik prefix cache
* batch büyüdükçe artan token gecikmesi
* istemci koptuğunda isteğin düşürülüp blokların bırakılması
* vLLM metrik adlarıyla /metrics (plan §7.6 engine kontratı)
- Testler: prefix hash zincirlemesi, LRU tahliyesi, iptal propagasyonu,
kuyruklama, SSE formatı, usage/cached_tokens, metriklerin gerçek
Prometheus parser'ıyla okunabilirliği.
- Gitea Actions CI: gofmt, vet, race detector.
Modül yolu gitea.mynodes.xyz/ilker/llmgw; `make rename` ile değiştirilebilir.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
25 lines
616 B
Go
25 lines
616 B
Go
package sim
|
||
|
||
import "testing"
|
||
|
||
func TestTokenizeOnEkKararli(t *testing.T) {
|
||
a := Tokenize("merhaba")
|
||
b := Tokenize("merhaba dunya")
|
||
if len(a) > len(b) {
|
||
t.Fatal("uzun metin daha az token verdi")
|
||
}
|
||
for i := range a[:len(a)-1] { // son token yarım olabilir
|
||
if a[i] != b[i] {
|
||
t.Fatalf("token %d ön ek kararlı değil", i)
|
||
}
|
||
}
|
||
}
|
||
|
||
func TestCountTokensTokenizeIleTutarli(t *testing.T) {
|
||
for _, s := range []string{"", "a", "abcd", "abcde", "uzunca bir prompt metni"} {
|
||
if got, want := CountTokens(s), len(Tokenize(s)); got != want {
|
||
t.Errorf("%q: CountTokens=%d Tokenize=%d", s, got, want)
|
||
}
|
||
}
|
||
}
|