feat(agent): switch LLM client from Ollama to OpenAI-compatible API (LM Studio support)
- Replace /api/chat with /v1/chat/completions endpoint - Use json_schema response_format (LM Studio does not support json_object) - Make schema parameter optional in call_ollama to support different schemas per use case - Add dedicated normalize schema (normalized_metadata) with release_kind field instead of release_type to avoid model repetition loops - Add dedicated merge schema (artist_merge) so model no longer confuses normalize and merge response structures - Add retry with frequency_penalty=1.5 on parse failure to suppress repetition - Add id3 crate as fallback metadata reader for MP3 files with large embedded cover art that exceed Symphonia probe limit of 1MB Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -35,12 +35,38 @@ pub async fn propose_merge(state: &Arc<AppState>, merge_id: Uuid) -> anyhow::Res
|
||||
|
||||
let user_message = build_merge_message(&artists_data);
|
||||
|
||||
let schema = serde_json::json!({
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"canonical_artist_name": { "type": "string" },
|
||||
"winner_artist_id": { "type": "integer" },
|
||||
"album_mappings": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"source_album_id": { "type": "integer" },
|
||||
"canonical_name": { "type": "string" },
|
||||
"merge_into_album_id": { "type": ["integer", "null"] }
|
||||
},
|
||||
"required": ["source_album_id", "canonical_name", "merge_into_album_id"],
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"notes": { "type": "string" }
|
||||
},
|
||||
"required": ["canonical_artist_name", "winner_artist_id", "album_mappings", "notes"],
|
||||
"additionalProperties": false
|
||||
});
|
||||
|
||||
let response = call_ollama(
|
||||
&state.config.ollama_url,
|
||||
&state.config.ollama_model,
|
||||
&state.merge_prompt,
|
||||
&user_message,
|
||||
state.config.ollama_auth.as_deref(),
|
||||
0.5,
|
||||
Some(("artist_merge", schema)),
|
||||
).await?;
|
||||
|
||||
let proposal = parse_merge_response(&response)?;
|
||||
|
||||
Reference in New Issue
Block a user