) => {
+ const text = e.clipboardData.getData('text/plain');
+ if (
+ text.length > 0 &&
+ config.pasteLongTextToFileLen > 0 &&
+ text.length > config.pasteLongTextToFileLen
+ ) {
+ // if the text is too long, we will convert it to a file
+ extraContext.addItems([
+ {
+ type: 'context',
+ name: 'Pasted Content',
+ content: text,
+ },
+ ]);
+ e.preventDefault();
+ return;
+ }
+
+ // if a file is pasted, we will handle it here
const files = Array.from(e.clipboardData.items)
.filter((item) => item.kind === 'file')
.map((item) => item.getAsFile())
diff --git a/tools/server/webui/src/components/SettingDialog.tsx b/tools/server/webui/src/components/SettingDialog.tsx
index b0044d25..0240a17f 100644
--- a/tools/server/webui/src/components/SettingDialog.tsx
+++ b/tools/server/webui/src/components/SettingDialog.tsx
@@ -100,6 +100,16 @@ const SETTING_SECTIONS: SettingSection[] = [
key,
}) as SettingFieldInput
),
+ {
+ type: SettingInputType.SHORT_INPUT,
+ label: 'Paste length to file',
+ key: 'pasteLongTextToFileLen',
+ },
+ {
+ type: SettingInputType.CHECKBOX,
+ label: 'Parse PDF as image instead of text',
+ key: 'pdfAsImage',
+ },
],
},
{
@@ -452,10 +462,10 @@ function SettingsModalLongInput({
label?: string;
}) {
return (
-