--- title: First Agent Template emoji: ⚡ colorFrom: pink colorTo: yellow sdk: gradio sdk_version: 5.20.1 app_file: app.py pinned: false tags: - smolagents - agent - smolagent - tool - agent-course --- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference # AI Assistant Agent with Useful Tools This Space provides an AI assistant agent built with the `smolagents` framework that can perform several useful tasks through specialized tools. The agent uses the Qwen2.5-Coder-32B-Instruct model to understand user requests and choose the appropriate tool to fulfill them. ## What This Agent Does This agent serves as an intelligent assistant that can: - Analyze text and provide detailed statistics - Get current time in different timezones around the world - Perform semantic search on text to find relevant information - Provide documentation about its own capabilities The agent uses a Gradio interface for easy interaction through natural language. Simply type your request, and the agent will handle the rest! ## Available Tools ### 1. Text Analyzer This tool analyzes text and provides comprehensive statistics including: - Word count - Character count - Unique words count - Average word length - Most common words (top 5) ### 2. Current Time in Timezone Gets the current local time for any timezone in the world using the pytz library. The tool accepts standard timezone format names like: - 'America/New_York' - 'Europe/London' - 'Asia/Tokyo' - 'UTC' ### 3. Semantic Search This tool performs semantic search on a corpus of text to find the most relevant sections matching a query. It uses: - Bag-of-words vectorization for text representation - Cosine similarity for relevance scoring - Smart text chunking for better results Note: While designed to also work with PDF documents, the current UI doesn't support file uploads. The semantic search works with text provided directly in the conversation. ### 4. Tools Documentation A special tool that lists all available tools and provides usage examples for each. Access this by asking about the agent's capabilities. ## Example Queries to Try ### Text Analysis - "Analyze this text: The quick brown fox jumps over the lazy dog." - "Give me statistics about this paragraph: Lorem ipsum dolor sit amet, consectetur adipiscing elit." ### Timezone Queries - "What time is it in Tokyo?" - "Get the current time in America/New_York" - "Tell me the time in UTC" ### Semantic Search - "Search for 'climate change' in this text: Global warming is the long-term heating of Earth's surface observed since the pre-industrial period due to human activities, primarily fossil fuel burning, which increases heat-trapping greenhouse gas levels in Earth's atmosphere." - "Find information about 'artificial intelligence' in this text: [paste your text here]" ### Getting Help - "What tools do you have?" - "Show me how to use this agent" - "Help" ## Requirements and Dependencies This agent requires: - smolagents framework - pytz for timezone functionality - numpy for semantic search vector operations - PyPDF2 (optional, for PDF processing if enabled) ## Usage Tips 1. Be specific in your requests 2. For semantic search, provide substantial text to search within 3. For timezone queries, use standard timezone names ## Limitations - The current UI does not support file uploads for PDF processing - Semantic search uses a simplified algorithm and works best with moderate amounts of text - The agent has a maximum context length, so very large inputs may be truncated ## Future Development Plans for future enhancements include: - Adding file upload capabilities - Implementing more sophisticated semantic search algorithms - Adding additional tools like web scraping (when environment permits) - Improving the PDF handling capabilities --- Feel free to contribute to this project by providing feedback or suggesting new tools that would be useful!