Move the rowing photo Claude call to the Python service
POST /rowing in the Go backend no longer calls the Anthropic SDK. It keeps the admin gate, EXIF date, duplicate check, sanity bounds and insert, and sends the image to a new internal Python route, POST /internal/rowing/read, which makes the Claude call and returns the three numbers it read. The route spends a paid call and has no auth of its own, so nginx 404s /py/internal/ and the route refuses anything carrying the proxy headers nginx adds. The python container now receives CLAUDE_API_KEY. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -10,15 +10,16 @@ type ClaudeConfig struct {
|
||||
APIKey string
|
||||
}
|
||||
|
||||
// InitClaude builds the shared Anthropic client. It is used in two places:
|
||||
// reading a rowing machine display from a photo (handlers.CreateRowing) and
|
||||
// classifying job-application emails (EmailSyncService.processEmail).
|
||||
// InitClaude builds the Anthropic client used to classify job-application
|
||||
// emails (EmailSyncService.processEmail). The other Claude caller, the rowing
|
||||
// photo reader, lives in the Python service and builds its own client from
|
||||
// the same CLAUDE_API_KEY.
|
||||
//
|
||||
// No validation happens here: with an empty or wrong API key construction
|
||||
// still succeeds and the failure only surfaces on the first request.
|
||||
func InitClaude(config *ClaudeConfig) *anthropic.Client {
|
||||
// anthropic.NewClient returns a value, not a pointer, so take its address
|
||||
// to share one client across every caller.
|
||||
// so it can be handed around without copying.
|
||||
client := anthropic.NewClient(option.WithAPIKey(config.APIKey))
|
||||
return &client
|
||||
}
|
||||
|
||||
@@ -888,8 +888,8 @@ If isJobEmail is false, only include that field. No text, no markdown, no explan
|
||||
// a plain "```" otherwise. It is deliberately forgiving: unfenced input is
|
||||
// returned unchanged apart from surrounding whitespace.
|
||||
//
|
||||
// Shared with handlers.CreateRowing, which prompts for bare JSON in the same
|
||||
// way and gets the same fenced output.
|
||||
// python/app/rowing.py carries a port of this for the rowing photo reader,
|
||||
// which prompts for bare JSON in the same way and gets the same fenced output.
|
||||
func StripMarkdownFence(raw string) string {
|
||||
raw = strings.TrimSpace(raw)
|
||||
raw = strings.TrimPrefix(raw, "```json")
|
||||
|
||||
Reference in New Issue
Block a user