feat: API endpoint for LLM call logs by job_id
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>master
parent
9fffde8312
commit
dafec2591b
@ -0,0 +1,37 @@
|
||||
//! Handler for LLM call log viewing.
|
||||
|
||||
use axum::extract::{Path, State};
|
||||
use axum::response::IntoResponse;
|
||||
use axum::Json;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::app_state::AppState;
|
||||
use crate::db;
|
||||
use crate::errors::AppError;
|
||||
use crate::middleware::auth::AuthUser;
|
||||
|
||||
/// GET /api/v1/llm-logs/:job_id
|
||||
///
|
||||
/// Returns all LLM call log entries for a generation job.
|
||||
pub async fn get_logs(
|
||||
auth_user: AuthUser,
|
||||
State(state): State<AppState>,
|
||||
Path(job_id): Path<Uuid>,
|
||||
) -> Result<impl IntoResponse, AppError> {
|
||||
// Verify the job_id belongs to a synthesis owned by this user
|
||||
let synthesis = sqlx::query_scalar::<_, Uuid>(
|
||||
"SELECT id FROM syntheses WHERE job_id = $1 AND user_id = $2 LIMIT 1",
|
||||
)
|
||||
.bind(job_id)
|
||||
.bind(auth_user.id)
|
||||
.fetch_optional(&state.pool)
|
||||
.await?;
|
||||
|
||||
if synthesis.is_none() {
|
||||
return Err(AppError::NotFound("No synthesis found for this job".into()));
|
||||
}
|
||||
|
||||
let logs = db::llm_call_log::list_by_job_id(&state.pool, auth_user.id, job_id).await?;
|
||||
|
||||
Ok(Json(logs))
|
||||
}
|
||||
Loading…
Reference in New Issue