Elffuss BraidHub

kikocis/continue public

86e71fea71da · 1.5 KiBRawPermalink
1import { CommandLineIcon } from "@heroicons/react/24/outline";
2import { useContext } from "react";
3import { StyledActionButton } from "../..";
4import { IdeMessengerContext } from "../../../context/IdeMessenger";
5import { ToolTip } from "../../gui/Tooltip";
6import OllamaCompletedStep from "./OllamaCompletedStep";
7
8interface OllamaModelDownloadProps {
9 title: string;
10 modelName: string;
11 hasDownloaded: boolean;
12}
13
14function OllamaModelDownload({
15 title,
16 modelName,
17 hasDownloaded,
18}: OllamaModelDownloadProps) {
19 const ideMessenger = useContext(IdeMessengerContext);
20 const command = `ollama pull ${modelName}`;
21 const id = `info-hover-${encodeURIComponent(command)}`;
22
23 function onClick() {
24 void ideMessenger.ide.runCommand(command);
25 ideMessenger.post("copyText", { text: command });
26 }
27
28 return (
29 <div className="flex flex-col">
30 <p className="mb-0 mt-4 text-base font-semibold">{title}</p>
31 {hasDownloaded ? (
32 <OllamaCompletedStep text={command} />
33 ) : (
34 <>
35 <StyledActionButton
36 data-tooltip-id={id}
37 onClick={onClick}
38 className="gap-2"
39 >
40 <p className="lines m-0 px-0 py-2 font-mono text-xs">{command}</p>
41 <CommandLineIcon width={16} height={16} />
42 </StyledActionButton>
43
44 <ToolTip id={id} place="top">
45 Copy into terminal
46 </ToolTip>
47 </>
48 )}
49 </div>
50 );
51}
52
53export default OllamaModelDownload;