[Bugfix]: allow extra fields in requests to openai compatible server (#10463)

Signed-off-by: Guillaume Calmettes <gcalmettes@scaleway.com>
This commit is contained in:
Guillaume Calmettes
2024-11-20 22:42:21 +01:00
committed by GitHub
parent 0cd3d9717e
commit c68f7ede6a
2 changed files with 28 additions and 14 deletions

View File

@@ -899,19 +899,19 @@ async def test_response_format_json_schema(client: openai.AsyncOpenAI):
@pytest.mark.asyncio
async def test_extra_fields(client: openai.AsyncOpenAI):
with pytest.raises(BadRequestError) as exc_info:
await client.chat.completions.create(
model=MODEL_NAME,
messages=[{
"role": "system",
"content": "You are a helpful assistant.",
"extra_field": "0",
}], # type: ignore
temperature=0,
seed=0)
async def test_extra_fields_allowed(client: openai.AsyncOpenAI):
resp = await client.chat.completions.create(
model=MODEL_NAME,
messages=[{
"role": "user",
"content": "what is 1+1?",
"extra_field": "0",
}], # type: ignore
temperature=0,
seed=0)
assert "extra_forbidden" in exc_info.value.message
content = resp.choices[0].message.content
assert content is not None
@pytest.mark.asyncio