File size: 2,404 Bytes
054839b
 
 
 
 
 
 
 
 
 
6073dc2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
---
title: Agent with smolagents + DeepSeek
emoji: 🧠
colorFrom: indigo
colorTo: blue
sdk: gradio
app_file: main.py
pinned: false
---

# Hugging Face Agent Project

This project implements a Hugging Face agent using the smolagents framework. The agent is designed to handle various tasks by utilizing custom tools and models.

## Project Structure

```
huggingface-agent-project
β”œβ”€β”€ main.py               # Entry point for the agent
β”œβ”€β”€ agent_config.py       # Configuration and model loading
β”œβ”€β”€ tools                 # Directory for custom tools
β”‚   β”œβ”€β”€ __init__.py       # Package initializer for tools
β”‚   β”œβ”€β”€ wiki_tool.py      # Tool for fetching Wikipedia summaries
β”‚   β”œβ”€β”€ web_search_tool.py # Tool for performing web searches using DuckDuckGo
β”‚   β”œβ”€β”€ excel_analysis_tool.py # Tool for analyzing Excel files
β”œβ”€β”€ requirements.txt      # Project dependencies
└── README.md             # Project documentation
```

## Setup Instructions

1. Clone the repository:
   ```
   git clone <repository-url>
   cd huggingface-agent-project
   ```

2. Install the required dependencies:
   ```
   pip install -r requirements.txt
   ```

## Usage

To run the agent, execute the following command:
```
python main.py
```

## Agent Capabilities

The agent is capable of performing various tasks by leveraging the following tools:

### Tools
- **WikiTool**: Fetches summaries of topics from Wikipedia, handling disambiguation and page errors gracefully.
- **WebSearchTool**: Performs web searches using DuckDuckGo and retrieves the first result's snippet.
- **ExcelAnalysisTool**: Loads an Excel file and sums sales from items labeled as "food", excluding drinks. Returns the total sales in USD with 2 decimal places.

### Models
- The agent uses the Hugging Face Inference API via `HfApiModel` to interact with models such as `DeepSeek-R1` or `DeepSeek-Coder`.

### Example Workflow
1. The agent receives a request.
2. Based on the request, it selects the appropriate tool (e.g., WikiTool for Wikipedia lookups).
3. The tool processes the request and returns the result.

## Contributing

Contributions are welcome! Please submit a pull request or open an issue for any enhancements or bug fixes.

## Future Enhancements

- Deployment to Hugging Face Spaces.
- Adding more tools for advanced functionalities.
- Improving error handling and logging.