|
@@ -51,7 +51,7 @@ async def get_current_user(authorization: Optional[str] = Header(None)):
|
|
|
return user
|
|
return user
|
|
|
|
|
|
|
|
OLLAMA_URL = "http://localhost:11434/api/chat"
|
|
OLLAMA_URL = "http://localhost:11434/api/chat"
|
|
|
-MODEL_NAME = "llama3.1:8b"
|
|
|
|
|
|
|
+MODEL_NAME = "qwen3.5:4b"
|
|
|
|
|
|
|
|
# Common stopwords to strip before searching the food database
|
|
# Common stopwords to strip before searching the food database
|
|
|
_STOPWORDS = {
|
|
_STOPWORDS = {
|
|
@@ -104,6 +104,7 @@ def extract_food_context(messages: list) -> str | None:
|
|
|
lines = [
|
|
lines = [
|
|
|
"[SYSTEM: NUTRITIONAL ANALYST MODE]",
|
|
"[SYSTEM: NUTRITIONAL ANALYST MODE]",
|
|
|
"You are the LocalFoodAI Analyst. Use ONLY verified local data for values.",
|
|
"You are the LocalFoodAI Analyst. Use ONLY verified local data for values.",
|
|
|
|
|
+ "CRITICAL: Provide direct, concise answers. Skip all internal monologues, <thought> tags, or reasoning steps.",
|
|
|
"For each food discussed, you MUST follow this structure:",
|
|
"For each food discussed, you MUST follow this structure:",
|
|
|
"1. Header: ### 🥗 [Name] (per 100g)",
|
|
"1. Header: ### 🥗 [Name] (per 100g)",
|
|
|
"2. Macros: A markdown table for Cal, P, F, C, Fib, Sug, Chol.",
|
|
"2. Macros: A markdown table for Cal, P, F, C, Fib, Sug, Chol.",
|
|
@@ -231,7 +232,8 @@ async def chat_endpoint(request: ChatRequest, current_user: dict = Depends(get_c
|
|
|
payload = {
|
|
payload = {
|
|
|
"model": MODEL_NAME,
|
|
"model": MODEL_NAME,
|
|
|
"messages": messages,
|
|
"messages": messages,
|
|
|
- "stream": True
|
|
|
|
|
|
|
+ "stream": True,
|
|
|
|
|
+ "think": False # Disable reasoning/thinking mode for faster responses
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
async def generate_response():
|
|
async def generate_response():
|