Skip to content

Commit

Permalink
fix: janhq#995 - Fix onboarding state and model sorting (janhq#1009)
Browse files Browse the repository at this point in the history
* fix: janhq#995 - Fix onboarding state and model sorting

* fix: typo
  • Loading branch information
louis-jan authored Dec 14, 2023
1 parent 137bc0e commit cb3055c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
2 changes: 1 addition & 1 deletion core/src/types/model/modelEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export type ModelInfo = {
* @stored
*/

enum InferenceEngine {
export enum InferenceEngine {
nitro = 'nitro',
openai = 'openai',
triton_trtllm = 'triton_trtllm',
Expand Down
11 changes: 9 additions & 2 deletions web/containers/DropdownListSidebar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect, useState } from 'react'

import { Model } from '@janhq/core'
import { InferenceEngine, Model } from '@janhq/core'
import {
Button,
Select,
Expand Down Expand Up @@ -41,7 +41,14 @@ export default function DropdownListSidebar() {

useEffect(() => {
getDownloadedModels().then((downloadedModels) => {
setDownloadedModels(downloadedModels)
setDownloadedModels(
downloadedModels.sort((a, b) =>
a.engine !== InferenceEngine.nitro &&
b.engine === InferenceEngine.nitro
? 1
: -1
)
)
if (downloadedModels.length > 0) {
setSelected(
downloadedModels.filter(
Expand Down
24 changes: 23 additions & 1 deletion web/screens/Chat/ChatBody/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Fragment } from 'react'

import ScrollToBottom from 'react-scroll-to-bottom'

import { InferenceEngine } from '@janhq/core'
import { Button } from '@janhq/uikit'
import { useAtomValue } from 'jotai'

Expand Down Expand Up @@ -41,6 +42,10 @@ const ChatBody: React.FC = () => {
</div>
)

const showOnboardingStep =
downloadedModels.filter((e) => e.engine === InferenceEngine.nitro)
.length === 0

return (
<Fragment>
{messages.length === 0 ? (
Expand All @@ -50,7 +55,24 @@ const ChatBody: React.FC = () => {
width={56}
height={56}
/>
<p className="mt-1 text-base font-medium">How can I help you?</p>
{showOnboardingStep ? (
<>
<p className="mt-1 text-base font-medium">
{`You don't have a local model yet.`}
</p>
<div className="w-auto px-4 py-2">
<Button
block
className="bg-blue-100 font-bold text-blue-600 hover:bg-blue-100 hover:text-blue-600"
onClick={() => setMainViewState(MainViewState.Hub)}
>
Explore The Hub
</Button>
</div>
</>
) : (
<p className="mt-1 text-base font-medium">How can I help you?</p>
)}
</div>
) : (
<ScrollToBottom className="flex h-full w-full flex-col">
Expand Down

0 comments on commit cb3055c

Please sign in to comment.