Skip to content

Commit f8ed8dc

Browse files
committed
handle the case where pdf image + server without mtmd
1 parent 71ac85b commit f8ed8dc

File tree

2 files changed

+32
-22
lines changed

2 files changed

+32
-22
lines changed

tools/server/public/index.html.gz

41 Bytes
Binary file not shown.

tools/server/webui/src/components/useChatExtraContext.tsx

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -82,28 +82,38 @@ export function useChatExtraContext(): ChatExtraContextApi {
8282
toast.error('Video and audio files are not supported yet.');
8383
break;
8484
} else if (mimeType.startsWith('application/pdf')) {
85-
const promise = config.pdfAsImage
86-
? convertPDFToImage(file).then((base64Urls) => {
87-
addItems(
88-
base64Urls.map((base64Url) => ({
89-
type: 'imageFile',
90-
name: file.name,
91-
base64Url,
92-
}))
93-
);
94-
})
95-
: convertPDFToText(file).then((content) => {
96-
toast.success(
97-
'PDF file converted to text. You can also convert it to image, see in Settings.'
98-
);
99-
addItems([
100-
{
101-
type: 'textFile',
102-
name: file.name,
103-
content,
104-
},
105-
]);
106-
});
85+
if (config.pdfAsImage && !isSupportVision) {
86+
toast(
87+
'Multimodal is not supported, PDF will be converted to text instead of image.'
88+
);
89+
break;
90+
}
91+
92+
const promise =
93+
config.pdfAsImage && isSupportVision
94+
? convertPDFToImage(file).then((base64Urls) => {
95+
addItems(
96+
base64Urls.map((base64Url) => ({
97+
type: 'imageFile',
98+
name: file.name,
99+
base64Url,
100+
}))
101+
);
102+
})
103+
: convertPDFToText(file).then((content) => {
104+
if (isSupportVision) {
105+
toast.success(
106+
'PDF file converted to text. You can also convert it to image, see in Settings.'
107+
);
108+
}
109+
addItems([
110+
{
111+
type: 'textFile',
112+
name: file.name,
113+
content,
114+
},
115+
]);
116+
});
107117

108118
promise.catch((error) => {
109119
console.error(error);

0 commit comments

Comments
 (0)