feat: promote assistant configuration
This commit is contained in:
1 parent
c0445cdca2
commit
cba2df72e2
13 files changed
+219
-23
No files matched your search
@@ -21,4 +21,13 @@ describe("assistant provider presets", () => {
|
||||
expect(assistantProviderRequiresApiKey(provider)).toBe(assistantProviderPresets[provider].category === "hosted");
|
||||
}
|
||||
});
|
||||
|
||||
test.each(assistantProviderIds.filter((provider) => provider !== "custom"))(
|
||||
"%s has a Dashboard Icons provider mark",
|
||||
(provider) => {
|
||||
const iconUrl = assistantProviderPresets[provider].iconUrl;
|
||||
expect(iconUrl).not.toBeNull();
|
||||
expect(() => new URL(iconUrl ?? "")).not.toThrow();
|
||||
},
|
||||
);
|
||||
});
|
||||
@@ -16,12 +16,15 @@ export const assistantProviderIds = [
|
||||
export type AssistantProvider = (typeof assistantProviderIds)[number];
|
||||
export type AssistantProviderCategory = "hosted" | "local" | "custom";
|
||||
|
||||
const providerIconBaseUrl = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons";
|
||||
|
||||
interface AssistantProviderPreset {
|
||||
baseUrl: string;
|
||||
modelDiscoveryPath: string | null;
|
||||
requiresApiKey: boolean;
|
||||
category: AssistantProviderCategory;
|
||||
discoveryAuthentication: "bearer" | "anthropic";
|
||||
iconUrl: string | null;
|
||||
}
|
||||
|
||||
export const assistantProviderPresets = {
|
||||
@@ -31,6 +34,7 @@ export const assistantProviderPresets = {
|
||||
requiresApiKey: true,
|
||||
category: "hosted",
|
||||
discoveryAuthentication: "bearer",
|
||||
iconUrl: `${providerIconBaseUrl}/openrouter-color.svg`,
|
||||
},
|
||||
openai: {
|
||||
baseUrl: "https://api.openai.com/v1",
|
||||
@@ -38,6 +42,7 @@ export const assistantProviderPresets = {
|
||||
requiresApiKey: true,
|
||||
category: "hosted",
|
||||
discoveryAuthentication: "bearer",
|
||||
iconUrl: `${providerIconBaseUrl}/openai.svg`,
|
||||
},
|
||||
anthropic: {
|
||||
baseUrl: "https://api.anthropic.com/v1",
|
||||
@@ -45,6 +50,7 @@ export const assistantProviderPresets = {
|
||||
requiresApiKey: true,
|
||||
category: "hosted",
|
||||
discoveryAuthentication: "anthropic",
|
||||
iconUrl: `${providerIconBaseUrl}/anthropic.svg`,
|
||||
},
|
||||
"google-gemini": {
|
||||
baseUrl: "https://generativelanguage.googleapis.com/v1beta/openai",
|
||||
@@ -52,6 +58,7 @@ export const assistantProviderPresets = {
|
||||
requiresApiKey: true,
|
||||
category: "hosted",
|
||||
discoveryAuthentication: "bearer",
|
||||
iconUrl: `${providerIconBaseUrl}/gemini-color.svg`,
|
||||
},
|
||||
xai: {
|
||||
baseUrl: "https://api.x.ai/v1",
|
||||
@@ -59,6 +66,7 @@ export const assistantProviderPresets = {
|
||||
requiresApiKey: true,
|
||||
category: "hosted",
|
||||
discoveryAuthentication: "bearer",
|
||||
iconUrl: `${providerIconBaseUrl}/xai.svg`,
|
||||
},
|
||||
groq: {
|
||||
baseUrl: "https://api.groq.com/openai/v1",
|
||||
@@ -66,6 +74,7 @@ export const assistantProviderPresets = {
|
||||
requiresApiKey: true,
|
||||
category: "hosted",
|
||||
discoveryAuthentication: "bearer",
|
||||
iconUrl: `${providerIconBaseUrl}/groq.svg`,
|
||||
},
|
||||
mistral: {
|
||||
baseUrl: "https://api.mistral.ai/v1",
|
||||
@@ -73,6 +82,7 @@ export const assistantProviderPresets = {
|
||||
requiresApiKey: true,
|
||||
category: "hosted",
|
||||
discoveryAuthentication: "bearer",
|
||||
iconUrl: `${providerIconBaseUrl}/mistral-color.svg`,
|
||||
},
|
||||
deepseek: {
|
||||
baseUrl: "https://api.deepseek.com",
|
||||
@@ -80,6 +90,7 @@ export const assistantProviderPresets = {
|
||||
requiresApiKey: true,
|
||||
category: "hosted",
|
||||
discoveryAuthentication: "bearer",
|
||||
iconUrl: `${providerIconBaseUrl}/deepseek-color.svg`,
|
||||
},
|
||||
together: {
|
||||
baseUrl: "https://api.together.xyz/v1",
|
||||
@@ -87,6 +98,7 @@ export const assistantProviderPresets = {
|
||||
requiresApiKey: true,
|
||||
category: "hosted",
|
||||
discoveryAuthentication: "bearer",
|
||||
iconUrl: `${providerIconBaseUrl}/together-color.svg`,
|
||||
},
|
||||
ollama: {
|
||||
baseUrl: "http://localhost:11434/v1",
|
||||
@@ -94,6 +106,7 @@ export const assistantProviderPresets = {
|
||||
requiresApiKey: false,
|
||||
category: "local",
|
||||
discoveryAuthentication: "bearer",
|
||||
iconUrl: `${providerIconBaseUrl}/ollama.svg`,
|
||||
},
|
||||
"lm-studio": {
|
||||
baseUrl: "http://localhost:1234/v1",
|
||||
@@ -101,6 +114,7 @@ export const assistantProviderPresets = {
|
||||
requiresApiKey: false,
|
||||
category: "local",
|
||||
discoveryAuthentication: "bearer",
|
||||
iconUrl: `${providerIconBaseUrl}/lmstudio.svg`,
|
||||
},
|
||||
custom: {
|
||||
baseUrl: "",
|
||||
@@ -108,6 +122,7 @@ export const assistantProviderPresets = {
|
||||
requiresApiKey: false,
|
||||
category: "custom",
|
||||
discoveryAuthentication: "bearer",
|
||||
iconUrl: null,
|
||||
},
|
||||
} as const satisfies Record<AssistantProvider, AssistantProviderPreset>;
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ export const SpotlightGroupActionItem = <TOption extends Record<string, unknown>
|
||||
option,
|
||||
}: SpotlightGroupActionItemProps<TOption>) => {
|
||||
const interaction = group.useInteraction(option, query);
|
||||
const unavailable = "unavailable" in option && option.unavailable === true;
|
||||
// Avoid passing React's special `key` prop via spread
|
||||
|
||||
const { key: _reactKey, ...optionProps } = option as unknown as { key?: unknown } & Record<string, unknown>;
|
||||
@@ -74,6 +75,7 @@ export const SpotlightGroupActionItem = <TOption extends Record<string, unknown>
|
||||
(interaction.type !== "javaScript" || interaction.closeSpotlightOnTrigger !== false)
|
||||
}
|
||||
className={classes.spotlightAction}
|
||||
aria-disabled={unavailable || undefined}
|
||||
>
|
||||
<group.Component {...(optionProps as TOption)} />
|
||||
</Spotlight.Action>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Group, Text } from "@mantine/core";
|
||||
import { Group, Stack, Text } from "@mantine/core";
|
||||
|
||||
import { createGroup } from "../../lib/group";
|
||||
import type { ContextSpecificItem } from "../home/context";
|
||||
@@ -16,9 +16,16 @@ export const contextSpecificActionsSearchGroups = createGroup<ContextSpecificIte
|
||||
);
|
||||
|
||||
return (
|
||||
<Group w="100%" wrap="nowrap" align="center" px="md" py="xs">
|
||||
<Group w="100%" wrap="nowrap" align="center" px="md" py="xs" opacity={option.unavailable ? 0.55 : 1}>
|
||||
{icon}
|
||||
<Text>{option.name}</Text>
|
||||
<Stack gap={0}>
|
||||
<Text>{option.name}</Text>
|
||||
{option.description && (
|
||||
<Text size="xs" c="dimmed">
|
||||
{option.description}
|
||||
</Text>
|
||||
)}
|
||||
</Stack>
|
||||
</Group>
|
||||
);
|
||||
},
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Group, Text } from "@mantine/core";
|
||||
import { Group, Stack, Text } from "@mantine/core";
|
||||
|
||||
import { createGroup } from "../../lib/group";
|
||||
import type { ContextSpecificItem } from "./context";
|
||||
@@ -16,9 +16,16 @@ export const contextSpecificSearchGroups = createGroup<ContextSpecificItem>({
|
||||
);
|
||||
|
||||
return (
|
||||
<Group w="100%" wrap="nowrap" align="center" px="md" py="xs">
|
||||
<Group w="100%" wrap="nowrap" align="center" px="md" py="xs" opacity={option.unavailable ? 0.55 : 1}>
|
||||
{icon}
|
||||
<Text>{option.name}</Text>
|
||||
<Stack gap={0}>
|
||||
<Text>{option.name}</Text>
|
||||
{option.description && (
|
||||
<Text size="xs" c="dimmed">
|
||||
{option.description}
|
||||
</Text>
|
||||
)}
|
||||
</Stack>
|
||||
</Group>
|
||||
);
|
||||
},
|
||||
|
||||
@@ -12,6 +12,8 @@ export type ContextSpecificItem = {
|
||||
icon: TablerIcon | string;
|
||||
interaction: () => inferSearchInteractionDefinition<SearchInteraction>;
|
||||
disabled?: boolean;
|
||||
description?: string;
|
||||
unavailable?: boolean;
|
||||
};
|
||||
|
||||
interface SpotlightContextProps {
|
||||
|
||||
@@ -1984,6 +1984,12 @@
|
||||
"open": "Open Homarr Assistant",
|
||||
"close": "Close assistant",
|
||||
"spotlight": "Ask Homarr Assistant",
|
||||
"spotlightDescription": "Start or continue a conversation with your Homarr instance.",
|
||||
"unavailable": {
|
||||
"checking": "Checking whether the assistant is available…",
|
||||
"notConfigured": "An administrator must configure and enable the assistant first.",
|
||||
"signIn": "Sign in to use Homarr Assistant."
|
||||
},
|
||||
"newConversation": "New conversation",
|
||||
"archivedConversation": "Archived conversation",
|
||||
"conversations": "Conversations",
|
||||
@@ -5578,6 +5584,7 @@
|
||||
"workshop": "Workshop",
|
||||
"searchEngies": "Search engines",
|
||||
"medias": "Medias",
|
||||
"assistant": "Assistant",
|
||||
"users": {
|
||||
"label": "Users",
|
||||
"items": {
|
||||
@@ -5977,7 +5984,7 @@
|
||||
"label": "Enable Homarr Assistant",
|
||||
"description": "Shows the assistant to all signed-in users. Existing Homarr permissions still apply to every internal tool call."
|
||||
},
|
||||
"save": "Save assistant settings",
|
||||
"save": "Save assistant",
|
||||
"notification": {
|
||||
"connectionSaved": {
|
||||
"title": "Provider connection saved",
|
||||
@@ -6884,6 +6891,9 @@
|
||||
"medias": {
|
||||
"label": "Medias"
|
||||
},
|
||||
"assistant": {
|
||||
"label": "Assistant"
|
||||
},
|
||||
"apps": {
|
||||
"label": "Apps",
|
||||
"new": {
|
||||
|
||||
Reference in new issue
Block a user