Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
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
Unverified
Commit
78d50e15
authored
Apr 17, 2024
by
xiaotian
Committed by
GitHub
Apr 17, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: base64 image undefined (#1231)
parent
3d046974
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
1 deletions
+6
-1
packages/service/core/chat/utils.ts
+6
-1
No files found.
packages/service/core/chat/utils.ts
View file @
78d50e15
...
...
@@ -6,6 +6,7 @@ import type {
}
from
'@fastgpt/global/core/ai/type.d'
;
import
axios
from
'axios'
;
import
{
ChatCompletionRequestMessageRoleEnum
}
from
'@fastgpt/global/core/ai/constants'
;
import
{
guessBase64ImageType
}
from
'../../common/file/utils'
;
/* slice chat context by tokens */
const
filterEmptyMessages
=
(
messages
:
ChatCompletionMessageParam
[])
=>
{
...
...
@@ -242,7 +243,11 @@ export const loadChatImgToBase64 = async (content: string | ChatCompletionConten
responseType
:
'arraybuffer'
});
const
base64
=
Buffer
.
from
(
response
.
data
).
toString
(
'base64'
);
item
.
image_url
.
url
=
`data:
${
response
.
headers
[
'content-type'
]}
;base64,
${
base64
}
`
;
let
imageType
=
response
.
headers
[
'content-type'
];
if
(
imageType
===
undefined
)
{
imageType
=
guessBase64ImageType
(
base64
);
}
item
.
image_url
.
url
=
`data:
${
imageType
}
;base64,
${
base64
}
`
;
return
item
;
})
);
...
...
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