mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-11-10 10:33:41 +08:00
Merge remote-tracking branch 'origin/upstream/main'
This commit is contained in:
@@ -1,22 +1,76 @@
|
||||
package tencent
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/songquanpeng/one-api/relay/channel/openai"
|
||||
"net/http"
|
||||
)
|
||||
// import (
|
||||
// "errors"
|
||||
// "fmt"
|
||||
// "github.com/gin-gonic/gin"
|
||||
// "github.com/songquanpeng/one-api/relay/channel"
|
||||
// "github.com/songquanpeng/one-api/relay/channel/openai"
|
||||
// "github.com/songquanpeng/one-api/relay/model"
|
||||
// "github.com/songquanpeng/one-api/relay/util"
|
||||
// "io"
|
||||
// "net/http"
|
||||
// "strings"
|
||||
// )
|
||||
|
||||
type Adaptor struct {
|
||||
}
|
||||
// // https://cloud.tencent.com/document/api/1729/101837
|
||||
|
||||
func (a *Adaptor) Auth(c *gin.Context) error {
|
||||
return nil
|
||||
}
|
||||
// type Adaptor struct {
|
||||
// Sign string
|
||||
// }
|
||||
|
||||
func (a *Adaptor) ConvertRequest(request *openai.GeneralOpenAIRequest) (any, error) {
|
||||
return nil, nil
|
||||
}
|
||||
// func (a *Adaptor) Init(meta *util.RelayMeta) {
|
||||
|
||||
func (a *Adaptor) DoResponse(c *gin.Context, resp *http.Response) (*openai.ErrorWithStatusCode, *openai.Usage, error) {
|
||||
return nil, nil, nil
|
||||
}
|
||||
// }
|
||||
|
||||
// func (a *Adaptor) GetRequestURL(meta *util.RelayMeta) (string, error) {
|
||||
// return fmt.Sprintf("%s/hyllm/v1/chat/completions", meta.BaseURL), nil
|
||||
// }
|
||||
|
||||
// func (a *Adaptor) SetupRequestHeader(c *gin.Context, req *http.Request, meta *util.RelayMeta) error {
|
||||
// channel.SetupCommonRequestHeader(c, req, meta)
|
||||
// req.Header.Set("Authorization", a.Sign)
|
||||
// req.Header.Set("X-TC-Action", meta.ActualModelName)
|
||||
// return nil
|
||||
// }
|
||||
|
||||
// func (a *Adaptor) ConvertRequest(c *gin.Context, relayMode int, request *model.GeneralOpenAIRequest) (any, error) {
|
||||
// if request == nil {
|
||||
// return nil, errors.New("request is nil")
|
||||
// }
|
||||
// apiKey := c.Request.Header.Get("Authorization")
|
||||
// apiKey = strings.TrimPrefix(apiKey, "Bearer ")
|
||||
// appId, secretId, secretKey, err := ParseConfig(apiKey)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
// tencentRequest := ConvertRequest(*request)
|
||||
// tencentRequest.AppId = appId
|
||||
// tencentRequest.SecretId = secretId
|
||||
// // we have to calculate the sign here
|
||||
// a.Sign = GetSign(*tencentRequest, secretKey)
|
||||
// return tencentRequest, nil
|
||||
// }
|
||||
|
||||
// func (a *Adaptor) DoRequest(c *gin.Context, meta *util.RelayMeta, requestBody io.Reader) (*http.Response, error) {
|
||||
// return channel.DoRequestHelper(a, c, meta, requestBody)
|
||||
// }
|
||||
|
||||
// func (a *Adaptor) DoResponse(c *gin.Context, resp *http.Response, meta *util.RelayMeta) (usage *model.Usage, err *model.ErrorWithStatusCode) {
|
||||
// if meta.IsStream {
|
||||
// var responseText string
|
||||
// err, responseText = StreamHandler(c, resp)
|
||||
// usage = openai.ResponseText2Usage(responseText, meta.ActualModelName, meta.PromptTokens)
|
||||
// } else {
|
||||
// err, usage = Handler(c, resp)
|
||||
// }
|
||||
// return
|
||||
// }
|
||||
|
||||
// func (a *Adaptor) GetModelList() []string {
|
||||
// return ModelList
|
||||
// }
|
||||
|
||||
// func (a *Adaptor) GetChannelName() string {
|
||||
// return "tencent"
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user