aimevzulari's picture
Upload 19 files
bed5cc5 verified
"""
Cursor Rules Generator - LLM Adapter Interface
This module defines the abstract base class for LLM adapters.
"""
from abc import ABC, abstractmethod
from typing import Dict, List, Optional, Any
class LLMAdapter(ABC):
"""Base adapter interface for LLM providers."""
@abstractmethod
def initialize(self, api_key: str, **kwargs) -> None:
"""Initialize the adapter with API key and optional parameters.
Args:
api_key: The API key for the LLM provider
**kwargs: Additional provider-specific parameters
"""
pass
@abstractmethod
def validate_api_key(self, api_key: str) -> bool:
"""Validate the API key.
Args:
api_key: The API key to validate
Returns:
bool: True if the API key is valid, False otherwise
"""
pass
@abstractmethod
def get_available_models(self) -> List[Dict[str, str]]:
"""Get a list of available models from the provider.
Returns:
List[Dict[str, str]]: A list of model information dictionaries
Each dictionary contains at least 'id' and 'name' keys
"""
pass
@abstractmethod
def generate_rule(
self,
model: str,
rule_type: str,
description: str,
content: str,
parameters: Optional[Dict[str, Any]] = None
) -> str:
"""Generate a Cursor Rule using the LLM provider.
Args:
model: The model ID to use for generation
rule_type: The type of rule to generate (Always, Auto Attached, Agent Requested, Manual)
description: A short description of the rule's purpose
content: The main content of the rule
parameters: Additional parameters for rule generation
May include: globs, referenced_files, prompt, temperature, etc.
Returns:
str: The generated rule in MDC format
"""
pass