Compare commits

..

4 Commits

Author SHA1 Message Date
JustSong
6916debf66 feat: update TestPrompt to specify output format for model name 2025-02-12 00:28:23 +08:00
JustSong
53da209134 feat: add AliBailian adaptor and update channel options 2025-02-12 00:15:43 +08:00
JustSong
517f6ad211 feat: update date range to display at least 7 days of data in Dashboard
Some checks are pending
CI / Unit tests (push) Waiting to run
CI / commit_lint (push) Waiting to run
2025-02-11 01:48:26 +08:00
JustSong
10aba11f18 style: improve code formatting in ChannelsTable component 2025-02-11 00:38:15 +08:00
10 changed files with 113 additions and 59 deletions

View File

@@ -163,4 +163,4 @@ var UserContentRequestProxy = env.String("USER_CONTENT_REQUEST_PROXY", "")
var UserContentRequestTimeout = env.Int("USER_CONTENT_REQUEST_TIMEOUT", 30)
var EnforceIncludeUsage = env.Bool("ENFORCE_INCLUDE_USAGE", false)
var TestPrompt = env.String("TEST_PROMPT", "Print your model name exactly and do not output without any other text.")
var TestPrompt = env.String("TEST_PROMPT", "Output only your specific model name with no additional text.")

View File

@@ -0,0 +1,20 @@
package alibailian
// https://help.aliyun.com/zh/model-studio/getting-started/models
var ModelList = []string{
"qwen-turbo",
"qwen-plus",
"qwen-long",
"qwen-max",
"qwen-coder-plus",
"qwen-coder-plus-latest",
"qwen-coder-turbo",
"qwen-coder-turbo-latest",
"qwen-mt-plus",
"qwen-mt-turbo",
"qwq-32b-preview",
"deepseek-r1",
"deepseek-v3",
}

View File

@@ -0,0 +1,19 @@
package alibailian
import (
"fmt"
"github.com/songquanpeng/one-api/relay/meta"
"github.com/songquanpeng/one-api/relay/relaymode"
)
func GetRequestURL(meta *meta.Meta) (string, error) {
switch meta.Mode {
case relaymode.ChatCompletions:
return fmt.Sprintf("%s/compatible-mode/v1/chat/completions", meta.BaseURL), nil
case relaymode.Embeddings:
return fmt.Sprintf("%s/compatible-mode/v1/embeddings", meta.BaseURL), nil
default:
}
return "", fmt.Errorf("unsupported relay mode %d for ali bailian", meta.Mode)
}

View File

