a06f331eb8
CI / benchmark (push) Has been skipped
install-script / posix-syntax (push) Successful in 6m1s
CI / build-onnx (push) Failing after 6m43s
init-smoke / dry-run (push) Failing after 15m57s
security / govulncheck (push) Has been cancelled
security / trivy-fs (push) Has been cancelled
CI / test (1.26, ubuntu-latest) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
CI / test (1.26, macos-latest) (push) Has been cancelled
CI / build-windows (push) Has been cancelled
CI / lint (push) Has been cancelled
install-script / powershell-syntax (push) Has been cancelled
install-script / install (macos-14) (push) Has been cancelled
install-script / install (ubuntu-latest) (push) Has been cancelled
91 lines
2.6 KiB
Go
91 lines
2.6 KiB
Go
package llm
|
|
|
|
import "testing"
|
|
|
|
func TestProfileForProvider(t *testing.T) {
|
|
cases := map[string]PromptProfile{
|
|
"anthropic": ProfileFrontier,
|
|
"openai": ProfileFrontier,
|
|
"claudecli": ProfileFrontier,
|
|
"gemini": ProfileFrontier,
|
|
"bedrock": ProfileFrontier,
|
|
"deepseek": ProfileFrontier,
|
|
"local": ProfileSmall,
|
|
"ollama": ProfileSmall,
|
|
"": ProfileSmall,
|
|
"unknown": ProfileSmall,
|
|
}
|
|
for name, want := range cases {
|
|
if got := ProfileForProvider(name); got != want {
|
|
t.Errorf("ProfileForProvider(%q)=%v want %v", name, got, want)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestSystemPrompts_DifferByTier(t *testing.T) {
|
|
if ExpandSystemPrompt(ProfileSmall) == ExpandSystemPrompt(ProfileFrontier) {
|
|
t.Error("expand prompt identical across tiers")
|
|
}
|
|
if RerankSystemPrompt(ProfileSmall) == RerankSystemPrompt(ProfileFrontier) {
|
|
t.Error("rerank prompt identical across tiers")
|
|
}
|
|
if VerifySystemPrompt(ProfileSmall) == VerifySystemPrompt(ProfileFrontier) {
|
|
t.Error("verify prompt identical across tiers")
|
|
}
|
|
for _, s := range []string{
|
|
ExpandSystemPrompt(ProfileSmall), ExpandSystemPrompt(ProfileFrontier),
|
|
RerankSystemPrompt(ProfileSmall), RerankSystemPrompt(ProfileFrontier),
|
|
VerifySystemPrompt(ProfileSmall), VerifySystemPrompt(ProfileFrontier),
|
|
} {
|
|
if s == "" {
|
|
t.Error("empty system prompt")
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestJSONSchemaFor_Freeform(t *testing.T) {
|
|
if JSONSchemaFor(ShapeFreeform, nil) != nil {
|
|
t.Error("freeform shape must have no schema")
|
|
}
|
|
}
|
|
|
|
func TestJSONSchemaFor_ListShapes(t *testing.T) {
|
|
cases := map[JSONShape]string{
|
|
ShapeExpandTerms: "terms",
|
|
ShapeRerankOrder: "order",
|
|
ShapeVerifyKeep: "keep",
|
|
}
|
|
for shape, key := range cases {
|
|
s := JSONSchemaFor(shape, nil)
|
|
if s == nil {
|
|
t.Fatalf("shape %d: nil schema", shape)
|
|
}
|
|
if s["type"] != "object" {
|
|
t.Errorf("shape %d: type=%v want object", shape, s["type"])
|
|
}
|
|
props, ok := s["properties"].(map[string]any)
|
|
if !ok {
|
|
t.Fatalf("shape %d: properties not a map: %v", shape, s["properties"])
|
|
}
|
|
if _, ok := props[key]; !ok {
|
|
t.Errorf("shape %d: missing property %q (have %v)", shape, key, props)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestJSONSchemaFor_ToolCallEnumeratesNames(t *testing.T) {
|
|
s := JSONSchemaFor(ShapeToolCall, []ToolSpec{{Name: "search_symbols"}, {Name: "get_callers"}})
|
|
props := s["properties"].(map[string]any)
|
|
tool := props["tool"].(map[string]any)
|
|
enum, ok := tool["enum"].([]any)
|
|
if !ok || len(enum) != 2 {
|
|
t.Fatalf("tool enum=%v", tool["enum"])
|
|
}
|
|
if enum[0] != "search_symbols" || enum[1] != "get_callers" {
|
|
t.Errorf("tool enum order=%v", enum)
|
|
}
|
|
if _, ok := props["args"]; !ok {
|
|
t.Error("tool-call schema missing args property")
|
|
}
|
|
}
|