diff --git a/local_code_assistant/commands/base.py b/local_code_assistant/commands/base.py new file mode 100644 index 0000000..0ada5f1 --- /dev/null +++ b/local_code_assistant/commands/base.py @@ -0,0 +1,50 @@ +"""Base command class for Local Code Assistant.""" + +from typing import Any, Optional + +from local_code_assistant.services.config import ConfigService +from local_code_assistant.services.ollama import OllamaService + + +class BaseCommand: + """Base class for CLI commands.""" + + def __init__(self, ollama: OllamaService, config: ConfigService): + """Initialize base command. + + Args: + ollama: Ollama service instance. + config: Configuration service instance. + """ + self.ollama = ollama + self.config = config + + def run(self, *args, **kwargs) -> Any: + """Execute the command. Override in subclasses. + + Returns: + Command result. + """ + raise NotImplementedError("Subclasses must implement run()") + + def _get_model(self, model: Optional[str] = None) -> str: + """Get model to use, falling back to default. + + Args: + model: Specified model or None. + + Returns: + Model name. + """ + return model or self.config.ollama_model + + def _get_temperature(self, temperature: Optional[float] = None) -> float: + """Get temperature, falling back to default. + + Args: + temperature: Specified temperature or None. + + Returns: + Temperature value. + """ + return temperature if temperature is not None else self.config.temperature \ No newline at end of file