Skip to content

Commit c8f7ecc

Browse files
Merge branch 'main' into ocr-llm-demo
2 parents 64d5292 + 5b0839e commit c8f7ecc

File tree

2 files changed

+136
-114
lines changed

2 files changed

+136
-114
lines changed
Lines changed: 60 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,80 @@
11
# Assistant Secretary Agent
22

3-
*An AI-powered assistant that routes user input across tools like Gmail, Google Calendar, Weather API, Calculator, and Oracle’s Generative AI services for smart, dynamic task automation.*
3+
An AI-powered assistant that routes user input across tools like Gmail, Google Calendar, Weather API, Calculator, and Oracle’s Generative AI services for smart, dynamic task automation.
44

5-
Reviewed: 31.03.2025
5+
Reviewed: 23.04.2025
66

7-
---
8-
9-
## When to use this asset?
7+
# When to use this asset?
108

119
Use this asset when you want to:
12-
- Automate tasks across Gmail, Calendar, and Weather
13-
- Get answers via OCI’s AI Agents and RAG-powered chat
14-
- Use a simple UI to interact with multiple tools seamlessly
15-
- Demo a multi-tool assistant combining local logic and cloud intelligence
10+
- Automate tasks across Gmail, Calendar, and Weather
11+
- Get answers via OCI’s AI Agents and RAG-powered chat
12+
- Use a simple UI to interact with multiple tools seamlessly
13+
- Demo a multi-tool assistant combining local logic and cloud intelligence
1614

1715
Ideal for:
18-
- AI developers building assistants
19-
- Oracle consultants showcasing GenAI + agent capabilities
20-
- Technical users exploring LLM + API routing in real-world use cases
16+
- AI developers building assistants
17+
- Showcasing GenAI + agent capabilities
18+
- Technical users exploring LLM + API routing in real-world use cases
2119

22-
---
23-
24-
## How to use this asset?
20+
# How to use this asset?
2521

2622
This assistant can be launched via:
27-
- **Terminal (CLI mode)**
28-
- **Streamlit UI** for visual interaction
23+
- Terminal (CLI mode)
24+
- Streamlit UI for visual interaction
2925

3026
It supports:
3127
- Reading and replying to emails
3228
- Summarizing or replying smartly using GenAI
3329
- Scheduling calendar events
3430
- Fetching and advising based on weather
35-
- Answering user queries via RAG and fallback GenAI tools
36-
37-
---
31+
- Answering user queries via RAG and fallback GenAI tools
3832

3933
## Setup Instructions
4034

