Skip to content

Commit 4f87294

Browse files
AyushSawant18588sashabaranovCopilot
authored
Add GuidedChoice to ChatCompletionRequest (#1034)
* Add GuidedChoice to ChatCompletionRequest * made separate NonOpenAIExtensions * fixed lint issue * renamed struct and removed inline json tag * Update chat.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update chat.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Alex Baranov <677093+sashabaranov@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 181c0e8 commit 4f87294

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

chat.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,16 @@ func (r *ChatCompletionResponseFormatJSONSchema) UnmarshalJSON(data []byte) erro
248248
return nil
249249
}
250250

251+
// ChatCompletionRequestExtensions contains third-party OpenAI API extensions (e.g., vendor-specific implementations like vLLM).
252+
type ChatCompletionRequestExtensions struct {
253+
// GuidedChoice is a vLLM-specific extension that restricts the model's output
254+
// to one of the predefined string choices provided in this field. This feature
255+
// is used to constrain the model's responses to a controlled set of options,
256+
// ensuring predictable and consistent outputs in scenarios where specific
257+
// choices are required.
258+
GuidedChoice []string `json:"guided_choice,omitempty"`
259+
}
260+
251261
// ChatCompletionRequest represents a request structure for chat completion API.
252262
type ChatCompletionRequest struct {
253263
Model string `json:"model"`
@@ -309,6 +319,8 @@ type ChatCompletionRequest struct {
309319
ChatTemplateKwargs map[string]any `json:"chat_template_kwargs,omitempty"`
310320
// Specifies the latency tier to use for processing the request.
311321
ServiceTier ServiceTier `json:"service_tier,omitempty"`
322+
// Embedded struct for non-OpenAI extensions
323+
ChatCompletionRequestExtensions
312324
}
313325

314326
type StreamOptions struct {

0 commit comments

Comments
 (0)