diff --git a/utils/agent.py b/utils/agent.py index ead6312..855290a 100644 --- a/utils/agent.py +++ b/utils/agent.py @@ -139,7 +139,7 @@ class Part(BaseModel): type: Literal["thinking", "text"] = Field(..., description="片段类型") content: str = Field(..., description="片段内容") - timer: Optional[Task] = Field(default=None, description="片段绑定的延时异步任务") + task: Optional[Task] = Field(default=None, description="片段绑定的异步任务") class StreamEventsDebouncer: @@ -207,14 +207,14 @@ class StreamEventsDebouncer: # 其余未匹配的所有事件原样透传 yield event - def _cancel_timer(self, index: int): + def _cancel_task(self, index: int): """ - 取消指定索引片段的计时器 + 取消指定索引片段的异步任务 :param index: 片段索引 """ part = self.parts.get(index) - if part and part.timer is not None and not part.timer.done(): - part.timer.cancel() + if part and part.task is not None and not part.task.done(): + part.task.cancel() class Agent: