-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathconstants.py
More file actions
230 lines (189 loc) · 7.56 KB
/
constants.py
File metadata and controls
230 lines (189 loc) · 7.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
"""Constants used in business logic."""
# Minimal and maximal supported Llama Stack version
MINIMAL_SUPPORTED_LLAMA_STACK_VERSION = "0.2.17"
MAXIMAL_SUPPORTED_LLAMA_STACK_VERSION = "0.6.0"
UNABLE_TO_PROCESS_RESPONSE = "Unable to process this request"
# Response stored in the conversation when the user interrupts a streaming request
INTERRUPTED_RESPONSE_MESSAGE = "You interrupted this request."
# Max seconds to wait for topic summary in background task after interrupt persist.
TOPIC_SUMMARY_INTERRUPT_TIMEOUT_SECONDS = 30.0
# Supported attachment types
ATTACHMENT_TYPES = frozenset(
{
"alert",
"api object",
"configuration",
"error message",
"event",
"log",
"stack trace",
}
)
# Supported attachment content types
ATTACHMENT_CONTENT_TYPES = frozenset(
{"text/plain", "application/json", "application/yaml", "application/xml"}
)
# Default system prompt used only when no other system prompt is specified in
# configuration file nor in the query request
DEFAULT_SYSTEM_PROMPT = "You are a helpful assistant"
# Default topic summary system prompt used only when no other topic summary system
# prompt is specified in configuration file
DEFAULT_TOPIC_SUMMARY_SYSTEM_PROMPT = """
Instructions:
- You are a topic summarizer
- Your job is to extract precise topic summary from user input
- Return only the final topic summary, no other text or explanation.
For Input Analysis:
- Scan entire user message
- Identify core subject matter
- Distill essence into concise descriptor
- Prioritize key concepts
- Eliminate extraneous details
For Output Constraints:
- Maximum 5 words
- Capitalize only significant words (e.g., nouns, verbs, adjectives, adverbs).
- Do **NOT** use all uppercase - capitalize only the first letter of significant words
- Exclude articles and prepositions (e.g., "a," "the," "of," "on," "in")
- Exclude all punctuation and interpunction marks (e.g., . , : ; ! ? | "")
- Retain original abbreviations. Do not expand an abbreviation if its specific meaning in the
context is unknown or ambiguous.
- Neutral objective language
- Do **NOT** provide explanations, reasoning, or "processing steps".
- Do **NOT** provide multiple options (e.g., do not use "or").
- Do **NOT** use introductory text like "The topic is...".
Examples:
- "AI Capabilities Summary" (Correct)
- "Machine Learning Applications" (Correct)
- "AI CAPABILITIES SUMMARY" (Incorrect—should not be fully uppercase)
Processing Steps
1. Analyze semantic structure
2. Identify primary topic
3. Remove contextual noise
4. Condense to essential meaning
5. Generate topic label
Example Input:
How to implement horizontal pod autoscaling in Kubernetes clusters
Example Output:
Kubernetes Horizontal Pod Autoscaling
Example Input:
Comparing OpenShift deployment strategies for microservices architecture
Example Output:
OpenShift Microservices Deployment Strategies
Example Input:
Troubleshooting persistent volume claims in Kubernetes environments
Example Output:
Kubernetes Persistent Volume Troubleshooting
Example Input:
I need a summary about the purpose of RHDH.
Example Output:
RHDH Purpose Summary
Input:
{query}
Output:
"""
# Authentication constants
DEFAULT_VIRTUAL_PATH = "/ls-access"
DEFAULT_USER_NAME = "lightspeed-user"
DEFAULT_SKIP_USER_ID_CHECK = True
DEFAULT_USER_UID = "00000000-0000-0000-0000-000"
# default value for token when no token is provided
NO_USER_TOKEN = ""
AUTH_MOD_K8S = "k8s"
AUTH_MOD_NOOP = "noop"
AUTH_MOD_NOOP_WITH_TOKEN = "noop-with-token"
AUTH_MOD_APIKEY_TOKEN = "api-key-token"
AUTH_MOD_JWK_TOKEN = "jwk-token"
AUTH_MOD_RH_IDENTITY = "rh-identity"
# Supported authentication modules
SUPPORTED_AUTHENTICATION_MODULES = frozenset(
{
AUTH_MOD_K8S,
AUTH_MOD_NOOP,
AUTH_MOD_NOOP_WITH_TOKEN,
AUTH_MOD_JWK_TOKEN,
AUTH_MOD_APIKEY_TOKEN,
AUTH_MOD_RH_IDENTITY,
}
)
DEFAULT_AUTHENTICATION_MODULE = AUTH_MOD_NOOP
# Maximum allowed size for base64-encoded x-rh-identity header (bytes)
DEFAULT_RH_IDENTITY_MAX_HEADER_SIZE = 8192
# Maximum allowed file upload size (bytes) - 100MB default
# Protects against DoS attacks via large file uploads
DEFAULT_MAX_FILE_UPLOAD_SIZE = 100 * 1024 * 1024 # 100 MB
DEFAULT_JWT_UID_CLAIM = "user_id"
DEFAULT_JWT_USER_NAME_CLAIM = "username"
# MCP authorization header special values
MCP_AUTH_KUBERNETES = "kubernetes"
MCP_AUTH_CLIENT = "client"
MCP_AUTH_OAUTH = "oauth"
# Media type constants for streaming responses
MEDIA_TYPE_JSON = "application/json"
MEDIA_TYPE_TEXT = "text/plain"
MEDIA_TYPE_EVENT_STREAM = "text/event-stream"
# Streaming event type constants
LLM_TOKEN_EVENT = "token"
LLM_TOOL_CALL_EVENT = "tool_call"
LLM_TOOL_RESULT_EVENT = "tool_result"
LLM_TURN_COMPLETE_EVENT = "turn_complete"
# PostgreSQL connection constants
# See: https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNECT-SSLMODE
POSTGRES_DEFAULT_SSL_MODE = "prefer"
# See: https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNECT-GSSENCMODE
POSTGRES_DEFAULT_GSS_ENCMODE = "prefer"
# cache constants
CACHE_TYPE_MEMORY = "memory"
CACHE_TYPE_SQLITE = "sqlite"
CACHE_TYPE_POSTGRES = "postgres"
CACHE_TYPE_NOOP = "noop"
# BYOK RAG
# Default RAG type for bring-your-own-knowledge RAG configurations, that type
# needs to be supported by Llama Stack
DEFAULT_RAG_TYPE = "inline::faiss"
# Default sentence transformer model for embedding generation, that type needs
# to be supported by Llama Stack and configured properly in providers and
# models sections
DEFAULT_EMBEDDING_MODEL = "sentence-transformers/all-mpnet-base-v2"
# Default embedding vector dimension for the sentence transformer model
DEFAULT_EMBEDDING_DIMENSION = 768
# quota limiters constants
USER_QUOTA_LIMITER = "user_limiter"
CLUSTER_QUOTA_LIMITER = "cluster_limiter"
# RAG as a tool constants
DEFAULT_RAG_TOOL = "file_search"
TOOL_RAG_MAX_CHUNKS = 10 # retrieved from RAG as a tool
# Inline RAG constants
BYOK_RAG_MAX_CHUNKS = 10 # retrieved from BYOK RAG
OKP_RAG_MAX_CHUNKS = 5 # retrieved from OKP RAG
# Solr OKP constants
SOLR_VECTOR_SEARCH_DEFAULT_K = 5
SOLR_VECTOR_SEARCH_DEFAULT_SCORE_THRESHOLD = 0.3
SOLR_VECTOR_SEARCH_DEFAULT_MODE = "hybrid"
# Internal Solr filter always applied to restrict results to chunk documents
SOLR_CHUNK_FILTER_QUERY = "is_chunk:true"
# SOLR OKP RAG - default base URL when okp.rhokp_url is unset in configuration
RH_SERVER_OKP_DEFAULT_URL = "http://localhost:8081"
SOLR_PROVIDER_ID = "okp_solr"
# Solr default configuration values (can be overridden via environment variables)
SOLR_DEFAULT_VECTOR_STORE_ID = "portal-rag"
SOLR_DEFAULT_VECTOR_FIELD = "chunk_vector"
SOLR_DEFAULT_CONTENT_FIELD = "chunk"
SOLR_DEFAULT_EMBEDDING_MODEL = (
"sentence-transformers/ibm-granite/granite-embedding-30m-english"
)
SOLR_DEFAULT_EMBEDDING_DIMENSION = 384
# Default score multiplier for BYOK RAG vector stores
DEFAULT_SCORE_MULTIPLIER = 1.0
# Special RAG ID that activates the OKP provider when listed in rag.inline or rag.tool
OKP_RAG_ID = "okp"
# Logging configuration constants
# Environment variable name for configurable log level
LIGHTSPEED_STACK_LOG_LEVEL_ENV_VAR = "LIGHTSPEED_STACK_LOG_LEVEL"
# Default log level when environment variable is not set
DEFAULT_LOG_LEVEL = "INFO"
# Default log format for plain-text logging in non-TTY environments
DEFAULT_LOG_FORMAT = "%(asctime)s %(levelname)-8s %(name)s:%(lineno)d %(message)s"
# Environment variable to force StreamHandler instead of RichHandler
# Set to any non-empty value to disable RichHandler
LIGHTSPEED_STACK_DISABLE_RICH_HANDLER_ENV_VAR = "LIGHTSPEED_STACK_DISABLE_RICH_HANDLER"
DEFAULT_VIOLATION_MESSAGE = "I cannot process this request due to policy restrictions."