mirror of
https://github.com/fumiama/deepinfra.git
synced 2026-06-05 00:32:46 +08:00
feat(model): support extra_body for openai
This commit is contained in:
@@ -34,10 +34,11 @@ type OpenAI struct {
|
|||||||
// callback/request
|
// callback/request
|
||||||
Model string `json:"model"`
|
Model string `json:"model"`
|
||||||
Messages []Message `json:"messages"`
|
Messages []Message `json:"messages"`
|
||||||
Temperature float32 `json:"temperature"` // Temperature 0.7
|
Temperature float32 `json:"temperature,omitempty"` // Temperature 0.7
|
||||||
TopP float32 `json:"top_p"` // TopP 0.9
|
TopP float32 `json:"top_p,omitempty"` // TopP 0.9
|
||||||
MaxTokens int `json:"max_tokens"` // MaxTokens 4096
|
MaxTokens int `json:"max_tokens,omitempty"` // MaxTokens 4096
|
||||||
ExtraBody any `json:"extra_body"`
|
// extra body
|
||||||
|
EnableThinking bool `json:"enable_thinking"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewOpenAI use temp 0.7, topp 0.9, maxn 4096 if you don't know the meaning.
|
// NewOpenAI use temp 0.7, topp 0.9, maxn 4096 if you don't know the meaning.
|
||||||
@@ -60,11 +61,6 @@ func (*OpenAI) Header(key string, h http.Header) {
|
|||||||
h.Add("Authorization", "Bearer "+key)
|
h.Add("Authorization", "Bearer "+key)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (opai *OpenAI) SetExtra(body any) *OpenAI {
|
|
||||||
opai.ExtraBody = body
|
|
||||||
return opai
|
|
||||||
}
|
|
||||||
|
|
||||||
func (opai *OpenAI) Body() *bytes.Buffer {
|
func (opai *OpenAI) Body() *bytes.Buffer {
|
||||||
w := bytes.NewBuffer(make([]byte, 0, 8192))
|
w := bytes.NewBuffer(make([]byte, 0, 8192))
|
||||||
err := json.NewEncoder(w).Encode(opai)
|
err := json.NewEncoder(w).Encode(opai)
|
||||||
|
|||||||
Reference in New Issue
Block a user