feat(generation): score articles with selected relevance model (#48)
This commit is contained in:
@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user