Skip to content

Commit

Permalink
Update Summarize the thread so far to flag threads as confidential
Browse files Browse the repository at this point in the history
 update summarize to respect confidentiality
update to use gpt-4o model
  • Loading branch information
wiz0floyd authored Jun 6, 2024
1 parent 90c5277 commit 1465cbc
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Parsers/Summarize the thread so far.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,25 @@ flags:gmi
var style = findWordAfterDashDash(current.text);

var chats = [];
var nda = false;
var chatGr = new GlideRecord('x_snc_pointsthing_chat');
chatGr.addEncodedQuery('thread_ts=' + thread_ts + '^ORts=' + thread_ts + '^textNOT LIKE!catchmeup^textNOT LIKE!summary^textNOT LIKE!catchup');
chatGr.orderBy('sys_created_on');
chatGr.query();
while (chatGr.next()){
var chat = chatGr.getDisplayValue('user') + ': ' + chatGr.getValue('text');
if (chat.indexOf('!nda') > -1 || chat.indexOf('!confidential') > -1) {
nda = true;
break;
}
chats.push(chat);
}

if(nda){
new x_snc_slackerbot.Slacker().send_chat(current, "This thread has been marked confidential and can not be summarized.", false);
return;
}

var prompt = current.text.replace(/!chatgpt/gmi, "").trim().substring(0, 1000);
var chatReq = new sn_ws.RESTMessageV2();
chatReq.setEndpoint('https://api.openai.com/v1/chat/completions');
Expand All @@ -39,7 +49,7 @@ flags:gmi
chatReq.setRequestHeader('User-Agent', "ServiceNow");
chatReq.setRequestHeader("Accept", "*/*");
var body = {
"model": "gpt-3.5-turbo",
"model": "gpt-4o",
"messages": [{"role": "user", "content": "summarize the following conversation" + style + ". You cannot ask for follow-up responses. Ignore the user named Slackbot.\n\n" + chats.join("\n")}],
// "max_tokens": 250
};
Expand Down

0 comments on commit 1465cbc

Please sign in to comment.