diff --git a/remote_config/keys.py b/remote_config/keys.py index 9af3e305f8..bb543f801f 100644 --- a/remote_config/keys.py +++ b/remote_config/keys.py @@ -2,4 +2,7 @@ REF_CACHE_LIMIT_KEY = "feature.text.ref_cache_limit" ENABLE_WEBPAGES = "feature.webpages.enable" CLIENT_REMOTE_CONFIG_JSON = "feature.client.remote_config_json" -EXPIRE_LEGACY_COOKIES = "feature.cookies.expire_legacy" \ No newline at end of file +EXPIRE_LEGACY_COOKIES = "feature.cookies.expire_legacy" + +# Chatbot configuration +CHATBOT_MAX_INPUT_CHARS = "feature.chatbot.max_input_chars" \ No newline at end of file diff --git a/sefaria/system/context_processors.py b/sefaria/system/context_processors.py index d2d758ecd1..c155edfcc4 100644 --- a/sefaria/system/context_processors.py +++ b/sefaria/system/context_processors.py @@ -16,6 +16,8 @@ from sefaria.utils.chatbot import build_chatbot_user_token from sefaria.utils.hebrew import hebrew_parasha_name from reader.views import render_react_component, _get_user_calendar_params +from remote_config import remoteConfigCache +from remote_config.keys import CHATBOT_MAX_INPUT_CHARS import structlog logger = structlog.get_logger(__name__) @@ -127,8 +129,10 @@ def chatbot_user_token(request): if not getattr(profile, "experiments", False): return {"chatbot_user_token": None, "chatbot_enabled": False} token = build_chatbot_user_token(request.user.id, CHATBOT_USER_ID_SECRET) + max_input_chars = remoteConfigCache.get(CHATBOT_MAX_INPUT_CHARS, default=500) return { "chatbot_user_token": token, "chatbot_enabled": True, "chatbot_api_base_url": settings.CHATBOT_API_BASE_URL, + "chatbot_max_input_chars": max_input_chars, } diff --git a/templates/base.html b/templates/base.html index c772c09672..e6d454df20 100644 --- a/templates/base.html +++ b/templates/base.html @@ -235,6 +235,7 @@ api-base-url="{{ chatbot_api_base_url }}" default-open="false" placement="right" + max-input-chars="{{ chatbot_max_input_chars }}" > {% endif %}