Initialize Security Copilot. Args: provider: LLM provider - "anthropic", "openai", "ollama", "ollama/ ", or model shortcuts like "qwen", "llama3", "mistral" model: Model to use (defaults to provider's best) api_key: API key (or
(
self,
provider: str = "anthropic",
model: Optional[str] = None,
api_key: Optional[str] = None,
base_url: Optional[str] = None,
)
| 35 | def __init__( |
| 36 | self, |
| 37 | provider: str = "anthropic", |
| 38 | model: str | None = None, |
| 39 | api_key: str | None = None, |
| 40 | base_url: str | None = None, |
| 41 | ): |
| 42 | """Initialize Security Copilot. |
| 43 | |
| 44 | Args: |
| 45 | provider: LLM provider - "anthropic", "openai", "ollama", "ollama/<model>", |
| 46 | or model shortcuts like "qwen", "llama3", "mistral" |
| 47 | model: Model to use (defaults to provider's best) |
| 48 | api_key: API key (or use environment variable) |
| 49 | base_url: Base URL for API (for ollama or openai-compatible) |
| 50 | |
| 51 | Examples: |
| 52 | SecurityCopilot("anthropic") |
| 53 | SecurityCopilot("ollama", model="qwen2.5") |
| 54 | SecurityCopilot("ollama/llama3.2") |
| 55 | SecurityCopilot("qwen") # shortcut for ollama/qwen2.5 |
| 56 | SecurityCopilot("openai-compatible", base_url="http://localhost:8000/v1", model="my-model") |
| 57 | """ |
| 58 | self.logger = get_logger("ai.copilot") |
| 59 | self.provider = provider |
| 60 | self.correlator = FindingCorrelator() |
| 61 | |
| 62 | kwargs = {} |
| 63 | if api_key: |
| 64 | kwargs["api_key"] = api_key |
| 65 | if model: |
| 66 | kwargs["model"] = model |
| 67 | if base_url: |
| 68 | kwargs["base_url"] = base_url |
| 69 | |
| 70 | self._client: BaseLLMClient | None = None |
| 71 | self._client_kwargs = kwargs |
| 72 | |
| 73 | # Conversation history for context |
| 74 | self.conversation: list[Message] = [] |
| 75 | self.scan_context: list[ScanResult] = [] |
| 76 | self.correlation_report: CorrelationReport | None = None |
| 77 | |
| 78 | def _get_client(self) -> BaseLLMClient: |
| 79 | """Lazy load LLM client.""" |
| 80 | if self._client is None: |
| 81 | self._client = get_llm_client(self.provider, **self._client_kwargs) |
nothing calls this directly
no test coverage detected