mirror of
https://github.com/kjanat/livedash-node.git
synced 2026-01-16 16:32:08 +01:00
feat: implement cache layer, CSP improvements, and database performance optimizations
- Add Redis cache implementation with LRU eviction - Enhance Content Security Policy with nonce generation - Optimize database queries with connection pooling - Add cache invalidation API endpoints - Improve security monitoring performance
This commit is contained in:
@ -223,7 +223,7 @@ async function retryWithBackoff<T>(
|
||||
operationName: string,
|
||||
maxRetries = BATCH_CONFIG.MAX_RETRIES
|
||||
): Promise<T> {
|
||||
let lastError: Error;
|
||||
let lastError: Error = new Error("Operation failed");
|
||||
|
||||
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
||||
try {
|
||||
@ -411,6 +411,7 @@ export async function getPendingBatchRequests(
|
||||
},
|
||||
processingStatus: AIRequestStatus.PENDING_BATCHING,
|
||||
batchId: null,
|
||||
sessionId: { not: null },
|
||||
},
|
||||
include: {
|
||||
session: {
|
||||
@ -436,7 +437,7 @@ export async function getPendingBatchRequests(
|
||||
content: string;
|
||||
order: number;
|
||||
}>;
|
||||
} | null;
|
||||
};
|
||||
})[]
|
||||
>;
|
||||
}
|
||||
@ -492,7 +493,9 @@ export async function createBatchRequest(
|
||||
messages: [
|
||||
{
|
||||
role: "system",
|
||||
content: getSystemPromptForProcessingType(request.processingType),
|
||||
content: getSystemPromptForProcessingType(
|
||||
request.processingType || "full_analysis"
|
||||
),
|
||||
},
|
||||
{
|
||||
role: "user",
|
||||
@ -1278,6 +1281,14 @@ async function processIndividualRequest(request: {
|
||||
messages: Array<{ role: string; content: string }>;
|
||||
temperature?: number;
|
||||
max_tokens?: number;
|
||||
processingType?: string;
|
||||
session?: {
|
||||
messages: Array<{
|
||||
role: string;
|
||||
content: string;
|
||||
order: number;
|
||||
}>;
|
||||
};
|
||||
}): Promise<{
|
||||
usage: {
|
||||
prompt_tokens: number;
|
||||
@ -1318,7 +1329,9 @@ async function processIndividualRequest(request: {
|
||||
messages: [
|
||||
{
|
||||
role: "system",
|
||||
content: getSystemPromptForProcessingType(request.processingType),
|
||||
content: getSystemPromptForProcessingType(
|
||||
request.processingType || "full_analysis"
|
||||
),
|
||||
},
|
||||
{
|
||||
role: "user",
|
||||
|
||||
Reference in New Issue
Block a user