-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCode.gs
29 lines (24 loc) · 929 Bytes
/
Code.gs
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
function main() {
var text = readDocument();
Logger.log("document read");
var formattedText = processText(text);
replaceText(formattedText);
}
function readDocument() {
var doc = DocumentApp.getActiveDocument();
var body = doc.getBody();
var text = body.getText();
return text;
}
function processText(text) {
// var prompt = "You are a helpful assistent.";
var prompt = "You are an assistant that will take the user's input and rewrite it in 'fancy legal talk'. \nFor example if the user says: 'do not copy this.' The assistant would say: 'Under any circumstances external party's may not copy or reproduce this'\n The assistant will also make it as long as possible"
var formattedText = callOpenAI(text, prompt);
return formattedText;
}
function replaceText(formattedText) {
var doc = DocumentApp.getActiveDocument();
var body = doc.getBody();
body.clear();
body.setText(formattedText);
}