mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-09 03:18:44 +00:00
fix: replace hard orjson imports with json in core SDK files
orjson is an optional dependency (only in proxy extras), so bare `import orjson` in core SDK files breaks users who haven't installed it. Replace with stdlib json.dumps/json.loads which is always available. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
4b94a99361
commit
288bd225c2
3 changed files with 9 additions and 10 deletions
|
|
@ -15,7 +15,6 @@ from typing import (
|
|||
)
|
||||
|
||||
import httpx # type: ignore
|
||||
import orjson
|
||||
from openai.types.file_deleted import FileDeleted
|
||||
|
||||
import litellm
|
||||
|
|
@ -179,7 +178,7 @@ class BaseLLMHTTPHandler:
|
|||
data=(
|
||||
signed_json_body
|
||||
if signed_json_body is not None
|
||||
else orjson.dumps(data).decode()
|
||||
else json.dumps(data)
|
||||
),
|
||||
timeout=timeout,
|
||||
stream=stream,
|
||||
|
|
@ -239,7 +238,7 @@ class BaseLLMHTTPHandler:
|
|||
data=(
|
||||
signed_json_body
|
||||
if signed_json_body is not None
|
||||
else orjson.dumps(data).decode()
|
||||
else json.dumps(data)
|
||||
),
|
||||
timeout=timeout,
|
||||
stream=stream,
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ OpenAI-like chat completion handler
|
|||
For handling OpenAI-like chat completions, like IBM WatsonX, etc.
|
||||
"""
|
||||
|
||||
import orjson
|
||||
import json
|
||||
from typing import Any, Callable, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
|
@ -139,7 +139,7 @@ class OpenAILikeChatHandler(OpenAILikeBase):
|
|||
client=client,
|
||||
api_base=api_base,
|
||||
headers=headers,
|
||||
data=orjson.dumps(data),
|
||||
data=json.dumps(data),
|
||||
model=model,
|
||||
messages=messages,
|
||||
logging_obj=logging_obj,
|
||||
|
|
@ -185,7 +185,7 @@ class OpenAILikeChatHandler(OpenAILikeBase):
|
|||
|
||||
try:
|
||||
response = await client.post(
|
||||
api_base, headers=headers, data=orjson.dumps(data), timeout=timeout
|
||||
api_base, headers=headers, data=json.dumps(data), timeout=timeout
|
||||
)
|
||||
response.raise_for_status()
|
||||
except httpx.HTTPStatusError as e:
|
||||
|
|
@ -350,7 +350,7 @@ class OpenAILikeChatHandler(OpenAILikeBase):
|
|||
),
|
||||
api_base=api_base,
|
||||
headers=headers,
|
||||
data=orjson.dumps(data),
|
||||
data=json.dumps(data),
|
||||
model=model,
|
||||
messages=messages,
|
||||
logging_obj=logging_obj,
|
||||
|
|
@ -370,7 +370,7 @@ class OpenAILikeChatHandler(OpenAILikeBase):
|
|||
client = HTTPHandler(timeout=timeout) # type: ignore
|
||||
try:
|
||||
response = client.post(
|
||||
url=api_base, headers=headers, data=orjson.dumps(data)
|
||||
url=api_base, headers=headers, data=json.dumps(data)
|
||||
)
|
||||
response.raise_for_status()
|
||||
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@
|
|||
OpenAI-like chat completion transformation
|
||||
"""
|
||||
|
||||
import json
|
||||
from typing import TYPE_CHECKING, Any, List, Optional, Tuple, Union
|
||||
|
||||
import httpx
|
||||
import orjson
|
||||
|
||||
from litellm.secret_managers.main import get_secret_str
|
||||
from litellm.types.llms.openai import AllMessageValues, ChatCompletionAssistantMessage
|
||||
|
|
@ -95,7 +95,7 @@ class OpenAILikeChatConfig(OpenAIGPTConfig):
|
|||
custom_llm_provider: Optional[str],
|
||||
base_model: Optional[str],
|
||||
) -> ModelResponse:
|
||||
response_json = orjson.loads(response.content)
|
||||
response_json = json.loads(response.content)
|
||||
logging_obj.post_call(
|
||||
input=messages,
|
||||
api_key="",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue