Skip to content

Commit

Permalink
Merge pull request #207 from earlduque/remove-token-cost
Browse files Browse the repository at this point in the history
Update Generate an AI chat.js
  • Loading branch information
earlduque authored Aug 24, 2023
2 parents 67ee1b5 + f8fd45a commit 1453d6d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Parsers/Generate an AI chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ chatReq.setRequestHeader("Accept", "*/*");
var body = {
"model": "gpt-3.5-turbo",
"messages": [{"role": "user", "content": prompt +". You cannot ask for follow-up responses"}],
"max_tokens": 250
// "max_tokens": 250
};
chatReq.setRequestBody(JSON.stringify(body));
var chatResponse = chatReq.execute();
gs.info(chatResponse.getBody());
var chatResponseBody = JSON.parse(chatResponse.getBody());

new x_snc_slackerbot.Slacker().send_chat(current, "> " + prompt.replace(/\n/gmi, ". ") + "\n> tokens: " + chatResponseBody.usage.total_tokens + " ($" + (parseInt(chatResponseBody.usage.total_tokens) * 0.000002).toFixed(6) + ")\n\n" + chatResponseBody.choices[0].message.content, false);
var show_tokens = false;
var token_cost = show_tokens ? "> tokens: " + chatResponseBody.usage.total_tokens + " ($" + (parseInt(chatResponseBody.usage.total_tokens) * 0.000002).toFixed(6) + ")\n" : "";

new x_snc_slackerbot.Slacker().send_chat(current, "> " + prompt.replace(/\n/gmi, ". ") + "\n" + token_cost + "\n" + chatResponseBody.choices[0].message.content, false);

0 comments on commit 1453d6d

Please sign in to comment.