Add AI-powered evidence description generation

Introduce a background worker that automatically generates
compliance-focused descriptions for uploaded evidence files
using configurable LLM providers. Descriptions are surfaced
across all interfaces: GraphQL API, MCP API, CLI, and the
console UI.

Key changes:
- Multi-provider LLM config with per-agent settings (pointer
  types for Temperature/MaxTokens to preserve zero values)
- Evidence description worker with bounded concurrency
- EvidenceDescriptionStatus typed enum with PostgreSQL enum type
- New `prb evidence` CLI commands (list, view, delete)
- Evidence description displayed in console table and preview
- Migration only marks evidences without files as completed

Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
Bryan Frimin
2026-03-26 14:30:04 +01:00
parent 8bbed534a9
commit 619ec7b882
24 changed files with 1390 additions and 125 deletions

View File

@@ -16,11 +16,13 @@ package anthropic
import (
"context"
"encoding/base64"
"encoding/json"
"errors"
"fmt"
"net/http"
"strconv"
"strings"
"time"
"github.com/anthropics/anthropic-sdk-go"
@@ -185,6 +187,8 @@ func buildMessages(messages []llm.Message) []anthropic.MessageParam {
},
),
)
case llm.FilePart:
blocks = append(blocks, buildFilePart(p))
}
}
out = append(out, anthropic.NewUserMessage(blocks...))
@@ -460,3 +464,24 @@ func (s *anthropicStream) mapStreamEvent(event *anthropic.MessageStreamEventUnio
return llm.ChatCompletionStreamEvent{}, false
}
}
func buildFilePart(p llm.FilePart) anthropic.ContentBlockParamUnion {
switch {
case strings.HasPrefix(p.MimeType, "image/"):
return anthropic.NewImageBlockBase64(p.MimeType, p.Data)
case p.MimeType == "application/pdf":
return anthropic.NewDocumentBlock(anthropic.Base64PDFSourceParam{
Data: p.Data,
})
case strings.HasPrefix(p.MimeType, "text/"):
decoded, err := base64.StdEncoding.DecodeString(p.Data)
if err != nil {
return anthropic.NewTextBlock(fmt.Sprintf("[file: %s, type: %s, error decoding content]", p.Filename, p.MimeType))
}
return anthropic.NewDocumentBlock(anthropic.PlainTextSourceParam{
Data: string(decoded),
})
default:
return anthropic.NewTextBlock(fmt.Sprintf("[file: %s, type: %s, unsupported format]", p.Filename, p.MimeType))
}
}