Skip to content

Commit

Permalink
Merge pull request #948 from julep-ai/f/add-columns-to-indices
Browse files Browse the repository at this point in the history
feat(agents-api): Add missing columns to indices
  • Loading branch information
whiterabbit1983 authored Dec 12, 2024
2 parents bf48324 + 24e9afb commit ce3e3fc
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 7 deletions.
9 changes: 6 additions & 3 deletions agents-api/agents_api/models/docs/search_docs_by_embedding.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def search_docs_by_embedding(
snippet_counter[count(item)] :=
owners[owner_type, owner_id_str],
owner_id = to_uuid(owner_id_str),
*docs {{
*docs:owner_id_metadata_doc_id_idx {{
owner_type,
owner_id,
doc_id: item,
Expand Down Expand Up @@ -142,13 +142,16 @@ def search_docs_by_embedding(
input[owner_type, owner_id, query],
# Restrict the search to all documents that match the owner
*docs {{
*docs:owner_id_metadata_doc_id_idx {{
owner_type,
owner_id,
doc_id,
title,
metadata,
}},
*docs {{
doc_id,
title,
}},
# Search for snippets in the embedding space
~snippets:embedding_space {{
Expand Down
9 changes: 6 additions & 3 deletions agents-api/agents_api/models/docs/search_docs_by_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def search_docs_by_text(
candidate[doc_id] :=
input[owner_type, owner_id],
*docs {{
*docs:owner_id_metadata_doc_id_idx {{
owner_type,
owner_id,
doc_id,
Expand Down Expand Up @@ -145,13 +145,16 @@ def search_docs_by_text(
metadata,
] :=
candidate[doc_id],
*docs {{
*docs:owner_id_metadata_doc_id_idx {{
owner_type,
owner_id,
doc_id,
title,
metadata,
}},
*docs {{
doc_id,
title,
}},
search_result [
doc_id,
snippet_data,
Expand Down
2 changes: 1 addition & 1 deletion agents-api/agents_api/models/execution/update_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def update_execution(

validate_status_query = """
valid_status[count(status)] :=
*executions {
*executions:execution_id_status_idx {
status,
execution_id: to_uuid($execution_id),
task_id: to_uuid($task_id),
Expand Down
26 changes: 26 additions & 0 deletions agents-api/migrations/migrate_1733985509_add_columns_to_indices.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# /usr/bin/env python3

MIGRATION_ID = "add_columns_to_indices"
CREATED_AT = 1733985509.241258


def up(client):
client.run(
"""
{ ::index drop executions:execution_id_status_idx }
{ ::index create executions:execution_id_status_idx { task_id, execution_id, status } }
{ ::index drop docs:owner_id_metadata_doc_id_idx }
{ ::index create docs:owner_id_metadata_doc_id_idx { owner_type, owner_id, metadata, doc_id } }
"""
)


def down(client):
client.run(
"""
{ ::index drop executions:execution_id_status_idx }
{ ::index create executions:execution_id_status_idx { execution_id, status } }
{ ::index drop docs:owner_id_metadata_doc_id_idx }
{ ::index create docs:owner_id_metadata_doc_id_idx { owner_id, metadata, doc_id } }
"""
)

0 comments on commit ce3e3fc

Please sign in to comment.