Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI Research Agent

A simple LangChain-based agent that conducts research, generates content, and saves findings to structured documents.

Overview

This project implements a simple, focused research assistant using LangChain and large language models. The agent can search the web, query Wikipedia, generate comprehensive documents, and automatically save research findings to files.

Features

  • Multi-source Research: Combines web search and Wikipedia data
  • Structured Output: Returns findings in a standardized format
  • File Storage: Automatically saves research documents with formatting
  • Error Handling: Robust error management for network and API issues
  • Agent-based Architecture: Uses LangChain's agent framework for complex tasks

Requirements

  • Python 3.8+
  • Dependencies listed in requirements.txt

Installation

  1. Clone the repository:

    git clone [repository-url]
    cd AI-Agent
    
  2. Create a virtual environment:

    python -m venv venv
    
  3. Activate the virtual environment:

    • Windows: .\venv\Scripts\activate
    • Unix/MacOS: source venv/bin/activate
  4. Install dependencies:

    pip install -r requirements.txt
    
  5. Set up environment variables: Create a .env file with your API keys:

    OPENAI_API_KEY=your_openai_key
    GOOGLE_API_KEY=your_google_key
    # Add other API keys as needed
    

Usage

Run the main script:

python main.py

Enter your research query when prompted. The agent will:

  1. Gather information from the web and Wikipedia
  2. Generate a structured research document
  3. Save the results to research_output.txt

Project Structure

  • main.py: Core application with LangChain agent setup
  • tools.py: Custom tools for search, Wikipedia, and file operations
  • requirements.txt: Project dependencies
  • research_output.txt: Generated research documents

Technical Details

Components

  • LangChain: Framework for LLM applications and agents
  • LLM Integration: Supports OpenAI, Google Gemini, and Anthropic models
  • Pydantic Models: Type validation for structured output
  • DuckDuckGo Search: Web search integration
  • Wikipedia API: Structured knowledge source

Output Format

Research documents are saved with the following structure:

  • Research topic and summary
  • Detailed content
  • Research process documentation
  • Sources and references
  • Tools used

Customization

You can modify the agent's behavior by:

  1. Changing the LLM provider in main.py:

    llm = ChatOpenAI(model="gpt-4")  # Change to your preferred model
  2. Adjusting the system prompt for different instructions

  3. Adding new tools to tools.py for additional capabilities

Limitations

  • Depends on third-party API access and rate limits
  • Research quality depends on the underlying LLM capabilities
  • Web search results may vary in quality and relevance

License

MIT License

About

AI-Agent is a LangChain‑based research assistant that combines web and Wikipedia querying to gather multi‑source information, generates structured research documents with robust error handling, and automatically saves the results to formatted files using a modular agent architecture.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages