John Friction Log #1182
Replies: 6 comments 21 replies
-
Schema Defaults do not get used when running a board programmatically. Given a schema:
The board does not use the default value of "39788322" when running the board programmatically without providing the storyID. |
Beta Was this translation helpful? Give feedback.
-
Breadboard Web does not allow non-required inputs to be left empty. This can be seen in the following board:
Breadboard Web Link: |
Beta Was this translation helpful? Give feedback.
-
Breadboard web does not use defaults when no inputs are provided. It was mentioned that defaults are used for non-required inputs, so this should be using the default value of 1. urlTemplate does not error if there is a parameter missing.
|
Beta Was this translation helpful? Give feedback.
-
Core-Kit fetch will always stringify the request body: invoke: async (
{ url, method, body, headers, raw, stream },
{ signal }: NodeHandlerContext
) => {
if (!url) throw new Error("Fetch requires `url` input");
const init: RequestInit = {
method,
headers,
signal,
};
// GET can not have a body.
if (method !== "GET") {
init.body = JSON.stringify(body);
} else if (body) {
throw new Error("GET requests can not have a body");
}
...
} This may not be a desired behaviour for certain API endpoints. For example, see : https://huggingface.co/docs/api-inference/detailed_parameters?code=js#image-classification-task Using fetch results in a successful API call, but core.fetch results in an error because of the mentioned request body being stringified. Hugging Face API key can be generated in https://huggingface.co/settings/tokens import fs from "fs";
import { core } from "@google-labs/core-kit";
// fileName can be any image on local file system
async function query(filename: string) {
const data = fs.readFileSync(filename);
const response = await fetch(
"https://api-inference.huggingface.co/models/google/vit-base-patch16-224",
{
headers: { Authorization: `Bearer myHuggingFaceAPIKey` },
method: "POST",
body: data,
}
);
const result = await response.json();
return result;
}
query("cat.jpg").then((response) => {
console.log(JSON.stringify(response));
});
// OUTPUT Example
[{"score":0.6734483242034912,"label":"lynx, catamount"},{"score":0.18709655106067657,"label":"tabby, tabby cat"},{"score":0.06381674110889435,"label":"Egyptian cat"},{"score":0.05342644825577736,"label":"tiger cat"},{"score":0.004754822701215744,"label":"Siamese cat, Siamese"}] // uses core.fetch, ERROR HAPPENS BECAUSE CORE KIT STRINGIFIES BODY
async function query2(filename: string) {
const data = fs.readFileSync(filename);
const response = await core.fetch({
headers: { Authorization: `Bearer myHuggingFaceAPIKey` },
method: "POST",
body: data,
url: "https://api-inference.huggingface.co/models/google/vit-base-patch16-224",
})
return response;
}
query2("cat.jpg").then((response) => {
// write to file because error message is too long
fs.writeFileSync("./response.txt", JSON.stringify(response))
console.log(JSON.stringify(response));
});
// OUTPUT Example
{"$error":{"error":["Error in `inputs`: Invalid image: {'type': 'Buffer', 'data': [255, 216, 255, 224, 0, 16, 74, 70, 73, 70, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 255, 219, 0, 67, 0, 3, 2 ...]}} |
Beta Was this translation helpful? Give feedback.
-
For context I am currently in the process of migrating the following board : https://github.com/ExaDev/breadboard/blob/develop/packages/example-boards/src/boards/playground/board-for-each.ts. Currently trying to figure out how to achieve the same effect using the new passthrough node: const passthrough = core.passthrough({
$metadata: {
title: "Passthrough",
},
board: input.board,
});
passthrough.board.to(passthrough); const passthroughOutput = passthrough({ board: boardJSON }); I was able to manually do this looping on the visual editor by wiring the output back into the input, so it seems stil possible to do so. But Still trying to figure out how to do it in code. |
Beta Was this translation helpful? Give feedback.
-
I've attempted to migrate the Tour-guide-writer board to the build API. I've migrated it without using the core.curry and core.map as I am not sure if there are plans to migrate/deperecate them. I just wondered how I can format the output of the board? I was expecting the text prefixed with # to be in bold, just like the old board, but that doesn't seem to work! code: |
Beta Was this translation helpful? Give feedback.
-
Notes while working on Breadboard.
Beta Was this translation helpful? Give feedback.
All reactions