This commit is contained in:
Krikorios
2025-07-14 10:14:20 +04:00
parent 890acbd5bc
commit 868c9b252c
21 changed files with 615 additions and 97 deletions
+6 -4
View File
@@ -3,7 +3,8 @@ import UTASChatBot from '@/lib/chatbot';
export async function POST(request: NextRequest) {
try {
const { message } = await request.json();
// Extract message and userContext from the request
const { message, userContext } = await request.json();
if (!message || typeof message !== 'string') {
return NextResponse.json({
@@ -15,14 +16,15 @@ export async function POST(request: NextRequest) {
const apiKey = process.env.OPENROUTER_API_KEY || '';
const chatbot = new UTASChatBot(apiKey);
// Generate AI response using OpenRouter
const response = await chatbot.generateResponse(message);
// Generate AI response using OpenRouter or Ollama, passing userContext
const response = await chatbot.generateResponse(message, userContext);
// Log the interaction for demo purposes
console.log('UTAS Chat:', {
timestamp: new Date().toISOString(),
message: message.substring(0, 100),
response: response.substring(0, 100)
response: response.substring(0, 100),
userRole: userContext?.role || 'anonymous'
});
// Return both message and response for backward compatibility