forked from phoenix/litellm-mirror
fix(azure.py): support health checks to text completion endpoints
This commit is contained in:
parent
0a76269541
commit
a7f182b8ec
3 changed files with 20 additions and 10 deletions
|
@ -741,6 +741,11 @@ class OpenAIChatCompletion(BaseLLM):
|
|||
completion = None
|
||||
|
||||
if mode == "completion":
|
||||
completion = await client.completions.with_raw_response.create(
|
||||
model=model, # type: ignore
|
||||
prompt=prompt, # type: ignore
|
||||
)
|
||||
elif mode == "chat":
|
||||
if messages is None:
|
||||
raise Exception("messages is not set")
|
||||
completion = await client.chat.completions.with_raw_response.create(
|
||||
|
@ -889,7 +894,7 @@ class OpenAITextCompletion(BaseLLM):
|
|||
headers=headers,
|
||||
model_response=model_response,
|
||||
model=model,
|
||||
timeout=timeout
|
||||
timeout=timeout,
|
||||
)
|
||||
else:
|
||||
return self.acompletion(api_base=api_base, data=data, headers=headers, model_response=model_response, prompt=prompt, api_key=api_key, logging_obj=logging_obj, model=model, timeout=timeout) # type: ignore
|
||||
|
@ -901,14 +906,11 @@ class OpenAITextCompletion(BaseLLM):
|
|||
headers=headers,
|
||||
model_response=model_response,
|
||||
model=model,
|
||||
timeout=timeout
|
||||
timeout=timeout,
|
||||
)
|
||||
else:
|
||||
response = httpx.post(
|
||||
url=f"{api_base}",
|
||||
json=data,
|
||||
headers=headers,
|
||||
timeout=timeout
|
||||
url=f"{api_base}", json=data, headers=headers, timeout=timeout
|
||||
)
|
||||
if response.status_code != 200:
|
||||
raise OpenAIError(
|
||||
|
@ -944,7 +946,7 @@ class OpenAITextCompletion(BaseLLM):
|
|||
prompt: str,
|
||||
api_key: str,
|
||||
model: str,
|
||||
timeout: float
|
||||
timeout: float,
|
||||
):
|
||||
async with httpx.AsyncClient(timeout=timeout) as client:
|
||||
try:
|
||||
|
@ -986,7 +988,7 @@ class OpenAITextCompletion(BaseLLM):
|
|||
headers: dict,
|
||||
model_response: ModelResponse,
|
||||
model: str,
|
||||
timeout: float
|
||||
timeout: float,
|
||||
):
|
||||
with httpx.stream(
|
||||
url=f"{api_base}",
|
||||
|
@ -1017,7 +1019,7 @@ class OpenAITextCompletion(BaseLLM):
|
|||
headers: dict,
|
||||
model_response: ModelResponse,
|
||||
model: str,
|
||||
timeout: float
|
||||
timeout: float,
|
||||
):
|
||||
client = httpx.AsyncClient()
|
||||
async with client.stream(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue