refactor: 重构 AgentScope ReAct Runner 与事件处理
- 重构 runtime/runner.py 实现 ReAct Agent 核心逻辑 - 更新事件编码器与存储机制 - 优化 prompt 系统与 tool 调用 - 调整 agent service 与 repository 配合
This commit is contained in:
@@ -53,6 +53,12 @@ class FriendshipRepository(Protocol):
|
||||
"""Get friendship by ID."""
|
||||
...
|
||||
|
||||
async def get_friendships_by_ids(
|
||||
self, friendship_ids: list[UUID]
|
||||
) -> dict[UUID, Friendship]:
|
||||
"""Batch get friendships by IDs."""
|
||||
...
|
||||
|
||||
async def get_inbox_messages_for_user(
|
||||
self, user_id: UUID, status: InboxMessageStatus | None = None
|
||||
) -> list[InboxMessage]:
|
||||
@@ -214,6 +220,28 @@ class SQLAlchemyFriendshipRepository(BaseRepository[Friendship]):
|
||||
)
|
||||
raise
|
||||
|
||||
async def get_friendships_by_ids(
|
||||
self, friendship_ids: list[UUID]
|
||||
) -> dict[UUID, Friendship]:
|
||||
if not friendship_ids:
|
||||
return {}
|
||||
try:
|
||||
unique_ids = list(dict.fromkeys(friendship_ids))
|
||||
stmt = (
|
||||
select(Friendship)
|
||||
.where(Friendship.id.in_(unique_ids))
|
||||
.where(Friendship.deleted_at.is_(None))
|
||||
)
|
||||
result = await self._session.execute(stmt)
|
||||
friendships = list(result.scalars().all())
|
||||
return {friendship.id: friendship for friendship in friendships}
|
||||
except SQLAlchemyError:
|
||||
logger.exception(
|
||||
"Failed to get friendships by ids",
|
||||
friendship_ids=[str(i) for i in friendship_ids],
|
||||
)
|
||||
raise
|
||||
|
||||
async def get_inbox_messages_for_user(
|
||||
self, user_id: UUID, status: InboxMessageStatus | None = None
|
||||
) -> list[InboxMessage]:
|
||||
|
||||
Reference in New Issue
Block a user