Skip to content

Conversation

cloudnautique
Copy link
Collaborator

Adds breaking change to the APIs to require Tool or FreeFrom tool objects.
Bumps versions of gptscript
Upgrade gptscript binary

README.md Outdated
try {
const { stdout, stderr, promise } = await gptScript.streamExec(prompt, opts);
const { stdout, stderr, promise } = await gptscript.streamExec(prompt, opts);
if (stdout) {
Copy link
Contributor

@vincent99 vincent99 Mar 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are stdout and stderr not set sometimes? Or if they always are, why are these wrapped in an if()? The StreamExecResult type says they're always set.

src/gptscript.js Outdated
Comment on lines 68 to 78
async function version() {
try {
const version = await run(['--version']);
return version;
} catch (error) {
throw error;
}
}
Copy link
Contributor

@vincent99 vincent99 Mar 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is all just

function version() {
  return run(['--version'])
}

but with extra steps…

async function foo() { return await bar() } is the same as function foo() { return bar() }. run() already returns a promise, just return that. You're making a 2nd promise (via async) that does nothing but waits for the first one.

And try { stuff() } catch (e) { throw e } is the same as just stuff(). You're catching what was already thrown and then just rethrowing it. Don't try/catch unless you're 1) going to do something with the error or 2) want the function to continue instead of throwing and terminating.

One or both of these can also be applied to various other functions below.

Comment on lines 120 to 122
downloadAndExtract(url, outputDir)
.then(() => console.log('Download and extraction completed.'))
.catch((error) => console.error('Error downloading and extracting:', error));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try/await/catch instead of mixing in old-school promises?

Adds breaking change to the APIs to require Tool or FreeFrom tool
objects.
Bumps versions of gptscript
Upgrade gptscript binary

Signed-off-by: Bill Maxwell <[email protected]>
@cloudnautique cloudnautique merged commit 64f3f85 into gptscript-ai:main Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants