@@ -29,6 +29,14 @@ npm exec -c "gptscript https://get.gptscript.ai/echo.gpt --input 'Hello, World!'
2929
3030you will see "Hello, World!" in the output of the command.
3131
32+ ## Client
33+
34+ There are currently a couple "global" options, and the client helps to manage those. A client without any options is
35+ likely what you want. However, here are the current global options:
36+
37+ - ` gptscriptURL ` : The URL (including `http(s)://) of an "SDK server" to use instead of the fork/exec model.
38+ - ` gptscriptBin ` : The path to a ` gptscript ` binary to use instead of the bundled one.
39+
3240## Options
3341
3442These are optional options that can be passed to the various ` exec ` functions.
@@ -52,7 +60,8 @@ Lists all the available built-in tools.
5260const gptscript = require (' @gptscript-ai/gptscript' );
5361
5462async function listTools () {
55- const tools = await gptscript .listTools ();
63+ const client = new gptscript.Client ();
64+ const tools = await client .listTools ();
5665 console .log (tools);
5766}
5867```
@@ -69,7 +78,8 @@ const gptscript = require('@gptscript-ai/gptscript');
6978async function listModels () {
7079 let models = [];
7180 try {
72- models = await gptscript .listModels ();
81+ const client = new gptscript.Client ();
82+ models = await client .listModels ();
7383 } catch (error) {
7484 console .error (error);
7585 }
@@ -87,7 +97,8 @@ const gptscript = require('@gptscript-ai/gptscript');
8797
8898async function version () {
8999 try {
90- console .log (await gptscript .version ());
100+ const client = new gptscript.Client ();
101+ console .log (await client .version ());
91102 } catch (error) {
92103 console .error (error);
93104 }
@@ -107,7 +118,8 @@ const t = {
107118};
108119
109120try {
110- const run = gptscript .evaluate (t);
121+ const client = new gptscript.Client ();
122+ const run = client .evaluate (t);
111123 console .log (await run .text ());
112124} catch (error) {
113125 console .error (error);
@@ -128,7 +140,8 @@ const opts = {
128140
129141async function execFile () {
130142 try {
131- const run = gptscript .run (' ./hello.gpt' , opts);
143+ const client = new gptscript.Client ();
144+ const run = client .run (' ./hello.gpt' , opts);
132145 console .log (await run .text ());
133146 } catch (e) {
134147 console .error (e);
@@ -165,10 +178,11 @@ const opts = {
165178
166179async function streamExecFileWithEvents () {
167180 try {
168- const run = gptscript .run (' ./test.gpt' , opts);
181+ const client = new gptscript.Client ();
182+ const run = client .run (' ./test.gpt' , opts);
169183
170184 run .on (gptscript .RunEventType .Event , data => {
171- console .log (` event: ${ data} ` );
185+ console .log (` event: ${ JSON . stringify ( data) } ` );
172186 });
173187
174188 await run .text ();
@@ -203,7 +217,8 @@ const t = {
203217};
204218
205219async function streamExecFileWithEvents () {
206- let run = gptscript .evaluate (t, opts);
220+ const client = new gptscript.Client ();
221+ let run = client .evaluate (t, opts);
207222 try {
208223 // Wait for the initial run to complete.
209224 await run .text ();
0 commit comments