chore: change variable name & package

This commit is contained in:
JustSong
2024-04-19 23:49:21 +08:00
parent a225850a6e
commit 9944dd5c39
6 changed files with 28 additions and 28 deletions

View File

@@ -3,8 +3,8 @@ package middleware
import (
"fmt"
"github.com/gin-gonic/gin"
"github.com/songquanpeng/one-api/common"
"github.com/songquanpeng/one-api/common/config"
"github.com/songquanpeng/one-api/common/ctxkey"
"github.com/songquanpeng/one-api/common/logger"
"github.com/songquanpeng/one-api/model"
"github.com/songquanpeng/one-api/relay/channeltype"
@@ -59,12 +59,12 @@ func Distribute() func(c *gin.Context) {
}
func SetupContextForSelectedChannel(c *gin.Context, channel *model.Channel, modelName string) {
c.Set(common.CtxKeyChannel, channel)
c.Set(ctxkey.Channel, channel)
c.Set("channel", channel.Type)
c.Set("channel_id", channel.Id)
c.Set("channel_name", channel.Name)
c.Set("model_mapping", channel.GetModelMapping())
c.Set(common.CtxKeyOriginModel, modelName) // for retry
c.Set(ctxkey.OriginModel, modelName) // for retry
c.Request.Header.Set("Authorization", fmt.Sprintf("Bearer %s", channel.Key))
c.Set("base_url", channel.GetBaseURL())
// this is for backward compatibility