Skip to content

Commit e424975

Browse files
AyushSawant18588sashabaranovCopilot
authored andcommitted
Add GuidedChoice to ChatCompletionRequest (sashabaranov#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 c353ff4 commit e424975

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
@@ -279,6 +279,16 @@ func (r *ChatCompletionResponseFormatJSONSchema) UnmarshalJSON(data []byte) erro
279279
return nil
280280
}
281281

282+
// ChatCompletionRequestExtensions contains third-party OpenAI API extensions (e.g., vendor-specific implementations like vLLM).
283+
type ChatCompletionRequestExtensions struct {
284+
// GuidedChoice is a vLLM-specific extension that restricts the model's output
285+
// to one of the predefined string choices provided in this field. This feature
286+
// is used to constrain the model's responses to a controlled set of options,
287+
// ensuring predictable and consistent outputs in scenarios where specific
288+
// choices are required.
289+
GuidedChoice []string `json:"guided_choice,omitempty"`
290+
}
291+
282292
// ChatCompletionRequest represents a request structure for chat completion API.
283293
type ChatCompletionRequest struct {
284294
Model string `json:"model"`
@@ -340,6 +350,8 @@ type ChatCompletionRequest struct {
340350
ChatTemplateKwargs map[string]any `json:"chat_template_kwargs,omitempty"`
341351
// Specifies the latency tier to use for processing the request.
342352
ServiceTier ServiceTier `json:"service_tier,omitempty"`
353+
// Embedded struct for non-OpenAI extensions
354+
ChatCompletionRequestExtensions
343355
}
344356

345357
type StreamOptions struct {

0 commit comments

Comments
 (0)