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

@ -70,6 +70,9 @@ func (p *OllamaProvider) Summarize(ctx context.Context, prompt string, opts GenO
if opts.JSONMode {
body["format"] = "json"
}
if len(opts.JSONSchema) > 0 {
body["format"] = opts.JSONSchema
}
b, _ := json.Marshal(body)
req, err := http.NewRequestWithContext(ctx, http.MethodPost, p.endpoint+"/api/generate", bytes.NewReader(b))
if err != nil {
@ -89,11 +92,16 @@ func (p *OllamaProvider) Summarize(ctx context.Context, prompt string, opts GenO
}
var result struct {
Response string `json:"response"`
Done bool `json:"done"`
DoneReason string `json:"done_reason"`
Response string `json:"response"`
}
if err := json.Unmarshal(raw, &result); err != nil {
return "", err
}
if opts.RequireComplete && (!result.Done || result.DoneReason != "stop") {
return "", errGenerationIncomplete
}
return result.Response, nil
}