You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to get OpenAI and Gemini models to use the same json structure for response. My response format for OpenAI models use strict: true but for Gemini I leave this out, since they don't accept that property.
The response format includes:
abc: {
type: ['string', 'null'],
description: 'Your answer to Question 3 goes here. Leave as null if no information is available.',
},
This works with OpenAI models but Gemini does not seem to accept a type of ['string', 'null'].
I've tried using oneOf as an alternative, but Gemini also doesn't seem to support that.
I could do something like:
abc: {
type: 'string',
description: 'Your answer to Question 3 goes here. Enter null if no information is available.',
},
But then the LLM will probably just include a null string instead of a real null value. And more importantly, it's not aligned with OpenAI's strict JSON structure.
What is the best way to deal with this?
(Is there really no better option than to define separate response structures for Gemini/OpenAI?)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to get OpenAI and Gemini models to use the same json structure for response. My response format for OpenAI models use
strict: true
but for Gemini I leave this out, since they don't accept that property.The response format includes:
This works with OpenAI models but Gemini does not seem to accept a type of
['string', 'null']
.I've tried using
oneOf
as an alternative, but Gemini also doesn't seem to support that.I could do something like:
But then the LLM will probably just include a null string instead of a real null value. And more importantly, it's not aligned with OpenAI's strict JSON structure.
What is the best way to deal with this?
(Is there really no better option than to define separate response structures for Gemini/OpenAI?)
Beta Was this translation helpful? Give feedback.
All reactions