Initial commit
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
import {
|
||||
generateSiteMenteSpeech,
|
||||
generateSiteMenteText,
|
||||
type SiteMenteMessage,
|
||||
} from "./geminiClient";
|
||||
|
||||
export type SiteMenteTextRequest = {
|
||||
messages: SiteMenteMessage[];
|
||||
};
|
||||
|
||||
export type SiteMenteTextResponse = {
|
||||
reply: string;
|
||||
};
|
||||
|
||||
export type SiteMenteVoiceRequest = {
|
||||
transcript: string;
|
||||
};
|
||||
|
||||
export type SiteMenteVoiceResponse = {
|
||||
reply: string;
|
||||
audio: {
|
||||
data: string;
|
||||
mimeType: string;
|
||||
};
|
||||
};
|
||||
|
||||
const SYSTEM_PROMPT = [
|
||||
"You are SiteMente, an AI site strategist that helps business owners make their websites think like a smart assistant.",
|
||||
"You deeply understand landing pages, funnels, customer psychology, and automation.",
|
||||
"You recommend specific AI Minds, suggest copy and UX changes, and ask focused clarifying questions before proposing changes.",
|
||||
"Keep answers concise, practical, and business-oriented.",
|
||||
].join(" ");
|
||||
|
||||
const withSystemPrompt = (messages: SiteMenteMessage[]) => {
|
||||
return [{ role: "system", content: SYSTEM_PROMPT }, ...messages];
|
||||
};
|
||||
|
||||
export const runSiteMenteText = async (
|
||||
request: SiteMenteTextRequest
|
||||
): Promise<SiteMenteTextResponse> => {
|
||||
const reply = await generateSiteMenteText(withSystemPrompt(request.messages));
|
||||
return { reply };
|
||||
};
|
||||
|
||||
export const runSiteMenteVoiceTurn = async (
|
||||
request: SiteMenteVoiceRequest
|
||||
): Promise<SiteMenteVoiceResponse> => {
|
||||
const messages: SiteMenteMessage[] = [
|
||||
{ role: "user", content: request.transcript },
|
||||
];
|
||||
const reply = await generateSiteMenteText(withSystemPrompt(messages));
|
||||
const audio = await generateSiteMenteSpeech(reply);
|
||||
|
||||
return {
|
||||
reply,
|
||||
audio: {
|
||||
data: Buffer.from(audio.audioBytes).toString("base64"),
|
||||
mimeType: audio.mimeType,
|
||||
},
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user