|
6 | 6 | MINIMAL_SUPPORTED_LLAMA_STACK_VERSION: Final[str] = "0.2.17" |
7 | 7 | MAXIMAL_SUPPORTED_LLAMA_STACK_VERSION: Final[str] = "0.6.0" |
8 | 8 |
|
9 | | -UNABLE_TO_PROCESS_RESPONSE = "Unable to process this request" |
| 9 | +UNABLE_TO_PROCESS_RESPONSE: Final[str] = "Unable to process this request" |
10 | 10 |
|
11 | 11 | # Response stored in the conversation when the user interrupts a streaming request |
12 | | -INTERRUPTED_RESPONSE_MESSAGE = "You interrupted this request." |
| 12 | +INTERRUPTED_RESPONSE_MESSAGE: Final[str] = "You interrupted this request." |
13 | 13 |
|
14 | 14 | # Max seconds to wait for topic summary in background task after interrupt persist. |
15 | | -TOPIC_SUMMARY_INTERRUPT_TIMEOUT_SECONDS = 30.0 |
| 15 | +TOPIC_SUMMARY_INTERRUPT_TIMEOUT_SECONDS: Final[float] = 30.0 |
16 | 16 |
|
17 | 17 | # Supported attachment types |
18 | 18 | ATTACHMENT_TYPES = frozenset( |
|
34 | 34 |
|
35 | 35 | # Default system prompt used only when no other system prompt is specified in |
36 | 36 | # configuration file nor in the query request |
37 | | -DEFAULT_SYSTEM_PROMPT = "You are a helpful assistant" |
| 37 | +DEFAULT_SYSTEM_PROMPT: Final[str] = "You are a helpful assistant" |
38 | 38 |
|
39 | 39 | # Default topic summary system prompt used only when no other topic summary system |
40 | 40 | # prompt is specified in configuration file |
41 | | -DEFAULT_TOPIC_SUMMARY_SYSTEM_PROMPT = """ |
| 41 | +DEFAULT_TOPIC_SUMMARY_SYSTEM_PROMPT: Final[str] = """ |
42 | 42 | Instructions: |
43 | 43 | - You are a topic summarizer |
44 | 44 | - Your job is to extract precise topic summary from user input |
|
104 | 104 | """ |
105 | 105 |
|
106 | 106 | # Authentication constants |
107 | | -DEFAULT_VIRTUAL_PATH = "/ls-access" |
108 | | -DEFAULT_USER_NAME = "lightspeed-user" |
109 | | -DEFAULT_SKIP_USER_ID_CHECK = True |
110 | | -DEFAULT_USER_UID = "00000000-0000-0000-0000-000" |
| 107 | +DEFAULT_VIRTUAL_PATH: Final[str] = "/ls-access" |
| 108 | +DEFAULT_USER_NAME: Final[str] = "lightspeed-user" |
| 109 | +DEFAULT_SKIP_USER_ID_CHECK: Final[bool] = True |
| 110 | +DEFAULT_USER_UID: Final[str] = "00000000-0000-0000-0000-000" |
111 | 111 | # default value for token when no token is provided |
112 | | -NO_USER_TOKEN = "" |
113 | | -AUTH_MOD_K8S = "k8s" |
114 | | -AUTH_MOD_NOOP = "noop" |
115 | | -AUTH_MOD_NOOP_WITH_TOKEN = "noop-with-token" |
116 | | -AUTH_MOD_APIKEY_TOKEN = "api-key-token" |
117 | | -AUTH_MOD_JWK_TOKEN = "jwk-token" |
118 | | -AUTH_MOD_RH_IDENTITY = "rh-identity" |
| 112 | +NO_USER_TOKEN: Final[str] = "" |
| 113 | +AUTH_MOD_K8S: Final[str] = "k8s" |
| 114 | +AUTH_MOD_NOOP: Final[str] = "noop" |
| 115 | +AUTH_MOD_NOOP_WITH_TOKEN: Final[str] = "noop-with-token" |
| 116 | +AUTH_MOD_APIKEY_TOKEN: Final[str] = "api-key-token" |
| 117 | +AUTH_MOD_JWK_TOKEN: Final[str] = "jwk-token" |
| 118 | +AUTH_MOD_RH_IDENTITY: Final[str] = "rh-identity" |
119 | 119 | # Supported authentication modules |
120 | 120 | SUPPORTED_AUTHENTICATION_MODULES = frozenset( |
121 | 121 | { |
|
129 | 129 | ) |
130 | 130 | DEFAULT_AUTHENTICATION_MODULE = AUTH_MOD_NOOP |
131 | 131 | # Maximum allowed size for base64-encoded x-rh-identity header (bytes) |
132 | | -DEFAULT_RH_IDENTITY_MAX_HEADER_SIZE = 8192 |
| 132 | +DEFAULT_RH_IDENTITY_MAX_HEADER_SIZE: Final[int] = 8192 |
133 | 133 |
|
134 | 134 | # Maximum allowed file upload size (bytes) - 100MB default |
135 | 135 | # Protects against DoS attacks via large file uploads |
136 | | -DEFAULT_MAX_FILE_UPLOAD_SIZE = 100 * 1024 * 1024 # 100 MB |
137 | | -DEFAULT_JWT_UID_CLAIM = "user_id" |
138 | | -DEFAULT_JWT_USER_NAME_CLAIM = "username" |
| 136 | +DEFAULT_MAX_FILE_UPLOAD_SIZE: Final[int] = 100 * 1024 * 1024 # 100 MB |
| 137 | +DEFAULT_JWT_UID_CLAIM: Final[str] = "user_id" |
| 138 | +DEFAULT_JWT_USER_NAME_CLAIM: Final[str] = "username" |
139 | 139 |
|
140 | 140 | # MCP authorization header special values |
141 | | -MCP_AUTH_KUBERNETES = "kubernetes" |
142 | | -MCP_AUTH_CLIENT = "client" |
143 | | -MCP_AUTH_OAUTH = "oauth" |
| 141 | +MCP_AUTH_KUBERNETES: Final[str] = "kubernetes" |
| 142 | +MCP_AUTH_CLIENT: Final[str] = "client" |
| 143 | +MCP_AUTH_OAUTH: Final[str] = "oauth" |
144 | 144 |
|
145 | 145 | # Media type constants for streaming responses |
146 | | -MEDIA_TYPE_JSON = "application/json" |
147 | | -MEDIA_TYPE_TEXT = "text/plain" |
148 | | -MEDIA_TYPE_EVENT_STREAM = "text/event-stream" |
| 146 | +MEDIA_TYPE_JSON: Final[str] = "application/json" |
| 147 | +MEDIA_TYPE_TEXT: Final[str] = "text/plain" |
| 148 | +MEDIA_TYPE_EVENT_STREAM: Final[str] = "text/event-stream" |
149 | 149 |
|
150 | 150 | # Streaming event type constants |
151 | | -LLM_TOKEN_EVENT = "token" |
152 | | -LLM_TOOL_CALL_EVENT = "tool_call" |
153 | | -LLM_TOOL_RESULT_EVENT = "tool_result" |
154 | | -LLM_TURN_COMPLETE_EVENT = "turn_complete" |
| 151 | +LLM_TOKEN_EVENT: Final[str] = "token" |
| 152 | +LLM_TOOL_CALL_EVENT: Final[str] = "tool_call" |
| 153 | +LLM_TOOL_RESULT_EVENT: Final[str] = "tool_result" |
| 154 | +LLM_TURN_COMPLETE_EVENT: Final[str] = "turn_complete" |
155 | 155 |
|
156 | 156 | # PostgreSQL connection constants |
157 | 157 | # See: https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNECT-SSLMODE |
158 | | -POSTGRES_DEFAULT_SSL_MODE = "prefer" |
| 158 | +POSTGRES_DEFAULT_SSL_MODE: Final[str] = "prefer" |
159 | 159 | # See: https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNECT-GSSENCMODE |
160 | | -POSTGRES_DEFAULT_GSS_ENCMODE = "prefer" |
| 160 | +POSTGRES_DEFAULT_GSS_ENCMODE: Final[str] = "prefer" |
161 | 161 |
|
162 | 162 | # cache constants |
163 | | -CACHE_TYPE_MEMORY = "memory" |
164 | | -CACHE_TYPE_SQLITE = "sqlite" |
165 | | -CACHE_TYPE_POSTGRES = "postgres" |
166 | | -CACHE_TYPE_NOOP = "noop" |
| 163 | +CACHE_TYPE_MEMORY: Final[str] = "memory" |
| 164 | +CACHE_TYPE_SQLITE: Final[str] = "sqlite" |
| 165 | +CACHE_TYPE_POSTGRES: Final[str] = "postgres" |
| 166 | +CACHE_TYPE_NOOP: Final[str] = "noop" |
167 | 167 |
|
168 | 168 | # BYOK RAG |
169 | 169 | # Default RAG type for bring-your-own-knowledge RAG configurations, that type |
170 | 170 | # needs to be supported by Llama Stack |
171 | | -DEFAULT_RAG_TYPE = "inline::faiss" |
| 171 | +DEFAULT_RAG_TYPE: Final[str] = "inline::faiss" |
172 | 172 |
|
173 | 173 | # Default sentence transformer model for embedding generation, that type needs |
174 | 174 | # to be supported by Llama Stack and configured properly in providers and |
175 | 175 | # models sections |
176 | | -DEFAULT_EMBEDDING_MODEL = "sentence-transformers/all-mpnet-base-v2" |
| 176 | +DEFAULT_EMBEDDING_MODEL: Final[str] = "sentence-transformers/all-mpnet-base-v2" |
177 | 177 |
|
178 | 178 | # Default embedding vector dimension for the sentence transformer model |
179 | | -DEFAULT_EMBEDDING_DIMENSION = 768 |
| 179 | +DEFAULT_EMBEDDING_DIMENSION: Final[int] = 768 |
180 | 180 |
|
181 | 181 | # quota limiters constants |
182 | | -USER_QUOTA_LIMITER = "user_limiter" |
183 | | -CLUSTER_QUOTA_LIMITER = "cluster_limiter" |
| 182 | +USER_QUOTA_LIMITER: Final[str] = "user_limiter" |
| 183 | +CLUSTER_QUOTA_LIMITER: Final[str] = "cluster_limiter" |
184 | 184 |
|
185 | 185 | # RAG as a tool constants |
186 | | -DEFAULT_RAG_TOOL = "file_search" |
187 | | -TOOL_RAG_MAX_CHUNKS = 10 # retrieved from RAG as a tool |
| 186 | +DEFAULT_RAG_TOOL: Final[str] = "file_search" |
| 187 | +TOOL_RAG_MAX_CHUNKS: Final[int] = 10 # retrieved from RAG as a tool |
188 | 188 |
|
189 | 189 | # Inline RAG constants |
190 | | -BYOK_RAG_MAX_CHUNKS = 10 # retrieved from BYOK RAG |
191 | | -OKP_RAG_MAX_CHUNKS = 5 # retrieved from OKP RAG |
| 190 | +BYOK_RAG_MAX_CHUNKS: Final[int] = 10 # retrieved from BYOK RAG |
| 191 | +OKP_RAG_MAX_CHUNKS: Final[int] = 5 # retrieved from OKP RAG |
192 | 192 |
|
193 | 193 | # Solr OKP constants |
194 | | -SOLR_VECTOR_SEARCH_DEFAULT_K = 5 |
195 | | -SOLR_VECTOR_SEARCH_DEFAULT_SCORE_THRESHOLD = 0.3 |
196 | | -SOLR_VECTOR_SEARCH_DEFAULT_MODE = "hybrid" |
| 194 | +SOLR_VECTOR_SEARCH_DEFAULT_K: Final[int] = 5 |
| 195 | +SOLR_VECTOR_SEARCH_DEFAULT_SCORE_THRESHOLD: Final[float] = 0.3 |
| 196 | +SOLR_VECTOR_SEARCH_DEFAULT_MODE: Final[str] = "hybrid" |
197 | 197 |
|
198 | 198 | # Internal Solr filter always applied to restrict results to chunk documents |
199 | | -SOLR_CHUNK_FILTER_QUERY = "is_chunk:true" |
| 199 | +SOLR_CHUNK_FILTER_QUERY: Final[str] = "is_chunk:true" |
200 | 200 |
|
201 | 201 | # SOLR OKP RAG - default base URL when okp.rhokp_url is unset in configuration |
202 | | -RH_SERVER_OKP_DEFAULT_URL = "http://localhost:8081" |
| 202 | +RH_SERVER_OKP_DEFAULT_URL: Final[str] = "http://localhost:8081" |
203 | 203 |
|
204 | | -SOLR_PROVIDER_ID = "okp_solr" |
| 204 | +SOLR_PROVIDER_ID: Final[str] = "okp_solr" |
205 | 205 |
|
206 | 206 | # Solr default configuration values (can be overridden via environment variables) |
207 | | -SOLR_DEFAULT_VECTOR_STORE_ID = "portal-rag" |
208 | | -SOLR_DEFAULT_VECTOR_FIELD = "chunk_vector" |
209 | | -SOLR_DEFAULT_CONTENT_FIELD = "chunk" |
210 | | -SOLR_DEFAULT_EMBEDDING_MODEL = ( |
| 207 | +SOLR_DEFAULT_VECTOR_STORE_ID: Final[str] = "portal-rag" |
| 208 | +SOLR_DEFAULT_VECTOR_FIELD: Final[str] = "chunk_vector" |
| 209 | +SOLR_DEFAULT_CONTENT_FIELD: Final[str] = "chunk" |
| 210 | +SOLR_DEFAULT_EMBEDDING_MODEL: Final[str] = ( |
211 | 211 | "sentence-transformers/ibm-granite/granite-embedding-30m-english" |
212 | 212 | ) |
213 | | -SOLR_DEFAULT_EMBEDDING_DIMENSION = 384 |
| 213 | +SOLR_DEFAULT_EMBEDDING_DIMENSION: Final[int] = 384 |
214 | 214 |
|
215 | 215 | # Default score multiplier for BYOK RAG vector stores |
216 | 216 | DEFAULT_SCORE_MULTIPLIER = 1.0 |
217 | 217 |
|
218 | 218 | # Special RAG ID that activates the OKP provider when listed in rag.inline or rag.tool |
219 | | -OKP_RAG_ID = "okp" |
| 219 | +OKP_RAG_ID: Final[str] = "okp" |
220 | 220 |
|
221 | 221 | # Logging configuration constants |
222 | 222 | # Environment variable name for configurable log level |
223 | | -LIGHTSPEED_STACK_LOG_LEVEL_ENV_VAR = "LIGHTSPEED_STACK_LOG_LEVEL" |
| 223 | +LIGHTSPEED_STACK_LOG_LEVEL_ENV_VAR: Final[str] = "LIGHTSPEED_STACK_LOG_LEVEL" |
224 | 224 | # Default log level when environment variable is not set |
225 | | -DEFAULT_LOG_LEVEL = "INFO" |
| 225 | +DEFAULT_LOG_LEVEL: Final[str] = "INFO" |
226 | 226 | # Default log format for plain-text logging in non-TTY environments |
227 | | -DEFAULT_LOG_FORMAT = "%(asctime)s %(levelname)-8s %(name)s:%(lineno)d %(message)s" |
| 227 | +DEFAULT_LOG_FORMAT: Final[str] = ( |
| 228 | + "%(asctime)s %(levelname)-8s %(name)s:%(lineno)d %(message)s" |
| 229 | +) |
228 | 230 | # Environment variable to force StreamHandler instead of RichHandler |
229 | 231 | # Set to any non-empty value to disable RichHandler |
230 | | -LIGHTSPEED_STACK_DISABLE_RICH_HANDLER_ENV_VAR = "LIGHTSPEED_STACK_DISABLE_RICH_HANDLER" |
| 232 | +LIGHTSPEED_STACK_DISABLE_RICH_HANDLER_ENV_VAR: Final[str] = ( |
| 233 | + "LIGHTSPEED_STACK_DISABLE_RICH_HANDLER" |
| 234 | +) |
231 | 235 |
|
232 | | -DEFAULT_VIOLATION_MESSAGE = "I cannot process this request due to policy restrictions." |
| 236 | +DEFAULT_VIOLATION_MESSAGE: Final[str] = ( |
| 237 | + "I cannot process this request due to policy restrictions." |
| 238 | +) |
233 | 239 |
|
234 | 240 | # Input size limits for API request validation |
235 | 241 | # Maximum character length for the question field in /v1/infer requests (32 KiB) |
236 | | -RLSAPI_V1_QUESTION_MAX_LENGTH = 32_768 |
| 242 | +RLSAPI_V1_QUESTION_MAX_LENGTH: Final[int] = 32_768 |
237 | 243 | # Maximum character length for the serialized /v1/responses request body (64 KiB) |
238 | | -RESPONSES_REQUEST_MAX_SIZE = 65_536 |
| 244 | +RESPONSES_REQUEST_MAX_SIZE: Final[int] = 65_536 |
0 commit comments