feat(generation): score articles with selected relevance model (#48)

This commit is contained in:
2026-11-25 18:09:36 +01:00
parent c5b8d0d4da
commit 90dd2a65d2
53 changed files with 1639 additions and 105 deletions

View File

@ -29,6 +29,9 @@ func newAnthropic(apiKey, model string) *anthropicProvider {
func (p *anthropicProvider) Name() string { return "anthropic" }
func (p *anthropicProvider) Summarize(ctx context.Context, prompt string, opts GenOptions) (string, error) {
if len(opts.JSONSchema) > 0 {
return "", errStructuredOutputUnsupported
}
maxTokens := opts.MaxOutputTokens
if maxTokens <= 0 {
maxTokens = 4096
@ -61,7 +64,8 @@ func (p *anthropicProvider) Summarize(ctx context.Context, prompt string, opts G
}
var result struct {
Content []struct {
StopReason string `json:"stop_reason"`
Content []struct {
Text string `json:"text"`
} `json:"content"`
}
@ -71,6 +75,9 @@ func (p *anthropicProvider) Summarize(ctx context.Context, prompt string, opts G
if len(result.Content) == 0 {
return "", nil
}
if opts.RequireComplete && result.StopReason != "end_turn" {
return "", errGenerationIncomplete
}
return result.Content[0].Text, nil
}