88a1dab810
---ci--- phase: 7 milestone: v0.2 status: complete requirements: covered: [REQ-2-001, REQ-2-002, REQ-2-003, REQ-2-004, REQ-2-005, REQ-2-006, REQ-2-007, REQ-2-008, REQ-2-009, REQ-2-010, REQ-2-011, REQ-2-012] partial: [] ---/ci--- Milestone v0.2 (ai-tutor-architecture) merged to main. Escalation record (audit remediation, durable): P1 executor delegation failed twice (empty subagent results, zero files created); auto-resolved at full autonomy to inline execution with identical plan fidelity (commit 3271373, reflog-only after phase branch squash-delete).
36 lines
996 B
Python
36 lines
996 B
Python
"""LLMProvider protocol — the port all agents depend on (D-017).
|
|
|
|
Implementations: openai_compat.OpenAICompatProvider (ollama-cloud + local),
|
|
mock.MockProvider (deterministic, tests/CI). Providers are dumb pipes:
|
|
no envelope logic here — the API layer owns meta/done/error events (D-016).
|
|
"""
|
|
|
|
from collections.abc import AsyncIterator
|
|
from typing import Protocol
|
|
|
|
from .types import Message
|
|
|
|
|
|
class LLMProvider(Protocol):
|
|
async def stream_chat(
|
|
self,
|
|
messages: list[Message],
|
|
*,
|
|
model: str,
|
|
temperature: float = 0.7,
|
|
response_format: dict | None = None,
|
|
) -> AsyncIterator[str]:
|
|
"""Yield incremental content deltas (plain text chunks)."""
|
|
...
|
|
|
|
async def chat(
|
|
self,
|
|
messages: list[Message],
|
|
*,
|
|
model: str,
|
|
temperature: float = 0.7,
|
|
response_format: dict | None = None,
|
|
) -> str:
|
|
"""Non-streaming completion — returns the full reply text."""
|
|
...
|