A powerful, modular AI research agent built with LangGraph, LangMem, and Groq. This agent can conduct structured research, maintain semantic memory, and provide comprehensive answers to complex questions.
- Structured Research Planning: Automatically creates multi-step research plans
- ReAct Pattern: Reasoning and Acting in a structured loop
- Multiple LLM Support: Groq (primary) and Mistral integration
- Interactive Mode: Command-line interface for ongoing research sessions
- Extensible Architecture: Easy to add new tools and capabilities
- Hierarchical Memory: Short-term, long-term, and episodic memory layers
- Knowledge Graph Construction: Automatic concept relationship mapping
- Citation Tracking: Network analysis of research sources and references
- Memory Consolidation: Intelligent promotion of important findings
- Research Session Management: Complete episode tracking and analysis
- Concept Extraction: Automatic identification of key concepts and relationships
- Web Research Suite: DuckDuckGo search, Wikipedia integration, arXiv papers, news search
- Document Processing: PDF analysis, text extraction, structure analysis, content summarization
- Data Visualization: Timeline charts, concept networks, metrics dashboards, word frequency analysis
- Intelligent Tool Selection: Automatic tool recommendation based on research context
- Multi-Source Integration: Seamless combination of memory and external research sources
- Multi-Agent Collaboration: Researcher, Critic, and Synthesizer agents working together
- Hypothesis Generation: Automatic generation of testable research hypotheses
- Hypothesis Testing: Evidence-based validation and ranking of hypotheses
- Quality Assessment: Comprehensive research quality scoring and validation
- Fact-Checking: Multi-perspective credibility analysis and source verification
- Research Methodology: Intelligent selection and critique of research approaches
- Streamlit Web Interface: Professional web UI with real-time progress tracking
- Gradio Alternative Interface: Simple, shareable web interface for quick research
- Interactive Visualizations: Real-time charts, graphs, and progress indicators
- Professional Report Generation: HTML, Markdown, PDF, and DOCX export formats
- Advanced Configuration: Customizable research depth and feature toggles
- Mobile-Friendly Design: Responsive interfaces that work on all devices
User β Agent Interface (CLI/Web)
β
LangGraph Agent (ReAct Pattern)
ββββββββββββββ βββββββββββββ
β Memory βββββββΊβ Vector DB β
β (LangMem) β β (Chroma) β
ββββββ¬ββββββββ βββββββββββββ
β ββββββββββββββββββ
ββββββΊβ Inference LLM β
β (Groq/Mistral) β
ββββββββββββββββββ
# Clone and navigate to the project
cd ai_research_agent
# Run setup script
python setup.py
# Set your API keys
export GROQ_API_KEY='your_groq_api_key_here'
# Run component tests
python test_agent.py
# Interactive mode
python main.py
# Direct question mode
python main.py "How does quantum computing work?"
- Python 3.8+
- Groq API key (required)
- Mistral API key (optional)
- OpenAI API key (optional, for embeddings)
Create a .env
file or set environment variables:
GROQ_API_KEY=your_groq_api_key_here
MISTRAL_API_KEY=your_mistral_api_key_here # optional
OPENAI_API_KEY=your_openai_api_key_here # optional
- Groq: Get from console.groq.com
- Mistral: Get from console.mistral.ai
- OpenAI: Get from platform.openai.com
$ python main.py
π€ AI Research Agent - Interactive Mode
==================================================
π¬ Enter your research question: What are the latest developments in AI safety?
π¬ Starting research on: What are the latest developments in AI safety?
============================================================
π Research Plan:
1. Search for recent AI safety research and publications
2. Identify key organizations and researchers in AI safety
3. Analyze current AI safety challenges and proposed solutions
4. Examine recent policy developments and industry initiatives
π Research Steps Completed: 4
π― Final Answer:
----------------------------------------
[Comprehensive research results...]
----------------------------------------
python main.py "Explain machine learning algorithms"
ai_research_agent/
βββ agent/
β βββ research_agent.py # Main agent logic with ReAct pattern
βββ llm/
β βββ groq_wrapper.py # LLM integrations
βββ memory/
β βββ langmem_tools.py # Semantic memory tools
β βββ vector_store.py # Vector database setup
βββ tools/
β βββ web_search.py # Web search capabilities
β βββ __init__.py
βββ main.py # Entry point and CLI interface
βββ config.py # Configuration management
βββ test_agent.py # Test suite
βββ setup.py # Setup and installation script
βββ requirements.txt # Python dependencies
βββ README.md # This file
- Planning Phase: Agent analyzes the question and creates a structured research plan
- Execution Phase: Each research step is executed systematically:
- Search semantic memory for relevant information
- Analyze findings and identify gaps
- Store important discoveries for future reference
- Synthesis Phase: All findings are combined into a comprehensive answer
- Semantic Memory: Uses LangMem for intelligent information storage and retrieval
- Context Preservation: Research context is maintained across sessions
- Automatic Indexing: Important findings are automatically stored with metadata
- State Management: Proper state tracking throughout the research process
- Tool Integration: Seamless integration of memory and search tools
- Error Handling: Robust error handling and fallback mechanisms
- Create tool in
tools/
directory - Import and integrate in
research_agent.py
- Update tool executor with new capabilities
- Enhance
memory/langmem_tools.py
with new memory operations - Add specialized memory tools for different research domains
- Implement hierarchical memory structures
- Create wrapper in
llm/
directory followinggroq_wrapper.py
pattern - Update
config.py
with new API configuration - Integrate in agent initialization
# Run full test suite
python test_agent.py
# Test specific components
python -c "from memory.langmem_tools import get_memory_tools; print('Memory tools:', len(get_memory_tools()))"
- β ReAct pattern with proper state management
- β Research planning capabilities
- β Multi-step reasoning workflows
- β Memory tools integration
- β Hierarchical memory (short-term, long-term, episodic)
- β Knowledge graph construction with NetworkX
- β Citation tracking and network analysis
- β Memory consolidation algorithms
- β Research session management
- β Concept extraction and relationship mapping
- β Knowledge graph visualization tools
- β Web scraping and search integration (DuckDuckGo, Wikipedia, arXiv, News)
- β PDF/document ingestion pipeline with text extraction
- β Academic paper analysis tools (arXiv integration)
- β Data visualization generators (timelines, networks, dashboards)
- β Intelligent tool selection and recommendation system
- β Multi-source research integration
- β Multi-agent collaboration (researcher + critic + synthesizer)
- β Hypothesis generation and testing
- β Quality assessment and fact-checking
- β Research methodology selection and critique
- β Evidence-based validation and ranking
- β Multi-perspective analysis and synthesis
- β Web interface (Streamlit/Gradio)
- β Real-time progress tracking
- β Interactive research reports
- β Export capabilities (PDF, DOCX, HTML, Markdown)
- β Professional report generation with templates
- β Mobile-friendly responsive design
- β Advanced configuration options
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
This project is open source. Feel free to use, modify, and distribute.
"No module named 'langgraph'"
pip install langgraph
"GROQ_API_KEY not found"
export GROQ_API_KEY='your_actual_api_key'
Memory tool errors
pip install langmem chromadb
- Check the test output:
python test_agent.py
- Verify your API keys are set correctly
- Ensure all requirements are installed:
pip install -r requirements.txt
Happy Researching! π¬β¨