Lazy initialization of OpenAI client
(self)
| 37 | |
| 38 | @property |
| 39 | def client(self): |
| 40 | """Lazy initialization of OpenAI client""" |
| 41 | if not self._client: |
| 42 | if 'azure' in self.base_url.lower(): |
| 43 | # Handle Azure OpenAI |
| 44 | self._client = AzureOpenAI( |
| 45 | api_key=self.api_key, |
| 46 | azure_endpoint=self.base_url, |
| 47 | api_version="2024-02-01", |
| 48 | max_retries=0 # Disable client retries - we handle them |
| 49 | ) |
| 50 | elif 'generativelanguage.googleapis.com' in self.base_url: |
| 51 | # Google AI with standard OpenAI-compatible client |
| 52 | self._client = OpenAI( |
| 53 | api_key=self.api_key, |
| 54 | base_url=self.base_url, |
| 55 | max_retries=0 # Disable client retries - we handle them |
| 56 | ) |
| 57 | else: |
| 58 | # Standard OpenAI-compatible client |
| 59 | self._client = OpenAI( |
| 60 | api_key=self.api_key, |
| 61 | base_url=self.base_url, |
| 62 | max_retries=0 # Disable client retries - we handle them |
| 63 | ) |
| 64 | return self._client |
| 65 | |
| 66 | def map_model(self, model: str) -> str: |
| 67 | """Map requested model to provider-specific name""" |
nothing calls this directly
no outgoing calls
no test coverage detected