-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
42 lines (35 loc) · 1.2 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
require ("chatgpt.php");
$ai = new ChatGPT;
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>OpenAI Api integration</title>
</head>
<body>
<pre>
<?php
// Text Generation
// $chats = [
// ["role" => "system", "content" => "You are a helpful assistant." ],
// ["role" => "user", "content" => "Who won the world series in 2020?" ],
// ["role" => "assistant", "content" => "The Los Angeles Dodgers won the World Series in 2020." ],
// ["role" => "user", "content" => "Where was it played?" ]
// ];
// $chat = 'who is Tristan White?';
// echo "<p>".$ai->textGeneration($chat)->choices[0]->message->content."</p>";
// echo "<p>".$ai->textGeneration($chats)->choices[0]->message->content."</p>";
// Image Generation
// $image = $ai->imageGeneration('Draw Tristan White as a magnificent robot');
// echo '<img src="'.$image->data[0]->url.'" alt="'.$image->data[0]->revised_prompt.'">';
// Text to Speech
// $path = "audio.mp3";
// $ai->textToSpeech('Who is Tristan White?',$path);
// echo '<audio autoplay controls><source src="'.$path.'" type="audio/mpeg"></audio>';
?>
</pre>
</body>
</html>