Skip to content

Commit

Permalink
🐛 fix agent memory sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
yanyongyu committed Apr 30, 2024
1 parent 1279649 commit 36542e6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions operagents/agent/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ async def act(self, timeline: "Timeline") -> TimelineEventSessionAct:
prop_count=len(props),
messages=messages,
)

self._do_observe(timeline, new_message)
async for response in self.backend.generate(timeline, messages, props):
if isinstance(response, GeneratePropUsage):
for prop_message in response.props:
Expand All @@ -216,9 +218,7 @@ async def act(self, timeline: "Timeline") -> TimelineEventSessionAct:
)
)
elif isinstance(response, GenerateResponse):
self._do_observe(timeline, new_message)
self._do_response(timeline, response.content)

return TimelineEventSessionAct(
session_id=timeline.current_session_id,
scene=timeline.current_scene,
Expand Down
4 changes: 2 additions & 2 deletions operagents/agent/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing_extensions import TypeVar
from typing import TYPE_CHECKING, Any, Generic, Literal, Annotated, TypeAlias

from pydantic import Field, BaseModel, ConfigDict, field_serializer
from pydantic import Field, BaseModel, ConfigDict, SerializeAsAny, field_serializer

from operagents.prop import Prop
from operagents.scene import Scene
Expand Down Expand Up @@ -85,7 +85,7 @@ class AgentEventUseProp(BaseModel, Generic[P]):
usage_id: str
prop: Prop[P]
prop_raw_params: str
prop_params: BaseModel | None
prop_params: SerializeAsAny[BaseModel] | None
prop_result: Any

_serialize_scene = field_serializer("scene")(scene_serializer)
Expand Down

0 comments on commit 36542e6

Please sign in to comment.