feat: add Homarr assistant

This commit is contained in:
ajnart committed 2026-08-13 19:56:10 +02:00
1 parent 3b6de1f91f
commit fd69cd28f0
27 files changed
+5210 -772

No files matched your search

+6
View File
@@ -19,6 +19,9 @@ export const schema = createSchema({
export const {
accounts,
apiKeys,
assistantConfigurations,
assistantMessages,
assistantThreads,
apps,
boardGroupPermissions,
boardUserPermissions,
@@ -58,6 +61,9 @@ export const {
export type User = InferSelectModel<typeof schema.users>;
export type Account = InferSelectModel<typeof schema.accounts>;
export type AssistantConfiguration = InferSelectModel<typeof schema.assistantConfigurations>;
export type AssistantMessage = InferSelectModel<typeof schema.assistantMessages>;
export type AssistantThread = InferSelectModel<typeof schema.assistantThreads>;
export type Session = InferSelectModel<typeof schema.sessions>;
export type VerificationToken = InferSelectModel<typeof schema.verificationTokens>;
export type Integration = InferSelectModel<typeof schema.integrations>;
+38
View File
@@ -481,6 +481,44 @@ export const serverSettings = mysqlTable("serverSetting", {
value: text().default(emptySuperJSON).notNull(),
});
export const assistantConfigurations = mysqlTable("assistant_configuration", {
id: varchar({ length: 64 }).notNull().primaryKey().default("default"),
enabled: boolean().notNull().default(false),
provider: varchar({ length: 32 })
.$type<"openrouter" | "openai" | "ollama" | "lm-studio" | "custom">()
.notNull()
.default("openrouter"),
baseUrl: varchar({ length: 2048 }).notNull().default("https://openrouter.ai/api/v1"),
modelDiscoveryPath: varchar({ length: 512 }).default("/models"),
encryptedApiKey: text().$type<`${string}.${string}`>(),
encryptedHeaders: text().$type<`${string}.${string}`>(),
modelId: varchar({ length: 256 }),
updatedAt: timestamp().notNull().defaultNow(),
});
export const assistantThreads = mysqlTable("assistant_thread", {
id: varchar({ length: 64 }).notNull().primaryKey(),
userId: varchar({ length: 64 })
.notNull()
.references(() => users.id, { onDelete: "cascade" }),
title: varchar({ length: 256 }),
modelId: varchar({ length: 256 }),
status: varchar({ length: 16 }).$type<"regular" | "archived">().notNull().default("regular"),
createdAt: timestamp().notNull().defaultNow(),
updatedAt: timestamp().notNull().defaultNow(),
});
export const assistantMessages = mysqlTable("assistant_message", {
id: varchar({ length: 64 }).notNull().primaryKey(),
threadId: varchar({ length: 64 })
.notNull()
.references(() => assistantThreads.id, { onDelete: "cascade" }),
parentId: varchar({ length: 64 }),
format: varchar({ length: 64 }).notNull().default("ai-sdk/v6"),
content: text().default(emptySuperJSON).notNull(),
createdAt: timestamp().notNull().defaultNow(),
});
export const apiKeyRelations = relations(apiKeys, ({ one }) => ({
user: one(users, {
fields: [apiKeys.userId],
+38
View File
@@ -480,6 +480,44 @@ export const serverSettings = pgTable("serverSetting", {
value: text().default(emptySuperJSON).notNull(),
});
export const assistantConfigurations = pgTable("assistant_configuration", {
id: varchar({ length: 64 }).notNull().primaryKey().default("default"),
enabled: boolean().notNull().default(false),
provider: varchar({ length: 32 })
.$type<"openrouter" | "openai" | "ollama" | "lm-studio" | "custom">()
.notNull()
.default("openrouter"),
baseUrl: varchar({ length: 2048 }).notNull().default("https://openrouter.ai/api/v1"),
modelDiscoveryPath: varchar({ length: 512 }).default("/models"),
encryptedApiKey: text().$type<`${string}.${string}`>(),
encryptedHeaders: text().$type<`${string}.${string}`>(),
modelId: varchar({ length: 256 }),
updatedAt: timestamp().notNull().defaultNow(),
});
export const assistantThreads = pgTable("assistant_thread", {
id: varchar({ length: 64 }).notNull().primaryKey(),
userId: varchar({ length: 64 })
.notNull()
.references(() => users.id, { onDelete: "cascade" }),
title: varchar({ length: 256 }),
modelId: varchar({ length: 256 }),
status: varchar({ length: 16 }).$type<"regular" | "archived">().notNull().default("regular"),
createdAt: timestamp().notNull().defaultNow(),
updatedAt: timestamp().notNull().defaultNow(),
});
export const assistantMessages = pgTable("assistant_message", {
id: varchar({ length: 64 }).notNull().primaryKey(),
threadId: varchar({ length: 64 })
.notNull()
.references(() => assistantThreads.id, { onDelete: "cascade" }),
parentId: varchar({ length: 64 }),
format: varchar({ length: 64 }).notNull().default("ai-sdk/v6"),
content: text().default(emptySuperJSON).notNull(),
createdAt: timestamp().notNull().defaultNow(),
});
export const apiKeyRelations = relations(apiKeys, ({ one }) => ({
user: one(users, {
fields: [apiKeys.userId],
+43
View File
@@ -465,6 +465,49 @@ export const serverSettings = sqliteTable("serverSetting", {
value: text().default(emptySuperJSON).notNull(),
});
export const assistantConfigurations = sqliteTable("assistant_configuration", {
id: text().notNull().primaryKey().default("default"),
enabled: int({ mode: "boolean" }).notNull().default(false),
provider: text().$type<"openrouter" | "openai" | "ollama" | "lm-studio" | "custom">().notNull().default("openrouter"),
baseUrl: text().notNull().default("https://openrouter.ai/api/v1"),
modelDiscoveryPath: text().default("/models"),
encryptedApiKey: text().$type<`${string}.${string}`>(),
encryptedHeaders: text().$type<`${string}.${string}`>(),
modelId: text(),
updatedAt: int({ mode: "timestamp" })
.notNull()
.default(sql`(unixepoch())`),
});
export const assistantThreads = sqliteTable("assistant_thread", {
id: text().notNull().primaryKey(),
userId: text()
.notNull()
.references(() => users.id, { onDelete: "cascade" }),
title: text(),
modelId: text(),
status: text().$type<"regular" | "archived">().notNull().default("regular"),
createdAt: int({ mode: "timestamp" })
.notNull()
.default(sql`(unixepoch())`),
updatedAt: int({ mode: "timestamp" })
.notNull()
.default(sql`(unixepoch())`),
});
export const assistantMessages = sqliteTable("assistant_message", {
id: text().notNull().primaryKey(),
threadId: text()
.notNull()
.references(() => assistantThreads.id, { onDelete: "cascade" }),
parentId: text(),
format: text().notNull().default("ai-sdk/v6"),
content: text().default(emptySuperJSON).notNull(),
createdAt: int({ mode: "timestamp" })
.notNull()
.default(sql`(unixepoch())`),
});
export const apiKeyRelations = relations(apiKeys, ({ one }) => ({
user: one(users, {
fields: [apiKeys.userId],