Files
rp/rp/config.py
T
retoor 602599380d feat: add cost tracking and budget management
feat: implement /shortcuts command for quick access
feat: add /cost, /budget, and /usage commands
feat: update assistant name to "rp"
feat: add support for web terminals and minigit tools
feat: improve error handling and http timeouts
docs: update changelog with version 1.64.0 details
refactor: move show_background_events to handlers
refactor: restructure command handling in handlers.py
refactor: integrate build formatter for cost and shortcuts
2025-11-29 19:46:44 +01:00

192 lines
4.6 KiB
Python

import os
DEFAULT_MODEL = "x-ai/grok-code-fast-1"
#DEFAULT_MODEL = "glm-4.6"
#DEFAULT_API_URL = "https://api.z.ai/api/coding/paas/v4/chat/completions"
DEFAULT_API_URL = "https://static.molodetz.nl/rp.cgi/api/v1/chat/completions"
DEFAULT_API_KEY = "aaf5fb68732c40de9472d980b23054c9.eAJs7s74sh7VDm9O"
MODEL_LIST_URL = "https://static.molodetz.nl/rp.cgi/api/v1/models"
config_directory = os.path.expanduser("~/.local/share/rp")
os.makedirs(config_directory, exist_ok=True)
DB_PATH = os.path.join(config_directory, "assistant_db.sqlite")
LOG_FILE = os.path.join(config_directory, "assistant_error.log")
CONTEXT_FILE = ".rcontext.txt"
HOME_CONTEXT_FILE = os.path.expanduser("~/.rcontext.txt")
GLOBAL_CONTEXT_FILE = os.path.join(config_directory, "rcontext.txt")
KNOWLEDGE_PATH = os.path.join(config_directory, "knowledge")
HISTORY_FILE = os.path.join(config_directory, "assistant_history")
DEFAULT_TEMPERATURE = 0.3
DEFAULT_MAX_TOKENS = 10000
MAX_AUTONOMOUS_ITERATIONS = 50
CONTEXT_COMPRESSION_THRESHOLD = 15
RECENT_MESSAGES_TO_KEEP = 20
CONTEXT_WINDOW = 256000
API_TOTAL_TOKEN_LIMIT = CONTEXT_WINDOW
MAX_OUTPUT_TOKENS = 30000
SAFETY_BUFFER_TOKENS = 30000
MAX_TOKENS_LIMIT = API_TOTAL_TOKEN_LIMIT - MAX_OUTPUT_TOKENS - SAFETY_BUFFER_TOKENS
SYSTEM_PROMPT_BUDGET = 15000
HISTORY_BUDGET = 40000
CURRENT_REQUEST_BUDGET = 30000
CONTEXT_SAFETY_MARGIN = 5000
ACTIVE_WORK_BUDGET = CONTEXT_WINDOW - SYSTEM_PROMPT_BUDGET - HISTORY_BUDGET - CURRENT_REQUEST_BUDGET - CONTEXT_SAFETY_MARGIN
CHARS_PER_TOKEN = 2.0
EMERGENCY_MESSAGES_TO_KEEP = 3
CONTENT_TRIM_LENGTH = 30000
MAX_TOOL_RESULT_LENGTH = 30000
STREAMING_ENABLED = True
TOKEN_THROUGHPUT_TARGET = 92
CACHE_PREFIX_MIN_LENGTH = 100
COMPRESSION_TRIGGER = 0.75
FALLBACK_COMPRESSION_RATIO = 5
TOOL_TIMEOUT_DEFAULT = 30
RETRY_STRATEGY = 'exponential'
MAX_RETRIES = 3
VERIFY_BEFORE_EXECUTE = True
ERROR_LOGGING_ENABLED = True
REQUESTS_PER_MINUTE = 480
TOKENS_PER_MINUTE = 2_000_000
CONCURRENT_REQUESTS = 4
VERIFICATION_REQUIRED = True
VISIBLE_REASONING = True
PRICING_INPUT = 0.20 / 1_000_000
PRICING_OUTPUT = 1.50 / 1_000_000
PRICING_CACHED = 0.02 / 1_000_000
PRICING_INPUT_EUR = 0.00020 / 1000
PRICING_OUTPUT_EUR = 0.00150 / 1000
BUILD_DEFAULT_BUDGET_EUR = 10.00
BUILD_MAX_STEPS = 50
BUILD_STEP_TIMEOUT = 300
BUILD_LIVE_COST_TICKER = True
BUILD_DEFAULT_VERBOSITY = 1
BUILD_SHOW_TOKEN_BREAKDOWN = False
BUILD_SHOW_TIME_ANALYSIS = False
BUILD_PROGRESS_WIDTH = 30
KEYBINDINGS_ENABLED = True
KEYBINDINGS_HELP_ON_START = False
LANGUAGE_KEYWORDS = {
"python": [
"def",
"class",
"import",
"from",
"if",
"else",
"elif",
"for",
"while",
"return",
"try",
"except",
"finally",
"with",
"as",
"lambda",
"yield",
"None",
"True",
"False",
"and",
"or",
"not",
"in",
"is",
],
"javascript": [
"function",
"var",
"let",
"const",
"if",
"else",
"for",
"while",
"return",
"try",
"catch",
"finally",
"class",
"extends",
"new",
"this",
"null",
"undefined",
"true",
"false",
],
"java": [
"public",
"private",
"protected",
"class",
"interface",
"extends",
"implements",
"static",
"final",
"void",
"int",
"String",
"boolean",
"if",
"else",
"for",
"while",
"return",
"try",
"catch",
"finally",
],
}
CACHE_ENABLED = True
API_CACHE_TTL = 3600
TOOL_CACHE_TTL = 300
WORKFLOW_MAX_RETRIES = 3
WORKFLOW_DEFAULT_TIMEOUT = 300
WORKFLOW_EXECUTOR_MAX_WORKERS = 5
AGENT_DEFAULT_TEMPERATURE = 0.7
AGENT_MAX_WORKERS = 3
AGENT_SESSION_TIMEOUT = 7200
KNOWLEDGE_IMPORTANCE_THRESHOLD = 0.5
KNOWLEDGE_SEARCH_LIMIT = 5
MEMORY_AUTO_SUMMARIZE = True
CONVERSATION_SUMMARY_THRESHOLD = 20
ADVANCED_CONTEXT_ENABLED = True
CONTEXT_RELEVANCE_THRESHOLD = 0.3
ADAPTIVE_CONTEXT_MIN = 10
ADAPTIVE_CONTEXT_MAX = 50
BACKGROUND_MONITOR_ENABLED = False
BACKGROUND_MONITOR_INTERVAL = 5.0
AUTONOMOUS_INTERACTION_INTERVAL = 10.0
MULTIPLEXER_BUFFER_SIZE = 1000
MULTIPLEXER_OUTPUT_TIMEOUT = 30
MAX_CONCURRENT_SESSIONS = 10
PROCESS_TIMEOUTS = {
"default": 300,
"apt": 600,
"ssh": 60,
"vim": 3600,
"git": 300,
"npm": 600,
"pip": 300,
}
HIGH_OUTPUT_THRESHOLD = 50
INACTIVE_THRESHOLD = 300
SESSION_NOTIFY_INTERVAL = 60
ENABLE_AUTONOMOUS_SESSIONS = True
ENABLE_BACKGROUND_UPDATES = True
ENABLE_TIMEOUT_DETECTION = True