Slack doc set fix (#3737)

This commit is contained in:
pablonyx
2025-01-22 09:57:21 -08:00
committed by GitHub
parent 3e58cf2667
commit 2a758ae33f
2 changed files with 21 additions and 5 deletions

View File

@ -104,13 +104,10 @@ def load_builtin_tools(db_session: Session) -> None:
logger.notice("All built-in tools are loaded/verified.")
def auto_add_search_tool_to_personas(db_session: Session) -> None:
def get_search_tool(db_session: Session) -> ToolDBModel | None:
"""
Automatically adds the SearchTool to all Persona objects in the database that have
`num_chunks` either unset or set to a value that isn't 0. This is done to migrate
Persona objects that were created before the concept of Tools were added.
Retrieves for the SearchTool from the BUILT_IN_TOOLS list.
"""
# Fetch the SearchTool from the database based on in_code_tool_id from BUILT_IN_TOOLS
search_tool_id = next(
(
tool["in_code_tool_id"]
@ -119,6 +116,7 @@ def auto_add_search_tool_to_personas(db_session: Session) -> None:
),
None,
)
if not search_tool_id:
raise RuntimeError("SearchTool not found in the BUILT_IN_TOOLS list.")
@ -126,6 +124,18 @@ def auto_add_search_tool_to_personas(db_session: Session) -> None:
select(ToolDBModel).where(ToolDBModel.in_code_tool_id == search_tool_id)
).scalar_one_or_none()
return search_tool
def auto_add_search_tool_to_personas(db_session: Session) -> None:
"""
Automatically adds the SearchTool to all Persona objects in the database that have
`num_chunks` either unset or set to a value that isn't 0. This is done to migrate
Persona objects that were created before the concept of Tools were added.
"""
# Fetch the SearchTool from the database based on in_code_tool_id from BUILT_IN_TOOLS
search_tool = get_search_tool(db_session)
if not search_tool:
raise RuntimeError("SearchTool not found in the database.")