diff --git a/litellm/integrations/qualifire/__init__.py b/litellm/integrations/qualifire/__init__.py index ef356dee1b5..c4c5e4d5d19 100644 --- a/litellm/integrations/qualifire/__init__.py +++ b/litellm/integrations/qualifire/__init__.py @@ -1,5 +1,5 @@ import os -from typing import TYPE_CHECKING, Optional +from typing import TYPE_CHECKING if TYPE_CHECKING: from litellm.integrations.custom_prompt_management import CustomPromptManagement diff --git a/litellm/integrations/qualifire/qualifire_client.py b/litellm/integrations/qualifire/qualifire_client.py index f166fa7cc46..955b8519527 100644 --- a/litellm/integrations/qualifire/qualifire_client.py +++ b/litellm/integrations/qualifire/qualifire_client.py @@ -1,16 +1,13 @@ """ HTTP client for the Qualifire Studio API. -Handles sync and async calls to the /compile endpoint. +Handles async calls to the /compile endpoint. """ -from typing import Any, Dict, List, Optional +from typing import Any, Dict, Optional import httpx -from litellm.llms.custom_httpx.http_handler import ( - _get_httpx_client, - get_async_httpx_client, -) +from litellm.llms.custom_httpx.http_handler import get_async_httpx_client from litellm.types.llms.custom_http import httpxSpecialProvider @@ -59,60 +56,22 @@ class QualifireClient: """Handle HTTP error responses with specific messages.""" if response.status_code == 401: raise Exception( - f"Authentication failed for Qualifire API. " - f"Please check your API key." + "Authentication failed for Qualifire API. " + "Please check your API key." ) elif response.status_code == 403: raise Exception( f"Access denied to prompt '{prompt_id}'. " - f"Please check your permissions." + "Please check your permissions." ) elif response.status_code == 404: raise Exception( f"Prompt '{prompt_id}' not found in Qualifire. " - f"Please check the prompt ID." + "Please check the prompt ID." ) response.raise_for_status() - def compile_prompt( - self, - prompt_id: str, - variables: Optional[Dict[str, Any]] = None, - revision: Optional[str] = None, - ) -> Dict[str, Any]: - """ - Compile a prompt by calling the Qualifire API synchronously. - - Args: - prompt_id: The Qualifire prompt CUID - variables: Variables for template substitution - revision: Optional revision CUID to pin a specific version - - Returns: - The compiled prompt response from Qualifire - """ - url = self._build_compile_url(prompt_id) - body = self._build_request_body(variables, revision) - - http_client = _get_httpx_client() - - try: - response = http_client.post( - url, - json=body, - headers=self._get_headers(), - ) - - if response.status_code >= 400: - self._handle_error_response(response, prompt_id) - - return response.json() - except httpx.HTTPError as e: - raise Exception( - f"Failed to compile prompt '{prompt_id}' from Qualifire: {e}" - ) - - async def async_compile_prompt( + async def compile_prompt( self, prompt_id: str, variables: Optional[Dict[str, Any]] = None, diff --git a/litellm/integrations/qualifire/qualifire_prompt_manager.py b/litellm/integrations/qualifire/qualifire_prompt_manager.py index 012341ac66b..5b2eeed5f0c 100644 --- a/litellm/integrations/qualifire/qualifire_prompt_manager.py +++ b/litellm/integrations/qualifire/qualifire_prompt_manager.py @@ -126,22 +126,20 @@ class QualifirePromptManager(CustomPromptManagement): prompt_version: Optional[int] = None, ) -> PromptManagementClient: """ - Compile a prompt using the Qualifire /compile endpoint (sync). + Sync wrapper that delegates to the async compile prompt helper. """ - if prompt_id is None: - raise ValueError("prompt_id is required for Qualifire prompt manager") + import asyncio - revision = self._extract_revision(prompt_spec) - - try: - response = self.client.compile_prompt( + return asyncio.get_event_loop().run_until_complete( + self.async_compile_prompt_helper( prompt_id=prompt_id, - variables=prompt_variables, - revision=revision, + prompt_variables=prompt_variables, + dynamic_callback_params=dynamic_callback_params, + prompt_spec=prompt_spec, + prompt_label=prompt_label, + prompt_version=prompt_version, ) - return self._parse_compile_response(prompt_id, response) - except Exception as e: - raise ValueError(f"Error compiling prompt '{prompt_id}' from Qualifire: {e}") + ) async def async_compile_prompt_helper( self, @@ -161,7 +159,7 @@ class QualifirePromptManager(CustomPromptManagement): revision = self._extract_revision(prompt_spec) try: - response = await self.client.async_compile_prompt( + response = await self.client.compile_prompt( prompt_id=prompt_id, variables=prompt_variables, revision=revision,