Small changes to prompt and models

This commit is contained in:
Phillip Michelsen
2026-07-19 15:07:41 +08:00
parent 535c437178
commit 8d630944ca
3 changed files with 192 additions and 76 deletions
@@ -73,7 +73,7 @@ func (c *Client) Prompt(ctx context.Context, model, description, dataURL, system
{Type: "image_url", ImageURL: &imageURL{URL: dataURL}},
}},
},
"response_format": map[string]any{"type": "json_schema", "json_schema": map[string]any{"name": "video_prompt", "strict": true, "schema": map[string]any{"type": "object", "properties": map[string]any{"video_prompt": map[string]string{"type": "string"}}, "required": []string{"video_prompt"}, "additionalProperties": false}}},
"response_format": map[string]any{"type": "json_object"},
}
resp, err := c.do(ctx, http.MethodPost, "/chat/completions", body)
if err != nil {
@@ -96,8 +96,9 @@ func (c *Client) Prompt(ctx context.Context, model, description, dataURL, system
var result struct {
VideoPrompt string `json:"video_prompt"`
}
content := out.Choices[0].Message.Content
if err = json.Unmarshal([]byte(out.Choices[0].Message.Content), &result); err != nil {
return "", err
return "", fmt.Errorf("invalid JSON from model: %w\ncontent=%q", err, content)
}
if strings.TrimSpace(result.VideoPrompt) == "" {
return "", fmt.Errorf("empty video prompt")