-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Model Info Menu * prettier formatting, slight colour modifications * refine the layout and add more info from knownmodel list --------- Co-authored-by: L❤️ ☮️ ✋ <[email protected]>
- Loading branch information
1 parent
6ee235d
commit 385ba8b
Showing
11 changed files
with
261 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { cn } from "@localai/theme/utils" | ||
import { Button } from "@localai/ui/button" | ||
import { CrossCircledIcon, InfoCircledIcon } from "@radix-ui/react-icons" | ||
|
||
import { useOverlayPopup } from "~features/inference-server/use-overlay-popup" | ||
import { useModel } from "~providers/model" | ||
|
||
export const ModelInfo = () => { | ||
const overlayPopup = useOverlayPopup() | ||
const { knownModelInfo, integrity, checkModel, isChecking } = useModel() | ||
|
||
return ( | ||
<div className="relative text-gray-10"> | ||
<Button | ||
ref={overlayPopup.buttonRef} | ||
disabled={isChecking} | ||
onClick={async () => { | ||
if (!integrity) { | ||
await checkModel() | ||
} | ||
overlayPopup.setIsVisible(true) | ||
}} | ||
className={cn( | ||
"w-6 h-6 p-1 justify-center", | ||
"group-hover:opacity-100 opacity-0 transition-opacity" | ||
)}> | ||
<InfoCircledIcon /> | ||
</Button> | ||
|
||
<div | ||
ref={overlayPopup.popupRef} | ||
className={cn( | ||
"absolute top-0 left-0", | ||
"transition-opacity", | ||
"text-xs sm:text-sm md:text-base", | ||
knownModelInfo ? "w-64 sm:w-64 md:w-96" : "w-36", | ||
overlayPopup.isVisible | ||
? "z-40 opacity-100 pointer-events-auto" | ||
: "z-0 opacity-0 pointer-events-none" | ||
)}> | ||
<div | ||
className={cn( | ||
"bg-gray-4 relative px-5 py-4 rounded-lg border border-gray-6", | ||
"flex-wrap" | ||
)}> | ||
<button | ||
className={cn("absolute left-1 top-1")} | ||
onClick={() => overlayPopup.setIsVisible(false)}> | ||
<CrossCircledIcon /> | ||
</button> | ||
{!knownModelInfo ? ( | ||
<span className="text-xs font-bold">NOT AVAILABLE</span> | ||
) : ( | ||
<div | ||
className={cn( | ||
"gap-2 w-full grid text-xs", | ||
"grid-cols-[2fr_5fr]" | ||
)}> | ||
<label className={cn("font-bold")}>ORIGIN</label> | ||
<code className="text-right break-all"> | ||
{knownModelInfo.downloadUrl.split("/").pop()} | ||
</code> | ||
|
||
<label className={cn("font-bold")}>TYPE</label> | ||
<code className="text-right">{knownModelInfo.modelType}</code> | ||
|
||
<label className={cn("font-bold")}>DESCRIPTION</label> | ||
<code className="text-right whitespace-pre-line"> | ||
{knownModelInfo.description} | ||
</code> | ||
|
||
<label className={cn("font-bold")}>LICENSE</label> | ||
<code className="text-right"> | ||
{knownModelInfo.licenses.join(", ")} | ||
</code> | ||
</div> | ||
)} | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
apps/desktop/src/features/inference-server/use-overlay-popup.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { useEffect, useRef, useState } from "react" | ||
|
||
export const useOverlayPopup = () => { | ||
const [isVisible, setIsVisible] = useState(false) | ||
const popupRef = useRef(null) | ||
const buttonRef = useRef(null) | ||
|
||
const toggle = () => setIsVisible((v) => !v) | ||
|
||
useEffect(() => { | ||
if (!isVisible) return | ||
|
||
const handleDocumentClick = (event: MouseEvent) => { | ||
if ( | ||
!popupRef.current.contains(event.target) && | ||
!buttonRef.current.contains(event.target) | ||
) { | ||
setIsVisible(false) | ||
} | ||
} | ||
|
||
document.addEventListener("click", handleDocumentClick) | ||
|
||
return () => { | ||
document.removeEventListener("click", handleDocumentClick) | ||
} | ||
}, [isVisible]) | ||
|
||
return { | ||
isVisible, | ||
setIsVisible, | ||
toggle, | ||
popupRef, | ||
buttonRef | ||
} | ||
} |
Oops, something went wrong.
385ba8b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
local-ai-web – ./
local-ai-web-louisgv.vercel.app
local-ai-web.vercel.app
aibackpack.app
www.knapsack.ai
localai.app
www.aibackpack.app
www.localai.app
local-ai-web-git-main-louisgv.vercel.app
knapsack.ai