feat: add Novita AI as model provider (#1609)
This commit is contained in:
parent
6a941748f8
commit
e090e76c86
@ -88,6 +88,7 @@ _✨ 通过标准的 OpenAI API 格式访问所有的大模型,开箱即用
|
||||
+ [x] [Cloudflare Workers AI](https://developers.cloudflare.com/workers-ai/)
|
||||
+ [x] [DeepL](https://www.deepl.com/)
|
||||
+ [x] [together.ai](https://www.together.ai/)
|
||||
+ [x] [novita.ai](https://www.novita.ai/)
|
||||
2. 支持配置镜像以及众多[第三方代理服务](https://iamazing.cn/page/openai-api-third-party-services)。
|
||||
3. 支持通过**负载均衡**的方式访问多个渠道。
|
||||
4. 支持 **stream 模式**,可以通过流式传输实现打字机效果。
|
||||
|
19
relay/adaptor/novita/constants.go
Normal file
19
relay/adaptor/novita/constants.go
Normal file
@ -0,0 +1,19 @@
|
||||
package novita
|
||||
|
||||
// https://novita.ai/llm-api
|
||||
|
||||
var ModelList = []string{
|
||||
"meta-llama/llama-3-8b-instruct",
|
||||
"meta-llama/llama-3-70b-instruct",
|
||||
"nousresearch/hermes-2-pro-llama-3-8b",
|
||||
"nousresearch/nous-hermes-llama2-13b",
|
||||
"mistralai/mistral-7b-instruct",
|
||||
"cognitivecomputations/dolphin-mixtral-8x22b",
|
||||
"sao10k/l3-70b-euryale-v2.1",
|
||||
"sophosympatheia/midnight-rose-70b",
|
||||
"gryphe/mythomax-l2-13b",
|
||||
"Nous-Hermes-2-Mixtral-8x7B-DPO",
|
||||
"lzlv_70b",
|
||||
"teknium/openhermes-2.5-mistral-7b",
|
||||
"microsoft/wizardlm-2-8x22b",
|
||||
}
|
15
relay/adaptor/novita/main.go
Normal file
15
relay/adaptor/novita/main.go
Normal file
@ -0,0 +1,15 @@
|
||||
package novita
|
||||
|
||||
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 novita", meta.Mode)
|
||||
}
|
@ -3,17 +3,19 @@ package openai
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/songquanpeng/one-api/relay/adaptor"
|
||||
"github.com/songquanpeng/one-api/relay/adaptor/doubao"
|
||||
"github.com/songquanpeng/one-api/relay/adaptor/minimax"
|
||||
"github.com/songquanpeng/one-api/relay/adaptor/novita"
|
||||
"github.com/songquanpeng/one-api/relay/channeltype"
|
||||
"github.com/songquanpeng/one-api/relay/meta"
|
||||
"github.com/songquanpeng/one-api/relay/model"
|
||||
"github.com/songquanpeng/one-api/relay/relaymode"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Adaptor struct {
|
||||
@ -48,6 +50,8 @@ func (a *Adaptor) GetRequestURL(meta *meta.Meta) (string, error) {
|
||||
return minimax.GetRequestURL(meta)
|
||||
case channeltype.Doubao:
|
||||
return doubao.GetRequestURL(meta)
|
||||
case channeltype.Novita:
|
||||
return novita.GetRequestURL(meta)
|
||||
default:
|
||||
return GetFullRequestURL(meta.BaseURL, meta.RequestURLPath, meta.ChannelType), nil
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
"github.com/songquanpeng/one-api/relay/adaptor/minimax"
|
||||
"github.com/songquanpeng/one-api/relay/adaptor/mistral"
|
||||
"github.com/songquanpeng/one-api/relay/adaptor/moonshot"
|
||||
"github.com/songquanpeng/one-api/relay/adaptor/novita"
|
||||
"github.com/songquanpeng/one-api/relay/adaptor/stepfun"
|
||||
"github.com/songquanpeng/one-api/relay/adaptor/togetherai"
|
||||
"github.com/songquanpeng/one-api/relay/channeltype"
|
||||
@ -28,6 +29,7 @@ var CompatibleChannels = []int{
|
||||
channeltype.StepFun,
|
||||
channeltype.DeepSeek,
|
||||
channeltype.TogetherAI,
|
||||
channeltype.Novita,
|
||||
}
|
||||
|
||||
func GetCompatibleChannelMeta(channelType int) (string, []string) {
|
||||
@ -56,6 +58,8 @@ func GetCompatibleChannelMeta(channelType int) (string, []string) {
|
||||
return "together.ai", togetherai.ModelList
|
||||
case channeltype.Doubao:
|
||||
return "doubao", doubao.ModelList
|
||||
case channeltype.Novita:
|
||||
return "novita", novita.ModelList
|
||||
default:
|
||||
return "openai", ModelList
|
||||
}
|
||||
|
@ -42,5 +42,6 @@ const (
|
||||
DeepL
|
||||
TogetherAI
|
||||
Doubao
|
||||
Novita
|
||||
Dummy
|
||||
)
|
||||
|
@ -42,6 +42,7 @@ var ChannelBaseURLs = []string{
|
||||
"https://api-free.deepl.com", // 38
|
||||
"https://api.together.xyz", // 39
|
||||
"https://ark.cn-beijing.volces.com", // 40
|
||||
"https://api.novita.ai/v3/openai", // 41
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
@ -161,6 +161,12 @@ export const CHANNEL_OPTIONS = {
|
||||
value: 39,
|
||||
color: 'primary'
|
||||
},
|
||||
41: {
|
||||
key: 41,
|
||||
text: 'Novita',
|
||||
value: 41,
|
||||
color: 'purple'
|
||||
},
|
||||
8: {
|
||||
key: 8,
|
||||
text: '自定义渠道',
|
||||
|
@ -6,6 +6,7 @@ export const CHANNEL_OPTIONS = [
|
||||
{key: 11, text: 'Google PaLM2', value: 11, color: 'orange'},
|
||||
{key: 24, text: 'Google Gemini', value: 24, color: 'orange'},
|
||||
{key: 28, text: 'Mistral AI', value: 28, color: 'orange'},
|
||||
{key: 41, text: 'Novita', value: 41, color: 'purple'},
|
||||
{key: 40, text: '字节跳动豆包', value: 40, color: 'blue'},
|
||||
{key: 15, text: '百度文心千帆', value: 15, color: 'blue'},
|
||||
{key: 17, text: '阿里通义千问', value: 17, color: 'orange'},
|
||||
|
Loading…
Reference in New Issue
Block a user