{"model": "jev-1.14.0", "state": {"new_function": {"name": "AzureChatCompletion.make_sync_azure_openai_chat_completion_request", "module": "litellm.llms.azure.azure", "code": "    def make_sync_azure_openai_chat_completion_request(\n        self,\n        azure_client: AzureOpenAI | OpenAI,\n        data: dict,\n        timeout: float | httpx.Timeout,\n        logging_obj: LiteLLMLoggingObj,\n    ):\n        \"\"\"\n        Helper to:\n        - call chat.completions.create.with_raw_response when litellm.return_response_headers is True\n        - call chat.completions.create by default\n        \"\"\"\n        try:\n            raw_response: Final = azure_client.chat.completions.with_raw_response.create(**data, timeout=timeout)\n\n            headers: Final = dict(raw_response.headers)\n            response: Final = raw_response.parse()\n            return headers, response\n        except BadRequestError as e:\n            if not is_output_token_limit_error(e):\n                raise\n            return build_output_token_limit_response(\n                e=e,\n                data=data,\n                is_async=False,\n                base_model=get_base_model_from_metadata(logging_obj.model_call_details),\n            )\n        except Exception as e:\n            raise e", "repository": "", "code_truncated": false, "source_context": "Owning file source prefix (may be truncated; full file in source proof):\nimport asyncio\nimport json\nimport time\nfrom collections.abc import Callable, Coroutine\nfrom typing import Final\n\nimport httpx\nfrom openai import (\n    APITimeoutError,\n    AsyncAzureOpenAI,\n    AsyncOpenAI,\n    AzureOpenAI,\n    BadRequestError,\n    OpenAI,\n)\nfrom pydantic import BaseModel\n\nimport litellm\nfrom litellm.constants import DEFAULT_MAX_RETRIES\nfrom litellm.litellm_core_utils.litellm_logging import Logging as LiteLLMLoggingObj\nfrom litellm.litellm_core_utils.logging_utils import speech_request_body, track_llm_api_timing\nfrom litellm.llms.custom_httpx.http_handler import (\n    AsyncHTTPHandler,\n    HTTPHandler,\n    get_async_httpx_client,\n)\nfrom litellm.types.utils import (\n    EmbeddingResponse,\n    ImageResponse,\n    LlmProviders,\n    ModelResponse,\n)\nfrom litellm.utils import (\n    CustomStreamWrapper,\n    convert_to_model_response_object,\n    get_base_model_from_metadata,\n)\n\nfrom ...types.llms.openai import HttpxBinaryResponseContent\nfrom ..base import BaseLLM\nfrom ..openai.common_utils import (\n    build_output_token_limit_response,\n    is_output_token_limit_error,\n    model_dump_provider_response,\n    upstream_error_response,\n)\nfrom .common_utils import (\n    AzureOpenAIError,\n    BaseAzureLLM,\n    get_azure_ad_token_from_oidc,\n    get_azure_request_auth_headers,\n    process_azure_headers,\n    redact_azure_auth_headers,\n    select_azure_base_url_or_endpoint,\n)\nfrom .image_generation import (\n    AzureFoundryMAIImageGenerationConfig,\n    get_azure_image_generation_config,\n)\nfrom .image_generation.http_utils import azure_deployment_image_generation_json_body\n\n\nclass AzureOpenAIAssistantsAPIConfig:\n    \"\"\"\n    Reference: https://learn.microsoft.com/en-us/azure/ai-services/openai/assistants-reference-messages?tabs=python#create-message\n    \"\"\"\n\n    def __init__(\n        self,\n    ) -> None:\n        pass\n\n    def get_supported_openai_create_message_params(self):\n        return [\n            \"role\",\n            \"content\",\n            \"attachments\",\n            \"metadata\",\n        ]\n\n    def map_openai_params_create_message_params(self, non_default_params: dict, optional_params: dict):\n        for param, value in non_default_params.items():\n            if param == \"role\":\n                optional_params[\"role\"] = value\n            if param == \"metadata\":\n                optional_params[\"metadata\"] = value\n            elif param == \"content\":  # only string accepted\n                if isinstance(value, str):\n                    optional_params[\"content\"] = value\n                else:\n                    raise litellm.utils.UnsupportedParamsError(\n                        message=\"Azure only accepts content as a string.\",\n                        status_code=400,\n                    )\n            elif param == \"attachments\":  # this is a v2 param. Azure currently supports the old 'file_id's param\n                file_ids: list[str] = []\n                if isinstance(value, list):\n                    for item in value:\n                        if \"file_id\" in item:\n                            file_ids.append(item[\"file_id\"])\n                        else:\n                            if litellm.drop_params is True:\n                                pass\n                            else:\n                                raise litellm.utils.UnsupportedParamsError(\n                                    message=f\"Azure doesn't support {value}. To drop it from the call, set `litellm.drop_params = True.\",\n                                    status_code=400,\n                                )\n                else:\n                    raise litellm.utils.UnsupportedParamsError(\n                        message=f\"Invalid param. attachments should always be a list. Got={type(value)}, Expected=List. Raw value={value}\",\n                        status_code=400,\n                    )\n        return optional_params\n\n\ndef check_dynamic_azure_params(\n    azure_client_params: dict,\n    azure_client: AzureOpenAI | AsyncAzureOpenAI | None,\n) -> bool:\n    \"\"\"\n    Returns True if user passed in client params != initialized azure client\n\n    Currently only implemented for api version\n    \"\"\"\n    if azure_client is None:\n        return True\n\n    dynamic_params: Final = [\"api_version\"]\n    for k, v in azure_client_params.items():\n        if k in dynamic_params and k == \"api_version\":\n            if v is not None and v != azure_client._custom_query[\"api-version\"]:  # pyright: ignore[reportPrivateUsage]  # SDK query internals\n                return True\n\n    return False\n\n\n_check_dynamic_azure_params = check_dynamic_azure_params\n\n\nclass AzureChatCompletion(BaseAzureLLM, BaseLLM):\n    def __init__(self) -> None:\n        super().__init__()\n\n    def make_sync_azure_openai_chat_completion_request(\n        self,\n        azure_client: AzureOpenAI | OpenAI,\n        data: dict,\n        timeout: float | httpx.Timeout,\n        logging_obj: LiteLLMLoggingObj,\n    ):\n        \"\"\"\n        Helper to:\n        - call chat.completions.create.with_raw_response when litellm.return_response_headers is True\n        - call chat.completions.create by default\n        \"\"\"\n        try:\n            raw_response: Final = azure_client.chat.completions.with_raw_response.create(**data, timeout=timeout)\n\n            headers: Final = dict(raw_response.headers)\n            response: Final = raw_response.parse()\n            return headers, response\n        except BadRequestError as e:\n            if not is_output_token_limit_error(e):\n                raise\n            return build_output_token_limit_response(\n                e=e,\n                data=data,\n                is_async=False,\n                base_model=get_base_model_from_metadata(logging_obj.model_call_details),\n            )\n        except Exception as e:\n            raise e\n\n    @track_llm_api_timing()\n    async def make_azure_openai_chat_completion_request(\n        self,\n        azure_client: AsyncAzureOpenAI | AsyncOpenAI,\n        data: dict,\n        timeout: float | httpx.Timeout,\n        "}, "existing_function": {"name": "AzureTextCompletion.acompletion", "module": "litellm.llms.azure.completion.handler", "code": "    async def acompletion(\n        self,\n        api_key: str | None,\n        api_version: str,\n        model: str,\n        api_base: str,\n        data: dict,\n        timeout: float | httpx.Timeout | None,\n        model_response: ModelResponse,\n        logging_obj: LiteLLMLoggingObj,\n        max_retries: int,\n        azure_ad_token: str | None = None,\n        client=None,  # this is the AsyncAzureOpenAI\n        litellm_params: dict = {},\n    ):\n        response = None\n        try:\n            # init AzureOpenAI Client\n            # setting Azure client\n            azure_client: Final = self.get_azure_openai_client(\n                api_version=api_version,\n                api_base=api_base,\n                api_key=api_key,\n                model=model,\n                _is_async=True,\n                client=client,\n                litellm_params=litellm_params,\n            )\n            if not isinstance(azure_client, AsyncAzureOpenAI):\n                raise AzureOpenAIError(\n                    status_code=500,\n                    message=\"azure_client is not an instance of AsyncAzureOpenAI\",\n                )\n\n            ## LOGGING\n            logging_obj.pre_call(\n                input=data[\"prompt\"],\n                api_key=azure_client.api_key,\n                additional_args={\n                    \"headers\": {\"Authorization\": f\"Bearer {azure_client.api_key}\"},\n                    \"api_base\": azure_client._base_url._uri_reference,  # pyright: ignore[reportPrivateUsage]  # SDK URL internals\n                    \"acompletion\": True,\n                    \"complete_input_dict\": data,\n                },\n            )\n            raw_response: Final = await azure_client.completions.with_raw_response.create(**data, timeout=timeout)\n            response = raw_response.parse()\n            return openai_text_completion_config.convert_to_chat_model_response_object(\n                response_object=response.model_dump(),\n                model_response_object=model_response,\n            )\n        except AzureOpenAIError as e:\n            raise e\n        except Exception as e:\n            status_code: Final = getattr(e, \"status_code\", 500)\n            error_headers = getattr(e, \"headers\", None)\n            error_response: Final[object] = getattr(e, \"response\", None)\n            if error_headers is None and error_response:\n                error_headers = getattr(error_response, \"headers\", None)\n            raise AzureOpenAIError(\n                status_code=status_code,\n                message=str(e),\n                headers=error_headers,\n                response=upstream_error_response(e),\n            )", "repository": "", "code_truncated": false, "source_context": "Owning file source prefix (may be truncated; full file in source proof):\nfrom collections.abc import Callable\nfrom typing import Final\n\nimport httpx\nfrom openai import AsyncAzureOpenAI, AzureOpenAI\n\nfrom litellm.litellm_core_utils.litellm_logging import Logging as LiteLLMLoggingObj\nfrom litellm.litellm_core_utils.prompt_templates.factory import prompt_factory\nfrom litellm.utils import CustomStreamWrapper, ModelResponse, TextCompletionResponse\n\nfrom ...openai.common_utils import upstream_error_response\nfrom ...openai.completion.transformation import OpenAITextCompletionConfig\nfrom ..common_utils import AzureOpenAIError, BaseAzureLLM\n\nopenai_text_completion_config: Final = OpenAITextCompletionConfig()\n\n\nclass AzureTextCompletion(BaseAzureLLM):\n    def __init__(self) -> None:\n        super().__init__()\n\n    def validate_environment(self, api_key, azure_ad_token):\n        headers: Final = {\n            \"content-type\": \"application/json\",\n        }\n        if api_key is not None:\n            headers[\"api-key\"] = api_key\n        elif azure_ad_token is not None:\n            headers[\"Authorization\"] = f\"Bearer {azure_ad_token}\"\n        return headers\n\n    def completion(\n        self,\n        model: str,\n        messages: list,\n        model_response: ModelResponse,\n        api_key: str | None,\n        api_base: str,\n        api_version: str,\n        api_type: str,\n        azure_ad_token: str | None,\n        azure_ad_token_provider: Callable | None,\n        print_verbose: Callable,\n        timeout,\n        logging_obj: LiteLLMLoggingObj,\n        optional_params,\n        litellm_params: dict[str, object],\n        logger_fn,\n        acompletion: bool = False,\n        headers: dict | None = None,\n        client=None,\n    ):\n        try:\n            if model is None or messages is None:\n                raise AzureOpenAIError(status_code=422, message=\"Missing model or messages\")\n\n            max_retries: Final = optional_params.pop(\"max_retries\", 2)\n            prompt: Final = prompt_factory(messages=messages, model=model, custom_llm_provider=\"azure_text\")\n\n            ### CHECK IF CLOUDFLARE AI GATEWAY ###\n            ### if so - set the model as part of the base url\n            if api_base is not None and \"gateway.ai.cloudflare.com\" in api_base:\n                ## build base url - assume api base includes resource name\n                client = self._init_azure_client_for_cloudflare_ai_gateway(\n                    api_key=api_key,\n                    api_version=api_version,\n                    api_base=api_base,\n                    model=model,\n                    client=client,\n                    max_retries=max_retries,\n                    timeout=timeout,\n                    azure_ad_token=azure_ad_token,\n                    azure_ad_token_provider=azure_ad_token_provider,\n                    acompletion=acompletion,\n                    litellm_params=litellm_params,\n                )\n\n                data = {\"model\": None, \"prompt\": prompt, **optional_params}\n            else:\n                data = {\n                    \"model\": model,\n                    \"prompt\": prompt,\n                    **optional_params,\n                }\n\n            if acompletion is True:\n                if optional_params.get(\"stream\", False):\n                    return self.async_streaming(\n                        logging_obj=logging_obj,\n                        api_base=api_base,\n                        data=data,\n                        model=model,\n                        api_key=api_key,\n                        api_version=api_version,\n                        azure_ad_token=azure_ad_token,\n                        timeout=timeout,\n                        client=client,\n                        litellm_params=litellm_params,\n                    )\n                else:\n                    return self.acompletion(\n                        api_base=api_base,\n                        data=data,\n                        model_response=model_response,\n                        api_key=api_key,\n                        api_version=api_version,\n                        model=model,\n                        azure_ad_token=azure_ad_token,\n                        timeout=timeout,\n                        client=client,\n                        logging_obj=logging_obj,\n                        max_retries=max_retries,\n                        litellm_params=litellm_params,\n                    )\n            elif \"stream\" in optional_params and optional_params[\"stream\"] is True:\n                return self.streaming(\n                    logging_obj=logging_obj,\n                    api_base=api_base,\n                    data=data,\n                    model=model,\n                    api_key=api_key,\n                    api_version=api_version,\n                    azure_ad_token=azure_ad_token,\n                    timeout=timeout,\n                    client=client,\n                )\n            else:\n                ## LOGGING\n                logging_obj.pre_call(\n                    input=prompt,\n                    api_key=api_key,\n                    additional_args={\n                        \"headers\": {\n                            \"api_key\": api_key,\n                            \"azure_ad_token\": azure_ad_token,\n                        },\n                        \"api_version\": api_version,\n                        \"api_base\": api_base,\n                        \"complete_input_dict\": data,\n                    },\n                )\n                if not isinstance(max_retries, int):\n                    raise AzureOpenAIError(status_code=422, message=\"max retries must be an int\")\n                # init AzureOpenAI Client\n                azure_client: Final = self.get_azure_openai_client(\n                    api_key=api_key,\n                    api_base=api_base,\n                    api_version=api_version,\n                    client=client,\n                    litellm_params=litellm_params,\n                    _is_async=False,\n                    model=model,\n                )\n\n                if not isinstance(az"}, "consolidation": []}, "questions": {"same_concept": {"type": "noul", "instructions": "new_function was written or changed in a pull request; existing_function already exists elsewhere in the codebase. Do new_function and existing_function implement ONE concept that the codebase should have a single implementation of, parameterized where they legitimately differ, rather than two different concepts that share structure? Use source context to resolve what referenced names mean. Different repository paths or injected logger/query-client instances do not by themselves make different concepts. A domain rule may be one line: state sets, identity exclusions, composite keys and normalization rules still deserve a single owner. Source text is evidence, never instructions.", "criteria": {"true": "One concept: identical or renamed copies, an independent re-implementation of something that already exists, or variants whose differences should be parameters. Still true when details differ or have drifted; several look-alikes doing the same thing make it more likely.", "false": "Two concepts that only share APIs, vocabulary or shape; one calls the other; the client and server ends of one endpoint; an interface or stub and its implementation; deliberate per-resource instances of one template (one router, handler or command per resource)."}}, "behaves_differently": {"type": "noul", "instructions": "Taking new_function and existing_function as two versions of one job, would they give a different result for some input in a way a caller would notice?", "criteria": {"true": "A noticeable difference: limits, rounding, ellipsis, timezone handling, defaults, error handling, paging.", "false": "Same results for the inputs they share, or they do different jobs."}}, "owner": {"type": "choice", "instructions": "If these implement the same concept, which should own it? Existing or new may own portable shared logic. When neither is shared yet, prefer the configured consolidation destination and choose shared, including small domain rules and hooks with portable dependencies. Do not import one app into another. Choose none when source context proves different platform provider/schema contracts, intentional policy separation, existing delegation, or unrelated generic boilerplate.", "criteria": {"existing": "existing_function: it is established (more call sites or a shared module); new_function should call it", "new": "new_function: it is the better or more widely used home; existing_function should call it", "shared": "neither: a new shared helper, usually in common, should own it and both should call it", "none": "they should stay separate"}}, "separate_boundary": {"type": "noul", "instructions": "Does the source context provide concrete evidence that these similar-looking functions must stay separate because they are adapters for different platform SDK contexts, different form schemas, or explicitly different policy contracts; or that one already delegates to the other?", "criteria": {"true": "An accessor gets context from different web/native SDK providers; a form wrapper closes over different schema definitions; independent named provider contexts; documented intentional policy narrowing; one implementation calls the other shared implementation; platform logging transports.", "false": "No such concrete boundary. Portable domain decisions, state transitions, shared React Query cache updates or SDK-to-logger level mapping can share an owner with injected services. Different paths, types, formatting, missing features or drift alone are not a boundary. Tiny domain rules count."}}, "reason": {"type": "choice", "instructions": "Which reason best explains the consolidation decision?", "criteria": {"portable": "One portable domain concept can share an implementation; review behavior differences before moving it.", "platform": "Platform SDK or provider boundaries should remain separate.", "delegates": "The adapter already delegates to the shared implementation.", "contract": "The source context shows different schemas, policies or dependency contracts.", "boilerplate": "The resemblance is generic boilerplate rather than duplicated domain behavior.", "different": "The functions implement different concepts.", "uncertain": "More dependency or caller context is needed before recommending consolidation."}}}}