mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-05-01 19:17:41 +03:00
Move openai specific workaround so it doesn't apply to other providers
This commit is contained in:
parent
95b5b89ed9
commit
33abaaa9f8
@ -153,9 +153,6 @@ Each line represents a detection state, not necessarily unique individuals. The
|
|||||||
if "other_concerns" in schema.get("required", []):
|
if "other_concerns" in schema.get("required", []):
|
||||||
schema["required"].remove("other_concerns")
|
schema["required"].remove("other_concerns")
|
||||||
|
|
||||||
# OpenAI strict mode requires additionalProperties: false on all objects
|
|
||||||
schema["additionalProperties"] = False
|
|
||||||
|
|
||||||
response_format = {
|
response_format = {
|
||||||
"type": "json_schema",
|
"type": "json_schema",
|
||||||
"json_schema": {
|
"json_schema": {
|
||||||
|
|||||||
@ -73,8 +73,17 @@ class OpenAIClient(GenAIClient):
|
|||||||
**self.genai_config.runtime_options,
|
**self.genai_config.runtime_options,
|
||||||
}
|
}
|
||||||
if response_format:
|
if response_format:
|
||||||
|
# OpenAI strict mode requires additionalProperties: false on the schema
|
||||||
|
if response_format.get("type") == "json_schema" and response_format.get(
|
||||||
|
"json_schema", {}
|
||||||
|
).get("strict"):
|
||||||
|
schema = response_format.get("json_schema", {}).get("schema")
|
||||||
|
if isinstance(schema, dict):
|
||||||
|
schema["additionalProperties"] = False
|
||||||
request_params["response_format"] = response_format
|
request_params["response_format"] = response_format
|
||||||
|
|
||||||
result = self.provider.chat.completions.create(**request_params)
|
result = self.provider.chat.completions.create(**request_params)
|
||||||
|
|
||||||
if (
|
if (
|
||||||
result is not None
|
result is not None
|
||||||
and hasattr(result, "choices")
|
and hasattr(result, "choices")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user