Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(fix) 'utf-8' codec can't encode characters error on OpenAI #7018

Merged
merged 6 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ documentation = "https://docs.litellm.ai"

[tool.poetry.dependencies]
python = ">=3.8.1,<4.0, !=3.9.7"
openai = ">=1.54.0"
httpx = ">=0.23.0,<0.28.0"
openai = ">=1.55.3"
python-dotenv = ">=0.2.0"
tiktoken = ">=0.7.0"
importlib-metadata = ">=6.8.0"
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# LITELLM PROXY DEPENDENCIES #
anyio==4.4.0 # openai + http req.
httpx==0.27.0 # Pin Httpx dependency
openai==1.55.3 # openai req.
fastapi==0.111.0 # server dep
backoff==2.2.1 # server dep
Expand Down
14 changes: 14 additions & 0 deletions tests/llm_translation/base_llm_unit_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,20 @@
response = litellm.completion(**base_completion_call_args, messages=messages)
assert response is not None

def test_multilingual_requests(self):
"""
Tests that the provider can handle multilingual requests and invalid utf-8 sequences

Context: https://github.com/openai/openai-python/issues/1921
"""
base_completion_call_args = self.get_base_completion_call_args()
response = litellm.completion(
**base_completion_call_args,
messages=[{"role": "user", "content": "你好世界!\ud83e, ö"}],
)
print("multilingual response: ", response)
Dismissed Show dismissed Hide dismissed
assert response is not None

@pytest.mark.parametrize(
"response_format",
[
Expand Down
10 changes: 10 additions & 0 deletions tests/llm_translation/test_openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import litellm
from litellm import Choices, Message, ModelResponse
from base_llm_unit_tests import BaseLLMChatTest


def test_openai_prediction_param():
Expand Down Expand Up @@ -268,3 +269,12 @@ async def test_vision_with_custom_model():
]
assert request_body["model"] == "my-custom-model"
assert request_body["max_tokens"] == 10


class TestOpenAIChatCompletion(BaseLLMChatTest):
def get_base_completion_call_args(self) -> dict:
return {"model": "gpt-4o-mini"}

def test_tool_call_no_arguments(self, tool_call_no_arguments):
"""Test that tool calls with no arguments is translated correctly. Relevant issue: https://github.com/BerriAI/litellm/issues/6833"""
pass
Loading