Skip to content

Commit

Permalink
test: OpenAI frontend invalid chat tokenizer network issue WAR (#7779)
Browse files Browse the repository at this point in the history
  • Loading branch information
kthui authored and krishung5 committed Nov 14, 2024
1 parent bc09c4d commit 6b173b2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ skip = "./.git,./.github"
# ignore short words, and typename parameters like OffsetT
ignore-regex = "\\b(.{1,4}|[A-Z]\\w*T)\\b"
# ignore allowed words
ignore-words-list = "passin"
ignore-words-list = "passin,couldn"
# use the 'clear' dictionary for unambiguous spelling mistakes
builtin = "clear"
# disable warnings about binary files and wrong encoding
Expand Down
12 changes: 9 additions & 3 deletions python/openai/tests/test_chat_completions.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,9 +564,15 @@ def test_chat_completions_invalid_chat_tokenizer(

# Pick a tokenizer with no chat template defined
invalid_chat_tokenizer = "gpt2"
app = setup_fastapi_app(
tokenizer=invalid_chat_tokenizer, server=server, backend=backend
)
try:
app = setup_fastapi_app(
tokenizer=invalid_chat_tokenizer, server=server, backend=backend
)
except OSError as e:
expected_msg = f"We couldn't connect to 'https://huggingface.co' to load this file, couldn't find it in the cached files and it looks like {invalid_chat_tokenizer} is not the path to a directory containing a file named config.json."
if expected_msg in str(e):
pytest.skip("HuggingFace network issues")
raise e
with TestClient(app) as client:
response = client.post(
"/v1/chat/completions",
Expand Down

0 comments on commit 6b173b2

Please sign in to comment.