Spaces:
Sleeping
Sleeping
Update src/app.py
Browse files206 unmodified lines20720820921021121221321421521621754 unmodified lines272273274275276277278206 unmodified linesreturn text.strip()def ask_ai(user_prompt, system_persona, max_tokens):if "GPT-4o" in model_choice:return query_local_model(user_prompt, system_persona, max_tokens)else:technical_name = model_map[model_choice]return query_local_model(user_prompt, system_persona, max_tokens, technical_name)# --- MAIN UI ---st.title("AI Toolkit")54 unmodified linesst.session_state.email_draft = replyif usage:m_name = "Granite" if "Granite" in model_choice else "GPT-4o"tracker.log_usage(m_name, usage["input"], usage["output"])update_sidebar_metrics() # Force update206 unmodified lines20720820921021121221321421521621721821922022122222322422522622722854 unmodified lines283284285286287288289290291292293294295206 unmodified linesreturn text.strip()def ask_ai(user_prompt, system_persona, max_tokens):# 1. Standardize Input: Convert the strings into the Message List format# This ensures compatibility with our new memory-aware backend functionsmessages_payload = [{"role": "system", "content": system_persona},{"role": "user", "content": user_prompt}]# 2. Routing Logicif "GPT-4o" in model_choice:# CORRECTED: Now calls the OpenAI functionreturn query_openai_model(messages_payload, max_tokens)else:# Lookup the technical name for Ollamatechnical_name = model_map[model_choice]# Calls the Local functionreturn query_local_model(messages_payload, max_tokens, technical_name)# --- MAIN UI ---st.title("AI Toolkit")54 unmodified linesst.session_state.email_draft = replyif usage:# 1. Determine a clean name for the logif "GPT-4o" in model_choice:m_name = "GPT-4o"else:# Use the first word of the model choice (e.g., "Llama", "Gemma", "Granite")m_name = model_choice.split(" ")[0]# 2. Log ittracker.log_usage(m_name, usage["input"], usage["output"])update_sidebar_metrics() # Force update
src/app.py+20-3