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
2ae6060a
authored
Nov 24, 2024
by
CalciumIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: support audio response_format #580
parent
e9aeb881
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
4 deletions
+20
-4
relay/channel/openai/adaptor.go
+13
-0
relay/relay-audio.go
+7
-4
No files found.
relay/channel/openai/adaptor.go
View file @
2ae6060a
...
@@ -132,6 +132,19 @@ func (a *Adaptor) ConvertAudioRequest(c *gin.Context, info *relaycommon.RelayInf
...
@@ -132,6 +132,19 @@ func (a *Adaptor) ConvertAudioRequest(c *gin.Context, info *relaycommon.RelayInf
writer
.
WriteField
(
"model"
,
request
.
Model
)
writer
.
WriteField
(
"model"
,
request
.
Model
)
// 获取所有表单字段
formData
:=
c
.
Request
.
PostForm
// 遍历表单字段并打印输出
for
key
,
values
:=
range
formData
{
if
key
==
"model"
{
continue
}
for
_
,
value
:=
range
values
{
writer
.
WriteField
(
key
,
value
)
}
}
// 添加文件字段
// 添加文件字段
file
,
header
,
err
:=
c
.
Request
.
FormFile
(
"file"
)
file
,
header
,
err
:=
c
.
Request
.
FormFile
(
"file"
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
relay/relay-audio.go
View file @
2ae6060a
...
@@ -33,15 +33,18 @@ func getAndValidAudioRequest(c *gin.Context, info *relaycommon.RelayInfo) (*dto.
...
@@ -33,15 +33,18 @@ func getAndValidAudioRequest(c *gin.Context, info *relaycommon.RelayInfo) (*dto.
}
}
}
}
default
:
default
:
err
=
c
.
Request
.
ParseForm
()
if
err
!=
nil
{
return
nil
,
err
}
formData
:=
c
.
Request
.
PostForm
if
audioRequest
.
Model
==
""
{
if
audioRequest
.
Model
==
""
{
audioRequest
.
Model
=
c
.
PostForm
(
"model"
)
audioRequest
.
Model
=
formData
.
Get
(
"model"
)
}
}
if
audioRequest
.
Model
==
""
{
if
audioRequest
.
Model
==
""
{
return
nil
,
errors
.
New
(
"model is required"
)
return
nil
,
errors
.
New
(
"model is required"
)
}
}
if
audioRequest
.
ResponseFormat
==
""
{
audioRequest
.
ResponseFormat
=
"json"
}
}
}
return
audioRequest
,
nil
return
audioRequest
,
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