Initial commit
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
"""
|
||||
Configuration management for the Edison application.
|
||||
"""
|
||||
import os
|
||||
import yaml
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
def get_config_path():
|
||||
"""
|
||||
Get the path to the configuration file.
|
||||
|
||||
Returns:
|
||||
str: The path to the configuration file.
|
||||
"""
|
||||
script_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
return os.path.join(script_dir, "edison.yaml")
|
||||
|
||||
def load_config():
|
||||
"""
|
||||
Load configuration from file.
|
||||
|
||||
Returns:
|
||||
dict: The loaded configuration.
|
||||
"""
|
||||
config_path = get_config_path()
|
||||
try:
|
||||
with open(config_path, 'r') as file:
|
||||
config = yaml.safe_load(file)
|
||||
logger.debug(f"Configuration loaded from {config_path}")
|
||||
return config
|
||||
except Exception as e:
|
||||
logger.error(f"Error loading configuration: {e}")
|
||||
return {}
|
||||
|
||||
def print_config(config):
|
||||
"""
|
||||
Print configuration information.
|
||||
|
||||
Args:
|
||||
config (dict): The configuration dictionary.
|
||||
"""
|
||||
print("Current configuration per edison.yaml:")
|
||||
print("— Model : " + str(config.get("model", "Not specified")))
|
||||
print("— Temperature : " + str(config.get("temperature", "Not specified")))
|
||||
print("— Max. Tokens : " + str(config.get("max_tokens", "Not specified")))
|
||||
print("— Safety : " + str(bool(config.get("safety", False))))
|
||||
print("— Streaming : " + str(bool(config.get("streaming", True))))
|
||||
print("— Show Prefix : " + str(bool(config.get("show_generating_prefix", True))))
|
||||
print("— Shell : " + str(config.get("shell", "Not specified")))
|
||||
|
||||
# Print UI configuration if available
|
||||
ui_config = config.get("ui", {})
|
||||
if ui_config:
|
||||
print("\nUI Configuration:")
|
||||
print("— Rich Formatting : " + str(bool(ui_config.get("rich_formatting", True))))
|
||||
print("— Theme : " + str(ui_config.get("theme", "monokai")))
|
||||
print("— Command Style : " + str(ui_config.get("command_style", "panel")))
|
||||
print("— Structured Expl.: " + str(bool(ui_config.get("structured_explanations", True))))
|
||||
Reference in New Issue
Block a user