|
1 | | -Assistant Secretary Agent |
2 | | -By Omar Salem |
| 1 | +# Assistant Secretary Agent |
3 | 2 |
|
4 | | -Assistant Secretary Agent is a powerful AI chatbot that dynamically routes user input to different tools including mail, Google Calendar, Weather, Calculator, and OCI GenAI (Cohere) for general questions and OCI AI Agent RAG-based answers. It includes a Streamlit UI and supports multi-tool workflows like reading emails, summarizing, replying, scheduling meetings, fetching weather, and more. |
| 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.* |
5 | 4 |
|
6 | | -Reviewed: March 31, 2025 |
| 5 | +Reviewed: 31.03.2025 |
7 | 6 |
|
8 | | -1. Prepare Your Credentials |
9 | | -Google API (Gmail + Calendar) |
10 | | -Go to: Google Cloud Console |
| 7 | +--- |
11 | 8 |
|
12 | | -Enable Gmail API and Calendar API |
| 9 | +## When to use this asset? |
13 | 10 |
|
14 | | -Create OAuth 2.0 credentials and download credentials.json |
| 11 | +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 |
15 | 16 |
|
16 | | -Place it in the project root directory |
| 17 | +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 |
17 | 21 |
|
18 | | -The first time you run the assistant, a token.json will be created automatically after login. |
| 22 | +--- |
19 | 23 |
|
20 | | -☁️ OCI Generative AI (Cohere on OCI) |
21 | | -Go to: OCI Console → Generative AI |
| 24 | +## How to use this asset? |
22 | 25 |
|
23 | | -Select a model like cohere.command-r-plus-08-2024 |
| 26 | +This assistant can be launched via: |
| 27 | +- **Terminal (CLI mode)** |
| 28 | +- **Streamlit UI** for visual interaction |
24 | 29 |
|
25 | | -Copy: |
| 30 | +It supports: |
| 31 | +- Reading and replying to emails |
| 32 | +- Summarizing or replying smartly using GenAI |
| 33 | +- Scheduling calendar events |
| 34 | +- Fetching and advising based on weather |
| 35 | +- Answering user queries via RAG and fallback GenAI tools |
26 | 36 |
|
27 | | -model_id |
| 37 | +--- |
28 | 38 |
|
29 | | -compartment_id |
| 39 | +## Setup Instructions |
30 | 40 |
|
31 | | -endpoint (e.g., https://inference.generativeai.us-chicago-1.oci.oraclecloud.com) |
| 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 |
32 | 47 |
|
33 | | -Paste them in oci_models.py |
| 48 | +--- |
34 | 49 |
|
35 | | -https://docs.oracle.com/en-us/iaas/Content/generative-ai-agents/overview.htm |
36 | | -Do the same for the OCI AI AGENT endpoint. Create an AI Agent with a knowledge base and add your RAG documents in that knowledge base. |
| 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` |
37 | 58 |
|
38 | | -Weather API |
39 | | -Get a free API key from: weatherapi.com |
| 59 | +🔗 [OCI GenAI Agent Guide](https://docs.oracle.com/en-us/iaas/Content/generative-ai-agents/overview.htm) |
40 | 60 |
|
41 | | -Add the key to tools.py in: |
| 61 | +Also create an **AI Agent** in OCI with a knowledge base, and upload your RAG documents into that knowledge base. |
42 | 62 |
|
43 | | -python |
44 | | -Copy |
45 | | -Edit |
| 63 | +--- |
46 | 64 |
|
| 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: |
| 69 | +```python |
47 | 70 | WEATHER_API_KEY = "your_api_key_here" |
| 71 | +``` |
48 | 72 |
|
49 | | -2. Start the Chatbot |
50 | | -Terminal Mode |
51 | | -bash |
52 | | -Copy |
53 | | -Edit |
| 73 | +--- |
| 74 | + |
| 75 | +### 💬 Start the Assistant |
| 76 | + |
| 77 | +**Terminal Mode** |
| 78 | +```bash |
54 | 79 | python assistant.py |
55 | | -Streamlit UI |
56 | | -bash |
57 | | -Copy |
58 | | -Edit |
59 | | -streamlit run ui.py |
60 | | -You’ll see the full chat interface with interactive steps and decision routing. |
61 | | - |
62 | | -3. Key Features |
63 | | -Tool Description |
64 | | - Fetch Gmail Retrieves unread emails, summarizes them |
65 | | - Select Email Lets you read the full email body |
66 | | - OCI AI Agent (RAG) Provides answers from RAG agent based on sender's country |
67 | | - Smart Replies Generates professional replies using OCI GenAI |
68 | | - Send Email Sends reply to the original sender |
69 | | - Schedule Emails Delay sending with background job |
70 | | - Weather + Advice Current weather or forecast with clothing tips |
71 | | - Book Meetings Books Google Calendar events & fetches weather for the date |
72 | | - Fallback Q&A General questions or how-to help using OCI GenAI |
73 | | - Calculator Extracts & evaluates math from user input |
74 | | - |
75 | | -4. Notes |
76 | | -Fully dynamic: user messages are routed in real-time using Cohere model hosted on OCI. |
77 | | - |
78 | | -Each tool is modular and can be expanded or replaced. |
79 | | - |
80 | | -Streamlit UI shows each step with visual feedback. |
81 | | - |
82 | | -5. License |
83 | | -Licensed under the Universal Permissive License (UPL), Version 1.0. |
84 | | -See LICENSE for details. |
| 80 | +``` |
| 81 | + |
| 82 | +**Streamlit UI** |
| 83 | +```bash |
| 84 | +streamlit run frontend.py |
| 85 | +``` |
| 86 | + |
| 87 | +--- |
| 88 | + |
| 89 | +## Key Features |
| 90 | + |
| 91 | +| Tool | Description | |
| 92 | +|--------------------|-----------------------------------------------------------------------------| |
| 93 | +| Fetch Gmail | Retrieves and summarizes unread emails | |
| 94 | +| Select Email | Shows full email body | |
| 95 | +| OCI AI Agent (RAG) | Answers based on Oracle AI Agent + RAG knowledge base | |
| 96 | +| Smart Replies | Drafts professional responses with OCI GenAI | |
| 97 | +| Send Email | Sends reply to the original sender | |
| 98 | +| Schedule Emails | Delays email sending using background job | |
| 99 | +| Weather + Advice | Gives weather report with clothing suggestion | |
| 100 | +| Book Meetings | Creates Google Calendar events and checks weather for that date | |
| 101 | +| Fallback Q&A | Handles general questions using OCI GenAI | |
| 102 | +| Calculator | Parses and evaluates math queries | |
| 103 | + |
| 104 | +--- |
| 105 | + |
| 106 | +## ⚠️ Notes |
| 107 | + |
| 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) |
| 115 | + |
| 116 | +To match received emails to locations (for RAG/OCI agent logic), update: |
| 117 | + |
| 118 | +**At line 397 in the code**: |
| 119 | +```python |
| 120 | +EMPLOYEE_DATA = { |
| 121 | + "example example <[email protected]>": "Netherlands", |
| 122 | + "example [email protected]": "Poland", |
| 123 | + "example [email protected]": "Italy" |
| 124 | +} |
| 125 | +``` |
| 126 | + |
| 127 | +**At line 812 in the code**: |
| 128 | +```python |
| 129 | +EMPLOYEE_CITY_MAP = { |
| 130 | + "example example <[email protected]>": "Netherlands", |
| 131 | + "example [email protected]": "Poland", |
| 132 | + "example [email protected]": "Italy" |
| 133 | +} |
| 134 | +``` |
| 135 | + |
| 136 | +Replace these keys with the **actual email addresses** you'll be receiving messages from. |
| 137 | + |
| 138 | +--- |
| 139 | + |
| 140 | +## Useful Links |
| 141 | + |
| 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 |
| 148 | + |
| 149 | +--- |
| 150 | + |
| 151 | +## License |
| 152 | + |
| 153 | +Copyright (c) 2024 Oracle and/or its affiliates. |
85 | 154 |
|
| 155 | +Licensed under the Universal Permissive License (UPL), Version 1.0. |
| 156 | +See [LICENSE](https://github.com/oracle-devrel/technology-engineering/blob/main/LICENSE) for more details. |
0 commit comments