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

Make SearchTool optional for Slack bots #3816

Closed
Closed
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
5 changes: 4 additions & 1 deletion backend/onyx/db/slack_channel_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def create_slack_channel_persona(
) -> Persona:
"""NOTE: does not commit changes"""

# Verify SearchTool exists and include it by default (but don't require it)
search_tool = get_search_tool(db_session)
if search_tool is None:
raise ValueError("Search tool not found")
Expand All @@ -65,7 +66,9 @@ def create_slack_channel_persona(
llm_filter_extraction=enable_auto_filters,
recency_bias=RecencyBiasSetting.AUTO,
prompt_ids=[default_prompt.id],
tool_ids=[search_tool.id],
tool_ids=[
search_tool.id
], # Include SearchTool by default, but it can be removed later
document_set_ids=document_set_ids,
llm_model_provider_override=None,
llm_model_version_override=None,
Expand Down
16 changes: 15 additions & 1 deletion backend/onyx/onyxbot/slack/handlers/handle_regular_answer.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,22 @@ def _get_slack_answer(
if slack_channel_config is not None
else False
)
# Check if SearchTool is enabled for this persona
search_tool_enabled = (
any(tool.in_code_tool_id == "SearchTool" for tool in persona.tools)
if persona and persona.tools
else True
) # Default to True if no persona/tools

# Set search behavior based on whether SearchTool is enabled
run_search = (
OptionalSearchSetting.AUTO
if search_tool_enabled
else OptionalSearchSetting.NEVER
)

retrieval_details = RetrievalDetails(
run_search=OptionalSearchSetting.ALWAYS,
run_search=run_search,
real_time=False,
filters=filters,
enable_auto_detect_filters=auto_detect_filters,
Expand Down
Loading