Skip to content

Instantly share code, notes, and snippets.

@timostamm
Created November 10, 2022 15:21
Show Gist options
  • Save timostamm/6f4200353052fd4a95204a3d6863e4b3 to your computer and use it in GitHub Desktop.
Save timostamm/6f4200353052fd4a95204a3d6863e4b3 to your computer and use it in GitHub Desktop.
Run a Connect-Web client against the Eliza demo service with Deno
version: v1
plugins:
- remote: buf.build/bufbuild/plugins/es
out: gen
- remote: buf.build/bufbuild/plugins/connect-web
out: gen
import {createConnectTransport, createPromiseClient} from "@bufbuild/connect-web";
import {ElizaService} from "./gen/buf/connect/demo/eliza/v1/eliza_connectweb.js";
const client = createPromiseClient(ElizaService, createConnectTransport({
baseUrl: "https://demo.connect.build"
}));
const res = await client.say({sentence: "hello"});
console.log(res);
{
"imports": {
"@bufbuild/protobuf": "https://cdn.skypack.dev/@bufbuild/protobuf",
"@bufbuild/connect-web": "https://cdn.skypack.dev/@bufbuild/connect-web"
}
}
default:
buf generate buf.build/bufbuild/eliza
deno lint .
deno run --import-map import_map.json --allow-net client.ts
@timostamm
Copy link
Author

If you run make, you should see the following output:

SayResponse { sentence: "Hello...I'm glad you could drop by today." }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment