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

fix(agents-api, memory-store): Add migration for delete cascade + search docs fixes #1023

Merged
merged 2 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions agents-api/agents_api/autogen/Docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class HybridDocSearchRequest(BaseDocSearchRequest):
model_config = ConfigDict(
populate_by_name=True,
)
confidence: Annotated[float, Field(ge=0.0, le=1.0)] = 0.5
confidence: Annotated[float, Field(ge=0.0, le=1.0)] = 0
"""
The confidence cutoff level
"""
Expand Down Expand Up @@ -222,7 +222,7 @@ class VectorDocSearchRequest(BaseDocSearchRequest):
model_config = ConfigDict(
populate_by_name=True,
)
confidence: Annotated[float, Field(ge=0.0, le=1.0)] = 0.5
confidence: Annotated[float, Field(ge=0.0, le=1.0)] = 0
"""
The confidence cutoff level
"""
Expand Down
4 changes: 2 additions & 2 deletions agents-api/agents_api/queries/docs/get_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@


def transform_get_doc(d: dict) -> dict:
content = d["content"][0] if len(d["content"]) == 1 else d["content"]
content = d["content"]

embeddings = d["embeddings"][0] if len(d["embeddings"]) == 1 else d["embeddings"]
embeddings = d["embeddings"]

if isinstance(embeddings, str):
embeddings = json.loads(embeddings)
Expand Down
4 changes: 2 additions & 2 deletions agents-api/agents_api/queries/docs/list_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@


def transform_list_docs(d: dict) -> dict:
content = d["content"][0] if len(d["content"]) == 1 else d["content"]
content = d["content"]

embeddings = d["embeddings"][0] if len(d["embeddings"]) == 1 else d["embeddings"]
embeddings = d["embeddings"]

if isinstance(embeddings, str):
embeddings = json.loads(embeddings)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ async def search_docs_by_embedding(
owner_types,
owner_ids,
k,
confidence,
1.0 - confidence,
metadata_filter,
],
)
2 changes: 1 addition & 1 deletion agents-api/agents_api/queries/docs/search_docs_hybrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ async def search_docs_hybrid(
owner_ids,
k,
alpha,
confidence,
1.0 - confidence,
metadata_filter,
search_language,
],
Expand Down
4 changes: 2 additions & 2 deletions integrations-service/integrations/autogen/Docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class HybridDocSearchRequest(BaseDocSearchRequest):
model_config = ConfigDict(
populate_by_name=True,
)
confidence: Annotated[float, Field(ge=0.0, le=1.0)] = 0.5
confidence: Annotated[float, Field(ge=0.0, le=1.0)] = 0
"""
The confidence cutoff level
"""
Expand Down Expand Up @@ -222,7 +222,7 @@ class VectorDocSearchRequest(BaseDocSearchRequest):
model_config = ConfigDict(
populate_by_name=True,
)
confidence: Annotated[float, Field(ge=0.0, le=1.0)] = 0.5
confidence: Annotated[float, Field(ge=0.0, le=1.0)] = 0
"""
The confidence cutoff level
"""
Expand Down
13 changes: 13 additions & 0 deletions memory-store/migrations/000020_executions_task_cascade.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
BEGIN;

-- Remove cascading foreign key constraint
ALTER TABLE executions
DROP CONSTRAINT IF EXISTS fk_executions_task;

-- Restore original foreign key without cascading behavior
ALTER TABLE executions
ADD CONSTRAINT fk_executions_task
FOREIGN KEY (developer_id, task_id, task_version)
REFERENCES tasks (developer_id, task_id, "version");

COMMIT;
14 changes: 14 additions & 0 deletions memory-store/migrations/000020_executions_task_cascade.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
BEGIN;

-- Temporarily remove foreign key to modify its behavior
ALTER TABLE executions
DROP CONSTRAINT IF EXISTS fk_executions_task;

-- Recreate foreign key with cascading deletes
ALTER TABLE executions
ADD CONSTRAINT fk_executions_task
FOREIGN KEY (developer_id, task_id, task_version)
REFERENCES tasks (developer_id, task_id, "version")
ON DELETE CASCADE;

COMMIT;
4 changes: 2 additions & 2 deletions typespec/docs/models.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ model VectorDocSearchRequest extends BaseDocSearchRequest {
/** The confidence cutoff level */
@minValue(0)
@maxValue(1)
confidence: float = 0.5;
confidence: float = 0;

/** Vector to use in the search. Must be the same dimensions as the embedding model or else an error will be thrown. */
vector: float[];
Expand All @@ -148,7 +148,7 @@ model HybridDocSearchRequest extends BaseDocSearchRequest {
/** The confidence cutoff level */
@minValue(0)
@maxValue(1)
confidence: float = 0.5;
confidence: float = 0;

/** The weight to apply to BM25 vs Vector search results. 0 => pure BM25; 1 => pure vector; */
@minValue(0)
Expand Down
4 changes: 2 additions & 2 deletions typespec/tsp-output/@typespec/openapi3/openapi-1.0.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2986,7 +2986,7 @@ components:
minimum: 0
maximum: 1
description: The confidence cutoff level
default: 0.5
default: 0
alpha:
type: number
minimum: 0
Expand Down Expand Up @@ -3069,7 +3069,7 @@ components:
minimum: 0
maximum: 1
description: The confidence cutoff level
default: 0.5
default: 0
vector:
type: array
items:
Expand Down
Loading