test_debug.py 1.2 KB

123456789101112131415161718192021222324
  1. import httpx
  2. import json
  3. def debug_chat():
  4. url = "http://localhost:11434/api/chat"
  5. messages = [
  6. {"role": "system", "content": "[SYSTEM: NUTRITIONAL ANALYST MODE]\nYou are the LocalFoodAI Analyst. Use ONLY verified local data for values.\nCRITICAL: Provide direct, concise answers. Skip all internal monologues, <thought> tags, or reasoning steps.\nFor each food discussed, you MUST follow this structure:\n1. Header: ### 🥗 [Name] (per 100g)\n2. Macros: A markdown table for Cal, P, F, C, Fib, Sug, Chol.\n3. Micros: A bulleted list for Na, Ca, Fe, K, VitA, VitC.\n4. Insight: A 1-sentence analysis of the food's nutritional profile.\nAlways prioritize local data over training memory. If a nutrient is missing, say 'Data not available'."},
  7. {"role": "user", "content": "How much protein in 100g of salmon?"}
  8. ]
  9. payload = {
  10. "model": "qwen3.5:9b",
  11. "messages": messages,
  12. "stream": False
  13. }
  14. print("Sending debug request...")
  15. with httpx.Client(timeout=300.0) as client:
  16. response = client.post(url, json=payload)
  17. print(f"Status: {response.status_code}")
  18. print("Response Body:")
  19. print(response.text)
  20. if __name__ == "__main__":
  21. debug_chat()