mirror of
https://github.com/huggingface/text-generation-inference.git
synced 2025-04-26 12:32:10 +00:00
Upgrade other tests.
This commit is contained in:
parent
ad904be5fc
commit
0e0844ce00
@ -42,6 +42,7 @@ from syrupy.extensions.json import JSONSnapshotExtension
|
||||
|
||||
from text_generation import AsyncClient
|
||||
from text_generation.types import (
|
||||
Completion,
|
||||
BestOfSequence,
|
||||
Message,
|
||||
ChatComplete,
|
||||
@ -131,6 +132,7 @@ class ResponseComparator(JSONSnapshotExtension):
|
||||
or isinstance(data, ChatComplete)
|
||||
or isinstance(data, ChatCompletionChunk)
|
||||
or isinstance(data, ChatCompletionComplete)
|
||||
or isinstance(data, Completion)
|
||||
or isinstance(data, OAIChatCompletionChunk)
|
||||
):
|
||||
data = data.model_dump()
|
||||
@ -140,6 +142,8 @@ class ResponseComparator(JSONSnapshotExtension):
|
||||
data = dict(data)
|
||||
elif isinstance(data, List):
|
||||
data = [self._serialize(d) for d in data]
|
||||
elif isinstance(data, dict):
|
||||
return data
|
||||
else:
|
||||
raise RuntimeError(f"Unexpected data {type(data)} : {data}")
|
||||
return data
|
||||
|
@ -12,11 +12,11 @@
|
||||
"logprobs": null
|
||||
}
|
||||
],
|
||||
"created": 1726656043,
|
||||
"created": 1741274364,
|
||||
"id": "",
|
||||
"model": "meta-llama/Meta-Llama-3.1-8B-Instruct",
|
||||
"model": "meta-llama/Llama-3.1-8B-Instruct",
|
||||
"object": "chat.completion.chunk",
|
||||
"system_fingerprint": "2.2.1-dev0-native",
|
||||
"system_fingerprint": "3.1.2-dev0-native",
|
||||
"usage": null
|
||||
},
|
||||
{
|
||||
@ -32,11 +32,11 @@
|
||||
"logprobs": null
|
||||
}
|
||||
],
|
||||
"created": 1726656043,
|
||||
"created": 1741274364,
|
||||
"id": "",
|
||||
"model": "meta-llama/Meta-Llama-3.1-8B-Instruct",
|
||||
"model": "meta-llama/Llama-3.1-8B-Instruct",
|
||||
"object": "chat.completion.chunk",
|
||||
"system_fingerprint": "2.2.1-dev0-native",
|
||||
"system_fingerprint": "3.1.2-dev0-native",
|
||||
"usage": null
|
||||
},
|
||||
{
|
||||
@ -52,11 +52,11 @@
|
||||
"logprobs": null
|
||||
}
|
||||
],
|
||||
"created": 1726656043,
|
||||
"created": 1741274364,
|
||||
"id": "",
|
||||
"model": "meta-llama/Meta-Llama-3.1-8B-Instruct",
|
||||
"model": "meta-llama/Llama-3.1-8B-Instruct",
|
||||
"object": "chat.completion.chunk",
|
||||
"system_fingerprint": "2.2.1-dev0-native",
|
||||
"system_fingerprint": "3.1.2-dev0-native",
|
||||
"usage": null
|
||||
},
|
||||
{
|
||||
@ -72,11 +72,11 @@
|
||||
"logprobs": null
|
||||
}
|
||||
],
|
||||
"created": 1726656043,
|
||||
"created": 1741274364,
|
||||
"id": "",
|
||||
"model": "meta-llama/Meta-Llama-3.1-8B-Instruct",
|
||||
"model": "meta-llama/Llama-3.1-8B-Instruct",
|
||||
"object": "chat.completion.chunk",
|
||||
"system_fingerprint": "2.2.1-dev0-native",
|
||||
"system_fingerprint": "3.1.2-dev0-native",
|
||||
"usage": null
|
||||
},
|
||||
{
|
||||
@ -92,11 +92,11 @@
|
||||
"logprobs": null
|
||||
}
|
||||
],
|
||||
"created": 1726656043,
|
||||
"created": 1741274364,
|
||||
"id": "",
|
||||
"model": "meta-llama/Meta-Llama-3.1-8B-Instruct",
|
||||
"model": "meta-llama/Llama-3.1-8B-Instruct",
|
||||
"object": "chat.completion.chunk",
|
||||
"system_fingerprint": "2.2.1-dev0-native",
|
||||
"system_fingerprint": "3.1.2-dev0-native",
|
||||
"usage": null
|
||||
},
|
||||
{
|
||||
@ -112,11 +112,11 @@
|
||||
"logprobs": null
|
||||
}
|
||||
],
|
||||
"created": 1726656043,
|
||||
"created": 1741274364,
|
||||
"id": "",
|
||||
"model": "meta-llama/Meta-Llama-3.1-8B-Instruct",
|
||||
"model": "meta-llama/Llama-3.1-8B-Instruct",
|
||||
"object": "chat.completion.chunk",
|
||||
"system_fingerprint": "2.2.1-dev0-native",
|
||||
"system_fingerprint": "3.1.2-dev0-native",
|
||||
"usage": null
|
||||
},
|
||||
{
|
||||
@ -132,11 +132,11 @@
|
||||
"logprobs": null
|
||||
}
|
||||
],
|
||||
"created": 1726656044,
|
||||
"created": 1741274364,
|
||||
"id": "",
|
||||
"model": "meta-llama/Meta-Llama-3.1-8B-Instruct",
|
||||
"model": "meta-llama/Llama-3.1-8B-Instruct",
|
||||
"object": "chat.completion.chunk",
|
||||
"system_fingerprint": "2.2.1-dev0-native",
|
||||
"system_fingerprint": "3.1.2-dev0-native",
|
||||
"usage": null
|
||||
},
|
||||
{
|
||||
@ -152,11 +152,11 @@
|
||||
"logprobs": null
|
||||
}
|
||||
],
|
||||
"created": 1726656044,
|
||||
"created": 1741274364,
|
||||
"id": "",
|
||||
"model": "meta-llama/Meta-Llama-3.1-8B-Instruct",
|
||||
"model": "meta-llama/Llama-3.1-8B-Instruct",
|
||||
"object": "chat.completion.chunk",
|
||||
"system_fingerprint": "2.2.1-dev0-native",
|
||||
"system_fingerprint": "3.1.2-dev0-native",
|
||||
"usage": null
|
||||
},
|
||||
{
|
||||
@ -172,11 +172,11 @@
|
||||
"logprobs": null
|
||||
}
|
||||
],
|
||||
"created": 1726656044,
|
||||
"created": 1741274364,
|
||||
"id": "",
|
||||
"model": "meta-llama/Meta-Llama-3.1-8B-Instruct",
|
||||
"model": "meta-llama/Llama-3.1-8B-Instruct",
|
||||
"object": "chat.completion.chunk",
|
||||
"system_fingerprint": "2.2.1-dev0-native",
|
||||
"system_fingerprint": "3.1.2-dev0-native",
|
||||
"usage": null
|
||||
},
|
||||
{
|
||||
@ -192,11 +192,20 @@
|
||||
"logprobs": null
|
||||
}
|
||||
],
|
||||
"created": 1726656044,
|
||||
"created": 1741274364,
|
||||
"id": "",
|
||||
"model": "meta-llama/Meta-Llama-3.1-8B-Instruct",
|
||||
"model": "meta-llama/Llama-3.1-8B-Instruct",
|
||||
"object": "chat.completion.chunk",
|
||||
"system_fingerprint": "2.2.1-dev0-native",
|
||||
"system_fingerprint": "3.1.2-dev0-native",
|
||||
"usage": null
|
||||
},
|
||||
{
|
||||
"choices": [],
|
||||
"created": 1741274364,
|
||||
"id": "",
|
||||
"model": "meta-llama/Llama-3.1-8B-Instruct",
|
||||
"object": "chat.completion.chunk",
|
||||
"system_fingerprint": "3.1.2-dev0-native",
|
||||
"usage": {
|
||||
"completion_tokens": 10,
|
||||
"prompt_tokens": 40,
|
||||
|
@ -96,8 +96,10 @@ async def test_flash_llama_completion_stream_usage(
|
||||
assert not had_usage
|
||||
if has_usage:
|
||||
had_usage = True
|
||||
elif c["usage"]:
|
||||
had_usage = True
|
||||
else:
|
||||
raise RuntimeError("Expected different payload")
|
||||
raise RuntimeError(f"Expected different payload: {c}")
|
||||
assert had_usage
|
||||
assert (
|
||||
string
|
||||
@ -147,6 +149,8 @@ async def test_flash_llama_completion_stream_usage(
|
||||
assert not had_usage
|
||||
if has_usage:
|
||||
had_usage = True
|
||||
elif c["usage"]:
|
||||
had_usage = True
|
||||
else:
|
||||
raise RuntimeError("Expected different payload")
|
||||
assert not had_usage
|
||||
|
@ -1,6 +1,4 @@
|
||||
import pytest
|
||||
import requests
|
||||
import json
|
||||
from openai import OpenAI
|
||||
from huggingface_hub import InferenceClient
|
||||
from huggingface_hub.inference._generated.types.chat_completion import (
|
||||
|
Loading…
Reference in New Issue
Block a user