add the “top_p" param
This commit is contained in:
parent
0685e8c153
commit
0a0a19c03a
|
|
@ -13,6 +13,7 @@
|
||||||
"chat_api_organization": "",
|
"chat_api_organization": "",
|
||||||
"chat_api_project": "",
|
"chat_api_project": "",
|
||||||
"chat_max_tokens": 4096,
|
"chat_max_tokens": 4096,
|
||||||
|
"chat_top_p": 1.0,
|
||||||
"chat_model_default": "gpt-4o",
|
"chat_model_default": "gpt-4o",
|
||||||
"chat_model_map": {},
|
"chat_model_map": {},
|
||||||
"chat_locale": "zh_CN",
|
"chat_locale": "zh_CN",
|
||||||
|
|
|
||||||
7
main.go
7
main.go
|
|
@ -42,6 +42,7 @@ type config struct {
|
||||||
ChatApiOrganization string `json:"chat_api_organization"`
|
ChatApiOrganization string `json:"chat_api_organization"`
|
||||||
ChatApiProject string `json:"chat_api_project"`
|
ChatApiProject string `json:"chat_api_project"`
|
||||||
ChatMaxTokens int `json:"chat_max_tokens"`
|
ChatMaxTokens int `json:"chat_max_tokens"`
|
||||||
|
ChatTopP float64 `json:chat_top_p`
|
||||||
ChatModelDefault string `json:"chat_model_default"`
|
ChatModelDefault string `json:"chat_model_default"`
|
||||||
ChatModelMap map[string]string `json:"chat_model_map"`
|
ChatModelMap map[string]string `json:"chat_model_map"`
|
||||||
ChatLocale string `json:"chat_locale"`
|
ChatLocale string `json:"chat_locale"`
|
||||||
|
|
@ -108,6 +109,10 @@ func readConfig() *config {
|
||||||
_cfg.ChatMaxTokens = 4096
|
_cfg.ChatMaxTokens = 4096
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if _cfg.ChatTopP <= 0 {
|
||||||
|
_cfg.ChatTopP = 0.9
|
||||||
|
}
|
||||||
|
|
||||||
return _cfg
|
return _cfg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -363,6 +368,8 @@ func (s *ProxyService) completions(c *gin.Context) {
|
||||||
body, _ = sjson.SetBytes(body, "max_tokens", s.cfg.ChatMaxTokens)
|
body, _ = sjson.SetBytes(body, "max_tokens", s.cfg.ChatMaxTokens)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
body, _ = sjson.SetBytes(body, "top_p", s.cfg.ChatTopP)
|
||||||
|
|
||||||
proxyUrl := s.cfg.ChatApiBase + "/chat/completions"
|
proxyUrl := s.cfg.ChatApiBase + "/chat/completions"
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, proxyUrl, io.NopCloser(bytes.NewBuffer(body)))
|
req, err := http.NewRequestWithContext(ctx, http.MethodPost, proxyUrl, io.NopCloser(bytes.NewBuffer(body)))
|
||||||
if nil != err {
|
if nil != err {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue