diff --git a/web/containers/ModelDropdown/ModelSection.tsx b/web/containers/ModelDropdown/ModelSection.tsx index d4132b6bb7..1270fa44d6 100644 --- a/web/containers/ModelDropdown/ModelSection.tsx +++ b/web/containers/ModelDropdown/ModelSection.tsx @@ -2,12 +2,15 @@ import { useCallback, useEffect, useState } from 'react' import Image from 'next/image' -import { LlmEngine, Model, RemoteEngine } from '@janhq/core' +import { EngineStatus, LlmEngine, Model, RemoteEngine } from '@janhq/core' import { Button } from '@janhq/joi' import { useSetAtom } from 'jotai' import { SettingsIcon } from 'lucide-react' +import { twMerge } from 'tailwind-merge' + +import useEngineQuery from '@/hooks/useEngineQuery' import useGetModelsByEngine from '@/hooks/useGetModelsByEngine' import { getTitleByCategory } from '@/utils/model-engine' @@ -30,6 +33,7 @@ const ModelSection: React.FC = ({ const [models, setModels] = useState([]) const { getModelsByEngine } = useGetModelsByEngine() const setUpRemoteModelStage = useSetAtom(setUpRemoteModelStageAtom) + const { data: engineData } = useEngineQuery() const engineLogo: string | undefined = models.find( (entry) => entry?.metadata?.logo != null @@ -56,43 +60,55 @@ const ModelSection: React.FC = ({ return (
-
- {engineName} -
+
+
+ {engineLogo && ( + logo + )} +
+ {engineName} +
+
+ +
    - {models.map((model) => ( -
  • onModelSelected(model)} - > - {model.metadata?.logo ? ( - logo - ) : ( - !model.engine?.includes('cortex.') && ( -
    - ) - )} -
    -

    {model.name ?? model.model}

    - {!model.engine?.includes('cortex.') && ( - + {models.map((model) => { + const isEngineReady = + engineData?.find((e) => e.name === model.engine)?.status === + EngineStatus.Ready + return ( +
  • - -
  • - ))} + onClick={() => { + if (isEngineReady) { + onModelSelected(model) + } + }} + > +
    +

    {model.name ?? model.model}

    +
    + + + ) + })}
)