Skip to content

Commit

Permalink
feat: Updated agents-api/agents_api/models/agent/c
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] committed Apr 13, 2024
1 parent 01f5bad commit aed0768
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions agents-api/agents_api/models/agent/create_tools.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""This module contains functions for creating tools in the CozoDB database."""

from uuid import UUID, uuid4

import pandas as pd
Expand All @@ -11,8 +13,21 @@ def create_tools_query(
functions: list[FunctionDef],
embeddings: list[list[float]],
) -> pd.DataFrame:
"""
Constructs a datalog query for inserting tool records into the 'agent_functions' relation in the CozoDB.
Parameters:
- agent_id (UUID): The unique identifier for the agent.
- functions (list[FunctionDef]): A list of function definitions to be inserted.
- embeddings (list[list[float]]): A list of embeddings corresponding to each function.
Returns:
- pd.DataFrame: A DataFrame containing the results of the query execution.
"""
# Ensure the number of functions matches the number of embeddings
assert len(functions) == len(embeddings)

# Construct the input records for the datalog query
functions_input: list[list] = []

for function, embedding in zip(functions, embeddings):
Expand All @@ -28,6 +43,7 @@ def create_tools_query(
]
)

# Datalog query for inserting new tool records into the 'agent_functions' relation
query = """
input[agent_id, tool_id, name, description, parameters, embedding] <- $records
?[agent_id, tool_id, name, description, parameters, embedding, updated_at] :=
Expand Down

0 comments on commit aed0768

Please sign in to comment.