28 lines
692 B
Python
28 lines
692 B
Python
"""LLMProvider port — 大语言模型能力契约。"""
|
|
|
|
from collections.abc import AsyncIterator
|
|
from typing import Protocol, runtime_checkable
|
|
|
|
|
|
@runtime_checkable
|
|
class LLMProvider(Protocol):
|
|
async def complete(
|
|
self,
|
|
messages: list[dict],
|
|
*,
|
|
temperature: float = 0.7,
|
|
model: str | None = None,
|
|
) -> str:
|
|
"""Single-turn completion, returns full response text."""
|
|
...
|
|
|
|
def stream(
|
|
self,
|
|
messages: list[dict],
|
|
*,
|
|
temperature: float = 0.7,
|
|
model: str | None = None,
|
|
) -> AsyncIterator[str]:
|
|
"""Streaming completion, yields text chunks (async generator)."""
|
|
...
|