From c6ace985c2ab8649cf614d252f8d2e7914bcd81c Mon Sep 17 00:00:00 2001 From: JustSong Date: Sun, 3 Mar 2024 22:51:01 +0800 Subject: [PATCH] fix: set missing ali parameters (close #1028) --- relay/channel/ali/main.go | 6 ++++++ relay/channel/ali/model.go | 2 ++ 2 files changed, 8 insertions(+) diff --git a/relay/channel/ali/main.go b/relay/channel/ali/main.go index b9625584..62115d58 100644 --- a/relay/channel/ali/main.go +++ b/relay/channel/ali/main.go @@ -33,6 +33,9 @@ func ConvertRequest(request model.GeneralOpenAIRequest) *ChatRequest { enableSearch = true aliModel = strings.TrimSuffix(aliModel, EnableSearchModelSuffix) } + if request.TopP >= 1 { + request.TopP = 0.9999 + } return &ChatRequest{ Model: aliModel, Input: Input{ @@ -42,6 +45,9 @@ func ConvertRequest(request model.GeneralOpenAIRequest) *ChatRequest { EnableSearch: enableSearch, IncrementalOutput: request.Stream, Seed: uint64(request.Seed), + MaxTokens: request.MaxTokens, + Temperature: request.Temperature, + TopP: request.TopP, }, } } diff --git a/relay/channel/ali/model.go b/relay/channel/ali/model.go index 54f13041..76e814d1 100644 --- a/relay/channel/ali/model.go +++ b/relay/channel/ali/model.go @@ -16,6 +16,8 @@ type Parameters struct { Seed uint64 `json:"seed,omitempty"` EnableSearch bool `json:"enable_search,omitempty"` IncrementalOutput bool `json:"incremental_output,omitempty"` + MaxTokens int `json:"max_tokens,omitempty"` + Temperature float64 `json:"temperature,omitempty"` } type ChatRequest struct {