breadboard-ai / breadboard

A library for prototyping generative AI applications.
Apache License 2.0
164 stars 22 forks source link

Implement a Kit that contains common utilities #1184

Open dglazkov opened 6 months ago

dglazkov commented 6 months ago

Things like spread/rest/etc. For manipulating lists, objects, and all other common needs that tend to pop up when building graphs.

Mearman commented 5 months ago

For now

PaulKinlan commented 5 months ago

I'd like a merge for objects, equivalent to {...a, ...b}

Mearman commented 5 months ago

This is the rough list I'm going by at the moment https://github.com/ExaDev-io/breadboard/blob/1184-implement-a-kit-that-contains-commo/packages/utility-kit/README.md

PaulKinlan commented 5 months ago

@dglazkov @Mearman I wrote Kit.wrap exactly for this case (existing system APIs). Can we try and exercise it?

See: https://github.com/breadboard-ai/breadboard/blob/9c394a59c8d9fa174892d7da3b0c4efeeba970c4/packages/breadboard/src/kits/builder.ts#L109

Docs: https://github.com/breadboard-ai/breadboard/blob/9c394a59c8d9fa174892d7da3b0c4efeeba970c4/packages/breadboard/docs/kits/libraries-as-kits.md?plain=1#L36

Tests: https://github.com/breadboard-ai/breadboard/blob/9c394a59c8d9fa174892d7da3b0c4efeeba970c4/packages/breadboard/tests/kits.ts#L26

I think there might be some issues specifically there is no "describer" yet.

Mearman commented 5 months ago

Ah I completely forgot about 'Wrap'. I shall have a play

Mearman commented 5 months ago

Ok, some I'm having to reshape to have sensible input and output ports. @PaulKinlan is there a nice way to wrap functions one-by-one?

PaulKinlan commented 5 months ago

Yeah - you should be able to just do it.

const MathKit = KitBuilder.wrap({ url: "test" }, { random: Math.random });

Mearman commented 5 months ago

Sorry I missed out, then including it alongside other nodes in an existing kit. Some of them require a bit of tinkering.

dglazkov commented 5 months ago

Yeah - you should be able to just do it.

const MathKit = KitBuilder.wrap({ url: "test" }, { random: Math.random });

I also forgot about the .wrap!!!

would be very interesting to compare this to the node defining machinery that @aomarks built.

Mearman commented 5 months ago

This ^ and my indecision about what to include in code nodes vs board mechanics vs kits, as well what I was thinking about regarding the "board signatures" makes me wonder if there is a better way of defining "logical nodes"/boards

dglazkov commented 5 months ago

makes me wonder if there is a better way of defining "logical nodes"/boards

now you have to tell me more about that 😆

Mearman commented 5 months ago

well initially it's spawned from wondering about passing a board that has a certain signature but I think it could extend to the underlying logic of the node. If you remember, ages ago I was wondering about ASTs for encoding board logic. Perhaps a BGL way of encoding an AST...?