-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some UX improvements (be able to produce n-tee iters, node message ty…
…pes)
- Loading branch information
1 parent
d63e401
commit 37bf9be
Showing
5 changed files
with
91 additions
and
82 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env -S npx ts-node --transpileOnly | ||
|
||
import { Substrate, Llama3Instruct70B } from "substrate"; | ||
|
||
async function main() { | ||
const SUBSTRATE_API_KEY = process.env["SUBSTRATE_API_KEY"]; | ||
|
||
const substrate = new Substrate({ | ||
apiKey: SUBSTRATE_API_KEY, | ||
baseUrl: "https://api-staging.substrate.run", | ||
}); | ||
|
||
const a = new Llama3Instruct70B({ | ||
prompt: "what are server side events useful for?", | ||
max_tokens: 50, | ||
}); | ||
const b = new Llama3Instruct70B({ | ||
prompt: "what is an async generator?", | ||
max_tokens: 50, | ||
}); | ||
|
||
const stream = await substrate.stream(a, b); | ||
|
||
const [s1, s2] = stream.tee(2); | ||
|
||
for await (let message of s1!.get(a)) { | ||
if (message.object === "node.delta") { | ||
console.log(message); | ||
} | ||
} | ||
for await (let message of s2!.get(b)) { | ||
if (message.object === "node.delta") { | ||
console.log(message); | ||
} | ||
} | ||
} | ||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters