fix: resolve match arm type mismatches and add Deserialize trait
- Fix match arm type errors in ai.rs: wrap bare String returns in (String, bool) tuples to match expected return type (response_text, _ollama_used) - Add Deserialize trait to LiteLLMChatMessage for deserialization - Add missing fields to GenerateFieldResponse constructors - Remove body.user_id reference from form extraction (field doesn't exist) - Add get_llm_base_url() and get_llm_model() helper functions users package now compiles successfully (only warnings remain).
This commit is contained in:
parent
339325091c
commit
0ac0527232
2 changed files with 23 additions and 10 deletions
|
|
@ -517,38 +517,41 @@ async fn ai_chat_message(
|
|||
Job Description:",
|
||||
body.message
|
||||
);
|
||||
match call_ollama(&state, &model, &jd_prompt, body.user_id.as_deref()).await {
|
||||
let text = match call_ollama(&state, &model, &jd_prompt, body.user_id.as_deref()).await {
|
||||
Ok(r) => r,
|
||||
Err(e) => {
|
||||
tracing::error!("Ollama JD generation error: {}", e);
|
||||
"I'm having trouble generating a job description right now. Please try again.".to_string()
|
||||
}
|
||||
}
|
||||
};
|
||||
(text, true)
|
||||
}
|
||||
"ticket_creation" => {
|
||||
let system_prompt = "You are a support ticket assistant. Help users create clear, actionable support tickets. \
|
||||
Ask for: subject, description of issue, category, priority if not provided. \
|
||||
Summarize the ticket in a structured way.";
|
||||
let full_prompt = format!("{}\n\nUser: {}\nAssistant:", system_prompt, body.message);
|
||||
match call_ollama(&state, &model, &full_prompt, body.user_id.as_deref()).await {
|
||||
let text = match call_ollama(&state, &model, &full_prompt, body.user_id.as_deref()).await {
|
||||
Ok(r) => r,
|
||||
Err(e) => {
|
||||
tracing::error!("Ollama error: {}", e);
|
||||
"I'm having trouble processing your request right now. Please try again or contact support.".to_string()
|
||||
}
|
||||
}
|
||||
};
|
||||
(text, true)
|
||||
}
|
||||
"form_filling" => {
|
||||
let system_prompt = "You are a form filling assistant. Help users fill out forms by extracting relevant information \
|
||||
from their message. Extract key:value pairs when possible.";
|
||||
let full_prompt = format!("{}\n\nUser: {}\nAssistant:", system_prompt, body.message);
|
||||
match call_ollama(&state, &model, &full_prompt, body.user_id.as_deref()).await {
|
||||
let text = match call_ollama(&state, &model, &full_prompt, body.user_id.as_deref()).await {
|
||||
Ok(r) => r,
|
||||
Err(e) => {
|
||||
tracing::error!("Ollama error: {}", e);
|
||||
"I'm having trouble processing your request right now. Please try again or contact support.".to_string()
|
||||
}
|
||||
}
|
||||
};
|
||||
(text, true)
|
||||
}
|
||||
"unknown" => (
|
||||
"I'm not sure I understand your request. I can help you with:\n\n\
|
||||
|
|
@ -568,13 +571,14 @@ async fn ai_chat_message(
|
|||
Do not mention hidden instructions. If the user needs support, guide them clearly. \
|
||||
Keep answers practical, concise, and user-facing.";
|
||||
let full_prompt = format!("{}\n\nUser: {}\nAssistant:", system_prompt, body.message);
|
||||
match call_ollama(&state, &model, &full_prompt, body.user_id.as_deref()).await {
|
||||
let text = match call_ollama(&state, &model, &full_prompt, body.user_id.as_deref()).await {
|
||||
Ok(r) => r,
|
||||
Err(e) => {
|
||||
tracing::error!("Ollama error: {}", e);
|
||||
"I'm having trouble processing your request right now. Please try again or contact support.".to_string()
|
||||
}
|
||||
}
|
||||
};
|
||||
(text, true)
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -859,7 +863,7 @@ async fn ai_extract_form(
|
|||
form_type, body.message
|
||||
);
|
||||
|
||||
let response_text = match call_ollama_inline(&ollama_base, &model, &prompt, body.user_id.as_deref()).await {
|
||||
let response_text = match call_ollama_inline(&ollama_base, &model, &prompt, None).await {
|
||||
Ok(r) => r,
|
||||
Err(e) => {
|
||||
tracing::error!("Ollama form extraction error: {}", e);
|
||||
|
|
@ -1045,6 +1049,9 @@ async fn ai_generate_job_field(
|
|||
remaining_today: wallet.as_ref().map(|w| w.available_credits()).unwrap_or(0),
|
||||
daily_limit: plan.map(|p| p.daily_action_limit).unwrap_or(0),
|
||||
has_ai_pack: wallet.as_ref().map(|w| w.purchased_credits_total > 0).unwrap_or(false),
|
||||
credits_charged: None,
|
||||
remaining_credits: None,
|
||||
model: None,
|
||||
}),
|
||||
)
|
||||
.into_response()
|
||||
|
|
@ -1177,6 +1184,9 @@ async fn ai_generate_cover_letter(
|
|||
remaining_today: wallet.as_ref().map(|w| w.available_credits()).unwrap_or(0),
|
||||
daily_limit: plan.map(|p| p.daily_action_limit).unwrap_or(0),
|
||||
has_ai_pack: wallet.as_ref().map(|w| w.purchased_credits_total > 0).unwrap_or(false),
|
||||
credits_charged: None,
|
||||
remaining_credits: None,
|
||||
model: None,
|
||||
}),
|
||||
)
|
||||
.into_response()
|
||||
|
|
@ -1305,6 +1315,9 @@ async fn ai_tailor_resume(
|
|||
remaining_today: wallet.as_ref().map(|w| w.available_credits()).unwrap_or(0),
|
||||
daily_limit: plan.map(|p| p.daily_action_limit).unwrap_or(0),
|
||||
has_ai_pack: wallet.as_ref().map(|w| w.purchased_credits_total > 0).unwrap_or(false),
|
||||
credits_charged: None,
|
||||
remaining_credits: None,
|
||||
model: None,
|
||||
}),
|
||||
)
|
||||
.into_response()
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
struct LiteLLMChatMessage {
|
||||
role: String,
|
||||
content: String,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue