Skip to content

Commit

Permalink
fix(docs): readme (#33)
Browse files Browse the repository at this point in the history
Signed-off-by: Tomas Pilar <tomas.pilar@ibm.com>
  • Loading branch information
pilartomas authored Mar 14, 2024
1 parent 83d5b48 commit ced7044
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 56 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
node-version: [18.x, 20.x]

steps:
- uses: actions/checkout@v3
Expand All @@ -28,7 +28,7 @@ jobs:

strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
node-version: [18.x, 20.x]

steps:
- uses: actions/checkout@v3
Expand Down
61 changes: 13 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
This is not the [watsonx.ai](https://www.ibm.com/products/watsonx-ai) CLI. This is the CLI for the Tech Preview program for IBM Foundation Models Studio.
You can start a trial version or request a demo via https://www.ibm.com/products/watsonx-ai.

This project provides convenient access to the Generative AI API from the command line. For a full description of the API, please visit the [Generative AI API Documentation](https://workbench.res.ibm.com/docs/api-reference).

![demo](./assets/img/demo.gif)
This project provides convenient access to the Generative AI API from the command line. For a full description of the API, please visit the [Generative AI API Documentation](https://bam.res.ibm.com/docs/api-reference).

_Are you looking for an SDK?<br>
If so, check out the [NodeJS SDK](https://github.com/IBM/ibm-generative-ai-node-sdk) and [Python SDK](https://github.com/IBM/ibm-generative-ai)._
Expand Down Expand Up @@ -73,51 +71,18 @@ genai --profile joe config

All the commands executed with `--profile joe` argument will use that configuration (and default as a fallback).

## Usage
## Commands

```bash
# Run single generate request:
genai generate "Once upon a time there lived a rabbit"
# " called Edward. He lived well because he had some things to eat. He had a wife called Daisy"

# Run multiple generate requests from a file:
# "Best Christmas gift for dad: "
# "Best Christmas gift for mum: "
# "Best Christmas gift for dog: "
genai generate -f inputs.txt
# "a new wallet"
# "a day out"
# "a bone"

# Run tokenize request:
genai tokenize "This is a future."
# {"token_count":5,"tokens":["This", "is", "a", "future", "."]}

# Retrieve generate config
genai generate config
# model_id: google/flan-ul2,
# parameters:
# max_new_tokens: 1,
# decoding_method: greedy
#

# Update generate config
genai generate config -m google/flan-ul2 --decoding-method greedy --max-new-tokens 5 --min-new-tokens 1

# Enter interactive mode
genai generate interactive

# List models
genai models list
# google/flan-t5-xxl
# google/flan-ul2
# ...

# Show model details
genai models info google/flan-ul2
# id: google/flan-ul2
# name: flan-ul2 (20B)
# size: 20B
# description: >-
# flan-ul2 (20B) is an encoder decoder model ...
$ genai --help
genai <command>

Commands:
genai config Manage CLI configuration
genai text Text generation, tokenization and chat services
genai model Available models
genai file Upload, download and manage files
genai request Request history (for the past 30 days)
genai tune Train and manage tuned models
genai completion Generate completion script
```
Binary file removed assets/img/demo.gif
Binary file not shown.
4 changes: 3 additions & 1 deletion src/commands/text/generation/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ export const createCommandDefinition = [
async (args) => {
const inlineInputs = args.inputs;
const inputs =
inlineInputs ?? (await readJSONStream(stdin)).map(parseInput);
inlineInputs.length > 0
? inlineInputs
: (await readJSONStream(stdin)).map(parseInput);

const { model, parameters, allowErrors } = args;
const promises = inputs.map((input) =>
Expand Down
11 changes: 6 additions & 5 deletions src/commands/text/tokenization/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ export const createCommandDefinition = [
.middleware(clientMiddleware)
.positional("inputs", {
describe: "Text serving as an input for the generation",
array: true,
conflicts: "input",
type: "array",
})
.options(
groupOptions(
Expand Down Expand Up @@ -48,10 +47,12 @@ export const createCommandDefinition = [
async (args) => {
const inlineInputs = args.inputs;
const inputs =
inlineInputs ?? (await readJSONStream(stdin)).map(parseInput);
inlineInputs.length > 0
? inlineInputs
: (await readJSONStream(stdin)).map(parseInput);

const { model, tokens, inputText } = args;
const { results } = await args.client.text.tokenization.create(
const output = await args.client.text.tokenization.create(
{
model_id: model,
input: inputs,
Expand All @@ -66,6 +67,6 @@ export const createCommandDefinition = [
signal: args.timeout,
}
);
args.print(results);
args.print(output);
},
];

0 comments on commit ced7044

Please sign in to comment.