@@ -10,6 +10,7 @@ import (
"github.com/gin-gonic/gin"
"github.com/songquanpeng/one-api/relay/adaptor"
"github.com/songquanpeng/one-api/relay/adaptor/alibailian"
"github.com/songquanpeng/one-api/relay/adaptor/baiduv2"
"github.com/songquanpeng/one-api/relay/adaptor/doubao"
"github.com/songquanpeng/one-api/relay/adaptor/minimax"
@@ -56,6 +57,8 @@ func (a *Adaptor) GetRequestURL(meta *meta.Meta) (string, error) {
return novita.GetRequestURL(meta)
case channeltype.BaiduV2:
return baiduv2.GetRequestURL(meta)
case channeltype.AliBailian:
return alibailian.GetRequestURL(meta)
default:
return GetFullRequestURL(meta.BaseURL, meta.RequestURLPath, meta.ChannelType), nil
}

View File

@@ -2,6 +2,7 @@ package openai
import (
"github.com/songquanpeng/one-api/relay/adaptor/ai360"
"github.com/songquanpeng/one-api/relay/adaptor/alibailian"
"github.com/songquanpeng/one-api/relay/adaptor/baichuan"
"github.com/songquanpeng/one-api/relay/adaptor/baiduv2"
"github.com/songquanpeng/one-api/relay/adaptor/deepseek"
@@ -79,6 +80,8 @@ func GetCompatibleChannelMeta(channelType int) (string, []string) {
return "xunfeiv2", xunfeiv2.ModelList
case channeltype.OpenRouter:
return "openrouter", openrouter.ModelList
case channeltype.AliBailian:
return "alibailian", alibailian.ModelList
default:
return "openai", ModelList
}

View File

@@ -50,5 +50,6 @@ const (
Replicate
BaiduV2
XunfeiV2
AliBailian
Dummy
)

View File

@@ -50,6 +50,7 @@ var ChannelBaseURLs = []string{
"https://api.replicate.com/v1/models/", // 46
"https://qianfan.baidubce.com", // 47
"https://spark-api-open.xf-yun.com", // 48
"https://dashscope.aliyuncs.com", // 49
}
func init() {

View File

@@ -490,7 +490,6 @@ const ChannelsTable = () => {
onClick={() => {
sortChannel('balance');
}}
hidden={!showDetail}
>
{t('channel.table.balance')}
</Table.HeaderCell>
@@ -499,6 +498,7 @@ const ChannelsTable = () => {
onClick={() => {
sortChannel('priority');
}}
hidden={!showDetail}
>
{t('channel.table.priority')}
</Table.HeaderCell>
@@ -538,7 +538,7 @@ const ChannelsTable = () => {
basic
/>
</Table.Cell>
<Table.Cell hidden={!showDetail}>
<Table.Cell>
<Popup
trigger={
<span
@@ -554,7 +554,7 @@ const ChannelsTable = () => {
basic
/>
</Table.Cell>
<Table.Cell>
<Table.Cell hidden={!showDetail}>
<Popup
trigger={
<Input

View File

@@ -28,7 +28,14 @@ export const CHANNEL_OPTIONS = [
color: 'blue',
tip: '请前往<a href="https://console.bce.baidu.com/iam/#/iam/apikey/list" target="_blank">此处</a>获取 API Key注意本渠道仅支持<a target="_blank" href="https://cloud.baidu.com/doc/WENXINWORKSHOP/s/em4tsqo3v">推理服务 V2</a>相关模型',
},
{key: 17, text: '阿里通义千问', value: 17, color: 'orange'},
{
key: 17,
text: '阿里通义千问',
value: 17,
color: 'orange',
tip: '如需使用阿里云百炼,请使用<strong>阿里云百炼</strong>渠道',
},
{key: 49, text: '阿里云百炼', value: 49, color: 'orange'},
{
key: 18,
text: '讯飞星火认知',

View File

@@ -122,11 +122,11 @@ const Dashboard = () => {
? new Date(Math.min(...dates.map((d) => new Date(d))))
: new Date();
// 确保至少显示5天的数据
const fiveDaysAgo = new Date();
fiveDaysAgo.setDate(fiveDaysAgo.getDate() - 4); // -4是因为包含今天
if (minDate > fiveDaysAgo) {
minDate = fiveDaysAgo;
// 确保至少显示7天的数据
const sevenDaysAgo = new Date();
sevenDaysAgo.setDate(sevenDaysAgo.getDate() - 6); // -6是因为包含今天
if (minDate > sevenDaysAgo) {
minDate = sevenDaysAgo;
}
// 生成所有日期
@@ -164,11 +164,11 @@ const Dashboard = () => {
? new Date(Math.min(...dates.map((d) => new Date(d))))
: new Date();
// 确保至少显示5天的数据
const fiveDaysAgo = new Date();
fiveDaysAgo.setDate(fiveDaysAgo.getDate() - 4); // -4是因为包含今天
if (minDate > fiveDaysAgo) {
minDate = fiveDaysAgo;
// 确保至少显示7天的数据
const sevenDaysAgo = new Date();
sevenDaysAgo.setDate(sevenDaysAgo.getDate() - 6); // -6是因为包含今天
if (minDate > sevenDaysAgo) {
minDate = sevenDaysAgo;
}
// 生成所有日期