Spaces:
Runtime error
Runtime error
""" | |
Simple SmoLagent Test | |
==================== | |
Test the basic SmoLagent setup with just CodeAgent and DuckDuckGoSearchTool | |
""" | |
from smolagents import CodeAgent, DuckDuckGoSearchTool | |
def test_basic_agent(): | |
"""Test basic SmoLagent setup without language model""" | |
print("π€ TESTING BASIC SMOLAGENT SETUP") | |
print("=" * 35) | |
try: | |
# Create agent with just tools (no language model) | |
agent = CodeAgent(tools=[DuckDuckGoSearchTool()]) | |
print("β Basic SmoLagent created successfully!") | |
print(f"π Agent has {len(agent.tools)} tool(s) available") | |
# List available tools | |
for i, tool in enumerate(agent.tools, 1): | |
print(f" {i}. {tool.__class__.__name__}") | |
# Test basic functionality | |
print("\nπ§ͺ Testing agent functionality...") | |
# Note: Without a language model, we can't run complex queries | |
# But we can verify the agent structure is correct | |
print("β Agent structure is valid") | |
print("β οΈ Note: Full AI analysis requires a language model") | |
return agent | |
except Exception as e: | |
print(f"β Basic agent setup failed: {e}") | |
return None | |
def test_with_search(): | |
"""Test the search functionality""" | |
print("\nπ TESTING SEARCH FUNCTIONALITY") | |
print("=" * 30) | |
try: | |
# Create search tool directly | |
search_tool = DuckDuckGoSearchTool() | |
print("β DuckDuckGo search tool created") | |
# Test search (if possible) | |
print("π Search tool ready for use") | |
return search_tool | |
except Exception as e: | |
print(f"β Search tool failed: {e}") | |
return None | |
def main(): | |
"""Main test function""" | |
print("π SMOLAGENT BASIC SETUP TEST") | |
print("=" * 30) | |
# Test 1: Basic agent | |
agent = test_basic_agent() | |
# Test 2: Search tool | |
search_tool = test_with_search() | |
# Summary | |
print("\nπ TEST SUMMARY") | |
print("=" * 15) | |
print(f"Basic Agent: {'β Working' if agent else 'β Failed'}") | |
print(f"Search Tool: {'β Working' if search_tool else 'β Failed'}") | |
if agent: | |
print("\nπ‘ Your basic SmoLagent is ready!") | |
print(" To add AI capabilities, configure a language model") | |
print(" Options: Ollama (free), OpenAI (paid), Hugging Face (free)") | |
else: | |
print("\nβ Basic setup failed. Check SmoLagents installation.") | |
print("\nπ Next: Run 'python upload.py' to use enhanced data analysis!") | |
if __name__ == "__main__": | |
main() | |