- 🌟 Introduction
- 🚀 Features
- 🛠️ Technologies Used
- 📊 Project Structure
- 🔍 How It Works
- 🖥️ Installation
- 🎮 Usage
- 📚 Skills Learned
- 🔬 Future Improvements
This project demonstrates the implementation of a sophisticated agent system capable of conducting in-depth research on various topics, leveraging multiple data sources, and generating comprehensive reports.
Genius LangGraph showcases the power of LangGraph, a library for building stateful, multi-step applications using language models. By combining LangGraph with tools like RAG (Retrieval Augmented Generation), web search capabilities, and specialized knowledge bases, we've created an AI agent that can navigate complex information landscapes and synthesize findings into coherent, well-structured reports.
- Multi-source Research: Utilizes arXiv papers, web search, and custom knowledge bases
- Intelligent Decision Making: Employs an "Oracle" LLM for determining optimal research strategies
- Dynamic Tool Selection: Chooses appropriate tools based on the research context
- Comprehensive Report Generation: Produces well-structured reports with introduction, research steps, main body, conclusion, and sources
- Stateful Conversations: Maintains context throughout the research process
- Visualizable Workflow: Includes graph visualization of the agent's decision-making process
- LangGraph: For building the stateful, multi-step AI agent
- LangChain: Provides the foundation for working with language models and tools
- OpenAI GPT Models: Powers the language understanding and generation capabilities
- Pinecone: Vector database for efficient similarity search in the knowledge base
- SerpAPI: Enables web search functionality
- arXiv API: Allows fetching of scientific paper abstracts
- Sentence Transformers: For generating text embeddings
- Graphviz: Visualizes the agent's decision-making graph
- Python Libraries: requests, re, typing, operator
graph TD
A[User Query] --> B[Oracle LLM]
B --> C{Tool Selection}
C --> |RAG Search| D[Pinecone Vector DB]
C --> |Web Search| E[SerpAPI]
C --> |ArXiv Fetch| F[ArXiv API]
D --> G[Information Synthesis]
E --> G
F --> G
G --> H[Report Generation]
H --> I[Final Answer]
-
Query Input: The user submits a research query to the system.
-
Oracle Decision: The "Oracle" LLM analyzes the query and decides on the best course of action.
-
Tool Execution: Based on the Oracle's decision, one of the following tools is executed:
- RAG Search: Queries the Pinecone vector database for relevant information from indexed arXiv papers.
- Web Search: Performs a Google search using SerpAPI to gather general knowledge.
- ArXiv Fetch: Retrieves specific paper abstracts from the arXiv database.
-
Information Gathering: The system iteratively collects information using the selected tools.
-
Synthesis and Report Generation: Once sufficient information is gathered, the system synthesizes the findings into a structured report.
-
Final Answer: The comprehensive report is presented to the user, complete with research steps, main content, conclusion, and sources.
-
Clone the repository:
git clone https://github.com/yourusername/Genius-LangGraph.git cd Genius-LangGraph
-
Install required packages:
pip install -r requirements.txt
-
Set up environment variables:
export OPENAI_API_KEY="your_openai_api_key" export PINECONE_API_KEY="your_pinecone_api_key" export SERPAPI_API_KEY="your_serpapi_api_key"
-
Open the Jupyter notebook:
jupyter notebook Genius LangGraph.ipynb
-
Run the cells to initialize the agent and necessary components.
-
Use the
runnable.invoke()
function to submit queries:out = runnable.invoke({ "input": "What are the latest advancements in quantum computing?", "chat_history": [] }) print(build_report(output=out["intermediate_steps"][-1].tool_input))
- Implementation of stateful AI agents using LangGraph
- Integration of multiple data sources and APIs (arXiv, SerpAPI, Pinecone)
- Advanced prompt engineering for tool selection and report generation
- Vector database operations for similarity search
- Graph-based workflow design and visualization
- Handling of complex, multi-step AI interactions
- Asynchronous programming in AI applications
- Implement user feedback loop for continuous improvement
- Add support for more specialized knowledge domains
- Enhance the report generation with data visualization capabilities
- Implement caching mechanisms for improved performance
- Develop a user-friendly web interface for easier interaction