Wires up 8 previously missing/stub Ask Ash capabilities: resume improvement, job post improvement, professional/jobseeker/company profile improvement, service description generation, KB article/notification writing, admin support ticket summarization, and lead/credit guidance. Also upgrades explain_plan_limits and check_ai_pack_balance from static canned strings to real generated answers. Adds AiProvider::complete_as(model, ...) so callers can target specific LiteLLM model aliases (jd-generator, profile-writer, service-writer, support-drafter, decision-support, askash-main/fast) that were already defined in apps/litellm/base/configmap.yaml but never actually used by ai-assistant, since it wasn't even configured to use the litellm provider (defaulted to plain Ollama with the tiny gemma3:270m model for every task, with no LLM_PROVIDER/LITELLM_* env vars set in the deployment). New content_tools module holds the shared generation logic; new routes registered for each feature; KB content generation and support ticket summarization are gated to ADMIN/EMPLOYEE roles via JWT claims. Registry gains 4 new ActionDefinitions (improve_job_post, generate_kb_content, lead_credit_guidance, ai_auto_apply_status) to match the existing registry pattern.
49 lines
1.3 KiB
Rust
49 lines
1.3 KiB
Rust
use axum::{
|
|
http::StatusCode,
|
|
response::{IntoResponse, Response},
|
|
Json,
|
|
};
|
|
use serde::Serialize;
|
|
|
|
#[derive(Debug, thiserror::Error)]
|
|
pub enum AppError {
|
|
#[error("bad request: {0}")]
|
|
BadRequest(String),
|
|
#[error("forbidden: {0}")]
|
|
Forbidden(String),
|
|
#[error("provider unavailable: {0}")]
|
|
ProviderUnavailable(String),
|
|
#[error("internal error: {0}")]
|
|
Internal(String),
|
|
#[error("external service error: {0}")]
|
|
ExternalService(String),
|
|
}
|
|
|
|
#[derive(Debug, Serialize)]
|
|
struct ErrorBody {
|
|
error: String,
|
|
}
|
|
|
|
impl IntoResponse for AppError {
|
|
fn into_response(self) -> Response {
|
|
let status = match self {
|
|
AppError::BadRequest(_) => StatusCode::BAD_REQUEST,
|
|
AppError::Forbidden(_) => StatusCode::FORBIDDEN,
|
|
AppError::ProviderUnavailable(_) => StatusCode::SERVICE_UNAVAILABLE,
|
|
AppError::Internal(_) => StatusCode::INTERNAL_SERVER_ERROR,
|
|
AppError::ExternalService(_) => StatusCode::BAD_GATEWAY,
|
|
};
|
|
|
|
let body = Json(ErrorBody {
|
|
error: self.to_string(),
|
|
});
|
|
|
|
(status, body).into_response()
|
|
}
|
|
}
|
|
|
|
impl From<sqlx::Error> for AppError {
|
|
fn from(value: sqlx::Error) -> Self {
|
|
AppError::Internal(value.to_string())
|
|
}
|
|
}
|