This project is designed to build AI agents using the Langchain framework and Google Generative AI models. The primary goal is to get experience with how to structure and integrate tools, and to get experience with how to structure the agent's execution flow. In a latter project I will adjust the code for a agentic tool call experience.
main.py: This file is intended to be the entry point for defining and running the Langchain agent. It will handle the setup of the Language Model (LLM), integrate tools, and orchestrate the agent's execution flow.util/tools.py: This file is designated for defining custom tools that the AI agent can utilize. These tools can encapsulate specific functionalities, API calls, or data processing logic that the agent needs to interact with the external environment.requirements.txt: Lists all Python dependencies, includinglangchain,wikipedia,langchain-community,langchain-openai,langchain-google,pydantic,python-dotenv, andgoogle-genai.
- Language Model (LLM): The project uses Google Generative AI models (e.g., Gemini) via
google-genaiandlangchain-googlefor natural language understanding and generation. - Langchain Agent: The core of the AI agent will be built using Langchain, which provides the framework for chaining LLM calls, tool usage, and memory management.
- Tools: Custom tools defined in
util/tools.py(or potentially external tools like Wikipedia viawikipediaandlangchain-community) will extend the agent's capabilities. - Environment Variables: Sensitive information and API keys are expected to be loaded from a
.envfile usingpython-dotenv.
- Install Dependencies: Ensure all required Python packages are installed:
pip install -r requirements.txt
- Environment Variables: Create a
.envfile in the project root and populate it with necessary API keys (e.g.,GOOGLE_API_KEY).
Once the agent logic is implemented in main.py, it can be run directly:
python main.py- Tool Definition: Custom tools should be defined as functions or classes in
util/tools.pyand integrated into the Langchain agent. - LLM Integration: The
google.genaiclient should be initialized and used to interact with Google's Generative AI models.
- Google Generative AI: The project relies heavily on Google's Generative AI services for its core intelligence.
- Wikipedia: The
wikipedialibrary is included for potential integration as a search tool for the agent. - Langchain: This framework is central to the agent's architecture, providing abstractions for LLMs, tools, and agents.