feat(frontend): agent resource sections
This commit is contained in:
1 parent
a10224d21e
commit
6134c026a6
3 files changed
+82
-80
No files matched your search
+7
-3
@@ -285,9 +285,13 @@ class App(ChatMixin):
|
||||
|
||||
# --- Resource Management ---
|
||||
|
||||
async def get_agent_resource(self, agent_id, kind, key):
|
||||
resource = await db.AgentResource.get_or_none(agent_id=agent_id, kind=kind, key=key)
|
||||
return resource.value if resource else None
|
||||
async def get_agent_resources(self, agent_id, kind=None, key=None):
|
||||
filter = {"agent_id": agent_id}
|
||||
if kind: filter['kind'] = kind
|
||||
if key: filter['key'] = key
|
||||
|
||||
values = await db.AgentResource.filter(**filter)
|
||||
return values
|
||||
|
||||
async def save_agent_resource(self, agent_id, kind, key, value):
|
||||
await db.AgentResource.update_or_create(
|
||||
|
||||
@@ -223,6 +223,14 @@ async def start_server(app):
|
||||
elif action == "get-agents":
|
||||
await send({'message': "agents retrieved", 'agents': await app.get_agents(user_id), 'nonce': nonce})
|
||||
|
||||
elif action == "get-agent-resources":
|
||||
values = await app.get_agent_resources(body['agentId'], body.get('kind'), body.get('key'))
|
||||
await send({'resources': [{'kind': r.kind, 'key': r.key, 'value': r.value} for r in values], 'nonce': nonce})
|
||||
|
||||
elif action == "save-agent-resource":
|
||||
await app.save_agent_resource(body['agentId'], body['kind'], body['key'], body['value'])
|
||||
await send({'message': "resource saved", 'nonce': nonce})
|
||||
|
||||
elif action == "get-agent-runs":
|
||||
await send({
|
||||
'runs': await app.get_agent_runs(agent_id=body.get('agentId'), user_id=user_id),
|
||||
|
||||
Reference in new issue
Block a user