mirror of
https://github.com/LLM-Red-Team/glm-free-api.git
synced 2024-12-23 01:19:22 +08:00
图像解析支持
This commit is contained in:
parent
9868897d07
commit
cbb14b0198
@ -316,14 +316,23 @@ function messagesPrepare(messages: any[], refs: any[]) {
|
|||||||
const role = message.role.replace('user', '我').replace('assistant', '你') || '我';
|
const role = message.role.replace('user', '我').replace('assistant', '你') || '我';
|
||||||
return content += `${role}:${message.content}\n你:`;
|
return content += `${role}:${message.content}\n你:`;
|
||||||
}, '');
|
}, '');
|
||||||
|
const fileRefs = refs.filter(ref => !ref.width && !ref.height);
|
||||||
|
const imageRefs = refs.filter(ref => ref.width || ref.height).map(ref => {
|
||||||
|
ref.image_url = ref.file_url;
|
||||||
|
return ref;
|
||||||
|
});
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
role: 'user',
|
role: 'user',
|
||||||
content: [
|
content: [
|
||||||
{ type: 'text', text: headPrompt + content },
|
{ type: 'text', text: headPrompt + content },
|
||||||
...(refs.length == 0 ? [] : [{
|
...(fileRefs.length == 0 ? [] : [{
|
||||||
type: 'file',
|
type: 'file',
|
||||||
file: refs
|
file: fileRefs
|
||||||
|
}]),
|
||||||
|
...(imageRefs.length == 0 ? [] : [{
|
||||||
|
type: 'image',
|
||||||
|
image: imageRefs
|
||||||
}])
|
}])
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user