mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-07-29 07:14:20 +00:00
Added implementations for get_agents_session, delete_agents_session and delete_agents
This commit is contained in:
parent
be3c5c034d
commit
9bcd03fe2a
1 changed files with 37 additions and 4 deletions
|
@ -152,10 +152,43 @@ class MetaReferenceAgentsImpl(Agents):
|
|||
session_id: str,
|
||||
turn_ids: Optional[List[str]] = None,
|
||||
) -> Session:
|
||||
raise NotImplementedError()
|
||||
session = await self.persistence_store.get(f"session:{agent_id}:{session_id}")
|
||||
try:
|
||||
session = Session(**json.loads(session))
|
||||
except json.JSONDecodeError as e:
|
||||
raise ValueError(
|
||||
f"Could not JSON decode session for {agent_id} and {session_id}"
|
||||
) from e
|
||||
turns = []
|
||||
for turn_id in turn_ids:
|
||||
turn = await self.persistence_store.get(f"session:{agent_id}:{session_id}:{turn_id}")
|
||||
try:
|
||||
turn = json.loads(turn)
|
||||
except json.JSONDecodeError as e:
|
||||
raise ValueError(
|
||||
f"Could not JSON decode session for {agent_id} and {session_id}"
|
||||
) from e
|
||||
try:
|
||||
turn = Turn(**turn)
|
||||
except Exception as e:
|
||||
raise ValueError(
|
||||
f"Could not validate(?) Turns for {turn_id}"
|
||||
) from e
|
||||
turns.append(turn)
|
||||
return Session(
|
||||
session_name=session.session_name,
|
||||
session_id=session_id,
|
||||
turns=turns if turns else [],
|
||||
started_at=session.started_at
|
||||
)
|
||||
|
||||
async def delete_agents_session(self, agent_id: str, session_id: str) -> None:
|
||||
raise NotImplementedError()
|
||||
|
||||
try:
|
||||
await self.persistence_store.delete(f"session:{agent_id}:{session_id}")
|
||||
except:
|
||||
raise ValueError("Session Key Not Found")
|
||||
async def delete_agents(self, agent_id: str) -> None:
|
||||
raise NotImplementedError()
|
||||
try:
|
||||
await self.persistence_store.delete(f"agent:{agent_id}")
|
||||
except:
|
||||
raise ValueError("Agent Key not found")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue