From e893d0d9a7ed6ad9ebc5280961507824738bf400 Mon Sep 17 00:00:00 2001 From: ayush Date: Thu, 10 Jul 2025 13:04:22 +0000 Subject: [PATCH 1/4] 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/4] 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/4] 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/4] 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 {