feat(07-02): singleton OpenAIProvider + GenericOpenAIProvider + MAX_AI_CHARS removal

- openai_provider.py: singleton self._client=AsyncOpenAI(...) in __init__ (D-07),
  _truncate() 60/40 smart truncation (D-13), removed MAX_AI_CHARS constant,
  changed __init__ signature to include context_chars, removed _client() method
- generic_openai_provider.py: new class, subclasses OpenAIProvider, conditional
  response_format={"type":"json_object"} on supports_json_mode flag (D-01/D-02),
  imports parse_classification + parse_suggestions from ai.utils (D-02 contract)
- ollama_provider.py: added context_chars kwarg with default 8000, passes through
- lmstudio_provider.py: added context_chars kwarg with default 8000, passes through
- classifier.py: removed MAX_AI_CHARS constant and text[:MAX_AI_CHARS] slices;
  truncation now handled inside each provider via _truncate()
- requirements.txt: bumped anthropic floor to >=0.95.0 (D-03 output_config support)
This commit is contained in:
curo1305
2026-06-04 18:58:19 +02:00
parent beb5b5e49d
commit 02bcbb9143
6 changed files with 152 additions and 20 deletions
+7 -1
View File
@@ -2,9 +2,15 @@ from ai.openai_provider import OpenAIProvider
class LMStudioProvider(OpenAIProvider):
def __init__(self, base_url: str = "http://host.docker.internal:1234", model: str = "gemma-4-e4b-it"):
def __init__(
self,
base_url: str = "http://host.docker.internal:1234",
model: str = "gemma-4-e4b-it",
context_chars: int = 8000,
):
super().__init__(
api_key="lm-studio",
model=model,
base_url=base_url.rstrip("/") + "/v1",
context_chars=context_chars,
)