65 lines
1.7 KiB
Python
65 lines
1.7 KiB
Python
"""
|
|
Configuration settings handler for Clover - A terminal assistant for AI-powered project management
|
|
"""
|
|
|
|
import os
|
|
import json
|
|
from pathlib import Path
|
|
|
|
def load_config():
|
|
"""
|
|
Load configuration from file or return defaults.
|
|
|
|
Returns:
|
|
dict: Configuration dictionary with default values
|
|
"""
|
|
config = {
|
|
'timeout': 300, # Default timeout in seconds
|
|
'threads': 5, # Default max threads
|
|
'model': 'gpt-4', # Default model
|
|
'api_key': None, # API key (should be set via environment variable)
|
|
'base_url': None, # Base URL for API (can be set via environment variable)
|
|
}
|
|
|
|
# Load from environment variables if available
|
|
if 'CLOVER_TIMEOUT' in os.environ:
|
|
config['timeout'] = int(os.environ['CLOVER_TIMEOUT'])
|
|
|
|
if 'CLOVER_THREADS' in os.environ:
|
|
config['threads'] = int(os.environ['CLOVER_THREADS'])
|
|
|
|
if 'CLOVER_MODEL' in os.environ:
|
|
config['model'] = os.environ['CLOVER_MODEL']
|
|
|
|
if 'OPENAI_API_KEY' in os.environ:
|
|
config['api_key'] = os.environ['OPENAI_API_KEY']
|
|
|
|
if 'CLOVER_BASE_URL' in os.environ:
|
|
config['base_url'] = os.environ['CLOVER_BASE_URL']
|
|
|
|
return config
|
|
|
|
def save_config(config):
|
|
"""
|
|
Save configuration to file.
|
|
|
|
Args:
|
|
config (dict): Configuration dictionary to save
|
|
"""
|
|
# In a full implementation, save to a config file
|
|
pass
|
|
|
|
def get_setting(key, default=None):
|
|
"""
|
|
Get a specific configuration setting.
|
|
|
|
Args:
|
|
key (str): Configuration key
|
|
default: Default value if key not found
|
|
|
|
Returns:
|
|
Value of the setting or default
|
|
"""
|
|
config = load_config()
|
|
return config.get(key, default)
|