- 更新 .gitignore 以排除测试相关目录。 - 增强 ChatbotAgent 和 DeepAgent 以利用 BaseState 进行状态管理。 - 引入 PresentArtifacts 工具,允许代理向用户展示输出文件。 - 在 state.py 中添加新的状态管理功能,包括 merge_artifacts 和 BaseState。 - 创建 AgentArtifactsCard 组件以在前端显示工件。 - 在 AgentChatComponent 和 AgentInputArea 中集成工件处理。 - 更新 MessageInputComponent 和 ToolCallRenderer 以更好地处理工件的 UI 展示。 - 添加工件状态管理和标准化函数的测试。 - 更新 docker-compose 以使用最新的沙箱配置器镜像。 - 在路线图中记录新功能。
31 lines
774 B
Python
31 lines
774 B
Python
"""Define the state structures for the agent."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Annotated, TypedDict
|
|
|
|
from langchain.agents import AgentState
|
|
|
|
|
|
def merge_artifacts(existing: list[str] | None, new: list[str] | None) -> list[str]:
|
|
"""Merge artifact file paths while preserving order and removing duplicates."""
|
|
if existing is None:
|
|
return new or []
|
|
if new is None:
|
|
return existing
|
|
return list(dict.fromkeys(existing + new))
|
|
|
|
|
|
class BaseState(AgentState):
|
|
"""Shared state fields for Yuxi agents."""
|
|
|
|
artifacts: Annotated[list[str], merge_artifacts]
|
|
|
|
|
|
class AgentStatePayload(TypedDict):
|
|
"""Serialized agent state payload consumed by the frontend."""
|
|
|
|
todos: list
|
|
files: dict
|
|
artifacts: list[str]
|