Skip to content

Commit

Permalink
更新日志
Browse files Browse the repository at this point in the history
  • Loading branch information
fruitbars committed Jun 23, 2024
1 parent 8c7afa8 commit 7e33eaa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
14 changes: 7 additions & 7 deletions pkg/adapter/qianfan_openai.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package adapter

import (
"github.com/sashabaranov/go-openai"
"log"
"go.uber.org/zap"
"simple-one-api/pkg/common"
baiduqianfan "simple-one-api/pkg/llm/baidu-qianfan"
"simple-one-api/pkg/mylog"
myopenai "simple-one-api/pkg/openai"
"strings"
)
Expand Down Expand Up @@ -54,7 +55,7 @@ func qianFanCheckMaxTokens(model string, maxtokens int) int {
return validateMaxTokens(maxtokens, config.Min, config.Max, config.DefaultMax)
}
}
log.Println("Unknown model prefix")
mylog.Logger.Warn("Unknown model prefix")
return 0
}

Expand Down Expand Up @@ -152,7 +153,7 @@ func QianFanResponseToOpenAIResponse(qfResp *baiduqianfan.QianFanResponse) *myop
oaResp := myopenai.OpenAIResponse{
ID: qfResp.ID,
Object: qfResp.Object,
Created: int64(qfResp.Created),
Created: qfResp.Created,
Model: "", // 假定使用的模型
SystemFingerprint: "", // 假定一个系统指纹
Usage: &myopenai.Usage{
Expand Down Expand Up @@ -180,16 +181,15 @@ func QianFanResponseToOpenAIResponse(qfResp *baiduqianfan.QianFanResponse) *myop
// 将 Choice 添加到 Choices 数组
oaResp.Choices = append(oaResp.Choices, choice)

log.Println(oaResp)
mylog.Logger.Info("resp", zap.Any("oaResp", oaResp))

return &oaResp
}

func QianFanResponseToOpenAIStreamResponse(qfResp *baiduqianfan.QianFanResponse) *myopenai.OpenAIStreamResponse {
// 创建一个 OpenAIResponse 实例
if qfResp.ErrorCode != 0 && len(qfResp.ErrorMsg) > 0 {

log.Println("something error")
mylog.Logger.Error("something error")
return &myopenai.OpenAIStreamResponse{
//ID: qfResp.ID,
Error: &myopenai.ErrorDetail{
Expand Down Expand Up @@ -236,7 +236,7 @@ func QianFanResponseToOpenAIStreamResponse(qfResp *baiduqianfan.QianFanResponse)

oaResp.Choices = append(oaResp.Choices, choice)

log.Println(oaResp)
mylog.Logger.Info("resp", zap.Any("resp", oaResp))

return &oaResp
}
5 changes: 3 additions & 2 deletions pkg/adapter/xinghuo_openai.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/fruitbars/gosparkclient"
"github.com/sashabaranov/go-openai"
"log"
"simple-one-api/pkg/mylog"
myopenai "simple-one-api/pkg/openai"
"time"
)
Expand Down Expand Up @@ -58,9 +59,9 @@ func OpenAIRequestToXingHuoRequest(openAIReq openai.ChatCompletionRequest) *gosp
}

case map[string]interface{}:
log.Println("ToolChoice is an object, ignore")
mylog.Logger.Warn("ToolChoice is an object, ignore")
default:
log.Println("Unhandled type, ignore")
mylog.Logger.Warn("Unhandled type, ignore")
}

return &sparkChatReq
Expand Down

0 comments on commit 7e33eaa

Please sign in to comment.