Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(agents-api): cozo queries for tasks #352

Merged
merged 7 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
Empty file.
28 changes: 25 additions & 3 deletions agents-api/agents_api/models/task/get_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,28 @@


@cozo_query
def get_task_query(developer_id: UUID, task_id: UUID) -> tuple[str, dict]:
query = """"""
return (query, {"developer_id": str(developer_id), "task_id": str(task_id)})
def get_task_query(agent_id: UUID, task_id: UUID) -> tuple[str, dict]:
query = """
?[
name,
description,
input_schema,
tools_available,
workflows,
created_at,
updated_at,
] := *tasks {
agent_id: to_uuid($agent_id),
task_id: to_uuid($task_id),
updated_at_ms,
name,
description,
input_schema,
tools_available,
workflows,
created_at,
@ 'NOW'
}, updated_at = to_int(updated_at_ms) / 1000
"""

return (query, {"agent_id": str(agent_id), "task_id": str(task_id)})
32 changes: 30 additions & 2 deletions agents-api/agents_api/models/task/list_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

@cozo_query
def list_tasks_query(
developer_id: UUID,
agent_id: UUID,
limit: int = 100,
offset: int = 0,
# metadata_filter: dict[str, Any] = {},
Expand All @@ -21,4 +21,32 @@ def list_tasks_query(
Returns:
creatorrr marked this conversation as resolved.
Show resolved Hide resolved
pd.DataFrame: A DataFrame containing the queried task data.
"""
pass

query = """
?[
task_id,
name,
description,
input_schema,
tools_available,
workflows,
created_at,
updated_at,
] := *tasks {
agent_id: to_uuid($agent_id),
task_id,
updated_at_ms,
name,
description,
input_schema,
tools_available,
workflows,
created_at,
@ 'NOW'
}, updated_at = to_int(updated_at_ms) / 1000

:limit $limit
:offset $offset
"""

return (query, {"agent_id": str(agent_id), "limit": limit, "offset": offset})
Loading