Skip to content

Commit

Permalink
also update the generate text example
Browse files Browse the repository at this point in the history
  • Loading branch information
steinwaywhw committed Aug 19, 2024
1 parent a3bb05d commit 73fbb1b
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 365 deletions.
31 changes: 31 additions & 0 deletions basics/generate-text/typescript/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# GenerateText in Typescript

To run this example,

```bash
# Set your API key as an environment variable.
# Get one here https://www.substrate.run/dashboard/keys if this is your first time.
export SUBSTRATE_API_KEY=<your Substrate API key>

# Navigate to the python example directory.
cd typescript
```

To run the example with tsx (default), run the following.

```bash
npx tsx ./example.ts
npx tsx ./example-multi.ts

# Or you can use the package.json scripts
npm run example
npm run example-multi
```

To run the example with Deno, uncomment the Deno sections in `example.ts` and
run the following.

```bash
deno run ./example.ts
deno run ./example-multi.ts
```
6 changes: 4 additions & 2 deletions basics/generate-text/typescript/example-multi.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env -S npx ts-node --transpileOnly
import { Substrate, MultiComputeText } from "substrate";
import { MultiComputeText, Substrate } from "substrate";

// Uncomment if using Deno
// import process from "node:process";

async function main() {
const apiKey = process.env["SUBSTRATE_API_KEY"] || "YOUR_API_KEY";
Expand Down
6 changes: 4 additions & 2 deletions basics/generate-text/typescript/example.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env -S npx ts-node --transpileOnly
import { Substrate, ComputeText } from "substrate";
import { ComputeText, Substrate } from "substrate";

// Uncomment if using Deno
// import process from "node:process";

async function main() {
const apiKey = process.env["SUBSTRATE_API_KEY"] || "YOUR_API_KEY";
Expand Down
337 changes: 0 additions & 337 deletions basics/generate-text/typescript/package-lock.json

This file was deleted.

Loading

0 comments on commit 73fbb1b

Please sign in to comment.