mirror of
https://github.com/AeThex-Corporation/AeThex-OS.git
synced 2026-04-21 07:27:20 +00:00
- ModuleManager: Central tracking for installed marketplace modules - DataAnalyzerWidget: Real-time CPU/RAM/Battery/Storage widget (unlocked by Data Analyzer module) - BottomNavBar: Navigation bar for Projects/Chat/Marketplace/Settings - RootShell: Real root command execution utility - TerminalActivity: Full root shell with neofetch, sysinfo, real Linux commands - Terminal Pro module: Adds aliases (ll, la, h), command history - ArcadeActivity + SnakeGame: Pixel Arcade module unlocks retro games - fade_in/fade_out animations for smooth transitions
39 lines
1.3 KiB
TypeScript
39 lines
1.3 KiB
TypeScript
import type { Request, Response } from "express";
|
|
import { GoogleGenAI } from "@google/genai";
|
|
|
|
const GEMINI_API_KEY = process.env.AI_INTEGRATIONS_GEMINI_API_KEY || process.env.GEMINI_API_KEY || "";
|
|
|
|
const ai = GEMINI_API_KEY ? new GoogleGenAI({ apiKey: GEMINI_API_KEY }) : null;
|
|
|
|
export default async function handler(req: Request, res: Response) {
|
|
if (req.method !== "POST") {
|
|
return res.status(405).json({ error: "Method not allowed" });
|
|
}
|
|
|
|
if (!ai) {
|
|
return res.status(503).json({
|
|
error: "AI service not configured",
|
|
message: "Please ensure the Gemini API key is set up."
|
|
});
|
|
}
|
|
|
|
try {
|
|
const { message } = req.body as { message: string };
|
|
|
|
if (!message) {
|
|
return res.status(400).json({ error: "Message is required" });
|
|
}
|
|
|
|
const response = await ai.models.generateContent({
|
|
model: "gemini-2.5-flash",
|
|
contents: `Generate a short, concise, and descriptive title (max 5 words) for a chat conversation that starts with this message: "${message}". Do not use quotes.`,
|
|
});
|
|
|
|
const title = response.text?.trim() || message.slice(0, 30);
|
|
return res.json({ title });
|
|
} catch (error) {
|
|
console.error("[AI] Title generation error:", error);
|
|
const fallbackTitle = (req.body?.message || "").slice(0, 30) + "...";
|
|
return res.json({ title: fallbackTitle });
|
|
}
|
|
}
|