refactor: 重构 AgentScope ReAct Runner 与事件处理
- 重构 runtime/runner.py 实现 ReAct Agent 核心逻辑 - 更新事件编码器与存储机制 - 优化 prompt 系统与 tool 调用 - 调整 agent service 与 repository 配合
This commit is contained in:
@@ -170,12 +170,9 @@ class AgentService:
|
||||
command={
|
||||
"command": "run",
|
||||
"owner_id": str(current_user.id),
|
||||
"run_input": {
|
||||
"messages": [
|
||||
msg.model_dump(mode="json", exclude_none=True)
|
||||
for msg in run_input.messages
|
||||
],
|
||||
},
|
||||
"run_input": run_input.model_dump(
|
||||
mode="json", by_alias=True, exclude_none=True
|
||||
),
|
||||
},
|
||||
dedup_key=None,
|
||||
)
|
||||
@@ -204,7 +201,7 @@ class AgentService:
|
||||
|
||||
yesterday = await self._repository.get_history_day(
|
||||
session_id=thread_id,
|
||||
before=today.get("day"), # type: ignore
|
||||
before=self._parse_history_day(today.get("day")),
|
||||
)
|
||||
|
||||
messages: list[dict[str, object]] = []
|
||||
@@ -215,6 +212,16 @@ class AgentService:
|
||||
|
||||
return {"messages": messages}
|
||||
|
||||
def _parse_history_day(self, value: object) -> date | None:
|
||||
if isinstance(value, date):
|
||||
return value
|
||||
if isinstance(value, str):
|
||||
try:
|
||||
return date.fromisoformat(value)
|
||||
except ValueError:
|
||||
return None
|
||||
return None
|
||||
|
||||
async def _prepare_user_message(
|
||||
self,
|
||||
*,
|
||||
|
||||
Reference in New Issue
Block a user