Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
3aae4efe
authored
May 16, 2024
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: support minimax
parent
f09e86de
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
62 additions
and
12 deletions
+62
-12
common/constants.go
+1
-0
relay/channel/lingyiwanwu/constrants.go
+11
-9
relay/channel/minimax/constants.go
+13
-0
relay/channel/minimax/relay-minimax.go
+10
-0
relay/channel/moonshot/constants.go
+2
-0
relay/channel/openai/adaptor.go
+25
-3
No files found.
common/constants.go
View file @
3aae4efe
...
@@ -208,6 +208,7 @@ const (
...
@@ -208,6 +208,7 @@ const (
ChannelTypeLingYiWanWu
=
31
ChannelTypeLingYiWanWu
=
31
ChannelTypeAws
=
33
ChannelTypeAws
=
33
ChannelTypeCohere
=
34
ChannelTypeCohere
=
34
ChannelTypeMiniMax
=
35
ChannelTypeDummy
// this one is only for count, do not add any channel after this
ChannelTypeDummy
// this one is only for count, do not add any channel after this
)
)
...
...
relay/channel/lingyiwanwu/constrants.go
View file @
3aae4efe
package
lingyiwanwu
package
lingyiwanwu
// https://platform.lingyiwanwu.com/docs
// https://platform.lingyiwanwu.com/docs
var
ModelList
=
[]
string
{
var
ModelList
=
[]
string
{
"yi-34b-chat-0205"
,
"yi-34b-chat-0205"
,
"yi-34b-chat-200k"
,
"yi-34b-chat-200k"
,
"yi-vl-plus"
,
"yi-vl-plus"
,
}
}
var
ChannelName
=
"lingyiwanwu"
relay/channel/minimax/constants.go
0 → 100644
View file @
3aae4efe
package
minimax
// https://www.minimaxi.com/document/guides/chat-model/V2?id=65e0736ab2845de20908e2dd
var
ModelList
=
[]
string
{
"abab6.5-chat"
,
"abab6.5s-chat"
,
"abab6-chat"
,
"abab5.5-chat"
,
"abab5.5s-chat"
,
}
var
ChannelName
=
"minimax"
relay/channel/minimax/relay-minimax.go
0 → 100644
View file @
3aae4efe
package
minimax
import
(
"fmt"
relaycommon
"one-api/relay/common"
)
func
GetRequestURL
(
info
*
relaycommon
.
RelayInfo
)
(
string
,
error
)
{
return
fmt
.
Sprintf
(
"%s/v1/text/chatcompletion_v2"
,
info
.
BaseUrl
),
nil
}
relay/channel/moonshot/constants.go
View file @
3aae4efe
...
@@ -5,3 +5,5 @@ var ModelList = []string{
...
@@ -5,3 +5,5 @@ var ModelList = []string{
"moonshot-v1-32k"
,
"moonshot-v1-32k"
,
"moonshot-v1-128k"
,
"moonshot-v1-128k"
,
}
}
var
ChannelName
=
"moonshot"
relay/channel/openai/adaptor.go
View file @
3aae4efe
...
@@ -11,6 +11,7 @@ import (
...
@@ -11,6 +11,7 @@ import (
"one-api/relay/channel"
"one-api/relay/channel"
"one-api/relay/channel/ai360"
"one-api/relay/channel/ai360"
"one-api/relay/channel/lingyiwanwu"
"one-api/relay/channel/lingyiwanwu"
"one-api/relay/channel/minimax"
"one-api/relay/channel/moonshot"
"one-api/relay/channel/moonshot"
relaycommon
"one-api/relay/common"
relaycommon
"one-api/relay/common"
"one-api/service"
"one-api/service"
...
@@ -26,7 +27,8 @@ func (a *Adaptor) Init(info *relaycommon.RelayInfo, request dto.GeneralOpenAIReq
...
@@ -26,7 +27,8 @@ func (a *Adaptor) Init(info *relaycommon.RelayInfo, request dto.GeneralOpenAIReq
}
}
func
(
a
*
Adaptor
)
GetRequestURL
(
info
*
relaycommon
.
RelayInfo
)
(
string
,
error
)
{
func
(
a
*
Adaptor
)
GetRequestURL
(
info
*
relaycommon
.
RelayInfo
)
(
string
,
error
)
{
if
info
.
ChannelType
==
common
.
ChannelTypeAzure
{
switch
info
.
ChannelType
{
case
common
.
ChannelTypeAzure
:
// https://learn.microsoft.com/en-us/azure/cognitive-services/openai/chatgpt-quickstart?pivots=rest-api&tabs=command-line#rest-api
// https://learn.microsoft.com/en-us/azure/cognitive-services/openai/chatgpt-quickstart?pivots=rest-api&tabs=command-line#rest-api
requestURL
:=
strings
.
Split
(
info
.
RequestURLPath
,
"?"
)[
0
]
requestURL
:=
strings
.
Split
(
info
.
RequestURLPath
,
"?"
)[
0
]
requestURL
=
fmt
.
Sprintf
(
"%s?api-version=%s"
,
requestURL
,
info
.
ApiVersion
)
requestURL
=
fmt
.
Sprintf
(
"%s?api-version=%s"
,
requestURL
,
info
.
ApiVersion
)
...
@@ -37,8 +39,15 @@ func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
...
@@ -37,8 +39,15 @@ func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
requestURL
=
fmt
.
Sprintf
(
"/openai/deployments/%s/%s"
,
model_
,
task
)
requestURL
=
fmt
.
Sprintf
(
"/openai/deployments/%s/%s"
,
model_
,
task
)
return
relaycommon
.
GetFullRequestURL
(
info
.
BaseUrl
,
requestURL
,
info
.
ChannelType
),
nil
return
relaycommon
.
GetFullRequestURL
(
info
.
BaseUrl
,
requestURL
,
info
.
ChannelType
),
nil
case
common
.
ChannelTypeMiniMax
:
return
minimax
.
GetRequestURL
(
info
)
//case common.ChannelTypeCustom:
// url := info.BaseUrl
// url = strings.Replace(url, "{model}", info.UpstreamModelName, -1)
// return url, nil
default
:
return
relaycommon
.
GetFullRequestURL
(
info
.
BaseUrl
,
info
.
RequestURLPath
,
info
.
ChannelType
),
nil
}
}
return
relaycommon
.
GetFullRequestURL
(
info
.
BaseUrl
,
info
.
RequestURLPath
,
info
.
ChannelType
),
nil
}
}
func
(
a
*
Adaptor
)
SetupRequestHeader
(
c
*
gin
.
Context
,
req
*
http
.
Request
,
info
*
relaycommon
.
RelayInfo
)
error
{
func
(
a
*
Adaptor
)
SetupRequestHeader
(
c
*
gin
.
Context
,
req
*
http
.
Request
,
info
*
relaycommon
.
RelayInfo
)
error
{
...
@@ -90,11 +99,24 @@ func (a *Adaptor) GetModelList() []string {
...
@@ -90,11 +99,24 @@ func (a *Adaptor) GetModelList() []string {
return
moonshot
.
ModelList
return
moonshot
.
ModelList
case
common
.
ChannelTypeLingYiWanWu
:
case
common
.
ChannelTypeLingYiWanWu
:
return
lingyiwanwu
.
ModelList
return
lingyiwanwu
.
ModelList
case
common
.
ChannelTypeMiniMax
:
return
minimax
.
ModelList
default
:
default
:
return
ModelList
return
ModelList
}
}
}
}
func
(
a
*
Adaptor
)
GetChannelName
()
string
{
func
(
a
*
Adaptor
)
GetChannelName
()
string
{
return
ChannelName
switch
a
.
ChannelType
{
case
common
.
ChannelType360
:
return
ai360
.
ChannelName
case
common
.
ChannelTypeMoonshot
:
return
moonshot
.
ChannelName
case
common
.
ChannelTypeLingYiWanWu
:
return
lingyiwanwu
.
ChannelName
case
common
.
ChannelTypeMiniMax
:
return
minimax
.
ChannelName
default
:
return
ChannelName
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment