“No message provided”]); exit; }
$prompt = “Create 3 short {$style} replies for a {$gender} user. User’s message: {$message}. Provide only replies in a JSON array.”;
$ch = curl_init(“https://api.openai.com/v1/chat/completions”);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
“model”=>”gpt-3.5-turbo”,
“messages”=>[
[“role”=>”system”,”content”=>”You are a helpful assistant.”],
[“role”=>”user”,”content”=>$prompt]
],
“temperature”=>0.8,
“max_tokens”=>200
]));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
“Content-Type: application/json”,
“Authorization: Bearer {$OPENAI_API_KEY}”
]);
$res = curl_exec($ch);
if(curl_errno($ch)){ echo json_encode([‘error’=>curl_error($ch)]); exit; }
curl_close($ch);
$data = json_decode($res,true);
$gpt_text = $data[‘choices’][0][‘message’][‘content’] ?? ”;
$replies = json_decode($gpt_text,true);
if(!is_array($replies)) $replies = array_filter(array_map(‘trim’,explode(“\n”,$gpt_text)));
echo json_encode([‘replies’=>$replies]);
exit;
}
?>
Impress People with Your Replies 😎
Impress People with Your Replies 😎
We’ll generate replies your friends will love ❤️
Mood
Type your message
🔒 Your chat is private
⏳ Generating…