Skip to content

Add GuidedChoice to ChatCompletionRequest #1034

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 4 commits into
base: master
Choose a base branch
from
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,12 @@ func (r *ChatCompletionResponseFormatJSONSchema) UnmarshalJSON(data []byte) erro
return nil
}

// NonOpenAIExtensions contains non-standard OpenAI API extensions.
type NonOpenAIExtensions struct {
// GuidedChoice restricts output to a set of predefined choices.
GuidedChoice []string `json:"guided_choice,omitempty"`
}

// ChatCompletionRequest represents a request structure for chat completion API.
type ChatCompletionRequest struct {
Model string `json:"model"`
Expand Down Expand Up @@ -309,6 +315,8 @@ type ChatCompletionRequest struct {
ChatTemplateKwargs map[string]any `json:"chat_template_kwargs,omitempty"`
// Specifies the latency tier to use for processing the request.
ServiceTier ServiceTier `json:"service_tier,omitempty"`
// Embedded struct for non-OpenAI extensions
NonOpenAIExtensions `json:",inline"`
Copy link
Preview

Copilot AI Jul 13, 2025

Choose a reason for hiding this comment

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

[nitpick] The json:",inline" tag is not recognized by Go’s encoding/json and can be removed, since anonymous struct fields are inlined by default.

Suggested change
NonOpenAIExtensions `json:",inline"`
NonOpenAIExtensions

Copilot uses AI. Check for mistakes.

}

type StreamOptions struct {
Expand Down
Loading