forked from gimyeongmin/ai-cpt4
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathai.josn
More file actions
84 lines (76 loc) · 2.23 KB
/
Copy pathai.josn
File metadata and controls
84 lines (76 loc) · 2.23 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>GPT-3 Text Generation</title>
</head>
<body>
<h1>GPT-3 Text Generation</h1>
<form>
<label for="prompt">Enter your prompt:</label>
<input type="text" id="prompt" name="prompt">
<br><br>
<button type="submit">Generate Text</button>
</form>
<br>
<div id="generated-text"></div>
</body>
</html><!DOCTYPE html>
<html>
<head>
<title>GPT-3 Example</title>
</head>
<body>
<h1>GPT-3 Output:</h1>
<p id="output"></p>
<script src="https://cdn.jsdelivr.net/npm/openai@2.0.0/dist/openai.min.js"></script>
<script>
const API_KEY = "834d0a00-bc00-4f00-00da-10000e000d0e";
const modelEngine = "text-davinci-002";
const prompt = "What is GPT-3?";
const completion = new openai.Completion(API_KEY);
completion.create(modelEngine, prompt, {
maxTokens: 1024,
n: 1,
stop: null,
temperature: 0.5
}).then(function(result) {
document.querySelector("#output").innerText = result.choices[0].text;
});
</script>
</body>
</html><html>
<head>
<title>AI 연구특허진흥원</title>
</head>
<body>
<h1>GPT-3 Generated Text</h1>
<p id="generated-text">Loading...</p>
<script>
async function generateText() {
// Replace YOUR_API_KEY with your actual API key
const apiKey = "834d0a00-bc00-4f00-00da-10000e000d0e";
const modelEngine = "text-davinci-002";
const prompt = "GPT-3 is";
const response = await fetch(`https://api.openai.com/v1/engines/${modelEngine}/jobs`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${834d0a00-bc00-4f00-00da-10000e000d0e}`
},
body: JSON.stringify({
prompt: prompt,
max_tokens: 1024,
n: 1,
stop: null,
temperature: 0.5
})
});
const json = await response.json();
const message = json.choices[0].text;
document.querySelector("#generated-text").innerHTML = message;
}
generateText();
</script>
</body>
</html>