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:
1️⃣ Ease and flexibility of wiring. Make wiring prototypes easy and fun.
2️⃣ Modularity and composability. Easily share, remix, reuse, and compose prototypes.
Breadboard requires Node version >=v19.0.0.
To install breadboard, run:
npm install @google-labs/breadboard
You will also need the LLM Starter Kit:
npm install @google-labs/llm-starter
The LLM Starter Kit comes with Breadboard nodes helpful for building LLM-based applications including the promptTemplate node, append node, generateText node, and more.
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())
)
)
);
To learn more about Breadboard, here are a couple of resources:
- Breadboard Tutorial -- learn how to use breadboard step-by-step, from easy to more complex.
- Node Types Reference - learn about the nodes that come built-in with Breadboard.
- Wiring spec -- all the different ways to wire nodes.
- Sample boards, helpfully visualized with Mermaid (click on the the link next to "Original:" heading to see the board code):
Package Name | NPM | Description |
---|---|---|
Core | ||
@google-labs/breadboard |
The core breadboard library | |
Kits | ||
@google-labs/core-kit |
Library for foundational board operations like append and import |
|
@google-labs/json-kit |
Library for working with JSON in boards | |
@google-labs/llm-starter |
Library for working with LLMs (Large Language Models) in boards | |
@google-labs/palm-kit |
Library for working with the PaLM API in boards | |
Tools & Support Libraries | ||
@google-labs/breadboard-server |
Library for running boards as Google Cloud Functions | |
@google-labs/breadboard-ui |
Web Components for building applications with Breadboard | |
@google-labs/create-breadboard-kit |
NPM init/create script for creating a kit | |
@google-labs/create-breadboard |
NPM init/create script for creating a board | |
Examples | ||
@google-labs/cloud-function |
Unpublished | Example of using Cloud Functions with Breadboard |
@google-labs/coffee-bot-board |
Unpublished | Example board that can order coffee |
@google-labs/graph-playground |
Unpublished | Examples project that runs some sample boards |
@google-labs/hello-world |
Unpublished | Example board based on the Breadboard tutorial |
Internal/Experiments | ||
@google-labs/breadboard-cli |
Unpublished | Command-line tool for generating, running, and debugging boards |
@google-labs/breadboard-web |
Unpublished | Library for running boards in a web browser |
@google-labs/breadboard-website |
Unpublished | The documentation website for Breadboard |
@google-labs/breadbuddy |
Unpublished | Library for generating web applications from boards |
@google-labs/discovery-types |
Unpublished | Library which generates TypeScript declarations from the PaLM API Discovery Document |
@google-labs/graph-integrity |
Unpublished | Library that validates boards |
@google-labs/node-nursery-web |
Unpublished | A place for experimenting with board nodes that aren't yet ready for their own package (web specific) |
@google-labs/node-nursery |
Unpublished | A place for experimenting with board nodes that aren't yet ready for their own package (general) |
@google-labs/node-proxy-server |
Unpublished | Library that allows running nodes remotely |
@google-labs/pinecone-kit |
Unpublished | Library for working with the Pinecone vector database in boards |
Deprecated | ||
@google-labs/graph-runner |
Legacy library for executing boards |