Spaces:
Running
Running
# | |
# SPDX-FileCopyrightText: Hadad <[email protected]> | |
# SPDX-License-Identifier: Apache-2.0 | |
# | |
import os # Import os module to access environment variables and interact with the operating system | |
import json # Import json module to parse JSON strings into Python objects | |
# Load initial welcome messages for the system from the environment variable "HELLO" | |
# If "HELLO" is not set, default to an empty JSON array represented as "[]" | |
# This variable typically contains a list of greeting messages or initialization instructions for the AI | |
JARVIS_INIT = json.loads(os.getenv("HELLO", "[]")) | |
# Deep Search service configuration variables loaded from environment variables | |
# DEEP_SEARCH_PROVIDER_HOST holds the URL or IP address of the deep search service provider | |
DEEP_SEARCH_PROVIDER_HOST = os.getenv("DEEP_SEARCH_PROVIDER_HOST") | |
# DEEP_SEARCH_PROVIDER_KEY contains the API key or authentication token required to access the deep search provider | |
DEEP_SEARCH_PROVIDER_KEY = os.getenv('DEEP_SEARCH_PROVIDER_KEY') | |
# DEEP_SEARCH_INSTRUCTIONS may include specific instructions or parameters guiding how deep search queries should be handled | |
DEEP_SEARCH_INSTRUCTIONS = os.getenv("DEEP_SEARCH_INSTRUCTIONS") | |
# Internal AI server configuration and system instructions | |
# INTERNAL_AI_GET_SERVER stores the endpoint URL or IP address for internal AI GET requests | |
INTERNAL_AI_GET_SERVER = os.getenv("INTERNAL_AI_GET_SERVER") | |
# INTERNAL_AI_INSTRUCTIONS contains system instructions used to guide the AI behavior | |
INTERNAL_AI_INSTRUCTIONS = os.getenv("INTERNAL_TRAINING_DATA") | |
# System instructions mappings and default instructions loaded from environment variables | |
# SYSTEM_PROMPT_MAPPING is a dictionary mapping instructions keys to their corresponding instructions texts, parsed from JSON | |
SYSTEM_PROMPT_MAPPING = json.loads(os.getenv("SYSTEM_PROMPT_MAPPING", "{}")) | |
# SYSTEM_PROMPT_DEFAULT is the fallback instructions text used when no specific instructions mapping is found | |
SYSTEM_PROMPT_DEFAULT = os.getenv("DEFAULT_SYSTEM") | |
# List of available server hosts for connections or operations | |
# This list is parsed from a JSON array string and filtered to exclude any empty or invalid entries | |
LINUX_SERVER_HOSTS = [h for h in json.loads(os.getenv("LINUX_SERVER_HOST", "[]")) if h] | |
# List of provider keys associated with servers, used for authentication | |
# The list is parsed from JSON and filtered to remove empty strings | |
LINUX_SERVER_PROVIDER_KEYS = [k for k in json.loads(os.getenv("LINUX_SERVER_PROVIDER_KEY", "[]")) if k] | |
# Set to keep track of provider keys that have been marked or flagged during runtime | |
LINUX_SERVER_PROVIDER_KEYS_MARKED = set() | |
# Dictionary to record the number of attempts made with each provider key | |
LINUX_SERVER_PROVIDER_KEYS_ATTEMPTS = {} | |
# Set of server error codes that the system recognizes as critical or requiring special handling | |
# The error codes are read from a comma-separated string, filtered to remove empty entries, converted to integers, and stored in a set | |
LINUX_SERVER_ERRORS = set(map(int, filter(None, os.getenv("LINUX_SERVER_ERROR", "").split(",")))) | |
# Human-friendly AI types and response messages loaded from environment variables | |
# AI_TYPES maps keys like "AI_TYPE_1" to descriptive names or categories of AI models or behaviors | |
AI_TYPES = {f"AI_TYPE_{i}": os.getenv(f"AI_TYPE_{i}") for i in range(1, 10)} | |
# RESPONSES maps keys like "RESPONSE_1" to predefined response templates or messages used by the AI system | |
RESPONSES = {f"RESPONSE_{i}": os.getenv(f"RESPONSE_{i}") for i in range(1, 11)} | |
# Model-related configurations loaded from environment variables | |
# MODEL_MAPPING is a dictionary mapping model keys to their corresponding model names or identifiers, parsed from JSON | |
MODEL_MAPPING = json.loads(os.getenv("MODEL_MAPPING", "{}")) | |
# MODEL_CONFIG contains detailed configuration settings for each model, such as parameters or options, parsed from JSON | |
MODEL_CONFIG = json.loads(os.getenv("MODEL_CONFIG", "{}")) | |
# MODEL_CHOICES is a list of available model names extracted from the values of MODEL_MAPPING, useful for selection menus or validation | |
MODEL_CHOICES = list(MODEL_MAPPING.values()) | |
# Default model configuration and key used as fallback if no specific model is selected | |
# DEFAULT_CONFIG contains default parameters or settings for the AI model, parsed from JSON | |
DEFAULT_CONFIG = json.loads(os.getenv("DEFAULT_CONFIG", "{}")) | |
# DEFAULT_MODEL_KEY is set to the first key found in MODEL_MAPPING if available, otherwise None | |
DEFAULT_MODEL_KEY = list(MODEL_MAPPING.keys())[0] if MODEL_MAPPING else None | |
# HTML meta tags for SEO and other purposes, loaded as a raw string from environment variables | |
# These tags are intended to be inserted into the <head> section of generated HTML pages | |
META_TAGS = os.getenv("META_TAGS") | |
# List of allowed file extensions for upload or processing, parsed from a JSON array string | |
# This list helps enforce file type restrictions within the system | |
ALLOWED_EXTENSIONS = json.loads(os.getenv("ALLOWED_EXTENSIONS", "[]")) | |
# Notices or announcements that may be displayed to users or logged by the system | |
# The content is loaded as a raw string from the environment variable "NOTICES" | |
NOTICES = os.getenv('NOTICES') | |