mirror of
				https://github.com/songquanpeng/one-api.git
				synced 2025-11-04 15:53:42 +08:00 
			
		
		
		
	feat: add Novita AI as model provider (#1609)
This commit is contained in:
		
							
								
								
									
										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() {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user