Skip to content

Commit

Permalink
fix docs search tool params
Browse files Browse the repository at this point in the history
  • Loading branch information
HamadaSalhab committed Oct 7, 2024
1 parent 38f8a1d commit 8432e95
Showing 1 changed file with 48 additions and 3 deletions.
51 changes: 48 additions & 3 deletions agents-api/agents_api/activities/execute_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from fastapi.background import BackgroundTasks
from temporalio import activity

from ..autogen.Docs import CreateDocRequest
from ..autogen.Docs import CreateDocRequest, HybridDocSearchRequest, TextOnlyDocSearchRequest, VectorDocSearchRequest
from ..autogen.Tools import SystemDef
from ..common.protocol.tasks import StepContext
from ..env import testing
Expand Down Expand Up @@ -91,7 +91,29 @@ async def execute_system(
elif system.operation == "search":
# The `search_agent_docs` function requires `x_developer_id` instead of `developer_id`.
arguments["x_developer_id"] = arguments.pop("developer_id")
return await search_agent_docs(**arguments)

if "text" in arguments and "vector" in arguments:
search_params = HybridDocSearchRequest(
text=arguments.pop("text"),
vector=arguments.pop("vector"),
limit=arguments.get("limit", 10),
)

elif "text" in arguments:
search_params = TextOnlyDocSearchRequest(
text=arguments.pop("text"),
limit=arguments.get("limit", 10),
)
elif "vector" in arguments:
search_params = VectorDocSearchRequest(
vector=arguments.pop("vector"),
limit=arguments.get("limit", 10),
)

return await search_agent_docs(
search_params=search_params,
**arguments,
)

# NO SUBRESOURCE
elif system.subresource == None:
Expand Down Expand Up @@ -138,7 +160,30 @@ async def execute_system(
elif system.operation == "search":
# The `search_user_docs` function requires `x_developer_id` instead of `developer_id`.
arguments["x_developer_id"] = arguments.pop("developer_id")
return await search_user_docs(**arguments)


if "text" in arguments and "vector" in arguments:
search_params = HybridDocSearchRequest(
text=arguments.pop("text"),
vector=arguments.pop("vector"),
limit=arguments.get("limit", 10),
)

elif "text" in arguments:
search_params = TextOnlyDocSearchRequest(
text=arguments.pop("text"),
limit=arguments.get("limit", 10),
)
elif "vector" in arguments:
search_params = VectorDocSearchRequest(
vector=arguments.pop("vector"),
limit=arguments.get("limit", 10),
)

return await search_user_docs(
search_params=search_params,
**arguments,
)

# NO SUBRESOURCE
elif system.subresource == None:
Expand Down

0 comments on commit 8432e95

Please sign in to comment.