mirror of
https://github.com/open-webui/open-webui
synced 2025-06-23 02:16:52 +00:00
feat: model file upload capability
This commit is contained in:
parent
6692fb2181
commit
c3acb30bb1
@ -120,6 +120,11 @@
|
|||||||
(model) => $models.find((m) => m.id === model)?.info?.meta?.capabilities?.vision ?? true
|
(model) => $models.find((m) => m.id === model)?.info?.meta?.capabilities?.vision ?? true
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let fileUploadCapableModels = [];
|
||||||
|
$: fileUploadCapableModels = (atSelectedModel?.id ? [atSelectedModel.id] : selectedModels).filter(
|
||||||
|
(model) => $models.find((m) => m.id === model)?.info?.meta?.capabilities?.file_upload ?? true
|
||||||
|
);
|
||||||
|
|
||||||
let webSearchCapableModels = [];
|
let webSearchCapableModels = [];
|
||||||
$: webSearchCapableModels = (atSelectedModel?.id ? [atSelectedModel.id] : selectedModels).filter(
|
$: webSearchCapableModels = (atSelectedModel?.id ? [atSelectedModel.id] : selectedModels).filter(
|
||||||
(model) => $models.find((m) => m.id === model)?.info?.meta?.capabilities?.web_search ?? true
|
(model) => $models.find((m) => m.id === model)?.info?.meta?.capabilities?.web_search ?? true
|
||||||
@ -1086,6 +1091,8 @@
|
|||||||
<div class="ml-1 self-end flex items-center flex-1 max-w-[80%] gap-0.5">
|
<div class="ml-1 self-end flex items-center flex-1 max-w-[80%] gap-0.5">
|
||||||
<InputMenu
|
<InputMenu
|
||||||
bind:selectedToolIds
|
bind:selectedToolIds
|
||||||
|
selectedModels={atSelectedModel ? [atSelectedModel.id] : selectedModels}
|
||||||
|
{fileUploadCapableModels}
|
||||||
{screenCaptureHandler}
|
{screenCaptureHandler}
|
||||||
{inputFilesHandler}
|
{inputFilesHandler}
|
||||||
uploadFilesHandler={() => {
|
uploadFilesHandler={() => {
|
||||||
|
@ -20,6 +20,11 @@
|
|||||||
|
|
||||||
const i18n = getContext('i18n');
|
const i18n = getContext('i18n');
|
||||||
|
|
||||||
|
export let selectedToolIds: string[] = [];
|
||||||
|
|
||||||
|
export let selectedModels: string[] = [];
|
||||||
|
export let fileUploadCapableModels: string[] = [];
|
||||||
|
|
||||||
export let screenCaptureHandler: Function;
|
export let screenCaptureHandler: Function;
|
||||||
export let uploadFilesHandler: Function;
|
export let uploadFilesHandler: Function;
|
||||||
export let inputFilesHandler: Function;
|
export let inputFilesHandler: Function;
|
||||||
@ -27,8 +32,6 @@
|
|||||||
export let uploadGoogleDriveHandler: Function;
|
export let uploadGoogleDriveHandler: Function;
|
||||||
export let uploadOneDriveHandler: Function;
|
export let uploadOneDriveHandler: Function;
|
||||||
|
|
||||||
export let selectedToolIds: string[] = [];
|
|
||||||
|
|
||||||
export let onClose: Function;
|
export let onClose: Function;
|
||||||
|
|
||||||
let tools = {};
|
let tools = {};
|
||||||
@ -40,7 +43,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
let fileUploadEnabled = true;
|
let fileUploadEnabled = true;
|
||||||
$: fileUploadEnabled = $user?.role === 'admin' || $user?.permissions?.chat?.file_upload;
|
$: fileUploadEnabled =
|
||||||
|
fileUploadCapableModels.length === selectedModels.length &&
|
||||||
|
($user?.role === 'admin' || $user?.permissions?.chat?.file_upload);
|
||||||
|
|
||||||
const init = async () => {
|
const init = async () => {
|
||||||
if ($_tools === null) {
|
if ($_tools === null) {
|
||||||
@ -169,7 +174,11 @@
|
|||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<Tooltip
|
<Tooltip
|
||||||
content={!fileUploadEnabled ? $i18n.t('You do not have permission to upload files.') : ''}
|
content={fileUploadCapableModels.length !== selectedModels.length
|
||||||
|
? $i18n.t('Model(s) do not support file upload')
|
||||||
|
: !fileUploadEnabled
|
||||||
|
? $i18n.t('You do not have permission to upload files.')
|
||||||
|
: ''}
|
||||||
className="w-full"
|
className="w-full"
|
||||||
>
|
>
|
||||||
<DropdownMenu.Item
|
<DropdownMenu.Item
|
||||||
@ -196,7 +205,11 @@
|
|||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|
||||||
<Tooltip
|
<Tooltip
|
||||||
content={!fileUploadEnabled ? $i18n.t('You do not have permission to upload files.') : ''}
|
content={fileUploadCapableModels.length !== selectedModels.length
|
||||||
|
? $i18n.t('Model(s) do not support file upload')
|
||||||
|
: !fileUploadEnabled
|
||||||
|
? $i18n.t('You do not have permission to upload files.')
|
||||||
|
: ''}
|
||||||
className="w-full"
|
className="w-full"
|
||||||
>
|
>
|
||||||
<DropdownMenu.Item
|
<DropdownMenu.Item
|
||||||
@ -214,6 +227,7 @@
|
|||||||
</DropdownMenu.Item>
|
</DropdownMenu.Item>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|
||||||
|
{#if fileUploadEnabled}
|
||||||
{#if $config?.features?.enable_google_drive_integration}
|
{#if $config?.features?.enable_google_drive_integration}
|
||||||
<DropdownMenu.Item
|
<DropdownMenu.Item
|
||||||
class="flex gap-2 items-center px-3 py-2 text-sm font-medium cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-xl"
|
class="flex gap-2 items-center px-3 py-2 text-sm font-medium cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-xl"
|
||||||
@ -256,7 +270,12 @@
|
|||||||
<DropdownMenu.SubTrigger
|
<DropdownMenu.SubTrigger
|
||||||
class="flex gap-2 items-center px-3 py-2 text-sm font-medium cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-xl w-full"
|
class="flex gap-2 items-center px-3 py-2 text-sm font-medium cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-xl w-full"
|
||||||
>
|
>
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" class="w-5 h-5" fill="none">
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
viewBox="0 0 32 32"
|
||||||
|
class="w-5 h-5"
|
||||||
|
fill="none"
|
||||||
|
>
|
||||||
<mask
|
<mask
|
||||||
id="mask0_87_7796"
|
id="mask0_87_7796"
|
||||||
style="mask-type:alpha"
|
style="mask-type:alpha"
|
||||||
@ -366,6 +385,7 @@
|
|||||||
</DropdownMenu.SubContent>
|
</DropdownMenu.SubContent>
|
||||||
</DropdownMenu.Sub>
|
</DropdownMenu.Sub>
|
||||||
{/if}
|
{/if}
|
||||||
|
{/if}
|
||||||
</DropdownMenu.Content>
|
</DropdownMenu.Content>
|
||||||
</div>
|
</div>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
|
@ -11,6 +11,10 @@
|
|||||||
label: $i18n.t('Vision'),
|
label: $i18n.t('Vision'),
|
||||||
description: $i18n.t('Model accepts image inputs')
|
description: $i18n.t('Model accepts image inputs')
|
||||||
},
|
},
|
||||||
|
file_upload: {
|
||||||
|
label: $i18n.t('File Upload'),
|
||||||
|
description: $i18n.t('Model accepts file inputs')
|
||||||
|
},
|
||||||
web_search: {
|
web_search: {
|
||||||
label: $i18n.t('Web Search'),
|
label: $i18n.t('Web Search'),
|
||||||
description: $i18n.t('Model can search the web for information')
|
description: $i18n.t('Model can search the web for information')
|
||||||
@ -37,6 +41,7 @@
|
|||||||
|
|
||||||
export let capabilities: {
|
export let capabilities: {
|
||||||
vision?: boolean;
|
vision?: boolean;
|
||||||
|
file_upload?: boolean;
|
||||||
web_search?: boolean;
|
web_search?: boolean;
|
||||||
image_generation?: boolean;
|
image_generation?: boolean;
|
||||||
code_interpreter?: boolean;
|
code_interpreter?: boolean;
|
||||||
|
@ -77,6 +77,7 @@
|
|||||||
};
|
};
|
||||||
let capabilities = {
|
let capabilities = {
|
||||||
vision: true,
|
vision: true,
|
||||||
|
file_upload: true,
|
||||||
web_search: true,
|
web_search: true,
|
||||||
image_generation: true,
|
image_generation: true,
|
||||||
code_interpreter: true,
|
code_interpreter: true,
|
||||||
|
Loading…
Reference in New Issue
Block a user