Commit c176e713 by Xyfacai

fix: 非openai 渠道使用 SystemPrompt 设置会panic

parent 6b9c1c3a
...@@ -90,7 +90,8 @@ func TextHelper(c *gin.Context, info *relaycommon.RelayInfo) (newAPIError *types ...@@ -90,7 +90,8 @@ func TextHelper(c *gin.Context, info *relaycommon.RelayInfo) (newAPIError *types
if info.ChannelSetting.SystemPrompt != "" { if info.ChannelSetting.SystemPrompt != "" {
// 如果有系统提示,则将其添加到请求中 // 如果有系统提示,则将其添加到请求中
request := convertedRequest.(*dto.GeneralOpenAIRequest) request, ok := convertedRequest.(*dto.GeneralOpenAIRequest)
if ok {
containSystemPrompt := false containSystemPrompt := false
for _, message := range request.Messages { for _, message := range request.Messages {
if message.Role == request.GetSystemRoleName() { if message.Role == request.GetSystemRoleName() {
...@@ -127,6 +128,7 @@ func TextHelper(c *gin.Context, info *relaycommon.RelayInfo) (newAPIError *types ...@@ -127,6 +128,7 @@ func TextHelper(c *gin.Context, info *relaycommon.RelayInfo) (newAPIError *types
} }
} }
} }
}
jsonData, err := common.Marshal(convertedRequest) jsonData, err := common.Marshal(convertedRequest)
if err != nil { if err != nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment