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
4577235c
authored
Nov 19, 2023
by
Calcium-Ion
Committed by
GitHub
Nov 19, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'main' into main
parents
9768d73c
36173b79
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
6 deletions
+13
-6
controller/relay-audio.go
+10
-3
controller/relay-utils.go
+2
-2
middleware/distributor.go
+1
-1
No files found.
controller/relay-audio.go
View file @
4577235c
...
...
@@ -32,10 +32,17 @@ func relayAudioHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode
group
:=
c
.
GetString
(
"group"
)
var
audioRequest
AudioRequest
err
:=
common
.
UnmarshalBodyReusable
(
c
,
&
audioRequest
)
if
err
!=
nil
{
return
errorWrapper
(
err
,
"bind_request_body_failed"
,
http
.
StatusBadRequest
)
if
!
strings
.
HasPrefix
(
c
.
Request
.
URL
.
Path
,
"/v1/audio/transcriptions"
)
{
err
:=
common
.
UnmarshalBodyReusable
(
c
,
&
audioRequest
)
if
err
!=
nil
{
return
errorWrapper
(
err
,
"bind_request_body_failed"
,
http
.
StatusBadRequest
)
}
}
else
{
audioRequest
=
AudioRequest
{
Model
:
"whisper-1"
,
}
}
//err := common.UnmarshalBodyReusable(c, &audioRequest)
// request validation
if
audioRequest
.
Model
==
""
{
...
...
controller/relay-utils.go
View file @
4577235c
...
...
@@ -82,11 +82,11 @@ func getImageToken(imageUrl MessageImageUrl) (int, error) {
return
0
,
err
}
defer
response
.
Body
.
Close
()
// 限制读取的字节数,防止下载整个图片
limitReader
:=
io
.
LimitReader
(
response
.
Body
,
8192
)
response
.
Body
.
Close
()
// 读取图片的头部信息来获取图片尺寸
config
,
_
,
err
:=
image
.
DecodeConfig
(
limitReader
)
if
err
!=
nil
{
...
...
middleware/distributor.go
View file @
4577235c
...
...
@@ -46,7 +46,7 @@ func Distribute() func(c *gin.Context) {
if
modelRequest
.
Model
==
""
{
modelRequest
.
Model
=
"midjourney"
}
}
else
{
}
else
if
!
strings
.
HasPrefix
(
c
.
Request
.
URL
.
Path
,
"/v1/audio/transcriptions"
)
{
err
=
common
.
UnmarshalBodyReusable
(
c
,
&
modelRequest
)
}
if
err
!=
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