api_llm¶
- exception fairdiverse.search.llm_model.api_llm.ApiException(msg, error_code)[source]¶
Bases:
Exception
Custom exception class for handling API-specific errors.
- Parameters:
msg – Error message describing the API failure
error_code – HTTP status code from the API response
- class fairdiverse.search.llm_model.api_llm.ApiProxy(url, api_key=None)[source]¶
Bases:
object
A proxy class for handling HTTP communications with LLM API endpoints. This class manages API request sessions, implements retry logic, and handles various HTTP status codes with exponential backoff for rate limits and server errors.
- Parameters:
url – The API endpoint URL
api_key – Optional API key for authentication with LLM services