1、重构Agent代码
2、实现WebSocket连接服务
This commit is contained in:
1 parent
2c1bac9bcb
commit
77ff26094d
16 files changed
+871
-322
No files matched your search
@@ -0,0 +1,22 @@
|
||||
from openai.types.chat import ChatCompletionMessageParam
|
||||
from pydantic import BaseModel, Field, PrivateAttr
|
||||
|
||||
from mini_agent.tools.tool import Tool
|
||||
|
||||
|
||||
class ConversationContext(BaseModel):
|
||||
conversation_id: str = Field(description="会话ID")
|
||||
messages: list[ChatCompletionMessageParam] = Field(description="消息历史", default_factory=list)
|
||||
|
||||
_discovered_tools: list[Tool] = PrivateAttr(default_factory=list)
|
||||
|
||||
discovered_tool_names: list[str] = Field(description="已发现的工具名称", default_factory=list)
|
||||
|
||||
@property
|
||||
def discovered_tools(self):
|
||||
return self._discovered_tools
|
||||
|
||||
def add_tool(self, tool: Tool):
|
||||
if tool.name not in self.discovered_tool_names:
|
||||
self.discovered_tool_names.append(tool.name)
|
||||
self.discovered_tools.append(tool)
|
||||
Reference in new issue
Block a user