mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-05-09 06:55:28 +03:00
only show chat link when a genai provider is configured with the chat role
This commit is contained in:
parent
a136dbdb9e
commit
9f57b89296
@ -93,6 +93,14 @@ export default function GeneralSettings({ className }: GeneralSettingsProps) {
|
|||||||
useSWR<ProfilesApiResponse>("profiles");
|
useSWR<ProfilesApiResponse>("profiles");
|
||||||
const logoutUrl = config?.proxy?.logout_url || "/api/logout";
|
const logoutUrl = config?.proxy?.logout_url || "/api/logout";
|
||||||
|
|
||||||
|
const hasChatAgent = useMemo(
|
||||||
|
() =>
|
||||||
|
Object.values(config?.genai ?? {}).some((agent) =>
|
||||||
|
agent?.roles?.includes("chat"),
|
||||||
|
),
|
||||||
|
[config?.genai],
|
||||||
|
);
|
||||||
|
|
||||||
// languages
|
// languages
|
||||||
|
|
||||||
const languages = useMemo(() => {
|
const languages = useMemo(() => {
|
||||||
@ -511,7 +519,7 @@ export default function GeneralSettings({ className }: GeneralSettingsProps) {
|
|||||||
<span>{t("menu.classification")}</span>
|
<span>{t("menu.classification")}</span>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
</Link>
|
</Link>
|
||||||
{config?.genai?.model !== "none" && (
|
{hasChatAgent && (
|
||||||
<Link to="/chat">
|
<Link to="/chat">
|
||||||
<MenuItem
|
<MenuItem
|
||||||
className="flex w-full items-center p-2 text-sm"
|
className="flex w-full items-center p-2 text-sm"
|
||||||
|
|||||||
@ -957,8 +957,9 @@ function ObjectDetailsTab({
|
|||||||
toast.success(
|
toast.success(
|
||||||
t("details.item.toast.success.regenerate", {
|
t("details.item.toast.success.regenerate", {
|
||||||
provider: capitalizeAll(
|
provider: capitalizeAll(
|
||||||
config?.genai.provider.replaceAll("_", " ") ??
|
Object.values(config?.genai ?? {})
|
||||||
t("generativeAI"),
|
.find((agent) => agent?.roles?.includes("descriptions"))
|
||||||
|
?.provider?.replaceAll("_", " ") ?? t("generativeAI"),
|
||||||
),
|
),
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
@ -976,8 +977,9 @@ function ObjectDetailsTab({
|
|||||||
toast.error(
|
toast.error(
|
||||||
t("details.item.toast.error.regenerate", {
|
t("details.item.toast.error.regenerate", {
|
||||||
provider: capitalizeAll(
|
provider: capitalizeAll(
|
||||||
config?.genai.provider.replaceAll("_", " ") ??
|
Object.values(config?.genai ?? {})
|
||||||
t("generativeAI"),
|
.find((agent) => agent?.roles?.includes("descriptions"))
|
||||||
|
?.provider?.replaceAll("_", " ") ?? t("generativeAI"),
|
||||||
),
|
),
|
||||||
errorMessage,
|
errorMessage,
|
||||||
}),
|
}),
|
||||||
|
|||||||
@ -28,6 +28,14 @@ export default function useNavigation(
|
|||||||
});
|
});
|
||||||
const isAdmin = useIsAdmin();
|
const isAdmin = useIsAdmin();
|
||||||
|
|
||||||
|
const hasChatAgent = useMemo(
|
||||||
|
() =>
|
||||||
|
Object.values(config?.genai ?? {}).some((agent) =>
|
||||||
|
agent?.roles?.includes("chat"),
|
||||||
|
),
|
||||||
|
[config?.genai],
|
||||||
|
);
|
||||||
|
|
||||||
return useMemo(
|
return useMemo(
|
||||||
() =>
|
() =>
|
||||||
[
|
[
|
||||||
@ -89,9 +97,9 @@ export default function useNavigation(
|
|||||||
icon: MdChat,
|
icon: MdChat,
|
||||||
title: "menu.chat",
|
title: "menu.chat",
|
||||||
url: "/chat",
|
url: "/chat",
|
||||||
enabled: isDesktop && isAdmin && config?.genai?.model !== "none",
|
enabled: isDesktop && isAdmin && hasChatAgent,
|
||||||
},
|
},
|
||||||
] as NavData[],
|
] as NavData[],
|
||||||
[config?.face_recognition?.enabled, config?.genai?.model, variant, isAdmin],
|
[config?.face_recognition?.enabled, hasChatAgent, variant, isAdmin],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -382,6 +382,18 @@ export type AllGroupsStreamingSettings = {
|
|||||||
[groupName: string]: GroupStreamingSettings;
|
[groupName: string]: GroupStreamingSettings;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type GenAIRole = "chat" | "descriptions" | "embeddings";
|
||||||
|
|
||||||
|
export type GenAIAgentConfig = {
|
||||||
|
api_key?: string;
|
||||||
|
base_url?: string;
|
||||||
|
model: string;
|
||||||
|
provider?: string;
|
||||||
|
roles: GenAIRole[];
|
||||||
|
provider_options?: Record<string, unknown>;
|
||||||
|
runtime_options?: Record<string, unknown>;
|
||||||
|
};
|
||||||
|
|
||||||
export interface FrigateConfig {
|
export interface FrigateConfig {
|
||||||
version: string;
|
version: string;
|
||||||
safe_mode: boolean;
|
safe_mode: boolean;
|
||||||
@ -478,12 +490,7 @@ export interface FrigateConfig {
|
|||||||
retry_interval: number;
|
retry_interval: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
genai: {
|
genai: Record<string, GenAIAgentConfig>;
|
||||||
provider: string;
|
|
||||||
base_url?: string;
|
|
||||||
api_key?: string;
|
|
||||||
model: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
go2rtc: {
|
go2rtc: {
|
||||||
streams: Record<string, string | string[]>;
|
streams: Record<string, string | string[]>;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user