mirror of
https://github.com/R0m1k3/Socialflow.git
synced 2026-10-18 20:56:54 +02:00
Add ability to configure and select AI models for text generation
Implement OpenRouter API integration for AI-powered text generation, allowing users to configure API keys, select models, and define system prompts for customized content creation. Replit-Commit-Author: Agent Replit-Commit-Session-Id: ae4037a0-2a6f-4530-9bac-79b543286bda Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/397bca8c-984f-43ff-841a-10897aeb8140/ae4037a0-2a6f-4530-9bac-79b543286bda/HPCBgsr
This commit is contained in:
1 parent
d63f776af0
commit
68ed90b0c9
6 files changed
+219
-39
No files matched your search
@@ -37,6 +37,16 @@ export const cloudinaryConfig = pgTable("cloudinary_config", {
|
||||
updatedAt: timestamp("updated_at").defaultNow(),
|
||||
});
|
||||
|
||||
export const openrouterConfig = pgTable("openrouter_config", {
|
||||
id: varchar("id").primaryKey().default(sql`gen_random_uuid()`),
|
||||
userId: varchar("user_id").notNull().unique().references(() => users.id, { onDelete: "cascade" }),
|
||||
apiKey: text("api_key").notNull(),
|
||||
model: text("model").notNull().default("anthropic/claude-3.5-sonnet"),
|
||||
systemPrompt: text("system_prompt").notNull().default("Tu es un expert en marketing des réseaux sociaux. Génère 3 variations de textes engageants pour des publications Facebook et Instagram à partir des informations produit fournies. Chaque variation doit être unique, captivante et optimisée pour l'engagement."),
|
||||
createdAt: timestamp("created_at").defaultNow(),
|
||||
updatedAt: timestamp("updated_at").defaultNow(),
|
||||
});
|
||||
|
||||
export const media = pgTable("media", {
|
||||
id: varchar("id").primaryKey().default(sql`gen_random_uuid()`),
|
||||
userId: varchar("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
|
||||
@@ -96,6 +106,7 @@ export const usersRelations = relations(users, ({ many, one }) => ({
|
||||
posts: many(posts),
|
||||
aiGenerations: many(aiGenerations),
|
||||
cloudinaryConfig: one(cloudinaryConfig),
|
||||
openrouterConfig: one(openrouterConfig),
|
||||
}));
|
||||
|
||||
export const cloudinaryConfigRelations = relations(cloudinaryConfig, ({ one }) => ({
|
||||
@@ -105,6 +116,13 @@ export const cloudinaryConfigRelations = relations(cloudinaryConfig, ({ one }) =
|
||||
}),
|
||||
}));
|
||||
|
||||
export const openrouterConfigRelations = relations(openrouterConfig, ({ one }) => ({
|
||||
user: one(users, {
|
||||
fields: [openrouterConfig.userId],
|
||||
references: [users.id],
|
||||
}),
|
||||
}));
|
||||
|
||||
export const socialPagesRelations = relations(socialPages, ({ one, many }) => ({
|
||||
user: one(users, {
|
||||
fields: [socialPages.userId],
|
||||
@@ -199,6 +217,12 @@ export const insertCloudinaryConfigSchema = createInsertSchema(cloudinaryConfig)
|
||||
updatedAt: true,
|
||||
});
|
||||
|
||||
export const insertOpenrouterConfigSchema = createInsertSchema(openrouterConfig).omit({
|
||||
id: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
});
|
||||
|
||||
// Types
|
||||
export type User = typeof users.$inferSelect;
|
||||
export type InsertUser = z.infer<typeof insertUserSchema>;
|
||||
@@ -220,3 +244,6 @@ export type InsertAiGeneration = z.infer<typeof insertAiGenerationSchema>;
|
||||
|
||||
export type CloudinaryConfig = typeof cloudinaryConfig.$inferSelect;
|
||||
export type InsertCloudinaryConfig = z.infer<typeof insertCloudinaryConfigSchema>;
|
||||
|
||||
export type OpenrouterConfig = typeof openrouterConfig.$inferSelect;
|
||||
export type InsertOpenrouterConfig = z.infer<typeof insertOpenrouterConfigSchema>;
|
||||
Reference in new issue
Block a user