Skip to content

Latest commit

 

History

History
137 lines (103 loc) · 2.69 KB

File metadata and controls

137 lines (103 loc) · 2.69 KB

Local AI Research Agent (Ollama + LangChain)

Python Ollama LangChain License: MIT

A fully local AI research agent powered by Ollama and LangChain. It can search the web, query Wikipedia, optionally save results, and return structured output via a Pydantic schema. Runs offline with no API keys or cloud services required.


Features

  • Tool-using agent (Search, Wikipedia, Save)
  • Structured output with Pydantic
  • 100% local via Ollama
  • No OpenAI keys or costs
  • Autonomous tool selection
  • DuckDuckGo Search integration
  • Wikipedia integration

Tech Stack

Component Technology
LLM Runtime Ollama
Model Qwen 2.5 Coder 7B
Framework LangChain
Parsing Pydantic
Tools DuckDuckGo + Wikipedia

Setup

Install Ollama

curl -fsSL https://ollama.com/install.sh | sh

🧩Pull the Model

Download the LLM locally:

ollama pull qwen2.5-coder:7b

Clone the Repository

git clone <your-repo-url>
cd <project-folder>

Create Virtual Environment

python3 -m venv venv
source venv/bin/activate

Install Dependencies

pip install -r requirements.txt

🎯Usage

python agent.py

Example:

What can I help you research? who are sharks

📤Example Output

Topic      : Sharks
Summary    : Sharks are cartilaginous fish...
Sources    : ['Wikipedia']
Tools used : ['wikipedia']

🧩Pydantic Response Schema

class ResearchResponse(BaseModel):
    topic: str
    summary: str
    sources: list[str]
    tools_used: list[str]

🧰 Tools Available

Tool Purpose
search DuckDuckGo web search
wikipedia Encyclopedia lookup
Save_text_to_file Optional saving

Example save usage:

research WW2 and save to file

🧪 Notes on Model Support

This project uses the following model:

qwen2.5-coder:7b

because it supports:

  • tool calling
  • reasoning
  • structured responses

Note: Other models may not support tool usage.

📌 Requirements

  • Python 3.9+
  • Ollama installed
  • macOS / Linux / WSL supported

📜 License

This project is licensed under the MIT License.


⭐ Contributions

PRs, issues, and improvements are welcome.

If you like the project, consider giving a ⭐ on GitHub!