Skip to content

utkarshsingh2723-sudo/Deepmind

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Deepmind

πŸ“˜ LangChain Agent with Tools, Memory & Tavily Search (LangChain v1)

A beginner-friendly AI Agent built using LangChain v1, OpenAI, Tavily Search, and custom tools. Supports:

βœ… Tool Calling βœ… Short-Term Memory (Chat History) βœ… Web Search using Tavily βœ… Weather Tool βœ… Datetime Tool βœ… Interactive CLI Chat βœ… Clean & simple LangChain v1 setup

πŸš€ Features πŸ”§ Built-in Tools

get_current_datetime β†’ Returns the current system time

get_weather(city) β†’ Weather using the free wttr.in API (no key needed)

TavilySearchResults β†’ Web search with Tavily

🧠 Memory System

Stores up to 10 recent message pairs (20 messages total)

Maintains context across conversations

Automatically formats memory for LangChain v1

πŸ€– Agent System

Uses ChatOpenAI (gpt-4o-mini)

Supports structured tool calling (LangChain v1 standard)

Handles parsing errors

Verbose mode enabled for debugging

πŸ“¦ Requirements

Install using your Python 3.10 environment:

pip install langchain==0.3.14 pip install langchain-openai==0.2.14 pip install langchain-core==0.3.29 pip install langchain-community==0.3.14 pip install tavily-python==0.5.0 pip install python-dotenv==1.0.1 pip install requests==2.32.3 pip install openai>=1.0.0 pip install pydantic>=2.0.0

Or, add everything inside requirements.txt and run:

pip install -r requirements.txt

πŸ”‘ Environment Variables

Create a file called .env in the same folder as your script:

OPENAI_API_KEY=your-openai-key-here TAVILY_API_KEY=your-tavily-key-here

Both keys are required:

OPENAI_API_KEY β†’ for the LLM

TAVILY_API_KEY β†’ for web search

▢️ How to Run 1️⃣ Activate venv venv\Scripts\activate

2️⃣ Run the agent python main.py

You will see:

============================================================ LangChain Agent with Tools and Memory (v1)

πŸ“‹ Loading API keys... πŸ€– Initializing agent... βœ… Agent ready!

πŸ’¬ Usage (Inside the Chat)

Enter messages normally:

You: what is the time now? πŸ€– Agent: The current time is...

⏱ Useful Commands Command Action quit / exit / q Stop the agent history Show recent chat history clear Clear memory πŸ›  Project Structure project/ β”‚ β”œβ”€β”€ main.py # Your agent code β”œβ”€β”€ .env # API keys β”œβ”€β”€ requirements.txt # Dependencies └── README.md # Documentation

πŸ“™ How the Agent Works

  1. Loads tools
  2. Loads prompt with memory placeholders
  3. Uses create_tool_calling_agent() (correct v1 method)
  4. Uses AgentExecutor to run
  5. Stores every human/assistant message in memory
  6. Trims memory to last 10 interactions
  7. Responds using LLM β€” with tool support when needed

Done !

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages