| 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 | |
| # optional, default duration is 8 hours/480 minutes. Max duration is 30 days/43200 minutes. | |
| hf_oauth_expiration_minutes: 480 | |
| Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference | |
| ## Setup | |
| 1. Install dependencies: | |
| ```bash | |
| uv pip install -r requirements.txt | |
| ``` | |
| 2. Copy `.env.example` to `.env` and fill in your API keys: | |
| ```bash | |
| cp .env.example .env | |
| ``` | |
| ``` | |
| GOOGLE_API_KEY=your-google-api-key-here | |
| TAVILY_API_KEY=your-tavily-api-key-here | |
| ``` | |
| ## Usage | |
| ### Run Gradio app locally | |
| ```bash | |
| uv run app.py | |
| ``` | |
| ### Run the agent directly | |
| ```bash | |
| uv run python -m agent.agent | |
| ``` | |
| ### Test the search tool only | |
| ```bash | |
| uv run python -m agent.tools.search | |
| ``` | |
| ### Use in code | |
| ```python | |
| from agent import run | |
| answer = run("What is LangGraph?") | |
| print(answer) | |
| ``` | |
| ## Project Structure | |
| ``` | |
| agent/ | |
| βββ __init__.py # Exports run() | |
| βββ agent.py # websearch_agent + run entrypoint | |
| βββ tools/ | |
| βββ __init__.py # Exports web_search | |
| βββ search.py # Tavily search tool (max_results=10) | |
| app.py # Gradio UI for HuggingFace Spaces | |
| .env.example # API keys template | |
| requirements.txt # Python dependencies | |
| ``` |