Skip to content

Commit

Permalink
Add example
Browse files Browse the repository at this point in the history
  • Loading branch information
liamgriffiths committed Jun 17, 2024
1 parent 86280dc commit 07d2fe6
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions examples/implicit-nodes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env -S npx ts-node --transpileOnly

import { Substrate, GenerateText } from "substrate";

async function main() {
const SUBSTRATE_API_KEY = process.env["SUBSTRATE_API_KEY"];

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

const a = new GenerateText(
{ prompt: "tell me about windmills" },
{ id: "a" },
);
const b = new GenerateText({ prompt: a.future.text }, { id: "b" });
const c = new GenerateText({ prompt: b.future.text }, { id: "c" });

// Because the `c` is the the final node in the graph we can find nodes it depends
// on through the relationships created via the input arguments.
const res = await substrate.run(c);
console.log(res.json);
}
main();

0 comments on commit 07d2fe6

Please sign in to comment.