AI Service
The AI service provides AI-powered chat functionality, enabling users to query fund data using natural language.Architecture
The AI service is a separate Django application using:- Django Channels for WebSocket support
- pydantic-ai for agent orchestration
- Multiple LLM providers with automatic fallback
Key Components
| Component | Description |
|---|---|
agents/ | Tool registry, model management, base classes |
apps/ | Domain-specific tools |
prompts/ | System prompt configuration |
settings/ | AI service configuration |
LLM Providers
The service supports multiple providers:| Provider | Models |
|---|---|
| Anthropic | Claude Opus, Sonnet, Haiku |
| OpenAI | GPT-4, GPT-3.5 |
| Gemini Pro | |
| AWS Bedrock | Claude via Bedrock |
Available Tools
Fund Family Tools
| Tool | Description |
|---|---|
list_fund_families | List all accessible fund families |
search_fund_family | Search by name |
Entity Tools
| Tool | Description |
|---|---|
search_entities | Search by name or external ID |
list_investor_entities | List investor entities |
list_investment_entities | List investments |
list_fund_entities | List funds |
Capital Activity Tools
| Tool | Description |
|---|---|
get_capital_activity_stats | Statistics for an investor |
get_capital_activity_summary | ITD summary with breakdown |
list_capital_activity_transactions | Transaction list |
Fee Tools
| Tool | Description |
|---|---|
get_itd_fees_accrued_and_paid | ITD fee summary |
search_fee_charge_event | Find fee events by date |
Financial Reporting Tools
| Tool | Description |
|---|---|
list_hypothetical_waterfalls | List waterfalls |
get_performance_stats_by_date | Performance metrics |
get_hypothetical_performance_multiples | TVPI, DPI, etc. |
Credit Facility Tools
| Tool | Description |
|---|---|
list_credit_facilities | List credit facilities |
get_credit_facility_stats | Principal summary |
Calculation Tools
| Tool | Description |
|---|---|
list_calculations | List MXL calculations |
explain_calculations | MXL documentation |
Running the Service
/ws/chat/.
Configuration
WebSocket Protocol
Client to Server
| Message | Description |
|---|---|
ChatMessageCommand | Send a chat message |
HeartbeatCommand | Keep connection alive |
Server to Client
| Message | Description |
|---|---|
ConnectedEvent | Connection established |
AckMessageEvent | Message received |
ChatMessageStreamStartEvent | Response starting |
ChatMessageStreamChunkEvent | Streaming chunk |
ChatMessageStreamEndEvent | Response complete |
TitleGeneratedEvent | Conversation title |
Adding New Tools
1
Create schemas
Define input/output models in
tools/schemas.py:2
Implement function
Create tool in
tools/functions.py:3
Register tool
Add to
tools/loader.py:Security
The AI agent:- Only accesses data the user has permission to view
- Uses the user’s authentication context
- Follows system prompt security policies
- Logs all tool invocations