Download scratch/test_agent.py from akra35567/Akiragpu: direct link, hf CLI and curl.
- Browser
- Download file 1.62 kB
-
https://huggingface.co/spaces/akra35567/Akiragpu/resolve/main/scratch/test_agent.py
- Command line
-
hf download hf://spaces/akra35567/Akiragpu/scratch/test_agent.py
-
curl -L -o test_agent.py https://huggingface.co/spaces/akra35567/Akiragpu/resolve/main/scratch/test_agent.py
1.62 kB
| # type: ignore | |
| import os | |
| import sys | |
| import json | |
| from loguru import logger | |
| # Adiciona o caminho do projeto | |
| sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | |
| from modules.api import LLMManager | |
| from modules.skills_registry import registry | |
| from modules.skills_library import initialize_skills | |
| def test_agent_logic(): | |
| logger.info("🧪 Iniciando teste de lógica de Agente...") | |
| initialize_skills() | |
| # Mock do config | |
| class MockConfig: | |
| GEMINI_API_KEY = os.getenv("GEMINI_API_KEY", "") | |
| SYSTEM_PROMPT = "Você é a Akira, uma assistente direta e curta. Use as ferramentas se necessário." | |
| MAX_TOKENS = 1000 | |
| get_system_prompt = lambda: "Você é a Akira, assistente direta." | |
| llm = LLMManager(MockConfig()) | |
| llm.providers = ['gemini'] | |
| # Caso 1: Pergunta sobre o tempo (deve disparar get_weather) | |
| prompt = "Qual a temperatura em Luanda agora?" | |
| logger.info(f"Pergunta: {prompt}") | |
| # Simulando o que o akira_endpoint faria | |
| tools = registry.get_tool_schemas() | |
| res, model = llm.generate(prompt, tools=tools) | |
| if isinstance(res, dict) and "tool_calls" in res: | |
| logger.success(f"✅ IA solicitou ferramentas: {[tc.name for tc in res['tool_calls']]}") | |
| for tc in res["tool_calls"]: | |
| args = tc.args if hasattr(tc, "args") else json.loads(tc.arguments) | |
| obs = registry.execute(tc.name, args) | |
| logger.info(f"🔧 Executado {tc.name} -> {obs}") | |
| else: | |
| logger.info(f"🤖 Resposta direta: {res}") | |
| if __name__ == "__main__": | |
| test_agent_logic() | |