feat: implement local audio streaming with controls in voice components
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { parentPort } from "node:worker_threads";
|
||||
import { initializeDatabase } from "../database/drizzle";
|
||||
import { buildConversationPromptMessages } from "./conversationContext";
|
||||
import { runModerationAnalysis } from "./llmModerationClient";
|
||||
import {
|
||||
@@ -9,6 +10,8 @@ import type { MessageRecord } from "./types";
|
||||
|
||||
const MAX_CONTEXT_TOKENS = 8000;
|
||||
|
||||
let dbInitialized = false;
|
||||
|
||||
interface AnalysisWorkerRequest {
|
||||
conversationKey: string;
|
||||
messages: MessageRecord[];
|
||||
@@ -32,6 +35,10 @@ async function processAnalysisRequest({
|
||||
messages,
|
||||
}: AnalysisWorkerRequest): Promise<AnalysisWorkerResponse> {
|
||||
try {
|
||||
if (!dbInitialized) {
|
||||
await initializeDatabase();
|
||||
dbInitialized = true;
|
||||
}
|
||||
const firstMessage = messages[0];
|
||||
if (!firstMessage) return { ok: true, conversationKey, rows: [] };
|
||||
|
||||
|
||||
@@ -218,6 +218,7 @@ export async function startWebserver(
|
||||
app.use(express.json());
|
||||
|
||||
app.use(express.static(path.join(__dirname, "../public")));
|
||||
app.use(express.static(path.join(__dirname, "../public/app")));
|
||||
|
||||
app.get("/", (_req: Request, res: Response) => {
|
||||
const reactIndex = path.join(__dirname, "../public/app/index.html");
|
||||
|
||||
Reference in New Issue
Block a user