1
0
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:
源文雨
2025-09-10 10:28:28 +08:00
parent f1b27f21d8
commit 8cde75e137
2 changed files with 7 additions and 3 deletions

View File

@@ -37,6 +37,7 @@ type OpenAI struct {
Temperature float32 `json:"temperature"` // Temperature 0.7
TopP float32 `json:"top_p"` // TopP 0.9
MaxTokens int `json:"max_tokens"` // MaxTokens 4096
ExtraBody any `json:"extra_body"`
}
// NewOpenAI use temp 0.7, topp 0.9, maxn 4096 if you don't know the meaning.
@@ -59,6 +60,11 @@ func (*OpenAI) Header(key string, h http.Header) {
h.Add("Authorization", "Bearer "+key)
}
func (opai *OpenAI) SetExtra(body any) *OpenAI {
opai.ExtraBody = body
return opai
}
func (opai *OpenAI) Body() *bytes.Buffer {
w := bytes.NewBuffer(make([]byte, 0, 8192))
err := json.NewEncoder(w).Encode(opai)