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
5cf33f35
authored
May 13, 2024
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 修复自定义渠道出错 #243
parent
699e29e2
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
11 additions
and
17 deletions
+11
-17
controller/channel-test.go
+1
-1
controller/model.go
+2
-2
relay/common/relay_info.go
+1
-1
relay/constant/api_type.go
+5
-10
web/src/helpers/render.js
+2
-3
No files found.
controller/channel-test.go
View file @
5cf33f35
...
@@ -53,7 +53,7 @@ func testChannel(channel *model.Channel, testModel string) (err error, openaiErr
...
@@ -53,7 +53,7 @@ func testChannel(channel *model.Channel, testModel string) (err error, openaiErr
}
}
meta
:=
relaycommon
.
GenRelayInfo
(
c
)
meta
:=
relaycommon
.
GenRelayInfo
(
c
)
apiType
:=
constant
.
ChannelType2APIType
(
channel
.
Type
)
apiType
,
_
:=
constant
.
ChannelType2APIType
(
channel
.
Type
)
adaptor
:=
relay
.
GetAdaptor
(
apiType
)
adaptor
:=
relay
.
GetAdaptor
(
apiType
)
if
adaptor
==
nil
{
if
adaptor
==
nil
{
return
fmt
.
Errorf
(
"invalid api type: %d, adaptor is nil"
,
apiType
),
nil
return
fmt
.
Errorf
(
"invalid api type: %d, adaptor is nil"
,
apiType
),
nil
...
...
controller/model.go
View file @
5cf33f35
...
@@ -138,8 +138,8 @@ func init() {
...
@@ -138,8 +138,8 @@ func init() {
}
}
channelId2Models
=
make
(
map
[
int
][]
string
)
channelId2Models
=
make
(
map
[
int
][]
string
)
for
i
:=
1
;
i
<=
common
.
ChannelTypeDummy
;
i
++
{
for
i
:=
1
;
i
<=
common
.
ChannelTypeDummy
;
i
++
{
apiType
:=
relayconstant
.
ChannelType2APIType
(
i
)
apiType
,
success
:=
relayconstant
.
ChannelType2APIType
(
i
)
if
apiType
==
-
1
||
apiType
==
relayconstant
.
APITypeAIProxyLibrary
{
if
!
success
||
apiType
==
relayconstant
.
APITypeAIProxyLibrary
{
continue
continue
}
}
meta
:=
&
relaycommon
.
RelayInfo
{
ChannelType
:
i
}
meta
:=
&
relaycommon
.
RelayInfo
{
ChannelType
:
i
}
...
...
relay/common/relay_info.go
View file @
5cf33f35
...
@@ -38,7 +38,7 @@ func GenRelayInfo(c *gin.Context) *RelayInfo {
...
@@ -38,7 +38,7 @@ func GenRelayInfo(c *gin.Context) *RelayInfo {
tokenUnlimited
:=
c
.
GetBool
(
"token_unlimited_quota"
)
tokenUnlimited
:=
c
.
GetBool
(
"token_unlimited_quota"
)
startTime
:=
time
.
Now
()
startTime
:=
time
.
Now
()
apiType
:=
constant
.
ChannelType2APIType
(
channelType
)
apiType
,
_
:=
constant
.
ChannelType2APIType
(
channelType
)
info
:=
&
RelayInfo
{
info
:=
&
RelayInfo
{
RelayMode
:
constant
.
Path2RelayMode
(
c
.
Request
.
URL
.
Path
),
RelayMode
:
constant
.
Path2RelayMode
(
c
.
Request
.
URL
.
Path
),
...
...
relay/constant/api_type.go
View file @
5cf33f35
...
@@ -24,19 +24,11 @@ const (
...
@@ -24,19 +24,11 @@ const (
APITypeDummy
// this one is only for count, do not add any channel after this
APITypeDummy
// this one is only for count, do not add any channel after this
)
)
func
ChannelType2APIType
(
channelType
int
)
int
{
func
ChannelType2APIType
(
channelType
int
)
(
int
,
bool
)
{
apiType
:=
-
1
apiType
:=
-
1
switch
channelType
{
switch
channelType
{
case
common
.
ChannelTypeOpenAI
:
case
common
.
ChannelTypeOpenAI
:
apiType
=
APITypeOpenAI
apiType
=
APITypeOpenAI
case
common
.
ChannelTypeAzure
:
apiType
=
APITypeOpenAI
case
common
.
ChannelTypeMoonshot
:
apiType
=
APITypeOpenAI
case
common
.
ChannelTypeLingYiWanWu
:
apiType
=
APITypeOpenAI
case
common
.
ChannelType360
:
apiType
=
APITypeOpenAI
case
common
.
ChannelTypeAnthropic
:
case
common
.
ChannelTypeAnthropic
:
apiType
=
APITypeAnthropic
apiType
=
APITypeAnthropic
case
common
.
ChannelTypeBaidu
:
case
common
.
ChannelTypeBaidu
:
...
@@ -66,5 +58,8 @@ func ChannelType2APIType(channelType int) int {
...
@@ -66,5 +58,8 @@ func ChannelType2APIType(channelType int) int {
case
common
.
ChannelTypeCohere
:
case
common
.
ChannelTypeCohere
:
apiType
=
APITypeCohere
apiType
=
APITypeCohere
}
}
return
apiType
if
apiType
==
-
1
{
return
APITypeOpenAI
,
false
}
return
apiType
,
true
}
}
web/src/helpers/render.js
View file @
5cf33f35
import
{
Label
}
from
'semantic-ui-react'
;
import
{
Tag
}
from
'@douyinfe/semi-ui'
;
import
{
Tag
}
from
'@douyinfe/semi-ui'
;
export
function
renderText
(
text
,
limit
)
{
export
function
renderText
(
text
,
limit
)
{
...
@@ -152,9 +151,9 @@ export function renderModelPrice(
...
@@ -152,9 +151,9 @@ export function renderModelPrice(
let
completionRatioPrice
=
let
completionRatioPrice
=
modelRatio
*
completionRatio
*
0.002
*
groupRatio
;
modelRatio
*
completionRatio
*
0.002
*
groupRatio
;
return
(
return
(
'输入
:
$'
+
'输入
$'
+
inputRatioPrice
.
toFixed
(
3
)
+
inputRatioPrice
.
toFixed
(
3
)
+
'/1K tokens,补全
:
$'
+
'/1K tokens,补全
$'
+
completionRatioPrice
.
toFixed
(
3
)
+
completionRatioPrice
.
toFixed
(
3
)
+
'/1K tokens'
'/1K tokens'
);
);
...
...
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