Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parameters #4807

Merged
merged 5 commits into from
Mar 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/eighty-ravens-mate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@google-labs/breadboard": minor
"@breadboard-ai/shared-ui": minor
"@breadboard-ai/a2": minor
---

Introduce parameters infrastructure.
6 changes: 3 additions & 3 deletions packages/a2/bgl/a2.bgl.json

Large diffs are not rendered by default.

77 changes: 77 additions & 0 deletions packages/a2/bgl/parameters-workbench.bgl.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"title": "Parameters Workbench",
"description": "",
"version": "0.0.1",
"nodes": [
{
"id": "a2-b14f4e35",
"type": "file://bgl/a2.bgl.json#module:combine-outputs",
"metadata": {
"title": "One",
"visual": {
"x": 260,
"y": 380,
"collapsed": "expanded",
"outputHeight": 88
},
"userModified": true
},
"configuration": {
"text": {
"role": "user",
"parts": [
{
"text": "{{\"type\":\"param\",\"path\":\"city\",\"title\":\"City\"}}\n\n{{\"type\":\"param\",\"path\":\"business\",\"title\":\"Business Name\"}}"
}
]
}
}
},
{
"id": "a2-afbf013b",
"type": "file://bgl/a2.bgl.json#module:combine-outputs",
"metadata": {
"title": "Two",
"visual": {
"x": 600,
"y": 380,
"collapsed": "expanded",
"outputHeight": 88
},
"userModified": true
},
"configuration": {
"text": {
"role": "user",
"parts": [
{
"text": "{{\"type\":\"in\",\"path\":\"a2-b14f4e35\",\"title\":\"One\"}}\n\n{{\"type\":\"param\",\"path\":\"city\",\"title\":\"City\"}}"
}
]
}
}
}
],
"edges": [
{
"from": "a2-b14f4e35",
"to": "a2-afbf013b",
"out": "context",
"in": "p-z-a2-b14f4e35"
}
],
"metadata": {
"visual": {},
"userModified": true,
"tags": []
},
"assets": {
"@@thumbnail": {
"metadata": {
"title": "Thumbnail",
"type": "file"
},
"data": "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjUwIiBoZWlnaHQ9IjIwMCIgdmlld0JveD0iMCAwIDI1MCAyMDAiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiAgICA8cmVjdCB4PSIxMC4wMCIKICAgICAgICAgICAgICAgICAgICB5PSI2My45NyIKICAgICAgICAgICAgICAgICAgICB3aWR0aD0iOTkuNjciCiAgICAgICAgICAgICAgICAgICAgaGVpZ2h0PSI3Mi4wNyIKICAgICAgICAgICAgICAgICAgICByeD0iMy41IgogICAgICAgICAgICAgICAgICAgIGZpbGw9IndoaXRlIgogICAgICAgICAgICAgICAgICAgIHN0cm9rZT0iIzIwYTIwMiIgLz4KPHJlY3QgeD0iMTQwLjMzIgogICAgICAgICAgICAgICAgICAgIHk9IjYzLjk3IgogICAgICAgICAgICAgICAgICAgIHdpZHRoPSI5OS42NyIKICAgICAgICAgICAgICAgICAgICBoZWlnaHQ9IjcyLjA3IgogICAgICAgICAgICAgICAgICAgIHJ4PSIzLjUiCiAgICAgICAgICAgICAgICAgICAgZmlsbD0id2hpdGUiCiAgICAgICAgICAgICAgICAgICAgc3Ryb2tlPSIjMjBhMjAyIiAvPgogICAgICAKICAgIDwvc3ZnPg=="
}
}
}
7 changes: 6 additions & 1 deletion packages/breadboard/src/bubble.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,12 @@ export class RequestedInputsManager {
) => {
const cachedValue = this.#cache.get(name);
if (cachedValue !== undefined) return cachedValue;
const descriptor = { id: node.id, type: node.type };
const configuration = node.configuration?.schema
? {
configuration: { schema: node.configuration.schema },
}
: {};
const descriptor = { id: node.id, type: node.type, ...configuration };
const requestInputResult = {
...result,
descriptor,
Expand Down
15 changes: 13 additions & 2 deletions packages/breadboard/src/data/file-system/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
PersistentBackend,
FileSystemBlobStore,
CreateRunFileSystemArgs,
CreateModuleFileSystemArgs,
} from "../types.js";
import { Path } from "./path.js";
import { err, noStreams, ok } from "./utils.js";
Expand Down Expand Up @@ -578,11 +579,21 @@ class FileSystemImpl implements FileSystem {
}
}

createModuleFileSystem(graphUrl: string): FileSystem {
env(): FileSystemEntry[] {
return [...this.#env.entries()].map(([path, file]) => {
return {
path,
data: file.data,
};
});
}

createModuleFileSystem(args: CreateModuleFileSystemArgs): FileSystem {
const { graphUrl, env } = args;
return new FileSystemImpl({
graphUrl,
local: this.#local,
env: mapToEntries(this.#env),
env: env || mapToEntries(this.#env),
assets: mapToEntries(this.#assets),
blobs: this.#blobs,
session: this.#session,
Expand Down
12 changes: 11 additions & 1 deletion packages/breadboard/src/data/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,12 @@ export type CreateRunFileSystemArgs = Omit<
"blobs" | "session" | "run" | "local"
>;

export type CreateModuleFileSystemArgs = {
graphUrl: string;
env?: FileSystemEntry[];
assets?: FileSystemEntry[];
};

export type FileSystem = {
query(args: FileSystemQueryArguments): Promise<FileSystemQueryResult>;
read(args: FileSystemReadArguments): Promise<FileSystemReadResult>;
Expand All @@ -474,5 +480,9 @@ export type FileSystem = {
* Use it to get the right FileSystem instance whenever a module is
* invoked.
*/
createModuleFileSystem(graphUrl: string): FileSystem;
createModuleFileSystem(args: CreateModuleFileSystemArgs): FileSystem;
/**
* Provides a quick way to access env entries.
*/
env(): FileSystemEntry[];
};
Loading
Loading