Skip to content

Commit

Permalink
fix: remote model always active badges (janhq#1113)
Browse files Browse the repository at this point in the history
* fix: remote model always active badge and doesn't have menu start and stop model

* fix: remote model condition check

---------

Co-authored-by: Louis <[email protected]>
  • Loading branch information
urmauur and louis-menlo authored Dec 20, 2023
1 parent a485fa9 commit 040987d
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions web/screens/Settings/Models/Row.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState } from 'react'

import { Model } from '@janhq/core'
import { InferenceEngine, Model } from '@janhq/core'
import { Badge } from '@janhq/uikit'

import {
Expand Down Expand Up @@ -33,6 +33,10 @@ export default function RowModel(props: RowModelProps) {

const isActiveModel = stateModel.model === props.data.id

const isRemoteModel =
props.data.engine === InferenceEngine.openai ||
InferenceEngine.triton_trtllm

const onModelActionClick = (modelId: string) => {
if (activeModel && activeModel.id === modelId) {
stopModel(modelId)
Expand All @@ -56,7 +60,15 @@ export default function RowModel(props: RowModelProps) {
<Badge themes="secondary">v{props.data.version}</Badge>
</td>
<td className="px-6 py-4">
{stateModel.loading && stateModel.model === props.data.id ? (
{isRemoteModel ? (
<Badge
themes="success"
className="inline-flex items-center space-x-2"
>
<span className="h-2 w-2 rounded-full bg-green-500" />
<span>Active</span>
</Badge>
) : stateModel.loading && stateModel.model === props.data.id ? (
<Badge
className="inline-flex items-center space-x-2"
themes="secondary"
Expand Down Expand Up @@ -85,15 +97,17 @@ export default function RowModel(props: RowModelProps) {
)}
</td>
<td className="px-6 py-4 text-center">
<div
className="cursor-pointer"
ref={setToggle}
onClick={() => {
setMore(!more)
}}
>
<MoreVerticalIcon className="h-5 w-5" />
</div>
{!isRemoteModel && (
<div
className="cursor-pointer"
ref={setToggle}
onClick={() => {
setMore(!more)
}}
>
<MoreVerticalIcon className="h-5 w-5" />
</div>
)}
{more && (
<div
className="absolute right-4 top-10 z-20 w-52 overflow-hidden rounded-lg border border-border bg-background py-2 shadow-lg"
Expand Down

0 comments on commit 040987d

Please sign in to comment.