41-
### 🔑 Google API (Gmail + Calendar)
42-
1. Go to **[Google Cloud Console](https://console.cloud.google.com)**
43-
2. Enable the **Gmail API** and **Calendar API**
44-
3. Create **OAuth 2.0 Credentials** and download `credentials.json`
45-
4. Place `credentials.json` in your project root
46-
5. The first time you run the assistant, a `token.json` will be created automatically
35+
### OCI Generative AI (Cohere on OCI)
4736

48-
---
37+
1. Go to OCI Console → Generative AI
38+
2. Select a model like `cohere.command-r-plus-08-2024`
39+
3. Copy the following values:
40+
- model_id
41+
- compartment_id
42+
- endpoint (e.g., `https://inference.generativeai.us-chicago-1.oci.oraclecloud.com`)
43+
4. Paste these in `oci_models.py`
4944

50-
### ☁️ OCI Generative AI (Cohere on OCI)
51-
1. Go to **OCI Console → Generative AI**
52-
2. Select a model like `cohere.command-r-plus-08-2024`
53-
3. Copy the following values:
54-
- `model_id`
55-
- `compartment_id`
56-
- `endpoint` (e.g., `https://inference.generativeai.us-chicago-1.oci.oraclecloud.com`)
57-
4. Paste these in `oci_models.py`
45+
[OCI GenAI Agent Guide](https://docs.oracle.com/en-us/iaas/Content/generative-ai-agents/overview.htm)
5846

59-
🔗 [OCI GenAI Agent Guide](https://docs.oracle.com/en-us/iaas/Content/generative-ai-agents/overview.htm)
47+
Also create an AI Agent in OCI with a knowledge base, and upload your RAG documents into that knowledge base.
6048

61-
Also create an **AI Agent** in OCI with a knowledge base, and upload your RAG documents into that knowledge base.
49+
### Google API (Gmail + Calendar)
6250

63-
---
51+
1. Go to [Google Cloud Console](https://console.cloud.google.com)
52+
2. Enable the Gmail API and Calendar API
53+
3. Create OAuth 2.0 Credentials and download `credentials.json`
54+
4. Place `credentials.json` in your project root
55+
5. The first time you run the assistant, a `token.json` will be created automatically
6456

65-
### 🌦️ Weather API
66-
1. Sign up at [weatherapi.com](https://www.weatherapi.com/)
67-
2. Get a free API key
68-
3. In `tools.py`, update this line with your key:
57+
### Weather API
58+
59+
1. Sign up at [weatherapi.com](https://www.weatherapi.com/)
60+
2. Get a free API key
61+
3. In `tools.py`, update this line with your key:
6962
```python
7063
WEATHER_API_KEY = "your_api_key_here"
7164
```
7265

73-
---
66+
### Start the Assistant
7467

75-
### 💬 Start the Assistant
76-
77-
**Terminal Mode**
68+
Terminal Mode:
7869
```bash
7970
python assistant.py
8071
```
8172

82-
**Streamlit UI**
73+
Streamlit UI:
8374
```bash
8475
streamlit run frontend.py
8576
```
8677

87-
---
88-
8978
## Key Features
9079

9180
| Tool | Description |
@@ -101,21 +90,17 @@ streamlit run frontend.py
10190
| Fallback Q&A | Handles general questions using OCI GenAI |
10291
| Calculator | Parses and evaluates math queries |
10392

104-
---
93+
## Notes
10594

106-
## ⚠️ Notes
95+
- The assistant dynamically routes user queries using Cohere (hosted on OCI)
96+
- Each tool is modular — easy to extend or replace
97+
- Streamlit UI provides real-time visibility on tool routing
10798

108-
- The assistant dynamically routes user queries using Cohere (hosted on OCI)
109-
- Each tool is modular — easy to extend or replace
110-
- Streamlit UI provides real-time visibility on tool routing
111-
112-
---
113-
114-
### 🔁 Update Email Mappings (Required)
99+
## Update Email Mappings (Required)
115100

116101
To match received emails to locations (for RAG/OCI agent logic), update:
117102

118-
**At line 397 in the code**:
103+
At line 397 in the code:
119104
```python
120105
EMPLOYEE_DATA = {
121106
"example example <[email protected]>": "Netherlands",
@@ -124,7 +109,7 @@ EMPLOYEE_DATA = {
124109
}
125110
```
126111

127-
**At line 812 in the code**:
112+
At line 812 in the code:
128113
```python
129114
EMPLOYEE_CITY_MAP = {
130115
"example example <[email protected]>": "Netherlands",
@@ -133,24 +118,28 @@ EMPLOYEE_CITY_MAP = {
133118
}
134119
```
135120

136-
Replace these keys with the **actual email addresses** you'll be receiving messages from.
121+
Replace these keys with the actual email addresses you'll be receiving messages from.
137122

138123
---
139124

140-
## Useful Links
125+
# Useful Links (Optional)
141126

142-
- [Oracle Generative AI Agents](https://docs.oracle.com/en-us/iaas/Content/generative-ai-agents/overview.htm)
143-
- Overview of OCI's GenAI agent features
144-
- [Oracle Cloud Docs](https://docs.oracle.com/en/cloud/)
145-
- Full documentation for OCI services
146-
- [Weather API](https://www.weatherapi.com/)
147-
- Used for real-time weather data
127+
- [Oracle Generative AI Agents](https://docs.oracle.com/en-us/iaas/Content/generative-ai-agents/overview.htm)
128+
Overview of OCI's GenAI agent features
129+
- [Oracle Cloud Docs](https://docs.oracle.com/en/cloud/)
130+
Full documentation for OCI services
131+
- [Weather API](https://www.weatherapi.com/)
132+
Used for real-time weather data
133+
- [Oracle](https://www.oracle.com)
134+
Oracle Website
148135

149136
---
150137

151-
## License
138+
# License
152139

153-
Copyright (c) 2024 Oracle and/or its affiliates.
140+
Copyright (c) 2025 Oracle and/or its affiliates.
141+
142+
Licensed under the Universal Permissive License (UPL), Version 1.0.
154143

155-
Licensed under the Universal Permissive License (UPL), Version 1.0.
156144
See [LICENSE](https://github.com/oracle-devrel/technology-engineering/blob/main/LICENSE) for more details.
145+
Lines changed: 76 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,57 @@
1-
CSV Analyzer Agent
2-
By Omar Salem & Luigi Saetta
1+
# CSV Analyzer Agent
32

4-
CSV Analyzer Agent is an AI-Agent assistant designed to automate document understanding and analysis.
5-
It intelligently routes user questions through a multi-step process that includes PDF information extraction, CSV data analysis, code generation, execution, and natural language explanation.
3+
CSV Analyzer Agent is an AI-Agent assistant designed to automate document understanding and analysis.
4+
It intelligently routes user questions through a multi-step process that includes PDF information extraction, CSV data analysis, code generation, execution, and natural language explanation.
65
It supports dynamic workflows like PDF parsing, CSV querying, and context-aware reporting through a Streamlit UI.
76

87
Reviewed: April 18, 2025
98

10-
1. Prepare Your Configuration
9+
# When to use this asset?
1110

12-
☁️ OCI Generative AI Model (Cohere/Llama on OCI)
13-
Go to: OCI Console → Generative AI
11+
Use this asset when you want to:
12+
- Parse and extract information from PDF documents
13+
- Ask questions about CSV files and receive data-backed answers
14+
- Automate code generation for data analysis
15+
- Get human-readable summaries of complex analytics
16+
- Demonstrate AI-powered multi-modal document analysis in action
1417

15-
Select a model like:
16-
meta.llama-3.3-70b-instruct
18+
Ideal for:
19+
- AI developers building document understanding tools
20+
- Oracle Cloud users integrating GenAI into document workflows
21+
- Data analysts exploring LLM + document orchestration using LangGraph
1722

18-
Copy:
23+
# How to use this asset?
1924

20-
- model_id
21-
- compartment_id
22-
- endpoint (e.g., https://inference.generativeai.us-chicago-1.oci.oraclecloud.com)
25+
This assistant can be launched via:
26+
- Streamlit UI
2327

24-
Paste them in `config.py`
28+
It supports:
29+
- CSV uploading and querying
30+
- PDF form parsing and field extraction
31+
- Secure Python code generation using OCI GenAI
32+
- Real-time execution and explanation of generated code
33+
- State-aware multi-turn conversation
34+
35+
## Setup Instructions
36+
37+
### OCI Generative AI Model (Cohere or LLaMA on OCI)
38+
39+
1. Go to: OCI Console → Generative AI
40+
2. Select a model like:
41+
`meta.llama-3.3-70b-instruct`
42+
3. Copy the following values:
43+
- model_id
44+
- compartment_id
45+
- endpoint (e.g., `https://inference.generativeai.us-chicago-1.oci.oraclecloud.com`)
46+
4. Paste them in `config.py`
2547

2648
Documentation:
27-
https://docs.oracle.com/en-us/iaas/Content/generative-ai/home.htm
49+
[OCI Generative AI Documentation](https://docs.oracle.com/en-us/iaas/Content/generative-ai/home.htm)
2850

2951
No API key is required — authentication is handled via OCI identity.
3052

31-
Also ensure your **OCI CLI credentials** are correctly set up. Create or edit the following config file at `config`:
53+
Ensure your OCI CLI credentials are configured.
54+
Edit or create the following config file at `~/.oci/config`:
3255

3356
```
3457
[DEFAULT]
@@ -39,45 +62,55 @@ region=eu-frankfurt-1
3962
key_file=~/.oci/oci_api_key.pem
4063
```
4164

42-
2. Start the Chatbot
65+
### Start the Chatbot
4366

44-
Streamlit UI
67+
Streamlit UI:
68+
```bash
4569
streamlit run assistant_ui_langgraph.py
70+
```
4671

72+
You will see a full chat interface with support for uploading CSVs and PDFs, asking questions, and receiving answers backed by the AI Agent (`csv_analyzer_agent.py`).
4773

48-
You will see a full chat interface with support for uploading CSVs and PDFs, asking questions, and receiving answers backed by the AI Agent (csv_analyzer_agent.py).
49-
50-
3. Key Features
74+
## Key Features
5175

52-
Tool | Description
53-
------------------------|-------------
54-
CSV Upload | Load a CSV file and analyze it with questions
55-
PDF Extraction | Extracts structured fields like title, items, department, justification from uploaded PDFs
56-
Request Routing | Determines if user input relates to CSV or PDF
57-
Secure Code Generation | Uses OCI GenAI to generate Python code to analyze your data
58-
Security Check | Prevents execution of harmful code (e.g., delete, drop)
59-
Code Execution | Executes LLM-generated Python code safely in a sandboxed context
60-
Answer Generation | Summarizes execution results into a final natural language response
61-
State Management | Remembers chat history, extracted information, and uploaded files
62-
Sidebar Display | Shows PDF structured data and generated code for full transparency
76+
| Tool | Description |
77+
|--------------------------|-----------------------------------------------------------------------------|
78+
| CSV Upload | Load a CSV file and analyze it with questions |
79+
| PDF Extraction | Extracts structured fields like title, items, department, justification |
80+
| Request Routing | Determines if user input relates to CSV or PDF |
81+
| Secure Code Generation | Uses OCI GenAI to generate Python code to analyze your data |
82+
| Security Check | Prevents execution of harmful code (e.g., delete, drop) |
83+
| Code Execution | Executes LLM-generated Python code safely in a sandboxed context |
84+
| Answer Generation | Summarizes execution results into a final natural language response |
85+
| State Management | Remembers chat history, extracted information, and uploaded files |
86+
| Sidebar Display | Shows PDF structured data and generated code for full transparency |
6387

64-
4. Notes
88+
## Notes
6589

66-
- Supports both document inputs (CSV + PDF)
67-
- Uses LangGraph to orchestrate tool routing and execution
68-
- Modular design — individual tools can be expanded or replaced
69-
- Streamlit UI provides a fully interactive interface with visual progress and outputs
70-
- Built to run on Oracle Cloud Infrastructure with native LLM integration
90+
- Supports both document inputs (CSV + PDF)
91+
- Uses LangGraph to orchestrate tool routing and execution
92+
- Modular design — individual tools can be expanded or replaced
93+
- Streamlit UI provides a fully interactive interface with visual progress and outputs
94+
- Built to run on Oracle Cloud Infrastructure with native LLM integration
7195

7296
## Prompt Customization
7397

7498
All core prompts used by the agent are stored in `prompts.py`.
7599

76-
You can easily **modify or extend these prompts** to change how the agent performs routing, extraction, analysis, and natural language response generation.
100+
You can easily modify or extend these prompts to change how the agent performs routing, extraction, analysis, and natural language response generation.
101+
102+
The prompt for extraction can be found in `csv_analyzer_agent.py`.
103+
104+
# Useful Links (Optional)
105+
106+
- [OCI Generative AI](https://docs.oracle.com/en-us/iaas/Content/generative-ai/home.htm)
107+
Official documentation for Oracle Generative AI
108+
109+
# License
110+
111+
Copyright (c) 2025 Oracle and/or its affiliates.
77112

78-
The prompt for extraction can be found in csv_analyzer_agent.py.
113+
Licensed under the Universal Permissive License (UPL), Version 1.0.
79114

80-
5. License
81-
Licensed under the MIT License.
82-
See `LICENSE` for details.
115+
See [LICENSE](https://github.com/oracle-devrel/technology-engineering/blob/main/LICENSE) for more details.
83116

0 commit comments

Comments
 (0)