Skip to content

chore: remove the gptscript packaged binary #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@ To use this module, you need to have Node.js installed on your system. Then, you
npm install @gptscript-ai/gptscript
```

This will install the gptscript binary in the `node_modules/@gptscript-ai/gptscript/bin` directory.

You can opt out of this behavior by setting the `NODE_GPTSCRIPT_SKIP_INSTALL_BINARY=true` environment variable before
running `npm install`.
In order to use the SDK, you also need the `gptscript` CLI installed. To direct `node-gptscript` to use a specific
binary, you can set the `GPTSCRIPT_BIN` environment variable to the path of the binary. Otherwise, `node-gptscript` will
use what is on your `PATH`.

## Usage

To use the module and run gptscripts, you need to first set the `OPENAI_API_KEY` environment variable to your OpenAI API
key. You can also set the `GPTSCRIPT_BIN` environment variable to change the execution of the gptscripts.
key.

To ensure it is working properly, you can run the following command:

Expand Down
1 change: 0 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
"gptscript": "bin/gptscript"
},
"scripts": {
"pretest": "npm run install-binary",
"install-binary": "node scripts/install-binary.js",
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
"postinstall": "node scripts/install-binary.js",
"clean": "rm -rf dist",
"build": "tsc"
},
Expand Down
130 changes: 0 additions & 130 deletions scripts/install-binary.js

This file was deleted.

8 changes: 5 additions & 3 deletions src/gptscript.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import http from "http"
import path from "path"
import child_process from "child_process"
import {fileURLToPath} from "url"
import net from "net"

export interface GlobalOpts {
Expand Down Expand Up @@ -791,7 +789,11 @@ function getCmdPath(): string {
return process.env.GPTSCRIPT_BIN
}

return path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "bin", "gptscript")
if (process.platform == "win32") {
return "gptscript.exe"
}

return "gptscript"
}

function parseBlocksFromNodes(nodes: any[]): Block[] {
Expand Down