Build fixes: offline-safe fonts, Next.js API route type updates, TS strict errors resolved, MUI import cleanup, chat markdown wrapper, Azure OpenAI typing, caching key + chapter API id types, and misc error-logging typings.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { NextRequest, NextResponse } from 'next/server'
|
||||
import { NextResponse } from 'next/server'
|
||||
import { z } from 'zod'
|
||||
import { PrismaClient, ChatMessageRole } from '@prisma/client'
|
||||
import { searchBibleHybrid, BibleVerse } from '@/lib/vector-search'
|
||||
@@ -21,7 +21,7 @@ const chatRequestSchema = z.object({
|
||||
})).optional().default([])
|
||||
})
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
export async function POST(request: Request) {
|
||||
try {
|
||||
const body = await request.json()
|
||||
const { message, conversationId, locale, history } = chatRequestSchema.parse(body)
|
||||
@@ -40,7 +40,7 @@ export async function POST(request: NextRequest) {
|
||||
console.log('Chat API - userId extracted from token:', userId)
|
||||
} catch (error) {
|
||||
// Continue without authentication for backward compatibility
|
||||
console.log('Chat API - authentication failed:', error.message)
|
||||
console.log('Chat API - authentication failed:', (error as any)?.message || error)
|
||||
}
|
||||
} else {
|
||||
console.log('Chat API - no valid auth header')
|
||||
@@ -335,7 +335,7 @@ function calculateMessageRelevance(message: any, currentMessage: string, locale:
|
||||
const messageWords = msgContent.split(/\s+/)
|
||||
|
||||
for (const word of currentWords) {
|
||||
if (messageWords.some(mWord => mWord.includes(word) || word.includes(mWord))) {
|
||||
if (messageWords.some((mWord: string) => mWord.includes(word) || word.includes(mWord))) {
|
||||
score += 0.2
|
||||
}
|
||||
}
|
||||
@@ -401,7 +401,7 @@ function summarizeMessage(message: any): string {
|
||||
if (content.length <= 100) return content
|
||||
|
||||
// Extract key points and questions
|
||||
const sentences = content.split(/[.!?]+/).filter(s => s.trim().length > 10)
|
||||
const sentences = content.split(/[.!?]+/).filter((s: string) => s.trim().length > 10)
|
||||
if (sentences.length <= 2) return content
|
||||
|
||||
// Keep first and last sentence, or most important parts
|
||||
|
||||
Reference in New Issue
Block a user