npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@google-labs/breadboard

v0.20.0

Published

A library for rapid generative AI application prototyping

Downloads

674

Readme

Breadboard

Milestone Stability Discord

A library for prototyping generative AI applications.

This library was inspired by the hardware maker community and their boundless creativity. They make amazing things with off-the-shelf parts and a breadboard, just wiring things together and trying this and that until it works.

Breadboard is an attempt to bring the same spirit of creativity and simplicity to making generative AI applications.

This library's design emphasizes two key properties:

:one: Ease and flexibility of wiring. Make wiring prototypes easy and fun.

:two: Modularity and composability. Easily share, remix, reuse, and compose prototypes.

Requirements

Breadboard requires Node version >=v19.0.0.

[!WARNING] The library is in active development, and we're transitioning to new syntax. Stuff below will likely be out of date. Please bear with us as we bring our words up to speed with our thoughts/actions.

Installing the library

To install breadboard, run:

npm install @google-labs/breadboard

You will also need the Core Kit:

npm install @google-labs/core-kit

Using breadboard

Just like for hardware makers, the wiring of a prototype begins with the Board.

import { Board } from "@google-labs/breadboard";

const board = new Board();

Breadboards are all nodes and wires. Nodes do useful things, and wires flow control and data between them.

Placing things on the board is simple. This example places an input and an output node on the board:

const input = board.input();
const output = board.output();

Wiring things is also simple:

input.wire("say->hear", output);

The statement above wires the say property of the input node to the hear property of the output node.

The wire method is chainable, so you can wire multiple wires at once. Wiring can also happen in both directions, allowing for more expressivity and flexibility.

Here's an example: a board that uses PaLM API to generate text:

const output = board.output();
board
  .input()
  .wire("say->", output)
  .wire(
    "say->text",
    kit
      .generateText()
      .wire("completion->hear", output)
      .wire("<-PALM_KEY", kit.secrets(["PALM_KEY"]))
  );

You can run boards using runOnce and run methods. The runOnce is the simplest; it takes inputs and produces a set of outputs:

const result = await board.runOnce({
  say: "Hi, how are you?",
});
console.log("result", result);

When run, the output of the sample board above will look something like this:

result { say: 'Hi, how are you?', hear: 'Doing alright.' }

The run method provides a lot more flexibility on how the board run happens, and is described in more detail Chapter 8: Continuous runs of Breadboard tutorial.

Breadboard is designed for modularity. You can easily save boards: they nicely serialize as JSON:

const json = JSON.stringify(board, null, 2);
await writeFile("./docs/tutorial/news-summarizer.json", json);

You can load this JSON from URLs:

const NEWS_BOARD_URL =
  "https://gist.githubusercontent.com/dglazkov/55db9bb36acd5ba5cfbd82d2901e7ced/raw/google-news-headlines.json";
const board = Board.load(NEWS_BOARD_URL);

You can include them into your own boards, similar to JS modules, and then treat them as nodes in your graph:

board
  .input()
  .wire(
    "say->text",
    board.invoke(NEWS_BOARD_URL).wire("text->hear", board.output())
  );

You can even create board templates by leaving "slots" in your board for others to fill in:

const input = board.input();
input.wire(
  "topic->",
  board.slot("news").wire(
    "headlines->",
    template.wire("topic<-", input).wire(
      "prompt->text",
      kit
        .generateText()
        .wire("<-PALM_KEY.", kit.secrets(["PALM_KEY"]))
        .wire("completion->summary", board.output())
    )
  )
);

For more information

To learn more about Breadboard, here are a couple of resources: