| title | Template Final Assignment |
|---|---|
| emoji | 🕵🏻♂️ |
| colorFrom | indigo |
| colorTo | indigo |
| sdk | gradio |
| sdk_version | 5.25.2 |
| app_file | app.py |
| pinned | false |
| hf_oauth | true |
| hf_oauth_expiration_minutes | 480 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
This project implements an AI agent using LangGraph and OpenAI models. The agent can answer questions, perform calculations, and search for information using various tools.
- Uses LangGraph for agent workflow management
- Integrates with OpenAI models
- Includes various tools:
- Basic math operations (add, subtract, multiply, divide, modulus)
- Web search via Tavily
- Wikipedia search
- ArXiv paper search
- Similar question search from vector database
- Vector store for retrieving similar questions and answers
- Gradio web interface for easy interaction
Create a .env file in the root directory with the following variables:
OPENAI_API_KEY=your_openai_api_key_here
TAVILY_API_KEY=your_tavily_api_key_here
Optionally, you can also add:
GOOGLE_API_KEY=your_google_api_key_here
pip install -r requirements.txtpython app.pyThis will start the Gradio web interface where you can interact with the agent.
You can modify the LLM provider and model in app.py:
agent = BasicAgent(provider="openai", model_name="gpt-4.1-2025-04-14")Supported providers:
openai(default): Uses OpenAI modelsgoogle: Uses Google Generative AI models
You can add new tools in agent.py by creating functions decorated with @tool:
@tool
def your_tool_name(param: type) -> return_type:
"""Tool description.
Args:
param: Parameter description
"""
# Tool implementation
return resultThen add your tool to the tools list:
tools = [
multiply, add, subtract, divide, modulus,
wiki_search, web_search, arvix_search,
your_tool_name, # Add your new tool here
]- The agent uses LangGraph to manage the workflow between different components.
- When a question is received, it first checks for similar questions in the vector database.
- The LLM (OpenAI by default) processes the question and decides what tools to use.
- If tools are needed, they are executed and the results are fed back to the LLM.
- The process continues until the LLM provides a final answer.
The agent is built using a state graph with the following components:
- Retriever Node: Searches for similar questions in the vector database
- Assistant Node: Processes the question and decides what to do next
- Tools Node: Executes tools requested by the assistant
The graph flow is:
- START → Retriever
- Retriever → Assistant
- Assistant → Tools (if needed) or END
- Tools → Assistant
This project is open source and available under the MIT License.