From 6e0e5311ae949c466b5c84308e382d0e01a20050 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Tue, 28 Jan 2025 20:46:23 +0000 Subject: [PATCH 1/4] Make SearchTool optional for Slack bots - Remove hardcoded SearchTool requirement from create_slack_channel_persona - Keep SearchTool existence check for system integrity - Maintain backward compatibility for existing Slack bot personas - Allow SearchTool to be enabled/disabled via UI as needed This change allows Slack bots to be created without SearchTool by default, while preserving the ability to enable it through the UI if desired. Co-Authored-By: Chris Weaver --- backend/onyx/db/slack_channel_config.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/onyx/db/slack_channel_config.py b/backend/onyx/db/slack_channel_config.py index 523909f22b9..a1a07d8cc95 100644 --- a/backend/onyx/db/slack_channel_config.py +++ b/backend/onyx/db/slack_channel_config.py @@ -48,6 +48,7 @@ def create_slack_channel_persona( ) -> Persona: """NOTE: does not commit changes""" + # Verify SearchTool exists but don't require it search_tool = get_search_tool(db_session) if search_tool is None: raise ValueError("Search tool not found") @@ -65,7 +66,7 @@ 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=[], # SearchTool is now optional for Slack bots document_set_ids=document_set_ids, llm_model_provider_override=None, llm_model_version_override=None, From 8508c591311f42452e669a051b0b59fe4351e798 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Wed, 29 Jan 2025 17:49:08 +0000 Subject: [PATCH 2/4] Make SearchTool optional but enabled by default for Slack bots - Modified handle_regular_answer.py to respect SearchTool configuration - Updated slack_channel_config.py to include SearchTool by default - Maintains backward compatibility for existing Slack bots The changes allow Slack bots to function without SearchTool while keeping it enabled by default for new bots. This provides more flexibility in bot configuration while maintaining existing behavior as the default. Co-Authored-By: Chris Weaver --- backend/onyx/db/slack_channel_config.py | 4 ++-- .../slack/handlers/handle_regular_answer.py | 14 +++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/backend/onyx/db/slack_channel_config.py b/backend/onyx/db/slack_channel_config.py index a1a07d8cc95..200276e8167 100644 --- a/backend/onyx/db/slack_channel_config.py +++ b/backend/onyx/db/slack_channel_config.py @@ -48,7 +48,7 @@ def create_slack_channel_persona( ) -> Persona: """NOTE: does not commit changes""" - # Verify SearchTool exists but don't require it + # 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") @@ -66,7 +66,7 @@ def create_slack_channel_persona( llm_filter_extraction=enable_auto_filters, recency_bias=RecencyBiasSetting.AUTO, prompt_ids=[default_prompt.id], - tool_ids=[], # SearchTool is now optional for Slack bots + 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, diff --git a/backend/onyx/onyxbot/slack/handlers/handle_regular_answer.py b/backend/onyx/onyxbot/slack/handlers/handle_regular_answer.py index cad549a7644..19e05174f5f 100644 --- a/backend/onyx/onyxbot/slack/handlers/handle_regular_answer.py +++ b/backend/onyx/onyxbot/slack/handlers/handle_regular_answer.py @@ -195,8 +195,20 @@ 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.AS_NEEDED if search_tool_enabled + else OptionalSearchSetting.DISABLED + ) + retrieval_details = RetrievalDetails( - run_search=OptionalSearchSetting.ALWAYS, + run_search=run_search, real_time=False, filters=filters, enable_auto_detect_filters=auto_detect_filters, From 7587badd40ae3420fa292d5ae6747d3bfc0ce5d2 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Wed, 29 Jan 2025 17:52:04 +0000 Subject: [PATCH 3/4] Apply formatting changes from pre-commit hooks Co-Authored-By: Chris Weaver --- backend/onyx/db/slack_channel_config.py | 4 +++- .../onyxbot/slack/handlers/handle_regular_answer.py | 12 +++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/backend/onyx/db/slack_channel_config.py b/backend/onyx/db/slack_channel_config.py index 200276e8167..8212d4d63dd 100644 --- a/backend/onyx/db/slack_channel_config.py +++ b/backend/onyx/db/slack_channel_config.py @@ -66,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], # Include SearchTool by default, but it can be removed later + 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, diff --git a/backend/onyx/onyxbot/slack/handlers/handle_regular_answer.py b/backend/onyx/onyxbot/slack/handlers/handle_regular_answer.py index 19e05174f5f..8b2fc244af2 100644 --- a/backend/onyx/onyxbot/slack/handlers/handle_regular_answer.py +++ b/backend/onyx/onyxbot/slack/handlers/handle_regular_answer.py @@ -196,14 +196,16 @@ def _get_slack_answer( 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 + 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.AS_NEEDED if search_tool_enabled + OptionalSearchSetting.AS_NEEDED + if search_tool_enabled else OptionalSearchSetting.DISABLED ) From 8e934e9662683c4a8068e8df9a6ee736e7ccfa97 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Wed, 29 Jan 2025 18:00:38 +0000 Subject: [PATCH 4/4] Fix mypy errors by using correct OptionalSearchSetting enum values Co-Authored-By: Chris Weaver --- backend/onyx/onyxbot/slack/handlers/handle_regular_answer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/onyx/onyxbot/slack/handlers/handle_regular_answer.py b/backend/onyx/onyxbot/slack/handlers/handle_regular_answer.py index 8b2fc244af2..3e9b893110b 100644 --- a/backend/onyx/onyxbot/slack/handlers/handle_regular_answer.py +++ b/backend/onyx/onyxbot/slack/handlers/handle_regular_answer.py @@ -204,9 +204,9 @@ def _get_slack_answer( # Set search behavior based on whether SearchTool is enabled run_search = ( - OptionalSearchSetting.AS_NEEDED + OptionalSearchSetting.AUTO if search_tool_enabled - else OptionalSearchSetting.DISABLED + else OptionalSearchSetting.NEVER ) retrieval_details = RetrievalDetails(