diff --git a/Makefile b/Makefile index d6f0a77..34f25a7 100644 --- a/Makefile +++ b/Makefile @@ -16,10 +16,10 @@ ui-mindmap: >cd ui/cli-ia-mindmap && npm install && npm run dev lint: ->flake8 . +>python -m flake8 . typecheck: ->mypy bus_server.py kb.py agent_server.py server tests +>python -m mypy src/bus_server.py src/core/kb.py src/agent_server.py src/server test: >python -m pytest -q diff --git a/models/backend.py b/models/backend.py index 547e6ea..1f3caa9 100644 --- a/models/backend.py +++ b/models/backend.py @@ -112,7 +112,7 @@ def chat(self, messages: List[Dict[str, str]]) -> str: if role == "system": system_content = (system_content + "\n" if system_content else "") + content continue - converted.append({"role": role, "content": [{"type": "text", "text": content}]} + converted.append({"role": role, "content": [{"type": "text", "text": content}]}) headers = { "x-api-key": self.api_key, @@ -149,4 +149,4 @@ def make_client(kind: str, endpoint: str, model: str): if kind == "anthropic": # Anthropic ignores the OpenAI-style endpoint; pass endpoint if overridden return AnthropicChat(model=model, endpoint=endpoint or None) - raise ValueError(f"unknown model backend {kind}") \ No newline at end of file + raise ValueError(f"unknown model backend {kind}") diff --git a/src/agent_server.py b/src/agent_server.py index f830723..d9af81e 100644 --- a/src/agent_server.py +++ b/src/agent_server.py @@ -312,7 +312,7 @@ async def health_check() -> Dict[str, str]: @app.post("/wake") async def wake_up() -> Dict[str, str]: if bus is not None: - bus.subscribe(role, lambda msg: logger.info("[%s] received: %s", role, msg)) # type: ignore[attr-defined] + logger.info("Bus client active for role %s", role) init_cron() return {"status": "awake", "role": role} diff --git a/src/bus_server.py b/src/bus_server.py index 8fb3fa5..d3d9ffe 100644 --- a/src/bus_server.py +++ b/src/bus_server.py @@ -10,7 +10,7 @@ import logging import traceback import re -from typing import Any, Dict +from typing import Any, AsyncIterator, Dict from fastapi import FastAPI, Depends, HTTPException, Request, status from contextlib import asynccontextmanager @@ -25,7 +25,7 @@ from integrations import social_hooks @asynccontextmanager -async def lifespan(app: FastAPI): +async def lifespan(app: FastAPI) -> AsyncIterator[None]: try: yield finally: diff --git a/src/server/main.py b/src/server/main.py index 2954341..f4ab96b 100644 --- a/src/server/main.py +++ b/src/server/main.py @@ -6,7 +6,7 @@ import json import os from pathlib import Path -from typing import Any, Dict +from typing import Any, AsyncIterator, Dict import logging import traceback import redis @@ -49,7 +49,7 @@ @asynccontextmanager -async def lifespan(app: FastAPI): +async def lifespan(app: FastAPI) -> AsyncIterator[None]: await init_db() try: yield @@ -81,7 +81,11 @@ async def healthz() -> Dict[str, bool]: async def readyz() -> Dict[str, bool]: db_ok = await ping_db() try: - redis_ok = bool(await get_redis().ping()) + ping_result = get_redis().ping() + if asyncio.iscoroutine(ping_result): + redis_ok = bool(await ping_result) + else: + redis_ok = bool(ping_result) except redis.exceptions.ConnectionError as exc: logger.error("Redis connection error during readyz: %s", exc) REDIS_READYZ_FAILURES.labels(reason="connection_error").inc()