Elffuss BraidHub

kikocis/continue public

0e7d07cb2a28 · 1.3 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
22 function onClick() {
23 void ideMessenger.ide.runCommand(command);
24 ideMessenger.post("copyText", { text: command });
25 }
26
27 return (
28 <div className="flex flex-col">
29 <p className="mb-0 mt-4 text-base font-semibold">{title}</p>
30 {hasDownloaded ? (
31 <OllamaCompletedStep text={command} />
32 ) : (
33 <ToolTip place="top" content="Copy into terminal">
34 <StyledActionButton onClick={onClick} className="gap-2">
35 <p className="lines m-0 px-0 py-2 font-mono text-xs">{command}</p>
36 <CommandLineIcon width={16} height={16} />
37 </StyledActionButton>
38 </ToolTip>
39 )}
40 </div>
41 );
42}
43
44export default OllamaModelDownload;