Skip to content

Commit cb3055c

Browse files
authored
fix: #995 - Fix onboarding state and model sorting (#1009)
* fix: #995 - Fix onboarding state and model sorting * fix: typo
1 parent 137bc0e commit cb3055c

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

core/src/types/model/modelEntity.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export type ModelInfo = {
1414
* @stored
1515
*/
1616

17-
enum InferenceEngine {
17+
export enum InferenceEngine {
1818
nitro = 'nitro',
1919
openai = 'openai',
2020
triton_trtllm = 'triton_trtllm',

web/containers/DropdownListSidebar/index.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useEffect, useState } from 'react'
22

3-
import { Model } from '@janhq/core'
3+
import { InferenceEngine, Model } from '@janhq/core'
44
import {
55
Button,
66
Select,
@@ -41,7 +41,14 @@ export default function DropdownListSidebar() {
4141

4242
useEffect(() => {
4343
getDownloadedModels().then((downloadedModels) => {
44-
setDownloadedModels(downloadedModels)
44+
setDownloadedModels(
45+
downloadedModels.sort((a, b) =>
46+
a.engine !== InferenceEngine.nitro &&
47+
b.engine === InferenceEngine.nitro
48+
? 1
49+
: -1
50+
)
51+
)
4552
if (downloadedModels.length > 0) {
4653
setSelected(
4754
downloadedModels.filter(

web/screens/Chat/ChatBody/index.tsx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Fragment } from 'react'
22

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

5+
import { InferenceEngine } from '@janhq/core'
56
import { Button } from '@janhq/uikit'
67
import { useAtomValue } from 'jotai'
78

@@ -41,6 +42,10 @@ const ChatBody: React.FC = () => {
4142
</div>
4243
)
4344

45+
const showOnboardingStep =
46+
downloadedModels.filter((e) => e.engine === InferenceEngine.nitro)
47+
.length === 0
48+
4449
return (
4550
<Fragment>
4651
{messages.length === 0 ? (
@@ -50,7 +55,24 @@ const ChatBody: React.FC = () => {
5055
width={56}
5156
height={56}
5257
/>
53-
<p className="mt-1 text-base font-medium">How can I help you?</p>
58+
{showOnboardingStep ? (
59+
<>
60+
<p className="mt-1 text-base font-medium">
61+
{`You don't have a local model yet.`}
62+
</p>
63+
<div className="w-auto px-4 py-2">
64+
<Button
65+
block
66+
className="bg-blue-100 font-bold text-blue-600 hover:bg-blue-100 hover:text-blue-600"
67+
onClick={() => setMainViewState(MainViewState.Hub)}
68+
>
69+
Explore The Hub
70+
</Button>
71+
</div>
72+
</>
73+
) : (
74+
<p className="mt-1 text-base font-medium">How can I help you?</p>
75+
)}
5476
</div>
5577
) : (
5678
<ScrollToBottom className="flex h-full w-full flex-col">

0 commit comments

Comments
 (0)