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