From e893d0d9a7ed6ad9ebc5280961507824738bf400 Mon Sep 17 00:00:00 2001 From: ayush Date: Thu, 10 Jul 2025 13:04:22 +0000 Subject: [PATCH 1/6] Add GuidedChoice to ChatCompletionRequest --- chat.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/chat.go b/chat.go index 0f0c5b5d5..5ba09f2ee 100644 --- a/chat.go +++ b/chat.go @@ -309,6 +309,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"` + // GuidedChoice restricts output to a set of predefined choices. + GuidedChoice []string `json:"guided_choice,omitempty"` } type StreamOptions struct { From 5c3ab187437b1e89157011c99440a8fc67a1774a Mon Sep 17 00:00:00 2001 From: ayush Date: Sun, 13 Jul 2025 10:10:33 +0000 Subject: [PATCH 2/6] made separate NonOpenAIExtensions --- chat.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/chat.go b/chat.go index 5ba09f2ee..214dedbd5 100644 --- a/chat.go +++ b/chat.go @@ -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"` @@ -309,8 +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"` - // GuidedChoice restricts output to a set of predefined choices. - GuidedChoice []string `json:"guided_choice,omitempty"` + // Embedded struct for non-OpenAI extensions + NonOpenAIExtensions `json:",inline"` } type StreamOptions struct { From e0f35846057b6c976bb8fc76ec1c4707ad97dd74 Mon Sep 17 00:00:00 2001 From: ayush Date: Sun, 13 Jul 2025 10:11:54 +0000 Subject: [PATCH 3/6] fixed lint issue --- chat.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chat.go b/chat.go index 214dedbd5..39ffc920e 100644 --- a/chat.go +++ b/chat.go @@ -248,7 +248,7 @@ func (r *ChatCompletionResponseFormatJSONSchema) UnmarshalJSON(data []byte) erro return nil } -// NonOpenAIExtensions contains non-standard OpenAI API extensions +// 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"` From 557eb1c73f5069419db95eee2c4b2d1b1181b593 Mon Sep 17 00:00:00 2001 From: ayush Date: Mon, 14 Jul 2025 04:47:08 +0000 Subject: [PATCH 4/6] renamed struct and removed inline json tag --- chat.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/chat.go b/chat.go index 39ffc920e..69e36cd25 100644 --- a/chat.go +++ b/chat.go @@ -248,8 +248,8 @@ func (r *ChatCompletionResponseFormatJSONSchema) UnmarshalJSON(data []byte) erro return nil } -// NonOpenAIExtensions contains non-standard OpenAI API extensions. -type NonOpenAIExtensions struct { +// ChatCompletionRequestExtensions contains non-standard OpenAI API extensions. +type ChatCompletionRequestExtensions struct { // GuidedChoice restricts output to a set of predefined choices. GuidedChoice []string `json:"guided_choice,omitempty"` } @@ -316,7 +316,7 @@ type ChatCompletionRequest struct { // 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"` + ChatCompletionRequestExtensions } type StreamOptions struct { From 1fcaa8af4306c88ebe076ddc1a4335ddc6622471 Mon Sep 17 00:00:00 2001 From: Alex Baranov <677093+sashabaranov@users.noreply.github.com> Date: Sat, 19 Jul 2025 20:54:30 +0100 Subject: [PATCH 5/6] Update chat.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- chat.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/chat.go b/chat.go index 69e36cd25..d8db35fbb 100644 --- a/chat.go +++ b/chat.go @@ -250,7 +250,11 @@ func (r *ChatCompletionResponseFormatJSONSchema) UnmarshalJSON(data []byte) erro // ChatCompletionRequestExtensions contains non-standard OpenAI API extensions. type ChatCompletionRequestExtensions struct { - // GuidedChoice restricts output to a set of predefined choices. + // GuidedChoice is a vLLM-specific extension that restricts the model's output + // to one of the predefined string choices provided in this field. This feature + // is used to constrain the model's responses to a controlled set of options, + // ensuring predictable and consistent outputs in scenarios where specific + // choices are required. GuidedChoice []string `json:"guided_choice,omitempty"` } From 9af75f40e3e3849dba67f02ab12ab3a22fad6a33 Mon Sep 17 00:00:00 2001 From: Alex Baranov <677093+sashabaranov@users.noreply.github.com> Date: Sat, 19 Jul 2025 20:54:45 +0100 Subject: [PATCH 6/6] Update chat.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- chat.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chat.go b/chat.go index d8db35fbb..e14acd9d9 100644 --- a/chat.go +++ b/chat.go @@ -248,7 +248,7 @@ func (r *ChatCompletionResponseFormatJSONSchema) UnmarshalJSON(data []byte) erro return nil } -// ChatCompletionRequestExtensions contains non-standard OpenAI API extensions. +// ChatCompletionRequestExtensions contains third-party OpenAI API extensions (e.g., vendor-specific implementations like vLLM). type ChatCompletionRequestExtensions struct { // GuidedChoice is a vLLM-specific extension that restricts the model's output // to one of the predefined string choices provided in this field. This feature