chore: 从汽车AI客服项目拷贝骨架并清理(blog页/redis)

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
浅念
2026-09-29 14:15:12 +08:00
parent 90860b8bfd
commit 49c0e5559c
97 changed files with 19131 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
from abc import ABC, abstractmethod
from collections.abc import AsyncGenerator
class AIProvider(ABC):
@abstractmethod
async def chat(self, messages: list[dict], system_prompt: str) -> str:
"""Send messages and return assistant reply text."""
@abstractmethod
async def stream_chat(
self, messages: list[dict], system_prompt: str
) -> AsyncGenerator[str, None]:
"""Stream assistant reply token by token."""
@abstractmethod
async def chat_with_extraction(
self, messages: list[dict], system_prompt: str
) -> tuple[str, dict]:
"""Send messages and return (reply_text, extracted_json).
The provider should request JSON output and parse it.
Falls back to empty dict if parsing fails.
"""