Add CLI commands and Gitea Actions workflow
This commit is contained in:
50
local_code_assistant/commands/base.py
Normal file
50
local_code_assistant/commands/base.py
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user