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
a71b737a
authored
Sep 09, 2023
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
合并请求
parent
c0636950
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
2 deletions
+21
-2
controller/relay-audio.go
+1
-1
controller/relay.go
+18
-0
middleware/distributor.go
+2
-1
No files found.
controller/relay-audio.go
View file @
a71b737a
...
@@ -106,7 +106,7 @@ func relayAudioHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode
...
@@ -106,7 +106,7 @@ func relayAudioHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode
if
quota
!=
0
{
if
quota
!=
0
{
tokenName
:=
c
.
GetString
(
"token_name"
)
tokenName
:=
c
.
GetString
(
"token_name"
)
logContent
:=
fmt
.
Sprintf
(
"模型倍率 %.2f,分组倍率 %.2f"
,
modelRatio
,
groupRatio
)
logContent
:=
fmt
.
Sprintf
(
"模型倍率 %.2f,分组倍率 %.2f"
,
modelRatio
,
groupRatio
)
model
.
RecordConsumeLog
(
userId
,
0
,
0
,
audioModel
,
tokenName
,
quota
,
logContent
)
model
.
RecordConsumeLog
(
userId
,
0
,
0
,
audioModel
,
tokenName
,
quota
,
logContent
,
tokenId
)
model
.
UpdateUserUsedQuotaAndRequestCount
(
userId
,
quota
)
model
.
UpdateUserUsedQuotaAndRequestCount
(
userId
,
quota
)
channelId
:=
c
.
GetInt
(
"channel_id"
)
channelId
:=
c
.
GetInt
(
"channel_id"
)
model
.
UpdateChannelUsedQuota
(
channelId
,
quota
)
model
.
UpdateChannelUsedQuota
(
channelId
,
quota
)
...
...
controller/relay.go
View file @
a71b737a
...
@@ -2,6 +2,7 @@ package controller
...
@@ -2,6 +2,7 @@ package controller
import
(
import
(
"fmt"
"fmt"
"log"
"net/http"
"net/http"
"one-api/common"
"one-api/common"
"strconv"
"strconv"
...
@@ -171,6 +172,23 @@ type CompletionsStreamResponse struct {
...
@@ -171,6 +172,23 @@ type CompletionsStreamResponse struct {
}
`json:"choices"`
}
`json:"choices"`
}
}
type
MidjourneyRequest
struct
{
Prompt
string
`json:"prompt"`
NotifyHook
string
`json:"notifyHook"`
Action
string
`json:"action"`
Index
int
`json:"index"`
State
string
`json:"state"`
TaskId
string
`json:"taskId"`
Base64Array
[]
string
`json:"base64Array"`
}
type
MidjourneyResponse
struct
{
Code
int
`json:"code"`
Description
string
`json:"description"`
Properties
interface
{}
`json:"properties"`
Result
string
`json:"result"`
}
func
Relay
(
c
*
gin
.
Context
)
{
func
Relay
(
c
*
gin
.
Context
)
{
relayMode
:=
RelayModeUnknown
relayMode
:=
RelayModeUnknown
if
strings
.
HasPrefix
(
c
.
Request
.
URL
.
Path
,
"/v1/chat/completions"
)
{
if
strings
.
HasPrefix
(
c
.
Request
.
URL
.
Path
,
"/v1/chat/completions"
)
{
...
...
middleware/distributor.go
View file @
a71b737a
...
@@ -2,6 +2,7 @@ package middleware
...
@@ -2,6 +2,7 @@ package middleware
import
(
import
(
"fmt"
"fmt"
"log"
"net/http"
"net/http"
"one-api/common"
"one-api/common"
"one-api/model"
"one-api/model"
...
@@ -96,7 +97,7 @@ func Distribute() func(c *gin.Context) {
...
@@ -96,7 +97,7 @@ func Distribute() func(c *gin.Context) {
modelRequest
.
Model
=
"whisper-1"
modelRequest
.
Model
=
"whisper-1"
}
}
}
}
channel
,
err
=
model
.
CacheGetRandomSatisfiedChannel
(
userGroup
,
modelRequest
.
Model
)
channel
,
err
:
=
model
.
CacheGetRandomSatisfiedChannel
(
userGroup
,
modelRequest
.
Model
)
if
err
!=
nil
{
if
err
!=
nil
{
message
:=
fmt
.
Sprintf
(
"当前分组 %s 下对于模型 %s 无可用渠道"
,
userGroup
,
modelRequest
.
Model
)
message
:=
fmt
.
Sprintf
(
"当前分组 %s 下对于模型 %s 无可用渠道"
,
userGroup
,
modelRequest
.
Model
)
if
channel
!=
nil
{
if
channel
!=
nil
{
...
...
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