mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-04-07 19:38:19 +02:00
Move DanswerBot Configs (#559)
This commit is contained in:
parent
90fbe1ab48
commit
3e05c4fa67
@ -11,10 +11,10 @@ from danswer.bots.slack.constants import LIKE_BLOCK_ACTION_ID
|
||||
from danswer.bots.slack.utils import build_feedback_block_id
|
||||
from danswer.bots.slack.utils import remove_slack_text_interactions
|
||||
from danswer.bots.slack.utils import translate_vespa_highlight_to_slack
|
||||
from danswer.configs.app_configs import DANSWER_BOT_NUM_DOCS_TO_DISPLAY
|
||||
from danswer.configs.app_configs import ENABLE_SLACK_DOC_FEEDBACK
|
||||
from danswer.configs.constants import DocumentSource
|
||||
from danswer.configs.constants import SearchFeedbackType
|
||||
from danswer.configs.danswerbot_configs import DANSWER_BOT_NUM_DOCS_TO_DISPLAY
|
||||
from danswer.configs.danswerbot_configs import ENABLE_SLACK_DOC_FEEDBACK
|
||||
from danswer.direct_qa.interfaces import DanswerQuote
|
||||
from danswer.server.models import SearchDoc
|
||||
from danswer.utils.text_processing import replace_whitespaces_w_space
|
||||
|
@ -13,13 +13,13 @@ from danswer.bots.slack.models import SlackMessageInfo
|
||||
from danswer.bots.slack.utils import ChannelIdAdapter
|
||||
from danswer.bots.slack.utils import fetch_userids_from_emails
|
||||
from danswer.bots.slack.utils import respond_in_thread
|
||||
from danswer.configs.app_configs import DANSWER_BOT_ANSWER_GENERATION_TIMEOUT
|
||||
from danswer.configs.app_configs import DANSWER_BOT_DISABLE_DOCS_ONLY_ANSWER
|
||||
from danswer.configs.app_configs import DANSWER_BOT_DISPLAY_ERROR_MSGS
|
||||
from danswer.configs.app_configs import DANSWER_BOT_NUM_RETRIES
|
||||
from danswer.configs.app_configs import DOCUMENT_INDEX_NAME
|
||||
from danswer.configs.app_configs import ENABLE_DANSWERBOT_REFLEXION
|
||||
from danswer.configs.constants import DOCUMENT_SETS
|
||||
from danswer.configs.danswerbot_configs import DANSWER_BOT_ANSWER_GENERATION_TIMEOUT
|
||||
from danswer.configs.danswerbot_configs import DANSWER_BOT_DISABLE_DOCS_ONLY_ANSWER
|
||||
from danswer.configs.danswerbot_configs import DANSWER_BOT_DISPLAY_ERROR_MSGS
|
||||
from danswer.configs.danswerbot_configs import DANSWER_BOT_NUM_RETRIES
|
||||
from danswer.configs.danswerbot_configs import ENABLE_DANSWERBOT_REFLEXION
|
||||
from danswer.db.engine import get_sqlalchemy_engine
|
||||
from danswer.db.models import SlackBotConfig
|
||||
from danswer.direct_qa.answer_question import answer_qa_query
|
||||
@ -38,6 +38,7 @@ def handle_message(
|
||||
answer_generation_timeout: int = DANSWER_BOT_ANSWER_GENERATION_TIMEOUT,
|
||||
should_respond_with_error_msgs: bool = DANSWER_BOT_DISPLAY_ERROR_MSGS,
|
||||
disable_docs_only_answer: bool = DANSWER_BOT_DISABLE_DOCS_ONLY_ANSWER,
|
||||
reflexion: bool = ENABLE_DANSWERBOT_REFLEXION,
|
||||
) -> bool:
|
||||
"""Potentially respond to the user message depending on filters and if an answer was generated
|
||||
|
||||
@ -64,8 +65,6 @@ def handle_message(
|
||||
document_set.name for document_set in channel_config.persona.document_sets
|
||||
]
|
||||
|
||||
reflexion = ENABLE_DANSWERBOT_REFLEXION
|
||||
|
||||
# List of user id to send message to, if None, send to everyone in channel
|
||||
send_to: list[str] | None = None
|
||||
respond_tag_only = False
|
||||
|
@ -20,9 +20,9 @@ from danswer.bots.slack.utils import ChannelIdAdapter
|
||||
from danswer.bots.slack.utils import decompose_block_id
|
||||
from danswer.bots.slack.utils import get_channel_name_from_id
|
||||
from danswer.bots.slack.utils import respond_in_thread
|
||||
from danswer.configs.app_configs import DANSWER_BOT_RESPOND_EVERY_CHANNEL
|
||||
from danswer.configs.app_configs import DANSWER_REACT_EMOJI
|
||||
from danswer.configs.app_configs import NOTIFY_SLACKBOT_NO_ANSWER
|
||||
from danswer.configs.danswerbot_configs import DANSWER_BOT_RESPOND_EVERY_CHANNEL
|
||||
from danswer.configs.danswerbot_configs import DANSWER_REACT_EMOJI
|
||||
from danswer.configs.danswerbot_configs import NOTIFY_SLACKBOT_NO_ANSWER
|
||||
from danswer.connectors.slack.utils import make_slack_api_rate_limited
|
||||
from danswer.db.engine import get_sqlalchemy_engine
|
||||
from danswer.dynamic_configs.interface import ConfigNotFoundError
|
||||
|
@ -14,8 +14,8 @@ from slack_sdk.models.metadata import Metadata
|
||||
|
||||
from danswer.bots.slack.constants import SLACK_CHANNEL_ID
|
||||
from danswer.bots.slack.tokens import fetch_tokens
|
||||
from danswer.configs.app_configs import DANSWER_BOT_NUM_RETRIES
|
||||
from danswer.configs.constants import ID_SEPARATOR
|
||||
from danswer.configs.danswerbot_configs import DANSWER_BOT_NUM_RETRIES
|
||||
from danswer.connectors.slack.utils import make_slack_api_rate_limited
|
||||
from danswer.connectors.slack.utils import UserIdReplacer
|
||||
from danswer.utils.logger import setup_logger
|
||||
|
@ -216,50 +216,3 @@ NUM_INDEXING_WORKERS = int(os.environ.get("NUM_INDEXING_WORKERS") or 1)
|
||||
LOG_ALL_MODEL_INTERACTIONS = (
|
||||
os.environ.get("LOG_ALL_MODEL_INTERACTIONS", "").lower() == "true"
|
||||
)
|
||||
|
||||
|
||||
#####
|
||||
# Danswer Slack Bot Configs
|
||||
#####
|
||||
DANSWER_BOT_NUM_RETRIES = int(os.environ.get("DANSWER_BOT_NUM_RETRIES", "5"))
|
||||
DANSWER_BOT_ANSWER_GENERATION_TIMEOUT = int(
|
||||
os.environ.get("DANSWER_BOT_ANSWER_GENERATION_TIMEOUT", "90")
|
||||
)
|
||||
# Number of docs to display in "Reference Documents"
|
||||
DANSWER_BOT_NUM_DOCS_TO_DISPLAY = int(
|
||||
os.environ.get("DANSWER_BOT_NUM_DOCS_TO_DISPLAY", "5")
|
||||
)
|
||||
# If the LLM fails to answer, Danswer can still show the "Reference Documents"
|
||||
DANSWER_BOT_DISABLE_DOCS_ONLY_ANSWER = os.environ.get(
|
||||
"DANSWER_BOT_DISABLE_DOCS_ONLY_ANSWER", ""
|
||||
).lower() not in ["false", ""]
|
||||
# When Danswer is considering a message, what emoji does it react with
|
||||
DANSWER_REACT_EMOJI = os.environ.get("DANSWER_REACT_EMOJI") or "eyes"
|
||||
# Should DanswerBot send an apology message if it's not able to find an answer
|
||||
# That way the user isn't confused as to why DanswerBot reacted but then said nothing
|
||||
# Off by default to be less intrusive (don't want to give a notif that just says we couldnt help)
|
||||
NOTIFY_SLACKBOT_NO_ANSWER = (
|
||||
os.environ.get("NOTIFY_SLACKBOT_NO_ANSWER", "").lower() == "true"
|
||||
)
|
||||
# Mostly for debugging purposes but it's for explaining what went wrong
|
||||
# if DanswerBot couldn't find an answer
|
||||
DANSWER_BOT_DISPLAY_ERROR_MSGS = os.environ.get(
|
||||
"DANSWER_BOT_DISPLAY_ERROR_MSGS", ""
|
||||
).lower() not in [
|
||||
"false",
|
||||
"",
|
||||
]
|
||||
# Default is only respond in channels that are included by a slack config set in the UI
|
||||
DANSWER_BOT_RESPOND_EVERY_CHANNEL = (
|
||||
os.environ.get("DANSWER_BOT_RESPOND_EVERY_CHANNEL", "").lower() == "true"
|
||||
)
|
||||
# Add a second LLM call post Answer to verify if the Answer is valid
|
||||
# Throws out answers that don't directly or fully answer the user query
|
||||
# This is the default for all DanswerBot channels unless the bot is configured individually
|
||||
ENABLE_DANSWERBOT_REFLEXION = (
|
||||
os.environ.get("ENABLE_DANSWERBOT_REFLEXION", "").lower() == "true"
|
||||
)
|
||||
# Add the per document feedback blocks that affect the document rankings via boosting
|
||||
ENABLE_SLACK_DOC_FEEDBACK = (
|
||||
os.environ.get("ENABLE_SLACK_DOC_FEEDBACK", "").lower() == "true"
|
||||
)
|
||||
|
47
backend/danswer/configs/danswerbot_configs.py
Normal file
47
backend/danswer/configs/danswerbot_configs.py
Normal file
@ -0,0 +1,47 @@
|
||||
import os
|
||||
|
||||
#####
|
||||
# Danswer Slack Bot Configs
|
||||
#####
|
||||
DANSWER_BOT_NUM_RETRIES = int(os.environ.get("DANSWER_BOT_NUM_RETRIES", "5"))
|
||||
DANSWER_BOT_ANSWER_GENERATION_TIMEOUT = int(
|
||||
os.environ.get("DANSWER_BOT_ANSWER_GENERATION_TIMEOUT", "90")
|
||||
)
|
||||
# Number of docs to display in "Reference Documents"
|
||||
DANSWER_BOT_NUM_DOCS_TO_DISPLAY = int(
|
||||
os.environ.get("DANSWER_BOT_NUM_DOCS_TO_DISPLAY", "5")
|
||||
)
|
||||
# If the LLM fails to answer, Danswer can still show the "Reference Documents"
|
||||
DANSWER_BOT_DISABLE_DOCS_ONLY_ANSWER = os.environ.get(
|
||||
"DANSWER_BOT_DISABLE_DOCS_ONLY_ANSWER", ""
|
||||
).lower() not in ["false", ""]
|
||||
# When Danswer is considering a message, what emoji does it react with
|
||||
DANSWER_REACT_EMOJI = os.environ.get("DANSWER_REACT_EMOJI") or "eyes"
|
||||
# Should DanswerBot send an apology message if it's not able to find an answer
|
||||
# That way the user isn't confused as to why DanswerBot reacted but then said nothing
|
||||
# Off by default to be less intrusive (don't want to give a notif that just says we couldnt help)
|
||||
NOTIFY_SLACKBOT_NO_ANSWER = (
|
||||
os.environ.get("NOTIFY_SLACKBOT_NO_ANSWER", "").lower() == "true"
|
||||
)
|
||||
# Mostly for debugging purposes but it's for explaining what went wrong
|
||||
# if DanswerBot couldn't find an answer
|
||||
DANSWER_BOT_DISPLAY_ERROR_MSGS = os.environ.get(
|
||||
"DANSWER_BOT_DISPLAY_ERROR_MSGS", ""
|
||||
).lower() not in [
|
||||
"false",
|
||||
"",
|
||||
]
|
||||
# Default is only respond in channels that are included by a slack config set in the UI
|
||||
DANSWER_BOT_RESPOND_EVERY_CHANNEL = (
|
||||
os.environ.get("DANSWER_BOT_RESPOND_EVERY_CHANNEL", "").lower() == "true"
|
||||
)
|
||||
# Add a second LLM call post Answer to verify if the Answer is valid
|
||||
# Throws out answers that don't directly or fully answer the user query
|
||||
# This is the default for all DanswerBot channels unless the bot is configured individually
|
||||
ENABLE_DANSWERBOT_REFLEXION = (
|
||||
os.environ.get("ENABLE_DANSWERBOT_REFLEXION", "").lower() == "true"
|
||||
)
|
||||
# Add the per document feedback blocks that affect the document rankings via boosting
|
||||
ENABLE_SLACK_DOC_FEEDBACK = (
|
||||
os.environ.get("ENABLE_SLACK_DOC_FEEDBACK", "").lower() == "true"
|
||||
)
|
@ -4,7 +4,6 @@ from sqlalchemy.orm import Session
|
||||
|
||||
from danswer.chunking.models import InferenceChunk
|
||||
from danswer.configs.app_configs import DISABLE_GENERATIVE_AI
|
||||
from danswer.configs.app_configs import ENABLE_DANSWERBOT_REFLEXION
|
||||
from danswer.configs.app_configs import NUM_DOCUMENT_TOKENS_FED_TO_GENERATIVE_MODEL
|
||||
from danswer.configs.app_configs import QA_TIMEOUT
|
||||
from danswer.configs.constants import IGNORE_FOR_QA
|
||||
@ -42,7 +41,7 @@ def answer_qa_query(
|
||||
disable_generative_answer: bool = DISABLE_GENERATIVE_AI,
|
||||
answer_generation_timeout: int = QA_TIMEOUT,
|
||||
real_time_flow: bool = True,
|
||||
enable_reflexion: bool = ENABLE_DANSWERBOT_REFLEXION,
|
||||
enable_reflexion: bool = False,
|
||||
retrieval_metrics_callback: Callable[[RetrievalMetricsContainer], None]
|
||||
| None = None,
|
||||
rerank_metrics_callback: Callable[[RerankMetricsContainer], None] | None = None,
|
||||
|
Loading…
x
Reference in New Issue
Block a user