-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtmp.txt
65 lines (57 loc) · 1.77 KB
/
tmp.txt
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
// chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
// var url = tabs[0].url;
// var urlDisplay = document.getElementById("urlDisplay");
// urlDisplay.innerHTML = "Current URL: " + url;
// });
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
var url = tabs[0].url;
var urlDisplay = document.getElementById("urlDisplay");
urlDisplay.innerHTML = "Current URL: " + url;
var apiKey = "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";
var apiUrl = "https://api.openai.com/v1/engines/davinci/jobs";
const data = {
prompt: "Write a short story about a character named John",
max_tokens: 100,
model: "davinci",
temperature: 0.5,
};
const headers = {
"Content-Type": "application/json",
Authorization: "Bearer " + apiKey,
};
fetch(apiUrl, {
method: "post",
headers: headers,
body: JSON.stringify(data),
})
.then(function (response) {
return response.json();
})
.then(function (json) {
console.log(story);
});
// var data = {
// prompt: "summarize the page at " + url,
// max_tokens: 100,
// model: "davinci",
// temperature: 0.5,
// };
// var headers = {
// "Content-Type": "application/json",
// Authorization: "Bearer " + apiKey,
// };
// fetch(apiUrl, {
// method: "post",
// headers: headers,
// body: JSON.stringify(data),
// })
// .then(function (response) {
// return response.json();
// })
// .then(function (json) {
// console.log(json);
// var summary = json.choices[0].text;
// var summaryDisplay = document.getElementById("summaryDisplay");
// summaryDisplay.innerHTML = "Summary: " + summary;
// });
});