diff --git a/pyproject.toml b/pyproject.toml index 9365868..27e9db1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,5 +40,5 @@ dev = [ [tool.taskipy.tasks] dev = "uvicorn src.naliiabotapi.main:app --host 0.0.0.0 --port 8010 --reload" -test = "pytest -v" +test = "pytest -vv" test-cov = "pytest tests/test_agent.py --cov=src.naliiabot.bot.agent --cov-report=html && python -m http.server 8000 --directory htmlcov" diff --git a/src/naliiabot/bot/tools/naliia_tools.py b/src/naliiabot/bot/tools/naliia_tools.py index 2c309d1..229f2af 100644 --- a/src/naliiabot/bot/tools/naliia_tools.py +++ b/src/naliiabot/bot/tools/naliia_tools.py @@ -11,7 +11,7 @@ from .schemes import ScheduleSchema TIMEZONE = "America/Bogota" -MCP_SERVER_URL = "http://localhost:8001/mcp" +MCP_SERVER_URL = "http://192.168.58.109:3001/mcp" _MCP_CLIENT = Client(MCP_SERVER_URL) @@ -76,10 +76,10 @@ class NaliiaTools: @tool def find_customer_by_identifier(identifier: str) -> str: """ - Busca un cliente por su identificador (teléfono, email o número de documento). + Busca un cliente por su identificador (teléfono o número de documento). Args: - identifier: Identificador del cliente (teléfono, email o número de documento). + identifier: Identificador del cliente (teléfono o número de documento). Returns: str: JSON con la información del cliente encontrado. @@ -97,6 +97,7 @@ class NaliiaTools: return result result = asyncio.run(call_tool()) + return result.content[0].text @tool @@ -122,6 +123,7 @@ class NaliiaTools: return result result = asyncio.run(call_tool()) + return result.content[0].text @tool @@ -150,6 +152,7 @@ class NaliiaTools: return result result = asyncio.run(call_tool()) + return result.content[0].text @tool(args_schema=ScheduleSchema) @@ -216,6 +219,8 @@ class NaliiaTools: logger.info(result) - asyncio.run(call_tool()) + return result + + result = asyncio.run(call_tool()) return True diff --git a/src/naliiabotapi/api/v1/webhooks/chat_hook.py b/src/naliiabotapi/api/v1/webhooks/chat_hook.py index d12638c..82120cf 100644 --- a/src/naliiabotapi/api/v1/webhooks/chat_hook.py +++ b/src/naliiabotapi/api/v1/webhooks/chat_hook.py @@ -14,7 +14,8 @@ async def send_whatsapp_message(request_data: SendMessageScheme): """ Envía un mensaje de texto a través de la API de WhatsApp. """ - instance_url = request_data["instance_url"] + # instance_url = request_data["instance_url"] + instance_url = 'http://192.168.58.109:8080' instance_name = request_data["instance_name"] apikey = request_data["apikey"] jid = request_data["jid"] diff --git a/tests/test_agent.py b/tests/test_agent.py index fa19296..e0d6d5e 100644 --- a/tests/test_agent.py +++ b/tests/test_agent.py @@ -32,7 +32,7 @@ class TestAgentConstruction: agent = Agent(model=mock_model) - assert agent.config.max_iterations == 10 + assert agent.config.max_iterations == 200 assert "helpful assistant" in agent.config.system_prompt assert agent.tools == [] diff --git a/tests/test_api.py b/tests/test_api.py index 1dea0fa..b961c51 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -5,9 +5,8 @@ from src.naliiabotapi.main import app @pytest.fixture def client(): - client = TestClient(app) - - return client + with TestClient(app) as client: + yield client def test_root(client):