mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-10-08 20:15:12 +02:00
Slack doc set fix (#3737)
This commit is contained in:
@@ -15,6 +15,7 @@ from onyx.db.models import User
|
|||||||
from onyx.db.persona import mark_persona_as_deleted
|
from onyx.db.persona import mark_persona_as_deleted
|
||||||
from onyx.db.persona import upsert_persona
|
from onyx.db.persona import upsert_persona
|
||||||
from onyx.db.prompts import get_default_prompt
|
from onyx.db.prompts import get_default_prompt
|
||||||
|
from onyx.tools.built_in_tools import get_search_tool
|
||||||
from onyx.utils.errors import EERequiredError
|
from onyx.utils.errors import EERequiredError
|
||||||
from onyx.utils.variable_functionality import (
|
from onyx.utils.variable_functionality import (
|
||||||
fetch_versioned_implementation_with_fallback,
|
fetch_versioned_implementation_with_fallback,
|
||||||
@@ -47,6 +48,10 @@ def create_slack_channel_persona(
|
|||||||
) -> Persona:
|
) -> Persona:
|
||||||
"""NOTE: does not commit changes"""
|
"""NOTE: does not commit changes"""
|
||||||
|
|
||||||
|
search_tool = get_search_tool(db_session)
|
||||||
|
if search_tool is None:
|
||||||
|
raise ValueError("Search tool not found")
|
||||||
|
|
||||||
# create/update persona associated with the Slack channel
|
# create/update persona associated with the Slack channel
|
||||||
persona_name = _build_persona_name(channel_name)
|
persona_name = _build_persona_name(channel_name)
|
||||||
default_prompt = get_default_prompt(db_session)
|
default_prompt = get_default_prompt(db_session)
|
||||||
@@ -60,6 +65,7 @@ def create_slack_channel_persona(
|
|||||||
llm_filter_extraction=enable_auto_filters,
|
llm_filter_extraction=enable_auto_filters,
|
||||||
recency_bias=RecencyBiasSetting.AUTO,
|
recency_bias=RecencyBiasSetting.AUTO,
|
||||||
prompt_ids=[default_prompt.id],
|
prompt_ids=[default_prompt.id],
|
||||||
|
tool_ids=[search_tool.id],
|
||||||
document_set_ids=document_set_ids,
|
document_set_ids=document_set_ids,
|
||||||
llm_model_provider_override=None,
|
llm_model_provider_override=None,
|
||||||
llm_model_version_override=None,
|
llm_model_version_override=None,
|
||||||
|
@@ -104,13 +104,10 @@ def load_builtin_tools(db_session: Session) -> None:
|
|||||||
logger.notice("All built-in tools are loaded/verified.")
|
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
|
Retrieves for the SearchTool from the BUILT_IN_TOOLS list.
|
||||||
`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_id = next(
|
search_tool_id = next(
|
||||||
(
|
(
|
||||||
tool["in_code_tool_id"]
|
tool["in_code_tool_id"]
|
||||||
@@ -119,6 +116,7 @@ def auto_add_search_tool_to_personas(db_session: Session) -> None:
|
|||||||
),
|
),
|
||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
|
|
||||||
if not search_tool_id:
|
if not search_tool_id:
|
||||||
raise RuntimeError("SearchTool not found in the BUILT_IN_TOOLS list.")
|
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)
|
select(ToolDBModel).where(ToolDBModel.in_code_tool_id == search_tool_id)
|
||||||
).scalar_one_or_none()
|
).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:
|
if not search_tool:
|
||||||
raise RuntimeError("SearchTool not found in the database.")
|
raise RuntimeError("SearchTool not found in the database.")
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user