mirror of
https://github.com/huggingface/text-generation-inference.git
synced 2025-06-18 23:32:06 +00:00
Migrate to V2 Pydantic interface
Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
This commit is contained in:
parent
839477670a
commit
d17f36e497
@ -138,10 +138,10 @@ client = InferenceClient("http://localhost:3000")
|
||||
|
||||
user_input = "I saw a puppy a cat and a raccoon during my bike ride in the park"
|
||||
resp = client.text_generation(
|
||||
f"convert to JSON: 'f{user_input}'. please use the following schema: {Animals.schema()}",
|
||||
f"convert to JSON: 'f{user_input}'. please use the following schema: {Animals.model_json_schema()}",
|
||||
max_new_tokens=100,
|
||||
seed=42,
|
||||
grammar={"type": "json", "value": Animals.schema()},
|
||||
grammar={"type": "json", "value": Animals.model_json_schema()},
|
||||
)
|
||||
|
||||
print(resp)
|
||||
|
@ -34,7 +34,7 @@ async def test_grammar_response_format_llama_json(llama_grammar, response_snapsh
|
||||
"messages": [
|
||||
{
|
||||
"role": "system",
|
||||
"content": f"Respond to the users questions and answer them in the following format: {Weather.schema()}",
|
||||
"content": f"Respond to the users questions and answer them in the following format: {Weather.model_json_schema()}",
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
@ -43,7 +43,7 @@ async def test_grammar_response_format_llama_json(llama_grammar, response_snapsh
|
||||
],
|
||||
"seed": 42,
|
||||
"max_tokens": 500,
|
||||
"response_format": {"type": "json_object", "value": Weather.schema()},
|
||||
"response_format": {"type": "json_object", "value": Weather.model_json_schema()},
|
||||
}
|
||||
# send the request
|
||||
response = requests.post(
|
||||
@ -75,7 +75,7 @@ async def test_grammar_response_format_llama_json(llama_grammar, response_snapsh
|
||||
|
||||
json_payload["response_format"] = {
|
||||
"type": "json_schema",
|
||||
"value": {"name": "weather", "strict": True, "schema": Weather.schema()},
|
||||
"value": {"name": "weather", "strict": True, "schema": Weather.model_json_schema()},
|
||||
}
|
||||
response = requests.post(
|
||||
f"{llama_grammar.base_url}/v1/chat/completions",
|
||||
@ -109,7 +109,7 @@ async def test_grammar_response_format_llama_error_if_tools_not_installed(
|
||||
"messages": [
|
||||
{
|
||||
"role": "system",
|
||||
"content": f"Respond to the users questions and answer them in the following format: {Weather.schema()}",
|
||||
"content": f"Respond to the users questions and answer them in the following format: {Weather.model_json_schema()}",
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
@ -119,7 +119,7 @@ async def test_grammar_response_format_llama_error_if_tools_not_installed(
|
||||
"seed": 42,
|
||||
"max_tokens": 500,
|
||||
"tools": [],
|
||||
"response_format": {"type": "json_object", "value": Weather.schema()},
|
||||
"response_format": {"type": "json_object", "value": Weather.model_json_schema()},
|
||||
},
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user