Skip to content

Commit 940d1c4

Browse files
committed
Password handling
1 parent fa4930b commit 940d1c4

8 files changed

Lines changed: 20 additions & 0 deletions

File tree

deploy/docker/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ IDENTITY_SERVER_PORT=8080
22
COMMUNITY_SERVER_PORT=8087
33
WORKSHOP_SERVER_PORT=8000
44
CHATBOT_SERVER_PORT=5002
5+
CHATBOT_LIFE=1
56
ENABLE_SHELL_INJECTION=false
67
ENABLE_LOG4J=false
78
LISTEN_IP="127.0.0.1"

deploy/docker/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ services:
181181
- API_USER=admin@example.com
182182
- API_PASSWORD=Admin!123
183183
- OPENAPI_SPEC=/app/resources/crapi-openapi-spec.json
184+
- CHATBOT_LIFE=${CHATBOT_LIFE:-1}
184185
- CHATBOT_LLM_PROVIDER=${CHATBOT_LLM_PROVIDER:-openai}
185186
- CHATBOT_LLM_MODEL=${CHATBOT_LLM_MODEL:-}
186187
- CHATBOT_EMBEDDINGS_MODEL=${CHATBOT_EMBEDDINGS_MODEL:-}

deploy/helm/templates/chatbot/config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ data:
2020
MONGO_DB_USER: {{ .Values.mongodb.config.mongoUser }}
2121
MONGO_DB_PASSWORD: {{ .Values.mongodb.config.mongoPassword }}
2222
MONGO_DB_NAME: {{ .Values.mongodb.config.mongoDbName }}
23+
CHATBOT_LIFE: {{ .Values.chatbotLife | quote }}
2324
CHATBOT_OPENAI_API_KEY: {{ .Values.chatbotOpenaiApiKey | default .Values.openAIApiKey | quote }}
2425
CHATBOT_OPENAI_BASE_URL: {{ .Values.chatbotOpenaiBaseUrl | quote }}
2526
CHATBOT_LLM_PROVIDER: {{ .Values.chatbotLlmProvider | quote }}

deploy/helm/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ tlsEnabled: false
1313
jwtExpiration: 604800000
1414
logLevel: INFO
1515

16+
chatbotLife: 1
17+
1618
# Chatbot LLM Configuration
1719
chatbotLlmProvider: openai
1820
chatbotLlmModel: ""

deploy/k8s/base/chatbot/config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ data:
1919
MONGO_DB_USER: "admin"
2020
MONGO_DB_PASSWORD: "crapisecretpassword"
2121
MONGO_DB_NAME: "crapi"
22+
CHATBOT_LIFE: "1"
2223
CHATBOT_OPENAI_API_KEY: ""
2324
CHATBOT_OPENAI_BASE_URL: ""
2425
CHATBOT_LLM_PROVIDER: "openai"

services/chatbot/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export DEFAULT_MODEL=gpt-4o-mini
1919
export MAX_CONTENT_LENGTH=50000
2020
export CHROMA_HOST=localhost
2121
export CHROMA_PORT=8000
22+
export CHATBOT_LIFE=1
2223
export CHATBOT_LLM_PROVIDER=openai
2324
export CHATBOT_LLM_MODEL=gpt-4o-mini
2425
export CHATBOT_OPENAI_API_KEY=

services/chatbot/src/chatbot/chat_api.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import logging
22
import os
3+
import random
34
from uuid import uuid4
45

56
from quart import Blueprint, jsonify, request
@@ -199,6 +200,17 @@ async def chat():
199200
session_id,
200201
len(message),
201202
)
203+
204+
if not Config.CHATBOT_LIFE:
205+
_busy_responses = [
206+
"I'm currently processing a large number of requests. Please check back in a few moments.",
207+
"Our systems are experiencing high load right now. Please try again shortly.",
208+
"Your request is being queued for processing. Please retry in a minute or two.",
209+
"The AI model is temporarily at capacity. Please try your question again soon.",
210+
"Processing is taking longer than expected due to demand. Please try again in a bit.",
211+
]
212+
return jsonify({"id": id, "message": random.choice(_busy_responses)}), 200
213+
202214
try:
203215
reply, response_id = await process_user_message(
204216
session_id, message, provider_api_key, model_name, user_jwt

services/chatbot/src/chatbot/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@ class Config:
3737
MAX_CONTENT_LENGTH = int(os.getenv("MAX_CONTENT_LENGTH", 100000))
3838
CHROMA_HOST = CHROMA_HOST
3939
CHROMA_PORT = CHROMA_PORT
40+
CHATBOT_LIFE = int(os.getenv("CHATBOT_LIFE", "1"))

0 commit comments

Comments
 (0)