Move prompts into embedded Markdown assets
This commit is contained in:
@@ -55,6 +55,7 @@ type Request struct {
|
||||
Config *config.Config `json:"-"`
|
||||
Messages []contracts.LLMMessage `json:"messages"`
|
||||
Model string `json:"model,omitempty"`
|
||||
PromptMetadata map[string]any `json:"prompt_metadata,omitempty"`
|
||||
StageName string `json:"stage_name,omitempty"`
|
||||
StartIndex int `json:"start_index"`
|
||||
LLMClient contracts.StructuredLLMClient
|
||||
@@ -137,6 +138,9 @@ func GenerateCandidates(ctx context.Context, req Request) (Result, error) {
|
||||
"start_index": req.StartIndex,
|
||||
"model": model,
|
||||
}
|
||||
if len(req.PromptMetadata) > 0 {
|
||||
requestMetadata["prompt_metadata"] = req.PromptMetadata
|
||||
}
|
||||
requestMetadata["response_schema"] = schemaMetadata(responseSchema)
|
||||
|
||||
if writer != nil {
|
||||
|
||||
@@ -191,6 +191,13 @@ func TestGenerateCandidatesDiagnosticsIncludeSchemaMetadata(t *testing.T) {
|
||||
req := defaultRequest(t)
|
||||
req.LLMClient = client
|
||||
req.DiagnosticsWriter = diag
|
||||
req.PromptMetadata = map[string]any{
|
||||
"prompt_id": "modules.grammar.proposal",
|
||||
"prompt_version": "v1",
|
||||
"prompt_source": "builtin",
|
||||
"embedded_path": "assets/modules/grammar",
|
||||
"sha256": "abc",
|
||||
}
|
||||
|
||||
_, err := GenerateCandidates(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -208,6 +215,13 @@ func TestGenerateCandidatesDiagnosticsIncludeSchemaMetadata(t *testing.T) {
|
||||
if schemaMap["id"] != want.ID || schemaMap["version"] != want.Version || schemaMap["name"] != want.Name || schemaMap["sha256"] != want.SHA256 {
|
||||
t.Fatalf("unexpected diagnostics schema metadata: got=%v want=%+v", schemaMap, want)
|
||||
}
|
||||
promptMap, ok := metadata["prompt_metadata"].(map[string]any)
|
||||
if !ok {
|
||||
t.Fatalf("expected prompt_metadata map, got %T", metadata["prompt_metadata"])
|
||||
}
|
||||
if promptMap["prompt_id"] != "modules.grammar.proposal" || promptMap["prompt_version"] != "v1" || promptMap["prompt_source"] != "builtin" || promptMap["embedded_path"] != "assets/modules/grammar" || promptMap["sha256"] != "abc" {
|
||||
t.Fatalf("unexpected prompt metadata map: %v", promptMap)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGenerateCandidatesMalformedStructuredResponse(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user