File size: 4,424 Bytes
6a27f73
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0369b23
6a27f73
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# AI Tool Usage Documentation

## Overview
This document details the AI tools, models, and configurations used in the Multi-Source Multi-Agent Finance Assistant project.

## Model Configuration

### Base Model
- **Provider**: Google AI (Gemini)
- **Model Version**: gemini-2.0-flash
- **Configuration**: 
  - API Key: Required (via GOOGLE_API_KEY environment variable)
  - Model Type: ChatGoogleGenerativeAI

### Embeddings
- **Model**: models/gemini-embedding-exp-03-07
- **Provider**: Google AI
- **Usage**: Document embedding for vector store

## Agent Configurations

### 1. Supervisor Agent
```python
Model: ChatGoogleGenerativeAI(model="gemini-2.0-flash")
Prompt Template:
"""
You are a supervisor managing three agents:
- a scraping_agent. Provide the link or path of any documment to it and it will help you with it's content
- a Financial_agent. Assign financial news related task to it. to see the current trend.
- a retriever_agent. retrive the data from vector store and if retrieval confidence < threshold, prompt user clarification.
Assign work to one agent at a time, do not call agents in parallel.
Analyse the result of each agent and after that provide what user want if you didn't get answer from one agent use another.
"""
```

### 2. Retriever Agent
```python
Model: ChatGoogleGenerativeAI(model="gemini-2.0-flash")
Tools: 
- create_retriever_tool(vectorstore.as_retriever())
Prompt Template:
"""
You are a retriever agent.

INSTRUCTIONS:
- Get the data from the vector store.
- if retrieval confidence < threshold, prompt user clarification.
- After you're done with your tasks, respond to the supervisor directly
"""
```

### 3. API Agent
```python
Model: ChatGoogleGenerativeAI(model="gemini-2.0-flash")
Tools:
- YahooFinanceNewsTool()
Prompt Template:
"""
You are a Financial agent.

INSTRUCTIONS:
- You polls real-time & historical market data.
- You use the YahooFinanceNewsTool to get the latest finanical news update.
- After you're done with your tasks, respond to the supervisor directly
- Respond ONLY with the results of your work, do NOT include ANY other text.
- You can use the tools provided to you to get the data.
"""
```

### 4. Scraping Agent
```python
Model: ChatGoogleGenerativeAI(model="gemini-2.0-flash")
Tools:
- web_loader: WebBaseLoader for URL content extraction
- pdf_loader: PyPDFLoader for PDF content extraction
- csv_loader: CSVLoader for CSV file processing
Prompt Template:
"""
You are a scraping agent.

INSTRUCTIONS:
- Use the provided links and file paths to scratch data from the file.
- Get the data from the web, pdf, csv
- After you're done with your tasks, respond to the supervisor directly
"""
```

## Vector Store Configuration

### FAISS Vector Store
- **Type**: FAISS (Facebook AI Similarity Search)
- **Embedding Model**: GoogleGenerativeAIEmbeddings
- **Chunk Size**: 1024
- **Chunk Overlap**: 64
- **Storage Path**: data_ingestion/faiss_index

## Voice Processing

### Speech-to-Text
- **Tool**: SpeechRecognition
- **Input Format**: WAV
- **API Endpoint**: /agents/voice-agent/stt

### Text-to-Speech
- **Tool**: gTTS (Google Text-to-Speech)
- **Output Format**: MP3
- **Supported Languages**: Multiple (default: 'en')
- **API Endpoint**: /agents/voice-agent/tts

## Code Generation Steps

1. **Agent Initialization**
   - Load environment variables
   - Configure Google AI API
   - Initialize model instances
   - Set up agent tools and prompts

2. **Vector Store Setup**
   - Initialize embeddings
   - Create/load FAISS index
   - Configure text splitting parameters
   - Set up document processing pipeline

3. **API Integration**
   - Set up FastAPI endpoints
   - Configure request/response handling
   - Implement streaming responses for audio
   - Handle file uploads and processing

4. **Frontend Integration**
   - Implement Streamlit interface
   - Set up audio recording and playback
   - Configure real-time communication with backend
   - Handle user input processing

## Model Parameters

### Text Processing
- **Chunk Size**: 1024 tokens
- **Chunk Overlap**: 64 tokens
- **Text Splitter**: RecursiveCharacterTextSplitter

### Vector Store
- **Similarity Search**: FAISS
- **Index Type**: L2 distance
- **Allow Dangerous Deserialization**: True (for local storage)

### Voice Processing
- **Audio Format**: WAV (input), MP3 (output)
- **Sample Rate**: Default system settings
- **Language Support**: Multiple languages (configurable)