feat!: migrate to OpenAI native tool calls and fix circular deps (#fuck-gemini)

- Fix circular dependencies in agent/tools
- Migrate from custom JSON to OpenAI tool calls format
- Add async streaming (step_stream, complete_stream)
- Simplify prompt system and remove token counting
- Add 5 new API endpoints (/health, /v1/models, /api/memory/*)
- Add 3 new tools (get_torrent_by_index, add_torrent_by_index, set_language)
- Fix all 500 tests and add coverage config (80% threshold)
- Add comprehensive docs (README, pytest guide)

BREAKING: LLM interface changed, memory injection via get_memory()
This commit is contained in:
2025-12-06 19:11:05 +01:00
parent 2c8cdd3ab1
commit 9ca31e45e0
92 changed files with 7897 additions and 1786 deletions
+8 -7
View File
@@ -1,17 +1,18 @@
# agent/parameters.py
from collections.abc import Callable
from dataclasses import dataclass
from typing import Any, Optional, Callable
import os
from typing import Any
@dataclass
class ParameterSchema:
"""Describes a required parameter for the agent."""
key: str
description: str
why_needed: str # Explanation for the AI
type: str # "string", "number", "object", etc.
validator: Optional[Callable[[Any], bool]] = None
validator: Callable[[Any], bool] | None = None
default: Any = None
required: bool = True
@@ -31,7 +32,7 @@ REQUIRED_PARAMETERS = [
type="object",
validator=lambda x: isinstance(x, dict),
required=True,
default={}
default={},
),
ParameterSchema(
key="tv_shows",
@@ -43,12 +44,12 @@ REQUIRED_PARAMETERS = [
type="array",
validator=lambda x: isinstance(x, list),
required=False,
default=[]
default=[],
),
]
def get_parameter_schema(key: str) -> Optional[ParameterSchema]:
def get_parameter_schema(key: str) -> ParameterSchema | None:
"""Get schema for a specific parameter."""
for param in REQUIRED_PARAMETERS:
if param.key == key:
@@ -79,7 +80,7 @@ def format_parameters_for_prompt() -> str:
return "\n".join(lines)
def validate_parameter(key: str, value: Any) -> tuple[bool, Optional[str]]:
def validate_parameter(key: str, value: Any) -> tuple[bool, str | None]:
"""
Validate a parameter value against its schema.