You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

aicat

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.0.1 to 6.0.1

old/askchat2.js

5

aicat.js

@@ -15,2 +15,5 @@ #!/usr/bin/env node

console.error("Note: The streaming output is on stderr and has some minor issues,")
console.error("but when it finishes streaming it will write the correct text to stdout.\n\n")
let inputText = "";

@@ -51,2 +54,4 @@ let model = 'gpt-3.5-turbo-16k'

let cleaned = function_call.arguments.replace(/[\x00-\x1F]+/g, '');
console.error()
textOut(JSON.parse(cleaned))

@@ -53,0 +58,0 @@ } catch (e) {

35

askchat.js
import { OpenAI } from "openai-streams/node"
function decodeJSON(jsonStr) {
try {
// Try to parse the JSON string
const parsed = JSON.parse(jsonStr);
// If parsing succeeded, stringify the parsed object
// to handle escaped characters and return it as a string
return JSON.stringify(parsed);
} catch (err) {
// If parsing failed, handle escape characters manually and return the string
// Replacing Unicode escape sequences
const replacedUnicode = jsonStr.replace(/\\u([\d\w]{4})/gi, (match, grp) => {
return String.fromCharCode(parseInt(grp, 16));
});
// Replacing other escape sequences
const replacedEscapes = replacedUnicode
function decode(str) {
const replacedEscapes = str
.replace(/\\b/g, '\b')

@@ -28,6 +12,5 @@ .replace(/\\f/g, '\f')

.replace(/\\\"/g, '\"')
.replace(/\\\'/g, '\'');
.replace(/\\\'/g, '\'')
.replace(/\"stdout\"\: \"/g, '')
return replacedEscapes;
}
}

@@ -50,3 +33,3 @@

}
const deltas = chunk.choices[0].delta

@@ -58,4 +41,8 @@ for (const key in deltas) {

function_call[key2] = (function_call[key2] || '') + deltas[key][key2]
//process.stderr.write('' + deltas[key][key2] + '')
process.stderr.write(decodeJSON(deltas[key][key2]))
lastout += deltas[key][key2]
if (decode(lastout).indexOf("\n") >= 0) {
process.stderr.write(decode(lastout))
lastout = ''
}
}

@@ -62,0 +49,0 @@ } else if (key === 'content') {

{
"name": "aicat",
"version": "5.0.1",
"version": "6.0.1",
"description": "",

@@ -5,0 +5,0 @@ "main": "aicat",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc