feat: jc 引擎主线搬入 app/engine(315 测试基线全绿:320 去掉 admin 5 用例)
Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -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.
|
||||
"""
|
||||
Reference in New Issue
Block a user