diff --git a/extensions/model-extension/package.json b/extensions/model-extension/package.json index e99122bcf..ef43ecadf 100644 --- a/extensions/model-extension/package.json +++ b/extensions/model-extension/package.json @@ -1,6 +1,6 @@ { "name": "@janhq/model-extension", - "version": "1.0.25", + "version": "1.0.27", "description": "Model Management Extension provides model exploration and seamless downloads", "main": "dist/index.js", "module": "dist/module.js", diff --git a/web/containers/DropdownListSidebar/index.tsx b/web/containers/DropdownListSidebar/index.tsx index 2940fbdbe..c05d26e51 100644 --- a/web/containers/DropdownListSidebar/index.tsx +++ b/web/containers/DropdownListSidebar/index.tsx @@ -139,16 +139,11 @@ const DropdownListSidebar = ({ // Update model parameter to the thread file if (model) - updateModelParameter( - activeThread.id, - { - params: modelParams, - modelId: model.id, - engine: model.engine, - }, - // Overwrite the existing model parameter - true - ) + updateModelParameter(activeThread.id, { + params: modelParams, + modelId: model.id, + engine: model.engine, + }) } }, [ diff --git a/web/hooks/useUpdateModelParameters.ts b/web/hooks/useUpdateModelParameters.ts index 99663229b..694394cee 100644 --- a/web/hooks/useUpdateModelParameters.ts +++ b/web/hooks/useUpdateModelParameters.ts @@ -37,8 +37,7 @@ export default function useUpdateModelParameters() { const updateModelParameter = async ( threadId: string, - settings: UpdateModelParameter, - overwrite: boolean = false + settings: UpdateModelParameter ) => { const thread = threads.find((thread) => thread.id === threadId) if (!thread) { @@ -67,14 +66,8 @@ export default function useUpdateModelParameters() { const runtimeParams = toRuntimeParams(updatedModelParams) const settingParams = toSettingParams(updatedModelParams) - assistant.model.parameters = { - ...(overwrite ? {} : assistant.model.parameters), - ...runtimeParams, - } - assistant.model.settings = { - ...(overwrite ? {} : assistant.model.settings), - ...settingParams, - } + assistant.model.parameters = runtimeParams + assistant.model.settings = settingParams if (selectedModel) { assistant.model.id = settings.modelId ?? selectedModel?.id assistant.model.engine = settings.engine ?? selectedModel?.engine diff --git a/web/screens/Chat/ChatInput/index.tsx b/web/screens/Chat/ChatInput/index.tsx index a7985a59c..c90a12cd2 100644 --- a/web/screens/Chat/ChatInput/index.tsx +++ b/web/screens/Chat/ChatInput/index.tsx @@ -53,10 +53,10 @@ const ChatInput: React.FC = () => { const activeThreadId = useAtomValue(getActiveThreadIdAtom) const [isWaitingToSend, setIsWaitingToSend] = useAtom(waitingToSendMessage) const [fileUpload, setFileUpload] = useAtom(fileUploadAtom) + const [showAttacmentMenus, setShowAttacmentMenus] = useState(false) const textareaRef = useRef(null) const fileInputRef = useRef(null) const imageInputRef = useRef(null) - const [showAttacmentMenus, setShowAttacmentMenus] = useState(false) const experimentalFeature = useAtomValue(experimentalFeatureEnabledAtom) const isGeneratingResponse = useAtomValue(isGeneratingResponseAtom) const threadStates = useAtomValue(threadStatesAtom) @@ -165,7 +165,8 @@ const ChatInput: React.FC = () => { if ( fileUpload.length > 0 || (activeThread?.assistants[0].tools && - !activeThread?.assistants[0].tools[0]?.enabled) + !activeThread?.assistants[0].tools[0]?.enabled && + !activeThread?.assistants[0].model.settings.vision_model) ) { e.stopPropagation() } else { @@ -177,12 +178,13 @@ const ChatInput: React.FC = () => { {fileUpload.length > 0 || (activeThread?.assistants[0].tools && - !activeThread?.assistants[0].tools[0]?.enabled && ( + !activeThread?.assistants[0].tools[0]?.enabled && + !activeThread?.assistants[0].model.settings.vision_model && ( {fileUpload.length !== 0 && ( Currently, we only support 1 attachment at the same - time + time. )} {activeThread?.assistants[0].tools && @@ -190,7 +192,7 @@ const ChatInput: React.FC = () => { false && ( Turn on Retrieval in Assistant Settings to use this - feature + feature. )} @@ -206,46 +208,86 @@ const ChatInput: React.FC = () => { className="absolute bottom-10 right-0 z-30 w-36 cursor-pointer rounded-lg border border-border bg-background py-1 shadow" >
    -
  • { - if (activeThread?.assistants[0].model.settings.vision_model) { - imageInputRef.current?.click() - setShowAttacmentMenus(false) - } - }} - > - - Image -
  • -
  • + +
  • { + if ( + activeThread?.assistants[0].model.settings.vision_model + ) { + imageInputRef.current?.click() + setShowAttacmentMenus(false) + } + }} + > + + Image +
  • + + + {!activeThread?.assistants[0].model.settings.vision_model && ( + + This feature only supports multimodal models. + + + )} + + + + +
  • { + if ( + !activeThread?.assistants[0].model.settings + .vision_model || + activeThread?.assistants[0].model.settings + .text_model !== false + ) { + fileInputRef.current?.click() + setShowAttacmentMenus(false) + } + }} + > + + Document +
  • +
    + + {(!activeThread?.assistants[0].tools || + !activeThread?.assistants[0].tools[0]?.enabled || activeThread?.assistants[0].model.settings.text_model === - false - ? 'cursor-not-allowed opacity-50' - : 'cursor-pointer' - )} - onClick={() => { - if ( - !activeThread?.assistants[0].model.settings.vision_model || - activeThread?.assistants[0].model.settings.text_model !== - false - ) { - fileInputRef.current?.click() - setShowAttacmentMenus(false) - } - }} - > - - Document - + false) && ( + + {activeThread?.assistants[0].model.settings.text_model === + false ? ( + + This model does not support text-based retrieval. + + ) : ( + + Turn on Retrieval in Assistant Settings to use this + feature. + + )} + + + )} + +
)} diff --git a/web/screens/Chat/index.tsx b/web/screens/Chat/index.tsx index 4f441ac45..85fd5332c 100644 --- a/web/screens/Chat/index.tsx +++ b/web/screens/Chat/index.tsx @@ -90,8 +90,9 @@ const ChatScreen: React.FC = () => { if (!experimentalFeature) return if ( e.dataTransfer.items.length === 1 && - activeThread?.assistants[0].tools && - activeThread?.assistants[0].tools[0]?.enabled + ((activeThread?.assistants[0].tools && + activeThread?.assistants[0].tools[0]?.enabled) || + activeThread?.assistants[0].model.settings.vision_model) ) { setDragOver(true) } else if ( @@ -112,7 +113,8 @@ const ChatScreen: React.FC = () => { files.length !== 1 || rejectFiles.length !== 0 || (activeThread?.assistants[0].tools && - !activeThread?.assistants[0].tools[0]?.enabled) + !activeThread?.assistants[0].tools[0]?.enabled && + !activeThread?.assistants[0].model.settings.vision_model) ) return const imageType = files[0]?.type.includes('image') diff --git a/web/utils/modelParam.ts b/web/utils/modelParam.ts index 4b9fe84ae..a6d144c3e 100644 --- a/web/utils/modelParam.ts +++ b/web/utils/modelParam.ts @@ -42,6 +42,8 @@ export const toSettingParams = ( prompt_template: undefined, llama_model_path: undefined, mmproj: undefined, + vision_model: undefined, + text_model: undefined, } const settingParams: ModelSettingParams = {}