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 6.0.1 to 7.0.1

55

aicat.js

@@ -6,3 +6,3 @@ #!/usr/bin/env node

import askChat from './askchat.js'
import {textOut, getDefinitions} from './fns.js'
import {fileOut, getDefinitions} from './fns.js'

@@ -17,3 +17,5 @@ const OPENAI_API_KEY = process.env.OPENAI_API_KEY;

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")
console.error("but when it finishes streaming it will write the correct text to stdout.\
\
")

@@ -39,27 +41,34 @@ let inputText = "";

let function_call
const sysinfo = `
const sysinfo = `You are an advanced AI software engineer.
You MUSST call fileOut() to output requested info.
IMPORTANT: Do not output any explanatory text. Just use fileOut one or more times and then call done() when finished.`
You are an advaned AI software engineer, taking the place of the Linux cat command.
You MUST Use the stdOut() function with the {out} parameter.
Output ONLY what is requested, with no extra example files.
DO NOT include a filename header since there is only one file being output.
`
let allowed = { name: 'fileOut' }
const note = `output raw text only: `
let msgs = [{role:'system', content: sysinfo,
role:'user', content: inputText}]
do {
let result = await askChat(msgs, getDefinitions(), model, allowed)
function_call = result.function_call
try {
if (!function_call) break
if (!function_call.arguments) break
let cleaned = function_call.arguments.replace(/[\x00-\x1F]+/g, '');
console.error()
cleaned = JSON.parse(cleaned)
if (function_call && function_call.name == 'fileOut') {
await fileOut(cleaned)
msgs.push({role: 'assistant', function_call, content: null })
msgs.push({role: 'function', name: 'fileOut', content: 'File saved. Call done() if finished outputting files.'})
allowed = 'auto'
} else {
break
}
} catch (e) {
console.error(e)
}
} while (function_call && function_call.name != 'done')
let {function_call} = await askChat([{role:'system', content: sysinfo,
role:'user', content: inputText}], getDefinitions(), model)
try {
let cleaned = function_call.arguments.replace(/[\x00-\x1F]+/g, '');
console.error()
textOut(JSON.parse(cleaned))
} catch (e) {
console.error(e)
console.log(function_call.arguments)
}

@@ -17,6 +17,5 @@ import { OpenAI } from "openai-streams/node"

async function askChat(messages, functions=null, model='gpt-3.5-turbo-16k') {
const cfg = { model, messages,
async function askChat(messages, functions=null, model='gpt-3.5-turbo-16k', allowed='auto') {
const cfg = { model, messages, function_call: allowed,
temperature: 0.0, n: 1,
function_call: { name: 'textOut' },
presence_penalty: 0.6 }

@@ -53,3 +52,2 @@ if (functions) cfg.functions = functions

}
return {content, function_call}

@@ -56,0 +54,0 @@ } catch (e) {

@@ -1,3 +0,5 @@

export function textOut({stdout}) {
process.stdout.write(stdout + '\n')
import fs from 'fs/promises'
export async function fileOut({filename, text}) {
await fs.writeFile(filename, text, 'utf8')
}

@@ -7,14 +9,26 @@

return [
{
"name": "textOut",
"description": "Outputs ONLY the text requested according to the context and instructions given, with ZERO explanation or external filenames etc.",
{
"name": "done",
"description": "Indicates all files have been output.",
"parameters": {
"type": "object",
"properties": {}
}
},
{
"name": "fileOut",
"description": "Outputs the text to the specified file.",
"parameters": {
"type": "object",
"properties": {
"stdout": {
"properties": {
"filename": {
"type": "string",
"description": "The output text as a JSON-encoded string.",
"description": "The relative filename.",
},
"text": {
"type": "string",
"description": "The file contents.",
},
},
"required": ["stdout"],
"required": ["filename", "text"],
},

@@ -21,0 +35,0 @@ }

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

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

@@ -5,4 +5,6 @@ Ask ChatGPT using some files as part of the instructions.

Then this is sent to OpenAI as a completion and the response is streamed to sdout.
## Breaking change
Then this is sent to OpenAI as a completion and the response is sent to stdout or to the file(s) specified by ChatGPT.
# Install

@@ -9,0 +11,0 @@

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