From e2c482f81c7d5da2bd377131302ad0dc57b9dd9b Mon Sep 17 00:00:00 2001 From: Tomas Dvorak Date: Thu, 12 Oct 2023 19:41:55 +0200 Subject: [PATCH 1/3] chore: update general texts Signed-off-by: Tomas Dvorak --- README.md | 11 ++++++----- package.json | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index cd9652e..0bbd78f 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,14 @@ -
+# IBM Generative AI Node.js SDK (Tech Preview) -# IBM Generative AI Node.js SDK +This is not the [watsonx.ai](https://www.ibm.com/products/watsonx-ai) Node.js SDK. This is the Node.js SDK for the Tech Preview program for IBM Foundation Models Studio. This SDK brings IBM Generative AI (GenAI) into Node.js programs and provides useful operations and types. -This library provides convenient access to the Generative AI API from Node.js applications. For a full description of the API, please visit the [Generative AI API Docs](https://workbench.res.ibm.com/docs/api-reference). +You can start a trial version or request a demo via https://www.ibm.com/products/watsonx-ai. -The SDK supports both TypeScript and JavaScript as well as ESM and CommonJS. +This library provides convenient access to the Generative AI API from Node.js applications. For a full description of the API, please visit the [Tech Preview API Documentation](https://workbench.res.ibm.com/docs/api-reference). -
+The SDK supports both TypeScript and JavaScript as well as ESM and CommonJS. +> Looking for the [watsonx.ai](https://www.ibm.com/products/watsonx-ai) Python SDK? Check out the [documentation](https://ibm.github.io/watson-machine-learning-sdk/foundation_models.html). > Looking for the Python version? Check out [IBM Generative AI Python SDK](https://github.com/IBM/ibm-generative-ai). > Looking for a command-line interface? Check out [IBM Generative AI CLI](https://github.com/IBM/ibm-generative-ai-cli). diff --git a/package.json b/package.json index 960d76c..77635d9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@ibm-generative-ai/node-sdk", "version": "1.4.3", - "description": "Node.js SDK for IBM Generative AI API", + "description": "IBM Generative AI Python SDK (Tech Preview)", "keywords": [ "ai", "generative", From f2eac9bb3f57afe83d23d37eaf571c6f4a9e9ec6 Mon Sep 17 00:00:00 2001 From: Tomas Dvorak Date: Thu, 12 Oct 2023 19:54:13 +0200 Subject: [PATCH 2/3] chore: update examples Signed-off-by: Tomas Dvorak --- README.md | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 0bbd78f..590a69e 100644 --- a/README.md +++ b/README.md @@ -65,13 +65,29 @@ import { Client } from '@ibm-generative-ai/node-sdk'; const client = new Client({ apiKey: 'pak-.....' }); // Single input -const output = await client.generate(singleInput); +const input = { + model_id: 'google/flan-ul2', + input: 'What is the capital of the United Kingdom?', + parameters: { + decoding_method: 'greedy', + min_new_tokens: 1, + max_new_tokens: 10, + }, +}; +const output = await client.generate(input); // Multiple inputs, processed in parallel, all resolving at once -const outputs = await Promise.all(client.generate(multipleInputs)); +const inputs = [ + { + input: 'What is the capital of the United Kingdom?', + model_id: 'google/flan-ul2', + }, + { input: 'What is the capital of the Mexico?', model_id: 'google/flan-ul2' }, +]; +const outputs = await Promise.all(client.generate(inputs)); // Multiple inputs, processed in parallel, resolving in the order of respective inputs -for (const outputPromise of client.generate(multipleInputs)) { +for (const outputPromise of client.generate(inputs)) { try { console.log(await outputPromise); } catch (err) { @@ -80,13 +96,13 @@ for (const outputPromise of client.generate(multipleInputs)) { } // Single input using callbacks -client.generate(singleInput, (err, output) => { +client.generate(input, (err, output) => { if (err) console.error(err); else console.log(output); }); // Multiple inputs using callbacks, processed in parallel, called in the order of respective inputs -client.generate(multipleInputs, (err, output) => { +client.generate(inputs, (err, output) => { if (err) console.error(err); else console.log(output); }); @@ -95,8 +111,13 @@ client.generate(multipleInputs, (err, output) => { ### Streams ```typescript +const input = { + model_id: 'google/flan-ul2', + input: 'What is the capital of the United Kingdom?', +}; + // Streaming (callback style) -client.generate(singleInput, { stream: true }, (err, output) => { +client.generate(input, { stream: true }, (err, output) => { if (err) { console.error(err); } else if (output === null) { @@ -110,7 +131,7 @@ client.generate(singleInput, { stream: true }, (err, output) => { }); // Streaming (async iterators) -const stream = client.generate(singleInput, { +const stream = client.generate(input, { stream: true, }); for await (const chunk of stream) { @@ -121,7 +142,7 @@ for await (const chunk of stream) { } // Streaming (built-in stream methods) -const stream = client.generate(singleInput, { +const stream = client.generate(input, { stream: true, }); stream.on('data', (chunk) => { From 529254952b35311fdcf0e320e5acab666b593696 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Dvo=C5=99=C3=A1k?= Date: Fri, 13 Oct 2023 13:26:14 +0200 Subject: [PATCH 3/3] Update package.json Co-authored-by: Tomas Pilar --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 77635d9..b6f550b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@ibm-generative-ai/node-sdk", "version": "1.4.3", - "description": "IBM Generative AI Python SDK (Tech Preview)", + "description": "IBM Generative AI Node.js SDK (Tech Preview)", "keywords": [ "ai", "generative",