feat(ai-chat): add AI tool-calling, chat history and withdrawal modeling - #5
Merged
Conversation
- Add floating action button (FAB) and interactive chat panel for portfolio Q&A - Inject real-time portfolio parameters and projection metrics into AI system prompt - Centralize AI provider and API key management inside Application Settings dialog - Add Demo API toggle support via VITE_DEMO_API_KEY with quota limits (5 forecasts, 15 chat messages) - Implement security controls: 500-char message capping and 3s cooldown rate-limiting for Demo API - Add Turkish and English translations for chat UI, settings, and quota indicators
- Add src/config/index.ts (APP_CONFIG) for centralizing app metadata, demo API quotas, security limits, AI defaults, and calculation constraints - Integrate APP_CONFIG across ai-service, ai-chat-service, settings store, and UI modals - Update project documentation files (README.md, README.tr.md, AGENTS.md, CONTRIBUTING.md, CONTRIBUTING.tr.md) to reflect the new architecture
Introduce persistent chat sessions and UI: add a zustand chat store (with persist), chat history UI in AiChat, session CRUD, and chat-store tests. Implement withdrawal tax (stopaj) logic and expose netWithdrawal: new calculateWithdrawalTax helper, projection changes to compute withholdingTax and netWithdrawal, summary fields, engine tests updated. Add per-month customWithdrawals with UI in ProjectionTable and store actions to set/clear overrides. Update AI config & services (demo provider/baseUrl, maxTokens, response cleaning), CSV export, translations, and small UI/UX fixes.
Introduce an in-band AI tool-calling system: new src/lib/ai-tools.ts (tool registry, parser, sanitizer, executor, default deps) and unit runner src/lib/ai-tools.test.ts. Integrate into chat flow: ai-chat-service now returns parsed tool calls; AiChat UI supports proposal approvals/rejections, tool execution results, and follow-up rounds. Add types for AiToolCall/AiToolCallResult and internal message flag. Update APP_CONFIG (toolCall limits, engine sanitization limits, demo chat cap), translations, vite dev server, and package.json test script. This enables AI to request precise engine calculations and propose mutations gated by user approval, with sanitization and read/mutate separation.
Make the AI chat panel resizable: add panel size state, pointer-based resize handlers, clamp constraints and visible resize handles (desktop). Adjust transition behavior while resizing. Update demo AI configuration to use "nvidia/nemotron-3-ultra-550b-a55b:free" and lower demo chat quota from 20 to 15. Docs updated (EN + TR) to instruct adding LANGUAGE_LABELS and to update APP_CONFIG.supportedLanguages when adding new locales. Files changed: src/components/chat/AiChat.tsx, src/config/index.ts, CONTRIBUTING.md, CONTRIBUTING.tr.md
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AI assistant now reads AND writes portfolio data in the app. Added persistent
chat history, centralized configuration, and an in-band tool-calling protocol
with explicit user approval before any data mutation.
Changes
clear_custom_withdrawals, create_scenario, reset_params, calculate_projection,
forecast_economics; approval card UI before store mutations (#1abab37)
Verification