mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 11:14:04 +00:00
_get_azure_openai_client
This commit is contained in:
parent
26be805ad3
commit
b74f3cb76c
1 changed files with 19 additions and 5 deletions
|
@ -331,6 +331,7 @@ class AzureChatCompletion(BaseAzureLLM, BaseLLM):
|
||||||
client=client,
|
client=client,
|
||||||
max_retries=max_retries,
|
max_retries=max_retries,
|
||||||
azure_client_params=azure_client_params,
|
azure_client_params=azure_client_params,
|
||||||
|
litellm_params=litellm_params,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
return self.acompletion(
|
return self.acompletion(
|
||||||
|
@ -349,6 +350,7 @@ class AzureChatCompletion(BaseAzureLLM, BaseLLM):
|
||||||
max_retries=max_retries,
|
max_retries=max_retries,
|
||||||
convert_tool_call_to_json_mode=json_mode,
|
convert_tool_call_to_json_mode=json_mode,
|
||||||
azure_client_params=azure_client_params,
|
azure_client_params=azure_client_params,
|
||||||
|
litellm_params=litellm_params,
|
||||||
)
|
)
|
||||||
elif "stream" in optional_params and optional_params["stream"] is True:
|
elif "stream" in optional_params and optional_params["stream"] is True:
|
||||||
return self.streaming(
|
return self.streaming(
|
||||||
|
@ -460,15 +462,26 @@ class AzureChatCompletion(BaseAzureLLM, BaseLLM):
|
||||||
convert_tool_call_to_json_mode: Optional[bool] = None,
|
convert_tool_call_to_json_mode: Optional[bool] = None,
|
||||||
client=None, # this is the AsyncAzureOpenAI
|
client=None, # this is the AsyncAzureOpenAI
|
||||||
azure_client_params: dict = {},
|
azure_client_params: dict = {},
|
||||||
|
litellm_params: Optional[dict] = {},
|
||||||
):
|
):
|
||||||
response = None
|
response = None
|
||||||
try:
|
try:
|
||||||
# setting Azure client
|
# setting Azure client
|
||||||
if client is None or dynamic_params:
|
azure_client = self._get_azure_openai_client(
|
||||||
azure_client = AsyncAzureOpenAI(**azure_client_params)
|
api_version=api_version,
|
||||||
else:
|
api_base=api_base,
|
||||||
azure_client = client
|
api_key=api_key,
|
||||||
|
azure_ad_token=azure_ad_token,
|
||||||
|
azure_ad_token_provider=azure_ad_token_provider,
|
||||||
|
model=model,
|
||||||
|
max_retries=max_retries,
|
||||||
|
timeout=timeout,
|
||||||
|
client=client,
|
||||||
|
client_type="async",
|
||||||
|
litellm_params=litellm_params,
|
||||||
|
)
|
||||||
|
if not isinstance(azure_client, AsyncAzureOpenAI):
|
||||||
|
raise ValueError("Azure client is not an instance of AsyncAzureOpenAI")
|
||||||
## LOGGING
|
## LOGGING
|
||||||
logging_obj.pre_call(
|
logging_obj.pre_call(
|
||||||
input=data["messages"],
|
input=data["messages"],
|
||||||
|
@ -622,6 +635,7 @@ class AzureChatCompletion(BaseAzureLLM, BaseLLM):
|
||||||
azure_ad_token_provider: Optional[Callable] = None,
|
azure_ad_token_provider: Optional[Callable] = None,
|
||||||
client=None,
|
client=None,
|
||||||
azure_client_params: dict = {},
|
azure_client_params: dict = {},
|
||||||
|
litellm_params: Optional[dict] = {},
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
if client is None or dynamic_params:
|
if client is None or dynamic_params:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue