120240418.0.12 • Published 10 days ago

substrate v120240418.0.12

Weekly downloads
16
License
MIT
Repository
github
Last release
10 days ago

꩜ Substrate TypeScript SDK

NPM version

The Substrate TypeScript SDK is the recommended way to interact with the Substrate API from server-side TypeScript or JavaScript.

Documentation

If you're just getting started, head to guides.substrate.run.

For a detailed API reference covering the nodes available on Substrate, see substrate.run/nodes.

For an interactive reference, check out explore.substrate.run. You can call Substrate.visualize(...nodes...) to generate an interactive visualization of any graph.

Installation

npm install substrate

Usage

import { Substrate, GenerateText, sb } from "substrate";

Initialize the Substrate client.

const substrate = new Substrate({ apiKey: SUBSTRATE_API_KEY });

Generate a story using the GenerateText node.

const story = new GenerateText({ prompt: "tell me a story" });

Summarize the output of the story node using another GenerateText node. Because story has not yet been run, we use sb.interpolate to work with its future output.

const summary = new GenerateText({
  prompt: sb.interpolate`summarize this story in one sentence: ${story.future.text}`,
});

Run the graph chaining storysummary. This is a simple example, but you can easily build arbitrarily complex branching workflows.

const response = await substrate.run(story, summary);

Get the output of the summary node by passing it to response.get.

const summaryOut = response.get(summary);
console.log(summaryOut.text);
// Princess Lily, a kind-hearted young princess, discovers a book of spells and uses it to grant her family and kingdom happiness.
120240418.0.12

10 days ago

120240418.0.11

11 days ago

120240416.0.11

17 days ago

120240416.0.10

22 days ago

120240411.0.10

25 days ago

120240411.0.9

29 days ago

120240403.0.7

1 month ago

120240405.0.9

30 days ago

120240405.0.8

1 month ago

120240405.0.7

1 month ago

120240315.0.5

1 month ago

120240315.0.6

1 month ago

120240315.0.3

1 month ago

120240313.0.1

1 month ago

120240313.0.0

1 month ago

120240313.0.2

1 month ago

9.5.1

6 months ago

9.5.0

6 months ago

9.4.1

7 months ago

9.4.0

10 months ago

9.3.0

10 months ago

9.2.0

2 years ago

9.1.0

2 years ago

9.0.0

2 years ago

8.2.0

2 years ago

8.1.0

2 years ago

8.0.0

2 years ago

7.0.0

3 years ago

6.8.2

3 years ago

6.7.0

3 years ago

6.8.1

3 years ago

6.7.2

3 years ago

6.8.0

3 years ago

6.7.1

3 years ago

6.7.3

3 years ago

6.6.3

3 years ago

6.6.2

3 years ago

6.6.1

3 years ago

6.6.0

3 years ago

6.5.3

3 years ago

6.5.2

3 years ago

6.5.0

3 years ago

6.5.1

3 years ago

6.4.0

3 years ago

6.3.0

3 years ago

6.3.1

3 years ago

6.2.0

4 years ago

6.1.0

4 years ago

6.1.1

4 years ago

6.0.0

4 years ago

5.0.0

5 years ago

3.0.0

6 years ago

2.3.0

6 years ago

2.2.0

6 years ago

2.1.0

6 years ago

2.0.0

6 years ago

1.0.2

11 years ago

1.0.1

11 years ago

1.0.0

11 years ago