fix: persist token counts and fix agentic insight_id mapping
- Add prompt_eval_count and eval_count columns to photo_insights so token usage from llama-swap/Ollama is stored and returned by the API - Fix agentic generator return: was (prompt_eval_count, eval_count), handler destructured first element as insight_id — now returns (insight_id, prompt_eval_count, eval_count) - Wire prompt_eval_count/eval_count from DB into PhotoInsightResponse instead of hardcoded None Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
+6
-6
@@ -561,8 +561,8 @@ pub async fn get_insight_handler(
|
||||
summary: insight.summary,
|
||||
generated_at: insight.generated_at,
|
||||
model_version: insight.model_version,
|
||||
prompt_eval_count: None,
|
||||
eval_count: None,
|
||||
prompt_eval_count: insight.prompt_eval_count,
|
||||
eval_count: insight.eval_count,
|
||||
approved: insight.approved,
|
||||
has_training_messages: insight.training_messages.is_some(),
|
||||
backend: insight.backend,
|
||||
@@ -637,8 +637,8 @@ pub async fn get_all_insights_handler(
|
||||
summary: insight.summary,
|
||||
generated_at: insight.generated_at,
|
||||
model_version: insight.model_version,
|
||||
prompt_eval_count: None,
|
||||
eval_count: None,
|
||||
prompt_eval_count: insight.prompt_eval_count,
|
||||
eval_count: insight.eval_count,
|
||||
approved: insight.approved,
|
||||
has_training_messages: insight.training_messages.is_some(),
|
||||
backend: insight.backend,
|
||||
@@ -833,12 +833,12 @@ pub async fn generate_agentic_insight_handler(
|
||||
let mut dao = job_dao.lock().expect("Unable to lock InsightJobDao");
|
||||
|
||||
match result {
|
||||
Ok(Ok(Ok((Some(insight_id), _)))) => {
|
||||
Ok(Ok(Ok((Some(insight_id), _, _)))) => {
|
||||
if let Err(e) = dao.complete_job(&ctx, job_id, insight_id) {
|
||||
log::error!("Failed to mark job {} as completed: {:?}", job_id, e);
|
||||
}
|
||||
}
|
||||
Ok(Ok(Ok((None, _)))) => {
|
||||
Ok(Ok(Ok((None, _, _)))) => {
|
||||
if let Err(e) = dao.fail_job(&ctx, job_id, "agentic generation returned no insight")
|
||||
{
|
||||
log::error!("Failed to mark job {} as failed: {:?}", job_id, e);
|
||||
|
||||
Reference in New Issue
Block a user