Skip to content

Commit 01ea3b3

Browse files
committed
chores
1 parent d4f07ff commit 01ea3b3

File tree

4 files changed

+61
-49
lines changed

4 files changed

+61
-49
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { cn } from "@hypr/ui/lib/utils";
2+
3+
export const RatingDisplay = (
4+
{ label, rating, maxRating = 3, icon: Icon }: {
5+
label: string;
6+
rating: number;
7+
maxRating?: number;
8+
icon: React.ElementType;
9+
},
10+
) => (
11+
<div className="flex flex-col items-center px-2">
12+
<span className="text-[10px] text-neutral-500 uppercase font-medium tracking-wider mb-1.5">{label}</span>
13+
<div className="flex space-x-1">
14+
{[...Array(maxRating)].map((_, i) => (
15+
<Icon
16+
key={i}
17+
className={cn(
18+
"w-3.5 h-3.5",
19+
i < rating ? "text-black fill-current" : "text-neutral-300",
20+
)}
21+
strokeWidth={i < rating ? 0 : 1.5}
22+
/>
23+
))}
24+
</div>
25+
</div>
26+
);
27+
28+
export const LanguageDisplay = ({ support }: { support: "multilingual" | "english-only" }) => {
29+
return (
30+
<div className="flex flex-col items-center px-2">
31+
<span className="text-[10px] text-neutral-500 uppercase font-medium tracking-wider mb-1.5">
32+
Language
33+
</span>
34+
<div className="text-xs font-medium">
35+
{support === "multilingual" ? "Multilingual" : "English Only"}
36+
</div>
37+
</div>
38+
);
39+
};

apps/desktop/src/components/settings/components/ai/stt-view.tsx

Lines changed: 7 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1+
import { Trans } from "@lingui/react/macro";
2+
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
3+
import { BrainIcon, DownloadIcon, Zap as SpeedIcon } from "lucide-react";
4+
import { useState } from "react";
5+
import { toast } from "sonner";
6+
17
import { showSttModelDownloadToast } from "@/components/toast/shared";
28
import { commands as localSttCommands, SupportedModel } from "@hypr/plugin-local-stt";
39
import { Button } from "@hypr/ui/components/ui/button";
410
import { Label } from "@hypr/ui/components/ui/label";
511
import { RadioGroup, RadioGroupItem } from "@hypr/ui/components/ui/radio-group";
612
import { cn } from "@hypr/ui/lib/utils";
7-
import { Trans } from "@lingui/react/macro";
8-
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
9-
import { BrainIcon, DownloadIcon, Zap as SpeedIcon } from "lucide-react";
10-
import { useState } from "react";
11-
import { toast } from "sonner";
13+
import { LanguageDisplay, RatingDisplay } from "./shared";
1214

1315
export const sttModelMetadata: Record<SupportedModel, {
1416
name: string;
@@ -100,44 +102,6 @@ export const sttModelMetadata: Record<SupportedModel, {
100102
},
101103
};
102104

103-
export const RatingDisplay = (
104-
{ label, rating, maxRating = 3, icon: Icon }: {
105-
label: string;
106-
rating: number;
107-
maxRating?: number;
108-
icon: React.ElementType;
109-
},
110-
) => (
111-
<div className="flex flex-col items-center px-2">
112-
<span className="text-[10px] text-neutral-500 uppercase font-medium tracking-wider mb-1.5">{label}</span>
113-
<div className="flex space-x-1">
114-
{[...Array(maxRating)].map((_, i) => (
115-
<Icon
116-
key={i}
117-
className={cn(
118-
"w-3.5 h-3.5",
119-
i < rating ? "text-black fill-current" : "text-neutral-300",
120-
)}
121-
strokeWidth={i < rating ? 0 : 1.5}
122-
/>
123-
))}
124-
</div>
125-
</div>
126-
);
127-
128-
export const LanguageDisplay = ({ support }: { support: "multilingual" | "english-only" }) => {
129-
return (
130-
<div className="flex flex-col items-center px-2">
131-
<span className="text-[10px] text-neutral-500 uppercase font-medium tracking-wider mb-1.5">
132-
Language
133-
</span>
134-
<div className="text-xs font-medium">
135-
{support === "multilingual" ? "Multilingual" : "English Only"}
136-
</div>
137-
</div>
138-
);
139-
};
140-
141105
export function STTView() {
142106
const queryClient = useQueryClient();
143107
const [downloadingModelName, setDownloadingModelName] = useState<string | null>(null);

apps/desktop/src/components/toast/model-download.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,18 @@ export default function ModelDownloadNotification() {
1212
queryFn: () => localSttCommands.getCurrentModel(),
1313
});
1414

15+
const currentLlmModel = useQuery({
16+
queryKey: ["current-llm-model"],
17+
queryFn: () => localLlmCommands.getCurrentModel(),
18+
});
19+
1520
const checkForModelDownload = useQuery({
1621
enabled: !!currentSttModel.data,
1722
queryKey: ["check-model-downloaded"],
1823
queryFn: async () => {
1924
const [stt, llm] = await Promise.all([
2025
localSttCommands.isModelDownloaded(currentSttModel.data!),
21-
localLlmCommands.isModelDownloaded(),
26+
localLlmCommands.isModelDownloaded(currentLlmModel.data!),
2227
]);
2328

2429
return {
@@ -43,7 +48,7 @@ export default function ModelDownloadNotification() {
4348
enabled: !checkForModelDownload.data?.llmModelDownloaded,
4449
queryKey: ["llm-model-downloading"],
4550
queryFn: async () => {
46-
return localLlmCommands.isModelDownloading();
51+
return localLlmCommands.isModelDownloading(currentLlmModel.data!);
4752
},
4853
refetchInterval: 3000,
4954
});

apps/desktop/src/components/toast/shared.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Channel } from "@tauri-apps/api/core";
22
import { useEffect, useState } from "react";
33

4-
import { commands as localLlmCommands } from "@hypr/plugin-local-llm";
4+
import { commands as localLlmCommands, SupportedModel as SupportedModelLLM } from "@hypr/plugin-local-llm";
55
import { commands as localSttCommands, SupportedModel } from "@hypr/plugin-local-stt";
66
import { commands as windowsCommands } from "@hypr/plugin-windows";
77
import { Button } from "@hypr/ui/components/ui/button";
@@ -81,11 +81,12 @@ export function showSttModelDownloadToast(model: SupportedModel, onComplete?: ()
8181
);
8282
}
8383

84-
export function showLlmModelDownloadToast() {
84+
export function showLlmModelDownloadToast(model?: SupportedModelLLM, onComplete?: () => void) {
8585
const llmChannel = new Channel();
86-
localLlmCommands.downloadModel(llmChannel);
86+
const modelToDownload = model || "Llama3p2_3bQ4";
87+
localLlmCommands.downloadModel(modelToDownload, llmChannel);
8788

88-
const id = "llm-model-download";
89+
const id = `llm-model-download-${modelToDownload}`;
8990

9091
toast(
9192
{
@@ -99,6 +100,9 @@ export function showLlmModelDownloadToast() {
99100
onComplete={() => {
100101
sonnerToast.dismiss(id);
101102
localLlmCommands.startServer();
103+
if (onComplete) {
104+
onComplete();
105+
}
102106
}}
103107
/>
104108
</div>

0 commit comments

Comments
 (0)