Files
geo/server/internal/shared/llm/ark_test.go
T
root 111498a65f feat: Refactor template handling and brand management
- Removed schema_json from article templates and related queries.
- Updated brand service to include website field in requests and responses.
- Simplified template wizard view by eliminating unused schema fields and related logic.
- Added tests for ark text format handling.
- Created migrations for dropping schema_json and adding website to brands.
2026-04-02 11:38:08 +08:00

66 lines
2.3 KiB
Go

package llm
import (
"testing"
"github.com/volcengine/volcengine-go-sdk/service/arkruntime/model/responses"
)
func TestBuildArkTextFormatJSONObjectDropsSchemaFields(t *testing.T) {
text := buildArkTextFormat(&ResponseFormat{
Type: ResponseFormatTypeJSONObject,
Name: "article_outline",
Description: "outline object",
SchemaJSON: []byte(`{"type":"object"}`),
Strict: true,
})
if text == nil || text.Format == nil {
t.Fatal("buildArkTextFormat() returned nil")
}
if got := text.Format.Type; got != responses.TextType_json_object {
t.Fatalf("buildArkTextFormat() type = %v, want %v", got, responses.TextType_json_object)
}
if text.Format.Name != "" {
t.Fatalf("buildArkTextFormat() name = %q, want empty for json_object", text.Format.Name)
}
if text.Format.Description != nil {
t.Fatalf("buildArkTextFormat() description = %v, want nil for json_object", *text.Format.Description)
}
if text.Format.Schema != nil {
t.Fatalf("buildArkTextFormat() schema = %v, want nil for json_object", text.Format.Schema)
}
if text.Format.Strict != nil {
t.Fatalf("buildArkTextFormat() strict = %v, want nil for json_object", *text.Format.Strict)
}
}
func TestBuildArkTextFormatJSONSchemaKeepsSchemaFields(t *testing.T) {
text := buildArkTextFormat(&ResponseFormat{
Type: ResponseFormatTypeJSONSchema,
Name: "article_outline",
Description: "outline object",
SchemaJSON: []byte(`{"type":"object"}`),
Strict: true,
})
if text == nil || text.Format == nil {
t.Fatal("buildArkTextFormat() returned nil")
}
if got := text.Format.Type; got != responses.TextType_json_schema {
t.Fatalf("buildArkTextFormat() type = %v, want %v", got, responses.TextType_json_schema)
}
if text.Format.Name != "article_outline" {
t.Fatalf("buildArkTextFormat() name = %q, want article_outline", text.Format.Name)
}
if text.Format.Description == nil || *text.Format.Description != "outline object" {
t.Fatalf("buildArkTextFormat() description = %v, want outline object", text.Format.Description)
}
if text.Format.Schema == nil || string(text.Format.Schema.Value) != `{"type":"object"}` {
t.Fatalf("buildArkTextFormat() schema = %v, want schema payload", text.Format.Schema)
}
if text.Format.Strict == nil || !*text.Format.Strict {
t.Fatalf("buildArkTextFormat() strict = %v, want true", text.Format.Strict)
}
}