Spaces:
Sleeping
Sleeping
File size: 1,760 Bytes
3a19347 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
"""
Configuration for Gradio + MCP Linux administration system.
Simplified for Gradio's built-in MCP support.
"""
import os
from typing import List
from dataclasses import dataclass
@dataclass
class OpenAIConfig:
"""OpenAI API configuration"""
api_key: str
model: str = "gpt-4o-mini"
temperature: float = 0.7
max_tokens: int = 1000
@classmethod
def from_env(cls) -> 'OpenAIConfig':
api_key = os.getenv('OPENAI_API_KEY')
if not api_key:
raise ValueError("OPENAI_API_KEY environment variable is required")
return cls(api_key=api_key)
@dataclass
class SecurityConfig:
"""Security settings for command execution"""
# Whitelist of safe commands
safe_commands: List[str] = None
# Maximum command timeout (seconds)
command_timeout: int = 30
def __post_init__(self):
if self.safe_commands is None:
self.safe_commands = [
"ls", "df", "cat", "ps", "whoami", "pwd", "date",
"uptime", "free", "top", "netstat", "ss",
"tail", "head", "grep", "find", "which"
]
@dataclass
class GradioConfig:
"""Gradio interface configuration"""
title: str = "Linux MCP Administration"
description: str = "AI-powered Linux system administration with MCP tools"
theme: str = "soft"
share: bool = False
# Chat interface settings
chatbot_height: int = 600
textbox_placeholder: str = "Ask me about Linux administration..."
class Config:
"""Main configuration class"""
def __init__(self):
self.openai = OpenAIConfig.from_env()
self.security = SecurityConfig()
self.gradio = GradioConfig()
# Global config instance
config = Config() |