File size: 2,069 Bytes
bed5cc5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
64
65
66
67
68
"""
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