Skip to content

Commit

Permalink
test: init tiktoken for huggingface hub tests
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelrince committed Apr 12, 2024
1 parent 1c6a6ef commit 98d308e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tests/test_huggingface_hub.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import pytest

import tiktoken
from huggingface_hub import InferenceClient, AsyncInferenceClient


@pytest.fixture(autouse=True)
def tiktoken_init() -> None:
tiktoken.get_encoding("cl100k_base")


@pytest.mark.vcr
def test_huggingface_hub_chat(tracer_init):
def test_huggingface_hub_chat(tracer_init, tiktoken_init):
client = InferenceClient(model="HuggingFaceH4/zephyr-7b-beta")
response = client.chat_completion(
messages=[{"role": "user", "content": "Hello World!"}],
Expand All @@ -16,7 +22,7 @@ def test_huggingface_hub_chat(tracer_init):

@pytest.mark.vcr
@pytest.mark.asyncio
async def test_huggingface_hub_async_chat(tracer_init):
async def test_huggingface_hub_async_chat(tracer_init, tiktoken_init):
client = AsyncInferenceClient(model="HuggingFaceH4/zephyr-7b-beta")
response = await client.chat_completion(
messages=[{"role": "user", "content": "Hello World!"}],
Expand Down

0 comments on commit 98d308e

Please sign in to comment.