Compare commits

..

6 Commits

Author SHA1 Message Date
JustSong
b169173860 fix: force set Accept header for ali stream request (close #1151) 2024-03-14 23:20:38 +08:00
JustSong
f33555ae78 fix: update max token for test (close #1154) 2024-03-14 23:17:19 +08:00
JustSong
c28ec10795 fix: fix cors for dashboard api 2024-03-14 23:14:39 +08:00
JustSong
e3767cbb07 fix: fix haiku model name (close #1149) 2024-03-14 23:13:05 +08:00
JustSong
be9eb59fbb feat: support lingyiwanwu 2024-03-14 23:11:36 +08:00
JustSong
89e111ac69 ci: fix ci condition 2024-03-14 01:17:19 +08:00
18 changed files with 43 additions and 3 deletions

View File

@@ -4,6 +4,7 @@ on:
push: push:
tags: tags:
- '*' - '*'
- '!*-pro*'
workflow_dispatch: workflow_dispatch:
inputs: inputs:
name: name:

View File

@@ -4,6 +4,7 @@ on:
push: push:
tags: tags:
- '*' - '*'
- '!*-pro*'
workflow_dispatch: workflow_dispatch:
inputs: inputs:
name: name:

View File

@@ -5,6 +5,7 @@ on:
tags: tags:
- '*' - '*'
- '!*-alpha*' - '!*-alpha*'
- '!*-pro*'
workflow_dispatch: workflow_dispatch:
inputs: inputs:
name: name:

View File

@@ -7,6 +7,7 @@ on:
tags: tags:
- '*' - '*'
- '!*-alpha*' - '!*-alpha*'
- '!*-pro*'
workflow_dispatch: workflow_dispatch:
inputs: inputs:
name: name:

View File

@@ -7,6 +7,7 @@ on:
tags: tags:
- '*' - '*'
- '!*-alpha*' - '!*-alpha*'
- '!*-pro*'
workflow_dispatch: workflow_dispatch:
inputs: inputs:
name: name:

View File

@@ -7,6 +7,7 @@ on:
tags: tags:
- '*' - '*'
- '!*-alpha*' - '!*-alpha*'
- '!*-pro*'
workflow_dispatch: workflow_dispatch:
inputs: inputs:
name: name:

View File

@@ -80,6 +80,7 @@ _✨ 通过标准的 OpenAI API 格式访问所有的大模型,开箱即用
+ [x] [MINIMAX](https://api.minimax.chat/) + [x] [MINIMAX](https://api.minimax.chat/)
+ [x] [Groq](https://wow.groq.com/) + [x] [Groq](https://wow.groq.com/)
+ [x] [Ollama](https://github.com/ollama/ollama) + [x] [Ollama](https://github.com/ollama/ollama)
+ [x] [零一万物](https://platform.lingyiwanwu.com/)
2. 支持配置镜像以及众多[第三方代理服务](https://iamazing.cn/page/openai-api-third-party-services)。 2. 支持配置镜像以及众多[第三方代理服务](https://iamazing.cn/page/openai-api-third-party-services)。
3. 支持通过**负载均衡**的方式访问多个渠道。 3. 支持通过**负载均衡**的方式访问多个渠道。
4. 支持 **stream 模式**,可以通过流式传输实现打字机效果。 4. 支持 **stream 模式**,可以通过流式传输实现打字机效果。

View File

@@ -70,6 +70,7 @@ const (
ChannelTypeMistral ChannelTypeMistral
ChannelTypeGroq ChannelTypeGroq
ChannelTypeOllama ChannelTypeOllama
ChannelTypeLingYiWanWu
ChannelTypeDummy ChannelTypeDummy
) )
@@ -106,6 +107,7 @@ var ChannelBaseURLs = []string{
"https://api.mistral.ai", // 28 "https://api.mistral.ai", // 28
"https://api.groq.com/openai", // 29 "https://api.groq.com/openai", // 29
"http://localhost:11434", // 30 "http://localhost:11434", // 30
"https://api.lingyiwanwu.com", // 31
} }
const ( const (

View File

@@ -69,7 +69,7 @@ var ModelRatio = map[string]float64{
"claude-instant-1.2": 0.8 / 1000 * USD, "claude-instant-1.2": 0.8 / 1000 * USD,
"claude-2.0": 8.0 / 1000 * USD, "claude-2.0": 8.0 / 1000 * USD,
"claude-2.1": 8.0 / 1000 * USD, "claude-2.1": 8.0 / 1000 * USD,
"claude-3-haiku-20240229": 0.25 / 1000 * USD, "claude-3-haiku-20240307": 0.25 / 1000 * USD,
"claude-3-sonnet-20240229": 3.0 / 1000 * USD, "claude-3-sonnet-20240229": 3.0 / 1000 * USD,
"claude-3-opus-20240229": 15.0 / 1000 * USD, "claude-3-opus-20240229": 15.0 / 1000 * USD,
// https://cloud.baidu.com/doc/WENXINWORKSHOP/s/hlrk4akp7 // https://cloud.baidu.com/doc/WENXINWORKSHOP/s/hlrk4akp7
@@ -130,6 +130,10 @@ var ModelRatio = map[string]float64{
"llama2-7b-2048": 0.1 / 1000 * USD, "llama2-7b-2048": 0.1 / 1000 * USD,
"mixtral-8x7b-32768": 0.27 / 1000 * USD, "mixtral-8x7b-32768": 0.27 / 1000 * USD,
"gemma-7b-it": 0.1 / 1000 * USD, "gemma-7b-it": 0.1 / 1000 * USD,
// https://platform.lingyiwanwu.com/docs#-计费单元
"yi-34b-chat-0205": 2.5 / 1000000 * RMB,
"yi-34b-chat-200k": 12.0 / 1000000 * RMB,
"yi-vl-plus": 6.0 / 1000000 * RMB,
} }
var CompletionRatio = map[string]float64{} var CompletionRatio = map[string]float64{}

View File

@@ -30,7 +30,7 @@ import (
func buildTestRequest() *relaymodel.GeneralOpenAIRequest { func buildTestRequest() *relaymodel.GeneralOpenAIRequest {
testRequest := &relaymodel.GeneralOpenAIRequest{ testRequest := &relaymodel.GeneralOpenAIRequest{
MaxTokens: 1, MaxTokens: 2,
Stream: false, Stream: false,
Model: "gpt-3.5-turbo", Model: "gpt-3.5-turbo",
} }

View File

@@ -32,6 +32,9 @@ func (a *Adaptor) GetRequestURL(meta *util.RelayMeta) (string, error) {
func (a *Adaptor) SetupRequestHeader(c *gin.Context, req *http.Request, meta *util.RelayMeta) error { func (a *Adaptor) SetupRequestHeader(c *gin.Context, req *http.Request, meta *util.RelayMeta) error {
channel.SetupCommonRequestHeader(c, req, meta) channel.SetupCommonRequestHeader(c, req, meta)
if meta.IsStream {
req.Header.Set("Accept", "text/event-stream")
}
req.Header.Set("Authorization", "Bearer "+meta.APIKey) req.Header.Set("Authorization", "Bearer "+meta.APIKey)
if meta.IsStream { if meta.IsStream {
req.Header.Set("X-DashScope-SSE", "enable") req.Header.Set("X-DashScope-SSE", "enable")

View File

@@ -2,7 +2,7 @@ package anthropic
var ModelList = []string{ var ModelList = []string{
"claude-instant-1.2", "claude-2.0", "claude-2.1", "claude-instant-1.2", "claude-2.0", "claude-2.1",
"claude-3-haiku-20240229", "claude-3-haiku-20240307",
"claude-3-sonnet-20240229", "claude-3-sonnet-20240229",
"claude-3-opus-20240229", "claude-3-opus-20240229",
} }

View File

@@ -0,0 +1,9 @@
package lingyiwanwu
// https://platform.lingyiwanwu.com/docs
var ModelList = []string{
"yi-34b-chat-0205",
"yi-34b-chat-200k",
"yi-vl-plus",
}

View File

@@ -5,6 +5,7 @@ import (
"github.com/songquanpeng/one-api/relay/channel/ai360" "github.com/songquanpeng/one-api/relay/channel/ai360"
"github.com/songquanpeng/one-api/relay/channel/baichuan" "github.com/songquanpeng/one-api/relay/channel/baichuan"
"github.com/songquanpeng/one-api/relay/channel/groq" "github.com/songquanpeng/one-api/relay/channel/groq"
"github.com/songquanpeng/one-api/relay/channel/lingyiwanwu"
"github.com/songquanpeng/one-api/relay/channel/minimax" "github.com/songquanpeng/one-api/relay/channel/minimax"
"github.com/songquanpeng/one-api/relay/channel/mistral" "github.com/songquanpeng/one-api/relay/channel/mistral"
"github.com/songquanpeng/one-api/relay/channel/moonshot" "github.com/songquanpeng/one-api/relay/channel/moonshot"
@@ -18,6 +19,7 @@ var CompatibleChannels = []int{
common.ChannelTypeMinimax, common.ChannelTypeMinimax,
common.ChannelTypeMistral, common.ChannelTypeMistral,
common.ChannelTypeGroq, common.ChannelTypeGroq,
common.ChannelTypeLingYiWanWu,
} }
func GetCompatibleChannelMeta(channelType int) (string, []string) { func GetCompatibleChannelMeta(channelType int) (string, []string) {
@@ -36,6 +38,8 @@ func GetCompatibleChannelMeta(channelType int) (string, []string) {
return "mistralai", mistral.ModelList return "mistralai", mistral.ModelList
case common.ChannelTypeGroq: case common.ChannelTypeGroq:
return "groq", groq.ModelList return "groq", groq.ModelList
case common.ChannelTypeLingYiWanWu:
return "lingyiwanwu", lingyiwanwu.ModelList
default: default:
return "openai", ModelList return "openai", ModelList
} }

View File

@@ -9,6 +9,7 @@ import (
func SetDashboardRouter(router *gin.Engine) { func SetDashboardRouter(router *gin.Engine) {
apiRouter := router.Group("/") apiRouter := router.Group("/")
apiRouter.Use(middleware.CORS())
apiRouter.Use(gzip.Gzip(gzip.DefaultCompression)) apiRouter.Use(gzip.Gzip(gzip.DefaultCompression))
apiRouter.Use(middleware.GlobalAPIRateLimit()) apiRouter.Use(middleware.GlobalAPIRateLimit())
apiRouter.Use(middleware.TokenAuth()) apiRouter.Use(middleware.TokenAuth())

View File

@@ -101,6 +101,12 @@ export const CHANNEL_OPTIONS = {
value: 30, value: 30,
color: 'default' color: 'default'
}, },
31: {
key: 31,
text: '零一万物',
value: 31,
color: 'default'
},
8: { 8: {
key: 8, key: 8,
text: '自定义渠道', text: '自定义渠道',

View File

@@ -169,6 +169,9 @@ const typeConfig = {
30: { 30: {
modelGroup: "ollama", modelGroup: "ollama",
}, },
31: {
modelGroup: "lingyiwanwu",
},
}; };
export { defaultConfig, typeConfig }; export { defaultConfig, typeConfig };

View File

@@ -16,6 +16,7 @@ export const CHANNEL_OPTIONS = [
{ key: 27, text: 'MiniMax', value: 27, color: 'red' }, { key: 27, text: 'MiniMax', value: 27, color: 'red' },
{ key: 29, text: 'Groq', value: 29, color: 'orange' }, { key: 29, text: 'Groq', value: 29, color: 'orange' },
{ key: 30, text: 'Ollama', value: 30, color: 'black' }, { key: 30, text: 'Ollama', value: 30, color: 'black' },
{ key: 31, text: '零一万物', value: 31, color: 'green' },
{ key: 8, text: '自定义渠道', value: 8, color: 'pink' }, { key: 8, text: '自定义渠道', value: 8, color: 'pink' },
{ key: 22, text: '知识库FastGPT', value: 22, color: 'blue' }, { key: 22, text: '知识库FastGPT', value: 22, color: 'blue' },
{ key: 21, text: '知识库AI Proxy', value: 21, color: 'purple' }, { key: 21, text: '知识库AI Proxy', value: 21, color: 'purple' },