Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions models/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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}")
raise ValueError(f"unknown model backend {kind}")
2 changes: 1 addition & 1 deletion src/agent_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down
4 changes: 2 additions & 2 deletions src/bus_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
10 changes: 7 additions & 3 deletions src/server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -49,7 +49,7 @@


@asynccontextmanager
async def lifespan(app: FastAPI):
async def lifespan(app: FastAPI) -> AsyncIterator[None]:
await init_db()
try:
yield
Expand Down Expand Up @@ -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()
Expand Down
Loading