Skip to content

Support response_format in chat completions#538

Open
kolsha wants to merge 7 commits into
trymirai:mainfrom
kolsha:support-response-format
Open

Support response_format in chat completions#538
kolsha wants to merge 7 commits into
trymirai:mainfrom
kolsha:support-response-format

Conversation

@kolsha

@kolsha kolsha commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Hey, folks!
I've started using uzu in my personal projects and noticed chat completions doesn't support OpenAI-style response_format yet.
I needed it, so I implemented it on top of the existing grammar support and opened a PR.
Happy to tweak the API or approach 🐼
Thanks!


Enhance chat session and grammar handling with new token IDs

  • Added trigger_token_id parameter to create_compiled_grammar for improved grammar configuration.
  • Introduced end_of_thinking_token_id in ChatSession to manage end-of-thinking scenarios.
  • Updated to_chat_messages function to include reasoning effort in the last message.
  • Added new tests for structured output with reasoning enabled and disabled.
  • Refactored response handling in ChatCompletionRequest to support new response formats and reasoning effort.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c1e629980b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread crates/backend-uzu/src/session/chat_session.rs Outdated
Comment thread crates/cli/src/server/chat_completions.rs Outdated
Comment thread crates/cli/src/server/chat_completions.rs Outdated
@kolsha kolsha marked this pull request as draft June 12, 2026 22:20

@eugenebokhan eugenebokhan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you please update your branch given the latest main commit e3c9a3c fixing the json schema parsing fix?

kolsha added 4 commits June 13, 2026 17:33
Enhance chat session and grammar handling with new token IDs

- Added `trigger_token_id` parameter to `create_compiled_grammar` for improved grammar configuration.
- Introduced `end_of_thinking_token_id` in `ChatSession` to manage end-of-thinking scenarios.
- Updated `to_chat_messages` function to include reasoning effort in the last message.
- Added new tests for structured output with reasoning enabled and disabled.
- Refactored response handling in `ChatCompletionRequest` to support new response formats and reasoning effort.
- Updated `create_compiled_grammar` to accept multiple trigger token IDs and additional parameters for pre-engagement token management.
- Modified `ChatSession` to handle a vector of end-of-thinking token IDs, enhancing flexibility in grammar engagement.
- Introduced logic for managing pre-engagement tokens and trimming slack tokens in `CompiledGrammarEngagementState`.
- Added tests to validate the new engagement logic and token handling.
@kolsha kolsha force-pushed the support-response-format branch from c1e6299 to 05a6779 Compare June 13, 2026 17:21
@kolsha

kolsha commented Jun 13, 2026

Copy link
Copy Markdown
Contributor Author

Could you please update your branch given the latest main commit e3c9a3c fixing the json schema parsing fix?

Sure, if understand correctly - you want the schema parsing logic to live inside backend.
I removed checks/schema from API side.

I also brought support for multiple trigger tokens. I'm lacking some context, so this might need some polishing.
Please let me know your thoughts.

psss
@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 05a6779468

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@arsenyinfo

This comment was marked as spam.

@eugenebokhan

Copy link
Copy Markdown
Contributor

Please resolve the conflicts and make sure CI tests pass

@kolsha kolsha marked this pull request as ready for review June 16, 2026 19:09
}
}

#[cfg(test)]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please either remove these tests or move them to a dedicated uzu/tests/unit dir

@eugenebokhan

Copy link
Copy Markdown
Contributor

Please update to the latest main given an openai response format pr was merged

@kolsha

kolsha commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

Done, please take a look when you have time

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.

3 participants