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
a8b24bed
authored
Jun 09, 2025
by
Calcium-Ion
Committed by
GitHub
Jun 09, 2025
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1184 from QuantumNous/refactor/message
fix: message 转 any 后,ImageUrl判断 panic
parents
af0f59cb
be38aaa8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
3 deletions
+38
-3
dto/openai_request.go
+38
-3
No files found.
dto/openai_request.go
View file @
a8b24bed
...
...
@@ -132,21 +132,50 @@ type MediaContent struct {
func
(
m
*
MediaContent
)
GetImageMedia
()
*
MessageImageUrl
{
if
m
.
ImageUrl
!=
nil
{
return
m
.
ImageUrl
.
(
*
MessageImageUrl
)
if
_
,
ok
:=
m
.
ImageUrl
.
(
*
MessageImageUrl
);
ok
{
return
m
.
ImageUrl
.
(
*
MessageImageUrl
)
}
if
itemMap
,
ok
:=
m
.
ImageUrl
.
(
map
[
string
]
any
);
ok
{
out
:=
&
MessageImageUrl
{
Url
:
common
.
Interface2String
(
itemMap
[
"url"
]),
Detail
:
common
.
Interface2String
(
itemMap
[
"detail"
]),
MimeType
:
common
.
Interface2String
(
itemMap
[
"mime_type"
]),
}
return
out
}
}
return
nil
}
func
(
m
*
MediaContent
)
GetInputAudio
()
*
MessageInputAudio
{
if
m
.
InputAudio
!=
nil
{
return
m
.
InputAudio
.
(
*
MessageInputAudio
)
if
_
,
ok
:=
m
.
InputAudio
.
(
*
MessageInputAudio
);
ok
{
return
m
.
InputAudio
.
(
*
MessageInputAudio
)
}
if
itemMap
,
ok
:=
m
.
InputAudio
.
(
map
[
string
]
any
);
ok
{
out
:=
&
MessageInputAudio
{
Data
:
common
.
Interface2String
(
itemMap
[
"data"
]),
Format
:
common
.
Interface2String
(
itemMap
[
"format"
]),
}
return
out
}
}
return
nil
}
func
(
m
*
MediaContent
)
GetFile
()
*
MessageFile
{
if
m
.
File
!=
nil
{
return
m
.
File
.
(
*
MessageFile
)
if
_
,
ok
:=
m
.
File
.
(
*
MessageFile
);
ok
{
return
m
.
File
.
(
*
MessageFile
)
}
if
itemMap
,
ok
:=
m
.
File
.
(
map
[
string
]
any
);
ok
{
out
:=
&
MessageFile
{
FileName
:
common
.
Interface2String
(
itemMap
[
"file_name"
]),
FileData
:
common
.
Interface2String
(
itemMap
[
"file_data"
]),
FileId
:
common
.
Interface2String
(
itemMap
[
"file_id"
]),
}
return
out
}
}
return
nil
}
...
...
@@ -286,6 +315,12 @@ func (m *Message) ParseContent() []MediaContent {
}
for
_
,
contentItemAny
:=
range
arrayContent
{
mediaItem
,
ok
:=
contentItemAny
.
(
MediaContent
)
if
ok
{
contentList
=
append
(
contentList
,
mediaItem
)
continue
}
contentItem
,
ok
:=
contentItemAny
.
(
map
[
string
]
any
)
if
!
ok
{
continue
...
...
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