-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathGeminiAPI.js
More file actions
40 lines (29 loc) · 926 Bytes
/
Copy pathGeminiAPI.js
File metadata and controls
40 lines (29 loc) · 926 Bytes
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
function onFormSubmit(e){
var reviewtext = e.namedValues["Describe your Experience "];
var apiKey = "your_api_key";
var apiUrl = "https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent"
var url = apiUrl +"?key="+apiKey;
var headers = {
"Content-Type": "application/json"
};
var requestBody = {
"contents": [
{
"parts": [
{
"text": "Identify the items that the reviewer liked and did not like. Please categorise them in different lists, nicely formatted"+reviewtext
}
]
}
]
};
var options = {
"method": "POST",
"headers": headers,
"payload": JSON.stringify(requestBody)
};
var response = UrlFetchApp.fetch(url,options);
var data = JSON.parse(response.getContentText());
var output = data.candidates[0].content.parts[0].text
Logger.log(output);
}