RayMelius/stockex-analyst is not hosted on any HF inference provider,
causing HTTP 400 errors. Fall back to Qwen/Qwen2.5-7B-Instruct.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fix HF 410: always use router.huggingface.co for all models
api-inference.huggingface.co is deprecated (HTTP 410).
All three services (ai_analyst, ch_ai_trader, dashboard) now
route every model through router.huggingface.co.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Fix HF routing: use router for third-party models, not model-specific endpoint
Only RayMelius/ finetuned models need the direct inference endpoint.
All other org/model format models (e.g. mistralai/Mistral-7B-Instruct-v0.3)
must go through router.huggingface.co which supports chat completions for them.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Restore SYSTEM_PROMPT and finetuned model default for AI Analyst
- HF_MODEL default: RayMelius/stockex-analyst (our Round 2 finetuned model)
- Add SYSTEM_PROMPT for correct finetuned model behaviour
- _try_hf: use direct inference API for RayMelius/ models + system prompt
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add dynamic LLM provider/model selection to AI Analyst
- ai_analyst: add Groq support, _active_provider/_active_model globals,
refactored call_llm routing (Ollama → Groq → HF auto fallback),
handle Kafka 'set_llm' control message to switch provider at runtime
- dashboard: /ai/select now publishes set_llm to Kafka control topic so
the AI Analyst service picks up provider changes immediately
- dashboard + index.html: sync LLM selector UI (provider/model dropdowns,
badge, SSE llm_config event) to latest working version
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- URL: api-inference.huggingface.co → router.huggingface.co/v1/chat/completions
(old URL no longer works; new router is the current HF standard)
- Model: mistralai/Mistral-7B-Instruct-v0.2 → Qwen/Qwen2.5-7B-Instruct-1M
(Mistral-7B removed from free tier; Qwen2.5-7B is in current free tier)
- Add status code logging so failures are visible in HF Spaces logs
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Button in AI Analyst panel header calls POST /session/ai_insight
- Dashboard publishes {"action": "generate_insight"} to control topic
- ai_analyst listens and runs LLM call in a background thread
- Button shows "Generating…" / disabled while waiting, re-enables on result
- Fix: control topic key was "command", now correctly uses "action"
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add AI Analyst service: Ollama (local) + HuggingFace (HF Spaces)
New ai_analyst/ai_analyst.py service consumes trades/snapshots from
Kafka, builds a market-context prompt every 30 min, calls Ollama
(llama3.1:8b) locally or HuggingFace Inference API (Mistral-7B) as
fallback, and publishes insights to the ai_insights Kafka topic.
Dashboard consumes ai_insights and broadcasts via SSE. New full-width
AI Analyst panel displays timestamped insights with animated cards.
- ai_analyst/ai_analyst.py: new service (Ollama-first, HF fallback)
- ai_analyst/Dockerfile: minimal Python image for local compose
- shared/config.py: add AI_INSIGHTS_TOPIC
- dashboard/dashboard.py: consume ai_insights, SSE broadcast
- dashboard/templates/index.html: AI Analyst panel + JS handlers
- Dockerfile: copy ai_analyst.py into HF single-container image
- entrypoint.sh: create ai_insights topic, start ai_analyst.py
- docker-compose.yml: ai_analyst service with OLLAMA_HOST + HF_TOKEN
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>