Skip to content

Commit 520db0a

Browse files
committed
style: manual fixes
1 parent f1a0d3f commit 520db0a

17 files changed

Lines changed: 82 additions & 78 deletions

File tree

ai/autosummarize/gemini.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,16 @@ const SERVICE_ACCOUNT_KEY = scriptPropertyWithDefault("service_account_key");
3737
*
3838
* @param {string} prompt The prompt to senb to Vertex AI API.
3939
* @param {string} options.temperature The temperature setting set by user.
40-
* @param {string} options.tokens The number of tokens to limit to the prompt.
40+
* @param {string} options.maxOutputTokens The number of tokens to limit to the prompt.
4141
*/
4242
function getAiSummary(parts, options = {}) {
43-
options = Object.assign(
44-
{},
45-
{ temperature: 0.1, tokens: 8192 },
46-
options ?? {},
47-
);
43+
const defaultOptions = {
44+
temperature: 0.1,
45+
maxOutputTokens: 8192,
46+
topK: 1,
47+
topP: 1,
48+
stopSequences: [],
49+
};
4850
const request = {
4951
contents: [
5052
{
@@ -53,11 +55,8 @@ function getAiSummary(parts, options = {}) {
5355
},
5456
],
5557
generationConfig: {
56-
temperature: options.temperature,
57-
topK: 1,
58-
topP: 1,
59-
maxOutputTokens: options.tokens,
60-
stopSequences: [],
58+
...defaultOptions,
59+
...options,
6160
},
6261
};
6362

ai/autosummarize/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ function removeAllSummaries() {
5959
const spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
6060
const allSheets = spreadsheet.getSheets();
6161

62-
allSheets.forEach((sheet) => {
62+
for (const sheet of allSheets) {
6363
const sheetName = sheet.getName();
6464
// Check if the sheet name starts with "AutoSummarize AI"
6565
if (sheetName.startsWith("AutoSummarize AI")) {
6666
spreadsheet.deleteSheet(sheet);
6767
}
68-
});
68+
}
6969
}
7070

7171
/**

ai/custom-func-ai-agent/Code.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17+
DEFAULT_OUTPUT_FORMAT =
18+
"Summarize it. Only keep the verdict result and main arguments. " +
19+
"Do not reiterate the fact being checked. Remove all markdown. " +
20+
"State the verdit result in a first paragraph in a few words and " +
21+
"the rest of the summary in a second paragraph.";
22+
1723
/**
1824
* Passes a statement to fact-check and, optionally, output formatting instructions.
1925
*
@@ -25,14 +31,7 @@ limitations under the License.
2531
* @return The generated and formatted verdict
2632
* @customfunction
2733
*/
28-
function FACT_CHECK(statement, outputFormat) {
29-
if (!outputFormat || outputFormat === "") {
30-
outputFormat =
31-
"Summarize it. Only keep the verdict result and main arguments. " +
32-
"Do not reiterate the fact being checked. Remove all markdown. " +
33-
"State the verdit result in a first paragraph in a few words and the rest of the summary in a second paragraph.";
34-
}
35-
34+
function FACT_CHECK(statement, outputFormat = DEFAULT_OUTPUT_FORMAT) {
3635
return requestOutputFormatting(
3736
`Here is a fact checking result: ${requestLlmAuditorAdkAiAgent(statement)}.\n\n${outputFormat}`,
3837
);

ai/custom-func-ai-studio/Code.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,5 @@ limitations under the License.
2323
* @customfunction
2424
*/
2525
function gemini(range, prompt) {
26-
prompt = `For the range of cells ${range}, ${prompt}`;
27-
return getAiSummary(prompt);
26+
return getAiSummary(`For the range of cells ${range}, ${prompt}`);
2827
}

ai/custom_func_vertex/Code.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* @customfunction
88
*/
99
function gemini(range, prompt) {
10-
prompt = `For the table of data: ${range}, Answer the following: ${prompt}. Do not use formatting. Remove all markdown.`;
11-
return getAiSummary(prompt);
10+
return getAiSummary(
11+
`For the table of data: ${range} Answer the following: ${prompt}. Do not use formatting. Remove all markdown.`,
12+
);
1213
}

ai/drive-rename/ui.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@ function buildSelectionPage(e) {
8484

8585
// Create an object of items
8686
const items = [];
87-
aiResponse.names.forEach((name) => {
87+
for (const name of aiResponse.names) {
8888
items.push({
8989
text: name,
9090
value: name,
9191
selected: false,
9292
});
93-
});
93+
}
9494

9595
// Set first item as selected
9696
items[0].selected = true;

ai/standup-chat-app/db.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class DB {
6464
*/
6565
get last() {
6666
const lastRow = this.sheet.getLastRow();
67-
if (lastRow === 0) return;
67+
if (lastRow === 0) return undefined;
6868
return JSON.parse(this.sheet.getSheetValues(lastRow, 1, 1, 2)[0][1]);
6969
}
7070

solutions/add-on/share-macro/UI.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,11 @@ function onClickFunction_(e) {
257257
.setOnClickAction(CardService.newAction().setFunctionName("onHomepage")),
258258
);
259259

260-
return (builder = CardService.newCardBuilder()
260+
const builder = CardService.newCardBuilder()
261261
.setHeader(cardHeader)
262262
.addSection(sectionBody1)
263263
.addSection(sectionBody2)
264-
.setFixedFooter(cardFooter)
265-
.build());
264+
.setFixedFooter(cardFooter);
265+
266+
return builder.build();
266267
}

solutions/automations/aggregate-document-content/Code.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,12 @@ function getContent(body) {
129129
let searchResult = null;
130130

131131
// Gets and loops through all paragraphs that match the style of APP_STYLE.
132-
while ((searchResult = body.findElement(searchType, searchResult))) {
132+
while (true) {
133+
searchResult = body.findElement(searchType, searchResult);
134+
if (!searchResult) {
135+
break;
136+
}
137+
133138
const par = searchResult.getElement().asParagraph();
134139
if (par.getHeading() === searchHeading) {
135140
// If heading style matches, searches for text string (case insensitive).

solutions/automations/calendar-timesheet/Code.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,15 @@ const getSettings = () => {
7171

7272
// find any calendars that were removed
7373
const unavailebleCalendars = [];
74-
savedCalendarSettings.forEach((savedCalendarSetting) => {
74+
for (const savedCalendarSetting of savedCalendarSettings) {
7575
if (
7676
!availableCalendars.find(
7777
(availableCalendar) => availableCalendar.id === savedCalendarSetting.id,
7878
)
7979
) {
8080
unavailebleCalendars.push(savedCalendarSetting);
8181
}
82-
});
82+
}
8383

8484
// map the current settings to the available calendars
8585
const calendarSettings = availableCalendars.map((availableCalendar) => {

0 commit comments

Comments
 (0)