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

@ -44,18 +44,26 @@ func (b *boundedCLICapture) Write(p []byte) (int, error) {
return len(p), nil
}
func (p *claudeCodeProvider) Summarize(ctx context.Context, prompt string, opts GenOptions) (string, error) {
if len(opts.JSONSchema) > 0 {
return "", errStructuredOutputUnsupported
}
var stdout boundedCLICapture
testMode, _ := ctx.Value(modelTestContextKey{}).(bool)
structuredMode := testMode || opts.RequireComplete
args := []string{"-p", prompt, "--model", p.model}
if testMode {
if structuredMode {
args = append(args, "--output-format", "json", "--no-session-persistence")
}
cmd := exec.CommandContext(ctx, "claude", args...)
cmd.Stdout = &stdout
cmd.Stderr = io.Discard
cmd.WaitDelay = 250 * time.Millisecond
if testMode {
overrides := map[string]string{"CLAUDE_CODE_MAX_OUTPUT_TOKENS": strconv.Itoa(opts.MaxOutputTokens), "CLAUDE_CODE_MAX_RETRIES": "0", "CLAUDE_CODE_RETRY_WATCHDOG": "", "MAX_THINKING_TOKENS": "0"}
if structuredMode {
outputTokens := opts.MaxOutputTokens
if outputTokens <= 0 {
outputTokens = 4096
}
overrides := map[string]string{"CLAUDE_CODE_MAX_OUTPUT_TOKENS": strconv.Itoa(outputTokens), "CLAUDE_CODE_MAX_RETRIES": "0", "CLAUDE_CODE_RETRY_WATCHDOG": "", "MAX_THINKING_TOKENS": "0"}
cmd.Env = []string{}
for _, entry := range os.Environ() {
key, _, _ := strings.Cut(entry, "=")
@ -74,7 +82,7 @@ func (p *claudeCodeProvider) Summarize(ctx context.Context, prompt string, opts
if stdout.overflow {
return "", errors.New("claude cli: response unavailable")
}
if testMode {
if structuredMode {
raw := stdout.buffer.Bytes()
code := generationErrorCode(raw)
if code != "" {