feat: 修改drawing 为django 接口
This commit is contained in:
17
backend/ai/llm/adapter/deepseek.py
Normal file
17
backend/ai/llm/adapter/deepseek.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from langchain_deepseek import ChatDeepSeek
|
||||
|
||||
from llm.base import MultiModalAICapability
|
||||
|
||||
|
||||
class DeepSeekAdapter(MultiModalAICapability):
|
||||
def __init__(self, api_key, model, **kwargs):
|
||||
|
||||
self.llm = ChatDeepSeek(api_key=api_key, model=model, streaming=True)
|
||||
|
||||
async def chat(self, messages, **kwargs):
|
||||
# 兼容 DeepSeek 的调用方式
|
||||
return await self.llm.ainvoke(messages)
|
||||
|
||||
async def stream_chat(self, messages, **kwargs):
|
||||
async for chunk in self.llm.astream(messages):
|
||||
yield chunk
|
||||
Reference in New Issue
Block a user