- MemoryService 异步路径委托 MemoryIngestService / MemoryRetrievalService;富化派发经 MemoryEnrichmentScheduler - WebSocket pipeline 经 ChatTurnService 与显式 DTO 编排单轮对话;回忆录片段入队由 MemoirIngestScheduler 封装 - 新增 LlmGateway(LlmUseCase),各 agent、任务与适配器对齐 ports - 补充 memory 提示适配、runtime 类型、memory-retrieval 文档、ai-touchpoints 说明与扫描脚本及配套测试 Made-with: Cursor
35 lines
871 B
Python
35 lines
871 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,
|
|
max_tokens: int | None = None,
|
|
) -> str:
|
|
"""Single-turn completion, returns full response text.
|
|
|
|
``max_tokens`` when set is passed to the underlying chat API (adapter-specific).
|
|
"""
|
|
|
|
...
|
|
|
|
def stream(
|
|
self,
|
|
messages: list[dict],
|
|
*,
|
|
temperature: float = 0.7,
|
|
model: str | None = None,
|
|
max_tokens: int | None = None,
|
|
) -> AsyncIterator[str]:
|
|
"""Streaming completion, yields text chunks (async generator)."""
|
|
|
|
...
|