15 Commits

Author SHA1 Message Date
alex wiesner
d1704af827 fix: persist assistant tool errors and markdown 2026-03-14 11:22:14 +00:00
alex wiesner
c4d39f2812 changes 2026-03-13 20:15:22 +00:00
208a4626ca feat(chat): add admin-editable assistant system prompt 2026-03-10 19:46:53 +00:00
1ad9d20037 fix(chat): stabilize assistant add flow and location routing 2026-03-10 15:59:07 +00:00
d8c8ecf2bd fix(chat): clean up tool output and embedded UX 2026-03-09 21:12:46 +00:00
bb54503235 fix(chat): add saved AI defaults and harden suggestions 2026-03-09 20:32:13 +00:00
21954df3ee fix(chat): improve OpenCode Zen integration and error handling
- Fetch models dynamically from OpenCode Zen API (36 models vs 5 hardcoded)
- Add function calling support check before using tools
- Add retry logic (num_retries=2) for transient failures
- Improve logging for debugging API calls and errors
- Update system prompt for multi-stop itinerary context
- Clean up unused imports in frontend components
- Remove deleted views.py (moved to views/__init__.py)
2026-03-09 16:11:14 +00:00
30fdcb078f fix: resolve three travel agent UI issues
- Connection error: wrap sync get_llm_api_key() in sync_to_async in
  stream_chat_completion() to fix SynchronousOnlyOperation raised when
  the async SSE generator calls a synchronous Django ORM function
- Models not loading: add opencode_zen handler to models endpoint
  returning its default model; fix frontend to show 'Default' instead
  of 'Loading...' indefinitely when no model list is returned
- Location in header: remove destination subtitle from Travel Assistant
  header — collection-wide chat has no single meaningful location
2026-03-09 13:34:35 +00:00
91d907204a fix(ai): critical fixes for agent-redesign - provider selection and auto-learn
Fix 1: Provider/Model Selection (Critical - unblocks LLM)
- Add /api/chat/providers/{id}/models/ endpoint to fetch available models
- Auto-select first configured provider instead of hardcoded 'openai'
- Add model dropdown populated from provider API
- Filter provider list to only show configured providers
- Show helpful error when no providers configured

Fix 2: Auto-Learn Preferences (Replaces manual input)
- Create auto_profile.py utility to infer preferences from user data
- Learn interests from Activity sport types and Location categories
- Learn trip style from Lodging types (hostel=budget, resort=luxury, etc.)
- Learn geographic preferences from VisitedRegion/VisitedCity
- Call auto-learn on every chat start (send_message)
- System prompt now indicates preferences are auto-inferred

Fix 3: Remove Manual Preference UI
- Remove travel_preferences section from Settings
- Remove preference form fields and save logic
- Remove preference fetch from server-side load
- Keep UserRecommendationPreferenceProfile type for backend use

The LLM should now work correctly:
- Users with any configured provider will have it auto-selected
- Model list is fetched dynamically from provider API
- Preferences are learned from actual travel history
2026-03-09 00:20:11 +00:00
9d5681b1ef feat(ai): implement agent-redesign plan with enhanced AI travel features
Phase 1 - Configuration Infrastructure (WS1):
- Add instance-level AI env vars (VOYAGE_AI_PROVIDER, VOYAGE_AI_MODEL, VOYAGE_AI_API_KEY)
- Implement fallback chain: user key → instance key → error
- Add UserAISettings model for per-user provider/model preferences
- Enhance provider catalog with instance_configured and user_configured flags
- Optimize provider catalog to avoid N+1 queries

Phase 1 - User Preference Learning (WS2):
- Add Travel Preferences tab to Settings page
- Improve preference formatting in system prompt with emoji headers
- Add multi-user preference aggregation for shared collections

Phase 2 - Day-Level Suggestions Modal (WS3):
- Create ItinerarySuggestionModal with 3-step flow (category → filters → results)
- Add AI suggestions button to itinerary Add dropdown
- Support restaurant, activity, event, and lodging categories
- Backend endpoint POST /api/chat/suggestions/day/ with context-aware prompts

Phase 3 - Collection-Level Chat Improvements (WS4):
- Inject collection context (destination, dates) into chat system prompt
- Add quick action buttons for common queries
- Add 'Add to itinerary' button on search_places results
- Update chat UI with travel-themed branding and improved tool result cards

Phase 3 - Web Search Capability (WS5):
- Add web_search agent tool using DuckDuckGo
- Support location_context parameter for biased results
- Handle rate limiting gracefully

Phase 4 - Extensibility Architecture (WS6):
- Implement decorator-based @agent_tool registry
- Convert existing tools to use decorators
- Add GET /api/chat/capabilities/ endpoint for tool discovery
- Refactor execute_tool() to use registry pattern
2026-03-08 23:53:14 +00:00
62578e7aa5 merge: collections AI chat integration
# Conflicts:
#	backend/server/chat/llm_client.py
#	frontend/src/routes/chat/+page.svelte
#	frontend/src/routes/settings/+page.svelte
2026-03-08 21:32:22 +00:00
d35feed98c feat(chat): add dynamic provider catalog and zen support 2026-03-08 21:29:48 +00:00
64f9fe7382 feat: embed AI travel chat in collection recommendations 2026-03-08 21:24:49 +00:00
fd3ca360de fix(chat): sanitize error responses and add tool kwargs allowlist
Prevent API key and sensitive info leakage through exception messages:
- Replace str(exc) with generic error messages in all catch-all handlers
- Add server-side exception logging via logger.exception()
- Add ALLOWED_KWARGS per-tool allowlist to filter untrusted LLM kwargs
- Bound tool execution loop to MAX_TOOL_ITERATIONS=10
- Fix tool_call delta merge to use tool_call index
2026-03-08 18:54:35 +00:00
757140ec70 feat(chat): add LLM-powered travel agent with multi-provider support
Implement a full chat-based travel agent using LiteLLM for multi-provider
LLM support (OpenAI, Anthropic, Gemini, Ollama, Groq, Mistral, etc.).

Backend:
- New 'chat' Django app with ChatConversation and ChatMessage models
- Streaming SSE endpoint via StreamingHttpResponse
- 5 agent tools: search_places, list_trips, get_trip_details,
  add_to_itinerary, get_weather
- LiteLLM client wrapper with per-user API key retrieval
- System prompt with user preference context injection

Frontend:
- New /chat route with full-page chat UI (DaisyUI + Tailwind)
- Collapsible conversation sidebar with CRUD
- SSE streaming response display with tool call visualization
- Provider selector dropdown
- SSE proxy fix to stream text/event-stream without buffering
- Navbar link and i18n keys
2026-03-08 18:44:44 +00:00