Mehdi commited on
Commit
d07e2ca
·
verified ·
1 Parent(s): cdd31f9

Upload pages/api/chat.js with huggingface_hub

Browse files
Files changed (1) hide show
  1. pages/api/chat.js +15 -0
pages/api/chat.js ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export default function handler(req, res) {
2
+ if (req.method === 'POST') {
3
+ const { message, language } = req.body
4
+
5
+ // In a real app, this would call your AI model
6
+ const response = language === 'fa'
7
+ ? `پاسخ به: "${message}"\n\nمن یک مدل هوش مصنوعی هستم که می‌توانم در برنامه‌نویسی به شما کمک کنم. لطفاً سوال دقیق‌تری بپرسید.`
8
+ : `Response to: "${message}"\n\nI'm an AI model that can help with programming. Please ask a more specific question.`
9
+
10
+ res.status(200).json({ response })
11
+ } else {
12
+ res.setHeader('Allow', ['POST'])
13
+ res.status(405).end(`Method ${req.method} Not Allowed`)
14
+ }
15
+ }