Skip to content

Commit

Permalink
fix(agents-api): Configure list and get docs return types for embeddi…
Browse files Browse the repository at this point in the history
…ngs and content + Fix confidence issue
  • Loading branch information
Ahmad-mtos committed Jan 6, 2025
1 parent f4e34a2 commit e1b406c
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 14 deletions.
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
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

0 comments on commit e1b406c

Please sign in to comment.