An autonomous research assistant built with LangChain and Google Gemini. Give it a topic: it searches Wikipedia and the live web (DuckDuckGo), reasons step-by-step via tool-calling, and returns a structured summary with sources - optionally saved to a file.
Inspired by Tech With Tim's tutorial, then extended with structured Pydantic outputs and a save-to-file tool.
- Tool-calling agent - LangChain
create_tool_calling_agentwith ReAct-style reasoning decides when to search, summarize, or save - Tools (
tools.py): Wikipedia fetch + summarize, DuckDuckGo web search, timestamped file saver (research_output.txt) - Structured output - Pydantic models: topic, summary, sources, tools used
- LLM -
gemini-2.5-flash(free tier); swappable for OpenAI/Groq - Verbose mode - watch the agent think in the terminal
Python · LangChain · Google Gemini API · DuckDuckGo Search · Wikipedia API · Pydantic
Prereqs: Python 3.10+, a free Gemini API key
git clone https://github.com/prsdx/First_Agentic_AI
cd First_Agentic_AI
python -m venv env
env\Scripts\activate # Windows# source env/bin/activate # macOS/Linux
pip install -r requirements.txtCreate a .env file in the root:
GOOGLE_API_KEY=your_gemini_api_key_here
Run it:
python main.pyEnter a topic, watch the agent reason, then check research_output.txt
(auto-generated) for saved results.
| File | Purpose |
|---|---|
main.py | Entrypoint: LLM init, prompt, agent executor |
tools.py | Wikipedia / DuckDuckGo / file-saver tool definitions |
requirements.txt | Pinned dependencies |
> Entering new AgentExecutor chain...
Thought: I need to research this topic. I will start with Wikipedia.
Action: wiki_tool
Action Input: history of AI agents
Observation: [Wikipedia snippet...]
Thought: Good overview. Now web search for recent developments.
Action: search
Action Input: history of AI agents
Observation: [DuckDuckGo results...]
Thought: Time to summarize and save.
Action: save_text_to_file
Observation: Data successfully saved to research_output.txt
> Finished chain.
- Built on LangChain
- Tutorial inspiration: Tech With Tim
- Built by @prsdx