--- title: AI Assistant with Tool Integration emoji: 🤖 colorFrom: blue colorTo: indigo sdk: gradio sdk_version: 5.0.0 app_file: app.py pinned: false license: mit --- # 🤖 AI Assistant with Tool Integration An intelligent AI assistant powered by GPT-4o-mini with Wikipedia and web search capabilities through Tavily. ## ✨ Features - **Smart Tool Selection**: Automatically chooses between Wikipedia and Tavily based on your query - **Real-time Web Search**: Get the latest news and information from the web - **Wikipedia Integration**: Access factual, encyclopedic information - **Modern UI**: Beautiful Gradio interface with conversation history - **ReAct Agent**: Uses LangGraph's ReAct pattern for reasoning and action ## 🚀 Live Demo Try the app on Hugging Face Spaces: [AndreaBagno/cas_task_1](https://huggingface.co/spaces/AndreaBagno/cas_task_1) ## 🛠️ Technologies - **LangChain & LangGraph**: For agent orchestration and tool calling - **OpenAI GPT-4o-mini**: Language model - **Gradio**: Interactive web interface - **Wikipedia API**: Factual information retrieval - **Tavily Search**: Real-time web search ## 💡 Example Queries - "What's the latest news about AI?" - "Tell me about quantum computing" - "Recent developments in climate change" - "Who is Giorgia Meloni and what's the latest news?" ## 🔧 Local Setup ### Prerequisites - Python 3.10 or higher - OpenAI API key - Tavily API key ### Installation 1. Clone the repository: ```bash git clone https://huggingface.co/spaces/AndreaBagno/cas_task_1 cd cas_task_1 ``` 2. Create a `local/.env` file with your API keys: ```bash mkdir -p local cat > local/.env << EOF OPENAI_API_KEY=your_openai_key_here TAVILY_API_KEY=your_tavily_key_here EOF ``` 3. Install dependencies: ```bash pip install -r requirements.txt ``` Or using uv: ```bash uv sync ``` 4. Run the application: ```bash python app.py ``` The app will be available at `http://localhost:7860` ## ⚙️ Configuration Edit `config.yaml` to customize: - Model parameters (temperature, max_tokens) - System prompts - Wikipedia settings - Tool configurations ## 📁 Project Structure ``` . ├── app.py # Gradio web interface ├── agent.py # AI agent with tool calling ├── config.yaml # Configuration settings ├── tools/ │ ├── wikipedia_tool.py # Wikipedia search tool │ └── tavily_tool.py # Tavily web search tool ├── assistant_avatar.png # Bot avatar image └── pyproject.toml # Python dependencies ``` ## 🔒 Privacy & Security - Conversations are not stored - API keys are loaded from environment variables - No user data is collected or shared ## 📝 License MIT License - feel free to use and modify! ## 👨‍💻 Author Created by Andrea Bagno for the CAS Generative AI course.