Add current stream operator status
This commit is contained in:
@@ -205,6 +205,11 @@ class Repository:
|
||||
result = await self.session.execute(stmt)
|
||||
return list(result.scalars().all())
|
||||
|
||||
async def get_latest_human_message(self, session_id: str) -> ChatMessage | None:
|
||||
"""Get the most recent non-bot chat message from a session."""
|
||||
messages = await self.get_recent_human_messages(session_id=session_id, limit=1)
|
||||
return messages[0] if messages else None
|
||||
|
||||
async def count_messages(self, session_id: str) -> int:
|
||||
"""Count chat messages stored for a session."""
|
||||
stmt = select(func.count()).select_from(ChatMessage).where(
|
||||
@@ -280,6 +285,28 @@ class Repository:
|
||||
result = await self.session.execute(stmt)
|
||||
return list(result.scalars().all())
|
||||
|
||||
async def get_latest_action(
|
||||
self,
|
||||
session_id: str,
|
||||
action_type: AgentActionType | None = None,
|
||||
mode: str | None = None,
|
||||
) -> AgentAction | None:
|
||||
"""Get the most recent action for a session, optionally filtered."""
|
||||
conditions = [AgentAction.session_id == session_id]
|
||||
if action_type:
|
||||
conditions.append(AgentAction.action_type == action_type)
|
||||
if mode:
|
||||
conditions.append(AgentAction.mode == mode)
|
||||
|
||||
stmt = (
|
||||
select(AgentAction)
|
||||
.where(*conditions)
|
||||
.order_by(AgentAction.timestamp.desc())
|
||||
.limit(1)
|
||||
)
|
||||
result = await self.session.execute(stmt)
|
||||
return result.scalars().first()
|
||||
|
||||
# Clip Candidate operations
|
||||
|
||||
async def add_clip_candidate(
|
||||
|
||||
Reference in New Issue
Block a user