Skip to content

Commit

Permalink
Merge branch 'dev' into x/rag-search
Browse files Browse the repository at this point in the history
  • Loading branch information
Vedantsahai18 committed Jan 13, 2025
2 parents 41ae093 + 3819cfb commit 1b02a79
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 33 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/translate-readme.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Translate ReadME

on:
push:
paths:
- "README.md"
# on:
# push:
# paths:
# - "README.md"

jobs:
readme-translator:
Expand Down Expand Up @@ -37,4 +37,4 @@ jobs:
delete-branch: true
add-paths: |
README.md
README-*.md
README-*.md
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
confidence: Annotated[float, Field(ge=-1.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
confidence: Annotated[float, Field(ge=-1.0, le=1.0)] = 0
"""
The confidence cutoff level
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
from ...common.utils.db_exceptions import common_db_exceptions
from ..utils import pg_query, rewrap_exceptions, wrap_in_class

# FIXME: We should use latest_transitions instead of transitions
# Query to get a paused execution token
get_paused_execution_token_query = """
SELECT * FROM latest_transitions
SELECT * FROM transitions
WHERE
execution_id = $1
AND type = 'wait'
Expand Down
14 changes: 5 additions & 9 deletions agents-api/agents_api/routers/agents/__init__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
# ruff: noqa: F401

from .create_agent import create_agent

# from .create_agent_tool import create_agent_tool
from .create_agent_tool import create_agent_tool
from .create_or_update_agent import create_or_update_agent
from .delete_agent import delete_agent

# from .delete_agent_tool import delete_agent_tool
from .delete_agent_tool import delete_agent_tool
from .get_agent_details import get_agent_details

# from .list_agent_tools import list_agent_tools
from .list_agent_tools import list_agent_tools
from .list_agents import list_agents
from .patch_agent import patch_agent

# from .patch_agent_tool import patch_agent_tool
from .patch_agent_tool import patch_agent_tool
from .router import router
from .update_agent import update_agent
# from .update_agent_tool import update_agent_tool
from .update_agent_tool import update_agent_tool
6 changes: 4 additions & 2 deletions agents-api/agents_api/routers/agents/create_agent_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ async def create_agent_tool(
x_developer_id: Annotated[UUID, Depends(get_developer_id)],
data: CreateToolRequest,
) -> ResourceCreatedResponse:
tool = await create_tools_query(
tools = await create_tools_query(
developer_id=x_developer_id,
agent_id=agent_id,
data=[data],
)[0]
)

tool = tools[0]

return ResourceCreatedResponse(id=tool.id, created_at=tool.created_at, jobs=[])
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
confidence: Annotated[float, Field(ge=-1.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
confidence: Annotated[float, Field(ge=-1.0, le=1.0)] = 0
"""
The confidence cutoff level
"""
Expand Down
16 changes: 8 additions & 8 deletions memory-store/migrations/000022_vector_search.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ CREATE OR REPLACE FUNCTION search_by_vector (
owner_types TEXT[],
owner_ids UUID [],
k integer DEFAULT 3,
confidence float DEFAULT 0.5,
confidence float DEFAULT 0.0,
metadata_filter jsonb DEFAULT NULL
) RETURNS SETOF doc_search_result LANGUAGE plpgsql AS $$
DECLARE
Expand All @@ -19,8 +19,8 @@ BEGIN
RAISE EXCEPTION 'k must be greater than 0';
END IF;

IF confidence < 0 OR confidence > 1 THEN
RAISE EXCEPTION 'confidence must be between 0 and 1';
IF confidence < -1 OR confidence > 1 THEN
RAISE EXCEPTION 'confidence must be between -1 and 1';
END IF;

IF owner_types IS NOT NULL AND owner_ids IS NOT NULL AND
Expand All @@ -29,7 +29,7 @@ BEGIN
END IF;

-- Calculate search threshold from confidence
search_threshold := confidence;
search_threshold := 1.0 - confidence;

-- Build owner filter SQL
owner_filter_sql := '
Expand All @@ -53,23 +53,23 @@ BEGIN
d.index,
d.title,
d.content,
((1 - (d.embedding <=> $1)) + 1) * 0.5 as distance,
(d.embedding <=> $1) as distance,
d.embedding,
d.metadata,
doc_owners.owner_type,
doc_owners.owner_id
FROM docs_embeddings d
LEFT JOIN doc_owners ON d.doc_id = doc_owners.doc_id
WHERE d.developer_id = $7
AND ((1 - (d.embedding <=> $1)) + 1) * 0.5 >= $2
AND (d.embedding <=> $1) <= $2
%s
%s
ORDER BY ((1 - (d.embedding <=> $1)) + 1) * 0.5 DESC
ORDER BY (d.embedding <=> $1) ASC
LIMIT ($3 * 4) -- Get more candidates than needed
)
SELECT DISTINCT ON (doc_id) *
FROM ranked_docs
ORDER BY doc_id, distance DESC
ORDER BY doc_id, distance ASC
LIMIT $3',
owner_filter_sql,
metadata_filter_sql
Expand Down
4 changes: 2 additions & 2 deletions typespec/docs/models.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ model BaseDocSearchRequest {

model VectorDocSearchRequest extends BaseDocSearchRequest {
/** The confidence cutoff level */
@minValue(0)
@minValue(-1)
@maxValue(1)
confidence: float = 0;

Expand All @@ -146,7 +146,7 @@ model TextOnlyDocSearchRequest extends BaseDocSearchRequest {

model HybridDocSearchRequest extends BaseDocSearchRequest {
/** The confidence cutoff level */
@minValue(0)
@minValue(-1)
@maxValue(1)
confidence: float = 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 @@ -2983,7 +2983,7 @@ components:
properties:
confidence:
type: number
minimum: 0
minimum: -1
maximum: 1
description: The confidence cutoff level
default: 0
Expand Down Expand Up @@ -3066,7 +3066,7 @@ components:
properties:
confidence:
type: number
minimum: 0
minimum: -1
maximum: 1
description: The confidence cutoff level
default: 0
Expand Down

0 comments on commit 1b02a79

Please sign in to comment.