Skip to content

[Inference Providers] Fix structured output #1579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

hanouticelina
Copy link
Contributor

@hanouticelina hanouticelina commented Jul 1, 2025

equivalent PR to huggingface/huggingface_hub#3082.
sambanova and nebius don’t fully follow OpenAI’s spec for the response_format field. This PR adds internal mappings for each provider. Seems like fireworks-ai is now following OpenAI specs for this field (double checked their docs as well).

Copy link
Contributor

@Wauplin Wauplin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

Seems like together and fireworks-ai are now following OpenAI specs for this field (double checked their docs as well).

Does it mean Python SDK broke for those 2 ? 😄

@hanouticelina
Copy link
Contributor Author

Does it mean Python SDK broke for those 2 ? 😄

for fireworks-ai, it still works (I mean, they definitely shouldn't break that and not keep it backward compatible 😄) as for Together, I initially thought they were now totally compatible, but it turns out they're still not fully compatible just yet, I pushed bf05b9b to add a mapping.

@julien-c
Copy link
Member

julien-c commented Jul 2, 2025

(take with a grain of salt as i've been following from afar)

They're all likely to change to be fully OpenAI compliant so we could write code that conditionally support the current situation but also works if they move to full compliance, no?

@hanouticelina
Copy link
Contributor Author

@julien-c i tried to make things forward compatible, for Nebius, we already are. For together, their API rejects requests that contain both a schema key (their specs) and a json_schema key (OAI compatible) inside response_format. Same for sambanova, i'm not sure we can be forward compatible, they don't support strict mode so we have to hardcode the value to false for now 🤷‍♀️

@julien-c
Copy link
Member

julien-c commented Jul 2, 2025

ah yes re-reading i'm a bit dumb i was thinking of supporting evolutions in responses, but in requests there's not really a way to do it.

Copy link
Contributor

@SBrandeis SBrandeis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good - I pushed a few changes to leverage the typing system a bit more, please review them @hanouticelina

I haven't tested the actual inference though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants