'gpt-3.5-turbo', 'messages' => [ [ 'role' => 'system', 'content' => 'You are a helpful Persian-speaking assistant. پاسخ‌ها را به فارسی بده.' ], [ 'role' => 'user', 'content' => $question ] ], 'temperature' => 0.7, 'max_tokens' => 2000 ]; // ارسال درخواست با CURL $ch = curl_init(GAPGPT_API_URL); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_TIMEOUT, 30); $result = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); $curlError = curl_error($ch); curl_close($ch); // بررسی خطاهای CURL if ($curlError) { return '❌ خطا در ارتباط با سرور: ' . $curlError; } // بررسی کد وضعیت HTTP if ($httpCode !== 200) { $errorMsg = json_decode($result, true); $errorDetail = isset($errorMsg['error']['message']) ? $errorMsg['error']['message'] : $result; return '❌ خطا در پاسخ سرور (کد ' . $httpCode . '): ' . $errorDetail; } // پردازش پاسخ $response = json_decode($result, true); if (isset($response['choices'][0]['message']['content'])) { $content = $response['choices'][0]['message']['content']; return nl2br(htmlspecialchars($content)); } else { return '❌ پاسخی از سمت API دریافت نشد.'; } } ?> <?php echo SITE_TITLE; ?>

🤖

پرسش‌های خود را مطرح کنید
💬 گفتگو
👋

سلام! سوال خود را مطرح کنید...

من یک دستیار هوش مصنوعی هستم

⚠️
پاسخ‌ها توسط هوش مصنوعی تولید می‌شوند