mirror of
https://github.com/R0m1k3/Socialflow.git
synced 2026-10-21 22:18:12 +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
@@ -6,6 +6,7 @@ import {
|
||||
scheduledPosts,
|
||||
aiGenerations,
|
||||
cloudinaryConfig,
|
||||
openrouterConfig,
|
||||
type User,
|
||||
type InsertUser,
|
||||
type SocialPage,
|
||||
@@ -20,6 +21,8 @@ import {
|
||||
type InsertAiGeneration,
|
||||
type CloudinaryConfig,
|
||||
type InsertCloudinaryConfig,
|
||||
type OpenrouterConfig,
|
||||
type InsertOpenrouterConfig,
|
||||
} from "@shared/schema";
|
||||
import { db } from "./db";
|
||||
import { eq, and, gte, lte, desc, isNull } from "drizzle-orm";
|
||||
@@ -66,6 +69,11 @@ export interface IStorage {
|
||||
getCloudinaryConfig(userId: string): Promise<CloudinaryConfig | undefined>;
|
||||
createCloudinaryConfig(config: InsertCloudinaryConfig): Promise<CloudinaryConfig>;
|
||||
updateCloudinaryConfig(userId: string, config: Partial<InsertCloudinaryConfig>): Promise<CloudinaryConfig>;
|
||||
|
||||
// OpenRouter Config
|
||||
getOpenrouterConfig(userId: string): Promise<OpenrouterConfig | undefined>;
|
||||
createOpenrouterConfig(config: InsertOpenrouterConfig): Promise<OpenrouterConfig>;
|
||||
updateOpenrouterConfig(userId: string, config: Partial<InsertOpenrouterConfig>): Promise<OpenrouterConfig>;
|
||||
}
|
||||
|
||||
export class DatabaseStorage implements IStorage {
|
||||
@@ -235,6 +243,25 @@ export class DatabaseStorage implements IStorage {
|
||||
.returning();
|
||||
return updated;
|
||||
}
|
||||
|
||||
// OpenRouter Config
|
||||
async getOpenrouterConfig(userId: string): Promise<OpenrouterConfig | undefined> {
|
||||
const [config] = await db.select().from(openrouterConfig).where(eq(openrouterConfig.userId, userId));
|
||||
return config || undefined;
|
||||
}
|
||||
|
||||
async createOpenrouterConfig(config: InsertOpenrouterConfig): Promise<OpenrouterConfig> {
|
||||
const [newConfig] = await db.insert(openrouterConfig).values(config).returning();
|
||||
return newConfig;
|
||||
}
|
||||
|
||||
async updateOpenrouterConfig(userId: string, config: Partial<InsertOpenrouterConfig>): Promise<OpenrouterConfig> {
|
||||
const [updated] = await db.update(openrouterConfig)
|
||||
.set({ ...config, updatedAt: new Date() })
|
||||
.where(eq(openrouterConfig.userId, userId))
|
||||
.returning();
|
||||
return updated;
|
||||
}
|
||||
}
|
||||
|
||||
export const storage = new DatabaseStorage();
|
||||
Reference in new issue
Block a user