mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-11-12 11:23:42 +08:00
refactor: add GetRatio to Adaptor
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/songquanpeng/one-api/relay/adaptor"
|
||||
"github.com/songquanpeng/one-api/relay/billing/ratio"
|
||||
"github.com/songquanpeng/one-api/relay/meta"
|
||||
"github.com/songquanpeng/one-api/relay/model"
|
||||
)
|
||||
@@ -55,8 +56,12 @@ func (a *Adaptor) DoResponse(c *gin.Context, resp *http.Response, meta *meta.Met
|
||||
return
|
||||
}
|
||||
|
||||
func (a *Adaptor) GetRatio(meta *meta.Meta) *ratio.Ratio {
|
||||
return adaptor.GetRatioHelper(meta, RatioMap)
|
||||
}
|
||||
|
||||
func (a *Adaptor) GetModelList() []string {
|
||||
return ModelList
|
||||
return adaptor.GetModelListHelper(RatioMap)
|
||||
}
|
||||
|
||||
func (a *Adaptor) GetChannelName() string {
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
package cohere
|
||||
|
||||
var ModelList = []string{
|
||||
"command", "command-nightly",
|
||||
"command-light", "command-light-nightly",
|
||||
"command-r", "command-r-plus",
|
||||
}
|
||||
import "github.com/songquanpeng/one-api/relay/billing/ratio"
|
||||
|
||||
func init() {
|
||||
num := len(ModelList)
|
||||
for i := 0; i < num; i++ {
|
||||
ModelList = append(ModelList, ModelList[i]+"-internet")
|
||||
}
|
||||
// https://cohere.com/pricing
|
||||
var RatioMap = map[string]ratio.Ratio{
|
||||
"command": {Input: 1 * ratio.MILLI_USD, Output: 2 * ratio.MILLI_USD},
|
||||
"command-internet": {Input: 1 * ratio.MILLI_USD, Output: 2 * ratio.MILLI_USD},
|
||||
"command-nightly": {Input: 1 * ratio.MILLI_USD, Output: 2 * ratio.MILLI_USD},
|
||||
"command-nightly-internet": {Input: 1 * ratio.MILLI_USD, Output: 2 * ratio.MILLI_USD},
|
||||
"command-light": {Input: 0.3 * ratio.MILLI_USD, Output: 0.6 * ratio.MILLI_USD},
|
||||
"command-light-internet": {Input: 0.3 * ratio.MILLI_USD, Output: 0.6 * ratio.MILLI_USD},
|
||||
"command-light-nightly": {Input: 0.3 * ratio.MILLI_USD, Output: 0.6 * ratio.MILLI_USD},
|
||||
"command-light-nightly-internet": {Input: 0.3 * ratio.MILLI_USD, Output: 0.6 * ratio.MILLI_USD},
|
||||
"command-r": {Input: 0.15 * ratio.MILLI_USD, Output: 0.6 * ratio.MILLI_USD},
|
||||
"command-r-internet": {Input: 0.15 * ratio.MILLI_USD, Output: 0.6 * ratio.MILLI_USD},
|
||||
"command-r-plus": {Input: 2.5 * ratio.MILLI_USD, Output: 10 * ratio.MILLI_USD},
|
||||
"command-r-plus-internet": {Input: 2.5 * ratio.MILLI_USD, Output: 10 * ratio.MILLI_USD},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user