mirror of
https://github.com/songquanpeng/one-api.git
synced 2026-03-03 10:14:25 +08:00
feat: add PPIO as model provider
This commit is contained in:
@@ -3,6 +3,7 @@ package openai
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/songquanpeng/one-api/relay/adaptor/ppio"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -59,6 +60,8 @@ func (a *Adaptor) GetRequestURL(meta *meta.Meta) (string, error) {
|
|||||||
return baiduv2.GetRequestURL(meta)
|
return baiduv2.GetRequestURL(meta)
|
||||||
case channeltype.AliBailian:
|
case channeltype.AliBailian:
|
||||||
return alibailian.GetRequestURL(meta)
|
return alibailian.GetRequestURL(meta)
|
||||||
|
case channeltype.PPIO:
|
||||||
|
return ppio.GetRequestURL(meta)
|
||||||
default:
|
default:
|
||||||
return GetFullRequestURL(meta.BaseURL, meta.RequestURLPath, meta.ChannelType), nil
|
return GetFullRequestURL(meta.BaseURL, meta.RequestURLPath, meta.ChannelType), nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import (
|
|||||||
"github.com/songquanpeng/one-api/relay/adaptor/moonshot"
|
"github.com/songquanpeng/one-api/relay/adaptor/moonshot"
|
||||||
"github.com/songquanpeng/one-api/relay/adaptor/novita"
|
"github.com/songquanpeng/one-api/relay/adaptor/novita"
|
||||||
"github.com/songquanpeng/one-api/relay/adaptor/openrouter"
|
"github.com/songquanpeng/one-api/relay/adaptor/openrouter"
|
||||||
|
"github.com/songquanpeng/one-api/relay/adaptor/ppio"
|
||||||
"github.com/songquanpeng/one-api/relay/adaptor/siliconflow"
|
"github.com/songquanpeng/one-api/relay/adaptor/siliconflow"
|
||||||
"github.com/songquanpeng/one-api/relay/adaptor/stepfun"
|
"github.com/songquanpeng/one-api/relay/adaptor/stepfun"
|
||||||
"github.com/songquanpeng/one-api/relay/adaptor/togetherai"
|
"github.com/songquanpeng/one-api/relay/adaptor/togetherai"
|
||||||
@@ -40,6 +41,7 @@ var CompatibleChannels = []int{
|
|||||||
channeltype.XAI,
|
channeltype.XAI,
|
||||||
channeltype.BaiduV2,
|
channeltype.BaiduV2,
|
||||||
channeltype.XunfeiV2,
|
channeltype.XunfeiV2,
|
||||||
|
channeltype.PPIO,
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetCompatibleChannelMeta(channelType int) (string, []string) {
|
func GetCompatibleChannelMeta(channelType int) (string, []string) {
|
||||||
@@ -82,6 +84,8 @@ func GetCompatibleChannelMeta(channelType int) (string, []string) {
|
|||||||
return "openrouter", openrouter.ModelList
|
return "openrouter", openrouter.ModelList
|
||||||
case channeltype.AliBailian:
|
case channeltype.AliBailian:
|
||||||
return "alibailian", alibailian.ModelList
|
return "alibailian", alibailian.ModelList
|
||||||
|
case channeltype.PPIO:
|
||||||
|
return "ppio", ppio.ModelList
|
||||||
default:
|
default:
|
||||||
return "openai", ModelList
|
return "openai", ModelList
|
||||||
}
|
}
|
||||||
|
|||||||
25
relay/adaptor/ppio/constants.go
Normal file
25
relay/adaptor/ppio/constants.go
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
package ppio
|
||||||
|
|
||||||
|
// https://api.ppinfra.com/v3/openai/v1/models
|
||||||
|
|
||||||
|
var ModelList = []string{
|
||||||
|
"deepseek/deepseek-r1/community",
|
||||||
|
"deepseek/deepseek-v3/community",
|
||||||
|
"deepseek/deepseek-r1",
|
||||||
|
"deepseek/deepseek-v3",
|
||||||
|
"deepseek/deepseek-r1-distill-llama-70b",
|
||||||
|
"deepseek/deepseek-r1-distill-qwen-32b",
|
||||||
|
"deepseek/deepseek-r1-distill-qwen-14b",
|
||||||
|
"deepseek/deepseek-r1-distill-llama-8b",
|
||||||
|
"qwen/qwen-2.5-72b-instruct",
|
||||||
|
"qwen/qwen-2-vl-72b-instruct",
|
||||||
|
"meta-llama/llama-3.2-3b-instruct",
|
||||||
|
"qwen/qwen2.5-32b-instruct",
|
||||||
|
"baichuan/baichuan2-13b-chat",
|
||||||
|
"meta-llama/llama-3.1-70b-instruct",
|
||||||
|
"meta-llama/llama-3.1-8b-instruct",
|
||||||
|
"01-ai/yi-1.5-34b-chat",
|
||||||
|
"01-ai/yi-1.5-9b-chat",
|
||||||
|
"thudm/glm-4-9b-chat",
|
||||||
|
"qwen/qwen-2-7b-instruct",
|
||||||
|
}
|
||||||
15
relay/adaptor/ppio/main.go
Normal file
15
relay/adaptor/ppio/main.go
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package ppio
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/songquanpeng/one-api/relay/meta"
|
||||||
|
"github.com/songquanpeng/one-api/relay/relaymode"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetRequestURL(meta *meta.Meta) (string, error) {
|
||||||
|
if meta.Mode == relaymode.ChatCompletions {
|
||||||
|
return fmt.Sprintf("%s/chat/completions", meta.BaseURL), nil
|
||||||
|
}
|
||||||
|
return "", fmt.Errorf("unsupported relay mode %d for ppio", meta.Mode)
|
||||||
|
}
|
||||||
@@ -51,5 +51,6 @@ const (
|
|||||||
BaiduV2
|
BaiduV2
|
||||||
XunfeiV2
|
XunfeiV2
|
||||||
AliBailian
|
AliBailian
|
||||||
|
PPIO
|
||||||
Dummy
|
Dummy
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ var ChannelBaseURLs = []string{
|
|||||||
"https://qianfan.baidubce.com", // 47
|
"https://qianfan.baidubce.com", // 47
|
||||||
"https://spark-api-open.xf-yun.com", // 48
|
"https://spark-api-open.xf-yun.com", // 48
|
||||||
"https://dashscope.aliyuncs.com", // 49
|
"https://dashscope.aliyuncs.com", // 49
|
||||||
|
"https://api.ppinfra.com/v3/openai", // 50
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ export const CHANNEL_OPTIONS = {
|
|||||||
value: 45,
|
value: 45,
|
||||||
color: 'primary'
|
color: 'primary'
|
||||||
},
|
},
|
||||||
45: {
|
46: {
|
||||||
key: 46,
|
key: 46,
|
||||||
text: 'Replicate',
|
text: 'Replicate',
|
||||||
value: 46,
|
value: 46,
|
||||||
@@ -197,6 +197,12 @@ export const CHANNEL_OPTIONS = {
|
|||||||
value: 41,
|
value: 41,
|
||||||
color: 'purple'
|
color: 'purple'
|
||||||
},
|
},
|
||||||
|
50: {
|
||||||
|
key: 50,
|
||||||
|
text: 'PPIO',
|
||||||
|
value: 50,
|
||||||
|
color: '#2874ff',
|
||||||
|
},
|
||||||
8: {
|
8: {
|
||||||
key: 8,
|
key: 8,
|
||||||
text: '自定义渠道',
|
text: '自定义渠道',
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ export const CHANNEL_OPTIONS = [
|
|||||||
{key: 24, text: 'Google Gemini', value: 24, color: 'orange'},
|
{key: 24, text: 'Google Gemini', value: 24, color: 'orange'},
|
||||||
{key: 28, text: 'Mistral AI', value: 28, color: 'orange'},
|
{key: 28, text: 'Mistral AI', value: 28, color: 'orange'},
|
||||||
{key: 41, text: 'Novita', value: 41, color: 'purple'},
|
{key: 41, text: 'Novita', value: 41, color: 'purple'},
|
||||||
|
{key: 50, text: 'PPIO', value: 50, color: '#2874ff'},
|
||||||
{
|
{
|
||||||
key: 40,
|
key: 40,
|
||||||
text: '字节火山引擎',
|
text: '字节火山引擎',
|
||||||
|
|||||||
Reference in New Issue
Block a user