Welcome to the page!
Scroll down to see the navbar follow you...
Some more content...
Keep scrolling...
|
3D CHAT AVATAR |
"gpt-4",
"messages" => [
["role" => "system", "content" => "You are a helpful assistant."],
["role" => "user", "content" => $user_input]
],
"max_tokens" => 150,
];
$headers = [
"Authorization: Bearer " . $api_key,
"Content-Type: application/json"
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
return $result['choices'][0]['message']['content'] ?? "No response from ChatGPT.";
}
if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['user_input'])) {
$user_input = strip_tags($_POST['user_input']);
$chat_output = callChatGPT($user_input);
} else {
$chat_output = "Ask me something!";
}
?>
|
|
|
|