This repository contains a Jupyter notebook demonstrating a fully automated "Deep Research" agent built with the OpenAI Agents SDK. The agent can plan web searches, summarize findings, compose a cohesive report, and email the results—all with minimal user intervention.
- Automated Planning & Search: Uses a Planner agent to break down research queries into targeted web searches and a Search agent to retrieve concise summaries.
- Report Generation: Leverages a Writer agent to synthesize search summaries into a structured, 2-3 paragraph report under 300 words.
- Email Delivery: Implements an Email agent powered by SendGrid to automatically send the generated report to a specified recipient.
- Traceability: Integrates OpenAI’s
traceutility for end-to-end visibility into each step of the agent’s decision-making.
-
Setup & Imports: Load environment variables, import SDK components, and configure API clients.
-
Agent Definitions:
search_agent: Summarizes web search results.planner_agent: Plans a series of targeted searches based on the user’s query.writer_agent: Drafts the final research report.email_agent: Composes and sends the report via SendGrid.
-
Planning & Execution Functions:
plan_searches(): Generates a search plan.perform_searches(): Executes searches and collects summaries.
-
Report & Email Functions:
write_report(): Generates the report from search summaries.send_email(): Sends the report as an email.
-
Execution Example: Runs a full research cycle on a sample query, e.g., "Latest AI Agent frameworks in 2025."
-
Tracing: View detailed run logs on the OpenAI Traces dashboard.
- Python 3.8+
- An OpenAI API key with Agents SDK access
- A SendGrid API key for email delivery
-
Clone the repository:
git clone https://github.com/Rishi-Kora/Deep-Research-chatbot-using-OpenAI.git cd Deep-Research-chatbot-using-OpenAI -
Install dependencies:
pip install agents-sdk python-dotenv pydantic sendgrid
-
Copy
.env.exampleto.envand fill in your API keys:OPENAI_API_KEY=your_openai_key SENDGRID_API_KEY=your_sendgrid_key EMAIL_SENDER=your_verified_sendgrid_sender@example.com EMAIL_RECIPIENT=recipient@example.com
-
Open the Jupyter notebook:
jupyter notebook Deep_research_using_OpenAI.ipynb
-
Update the
queryvariable in the final cell with your own research topic. -
Run all cells. The notebook will:
- Plan and execute web searches
- Generate a concise research report
- Email the report
This project is licensed under the MIT License.