Feat Support chat completion response format and seed new fields (#525)

* feat: support chat completion response format

* fix linting error

* fix

* fix linting

* Revert "fix linting"

This reverts commit 015c6ad62aad561218b693225f58670b5619dba8.

* Revert "fix"

This reverts commit 7b2ffe28c3e586b629d23479ec1728bf52f0c66f.

* Revert "fix linting error"

This reverts commit 29960423784e296cb6d22c5db8f8ccf00cac59fd.

* chore: add seed new parameter

* fix
This commit is contained in:
Simone Vellei
2023-11-07 15:25:21 +01:00
committed by GitHub
parent d07833e19b
commit 6d9c3a6365

13
chat.go
View File

@@ -69,6 +69,17 @@ type FunctionCall struct {
Arguments string `json:"arguments,omitempty"` Arguments string `json:"arguments,omitempty"`
} }
type ChatCompletionResponseFormatType string
const (
ChatCompletionResponseFormatTypeJSONObject ChatCompletionResponseFormatType = "json_object"
ChatCompletionResponseFormatTypeText ChatCompletionResponseFormatType = "text"
)
type ChatCompletionResponseFormat struct {
Type ChatCompletionResponseFormatType `json:"type"`
}
// ChatCompletionRequest represents a request structure for chat completion API. // ChatCompletionRequest represents a request structure for chat completion API.
type ChatCompletionRequest struct { type ChatCompletionRequest struct {
Model string `json:"model"` Model string `json:"model"`
@@ -80,6 +91,8 @@ type ChatCompletionRequest struct {
Stream bool `json:"stream,omitempty"` Stream bool `json:"stream,omitempty"`
Stop []string `json:"stop,omitempty"` Stop []string `json:"stop,omitempty"`
PresencePenalty float32 `json:"presence_penalty,omitempty"` PresencePenalty float32 `json:"presence_penalty,omitempty"`
ResponseFormat ChatCompletionResponseFormat `json:"response_format,omitempty"`
Seed *int `json:"seed,omitempty"`
FrequencyPenalty float32 `json:"frequency_penalty,omitempty"` FrequencyPenalty float32 `json:"frequency_penalty,omitempty"`
// LogitBias is must be a token id string (specified by their token ID in the tokenizer), not a word string. // LogitBias is must be a token id string (specified by their token ID in the tokenizer), not a word string.
// incorrect: `"logit_bias":{"You": 6}`, correct: `"logit_bias":{"1639": 6}` // incorrect: `"logit_bias":{"You": 6}`, correct: `"logit_bias":{"1639": 6}`