forked from njerschow/openai-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
38 lines (36 loc) · 946 Bytes
/
index.html
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
<html>
<head>
<!--<script src="https://unpkg.com/tensorfork-openai-api@latest/browser.js"></script>-->
<script src="./browser.js"></script>
<script>
window.api = new OpenAI();
</script>
</head>
<body>
<pre style="max-width: 100vw; word-wrap: break-word; white-space: pre-wrap;" id="output">Hello, my name is</pre>
<script>
fn = (async () => {
const engine = window.engine || (await window.api.list_engines()).data.data[0].id;
window.engine = engine;
const el = document.getElementById('output');
const gptResponse = await window.api.complete({
engine: engine,
prompt: el.innerHTML,
maxTokens: 32,
temperature: 0.6,
frequency_penalty: 0.85,
topP: 1,
n: 1,
stream: false,
//stop: ['\n', "testing"],
echo: true,
});
const text = gptResponse.data.choices[0].text;
console.log(text);
el.innerHTML = text;
fn();
});
fn();
</script>
</body>
</html>