Spaces:
Running
Running
owenkaplinsky
commited on
Commit
·
c54bef9
1
Parent(s):
c7adf96
Fix in_json
Browse files- project/chat.py +8 -7
- project/src/blocks/text.js +1 -1
- project/src/generators/python.js +1 -1
- project/src/toolbox.js +10 -0
project/chat.py
CHANGED
|
@@ -609,8 +609,8 @@ def create_gradio_interface():
|
|
| 609 |
**CRITICAL: Understand the difference between placing blocks INSIDE the MCP vs. placing blocks in MCP OUTPUTS**
|
| 610 |
- The MCP block is a statement container (like a loop or conditional)
|
| 611 |
- Blocks placed `type: "under"` with the MCP's blockID go INSIDE the MCP's code body
|
| 612 |
-
- Blocks placed `type: "input"` with `input_name: "
|
| 613 |
-
- By default, the MCP does NOT have
|
| 614 |
|
| 615 |
**IF/ELSE Blocks:**
|
| 616 |
|
|
@@ -643,11 +643,11 @@ def create_gradio_interface():
|
|
| 643 |
Optional: use `input_name` for statement input names only (e.g., "DO0", "DO1", "ELSE" for IF blocks).
|
| 644 |
Example: `create_block(text_append(...), blockID: ifBlockID, type: "under", input_name: "DO0")` places the block in the IF branch.
|
| 645 |
|
| 646 |
-
- `type: "input"` - ONLY for value blocks placed in MCP output slots
|
| 647 |
-
Example: `text(inputs(TEXT: "hello"))` with `type: "input", input_name: "
|
| 648 |
Requirement: The create_mcp block must have explicit outputs defined (you will see `outputs(...)` in the workspace state). Do not use this if outputs are not visible.
|
| 649 |
|
| 650 |
-
Key rule: Statement input names (DO0, DO1, ELSE) are for `type: "under"`. Output slot names
|
| 651 |
|
| 652 |
**Value block nesting** - For value blocks inside other blocks: nest them directly in the create_block command (do not use `blockID` or `type`).
|
| 653 |
Example: `math_arithmetic(inputs(A: math_number(inputs(NUM: 5)), B: math_number(inputs(NUM: 3))))`
|
|
@@ -727,7 +727,8 @@ def create_gradio_interface():
|
|
| 727 |
Before constructing ANY expression block (text_join, math operations, etc.), identify where it goes:
|
| 728 |
- Assigned to a variable (via set_var block)
|
| 729 |
- Passed as input to another block (nested in the create_block call)
|
| 730 |
-
- Placed in an MCP output slot (using type: "input" and input_name: "
|
|
|
|
| 731 |
|
| 732 |
Do NOT create orphaned expression blocks with no destination. They serve no purpose.
|
| 733 |
|
|
@@ -783,7 +784,7 @@ def create_gradio_interface():
|
|
| 783 |
THESE DECLARATIONS ARE REQUIRED EVERY TIME AN IF STATEMENT IS MENTIONED, AND YOU MUST ALWAYS PROVIDE EXACTLY THREE INTEGERS WITH NO EXCEPTIONS OR SUBSTITUTIONS. FAILURE TO DO SO IMMEDIATELY INVALIDATES THE RESPONSE IN ITS ENTIRETY.
|
| 784 |
YOU MUST HAVE EXPLICITLY SAID THESE THREE VALUES NO MATTER WHAT. THIS IS NON-NEGOTIABLE. THIS IS A HARD REQUIREMENT. ALWAYS SAY THIS, EVERY SINGLE TIME, NO MATTER WHAT.
|
| 785 |
|
| 786 |
-
4. **Check the create_mcp block state:** Before using `type: "input"` and `input_name: "
|
| 787 |
|
| 788 |
5. Perform the actions in order without asking for approval or asking to wait for intermediate results."""
|
| 789 |
tools = [
|
|
|
|
| 609 |
**CRITICAL: Understand the difference between placing blocks INSIDE the MCP vs. placing blocks in MCP OUTPUTS**
|
| 610 |
- The MCP block is a statement container (like a loop or conditional)
|
| 611 |
- Blocks placed `type: "under"` with the MCP's blockID go INSIDE the MCP's code body
|
| 612 |
+
- Blocks placed `type: "input"` with `input_name: "name"` only work if the MCP has explicit outputs defined
|
| 613 |
+
- By default, the MCP does NOT have output slots - you must create/edit outputs first
|
| 614 |
|
| 615 |
**IF/ELSE Blocks:**
|
| 616 |
|
|
|
|
| 643 |
Optional: use `input_name` for statement input names only (e.g., "DO0", "DO1", "ELSE" for IF blocks).
|
| 644 |
Example: `create_block(text_append(...), blockID: ifBlockID, type: "under", input_name: "DO0")` places the block in the IF branch.
|
| 645 |
|
| 646 |
+
- `type: "input"` - ONLY for value blocks placed in MCP output slots.
|
| 647 |
+
Example: `text(inputs(TEXT: "hello"))` with `type: "input", input_name: "name"` places the text block in the MCP's first output slot.
|
| 648 |
Requirement: The create_mcp block must have explicit outputs defined (you will see `outputs(...)` in the workspace state). Do not use this if outputs are not visible.
|
| 649 |
|
| 650 |
+
Key rule: Statement input names (DO0, DO1, ELSE) are for `type: "under"`. Output slot names are for `type: "input"`. Never mix them.
|
| 651 |
|
| 652 |
**Value block nesting** - For value blocks inside other blocks: nest them directly in the create_block command (do not use `blockID` or `type`).
|
| 653 |
Example: `math_arithmetic(inputs(A: math_number(inputs(NUM: 5)), B: math_number(inputs(NUM: 3))))`
|
|
|
|
| 727 |
Before constructing ANY expression block (text_join, math operations, etc.), identify where it goes:
|
| 728 |
- Assigned to a variable (via set_var block)
|
| 729 |
- Passed as input to another block (nested in the create_block call)
|
| 730 |
+
- Placed in an MCP output slot (using type: "input" and input_name: "name")
|
| 731 |
+
- You CANNOT use type "under" to put a value block in the output slot of the MCP server. You MUST use "type" with "name".
|
| 732 |
|
| 733 |
Do NOT create orphaned expression blocks with no destination. They serve no purpose.
|
| 734 |
|
|
|
|
| 784 |
THESE DECLARATIONS ARE REQUIRED EVERY TIME AN IF STATEMENT IS MENTIONED, AND YOU MUST ALWAYS PROVIDE EXACTLY THREE INTEGERS WITH NO EXCEPTIONS OR SUBSTITUTIONS. FAILURE TO DO SO IMMEDIATELY INVALIDATES THE RESPONSE IN ITS ENTIRETY.
|
| 785 |
YOU MUST HAVE EXPLICITLY SAID THESE THREE VALUES NO MATTER WHAT. THIS IS NON-NEGOTIABLE. THIS IS A HARD REQUIREMENT. ALWAYS SAY THIS, EVERY SINGLE TIME, NO MATTER WHAT.
|
| 786 |
|
| 787 |
+
4. **Check the create_mcp block state:** Before using `type: "input"` and `input_name: "name"`, verify that the create_mcp block has outputs defined in the workspace state. If you do not see `outputs(...)` in the create_mcp block, do NOT use these parameters.
|
| 788 |
|
| 789 |
5. Perform the actions in order without asking for approval or asking to wait for intermediate results."""
|
| 790 |
tools = [
|
project/src/blocks/text.js
CHANGED
|
@@ -590,7 +590,7 @@ const in_json = {
|
|
| 590 |
"message0": "get %1 from JSON %2",
|
| 591 |
"args0": [
|
| 592 |
{
|
| 593 |
-
"type": "
|
| 594 |
"name": "NAME",
|
| 595 |
},
|
| 596 |
{
|
|
|
|
| 590 |
"message0": "get %1 from JSON %2",
|
| 591 |
"args0": [
|
| 592 |
{
|
| 593 |
+
"type": "input_value",
|
| 594 |
"name": "NAME",
|
| 595 |
},
|
| 596 |
{
|
project/src/generators/python.js
CHANGED
|
@@ -337,7 +337,7 @@ forBlock['call_api'] = function (block, generator) {
|
|
| 337 |
};
|
| 338 |
|
| 339 |
forBlock['in_json'] = function (block, generator) {
|
| 340 |
-
const name =
|
| 341 |
const json = generator.valueToCode(block, 'JSON', Order.NONE);
|
| 342 |
|
| 343 |
// Generate code to call an LLM model with a prompt
|
|
|
|
| 337 |
};
|
| 338 |
|
| 339 |
forBlock['in_json'] = function (block, generator) {
|
| 340 |
+
const name = generator.valueToCode(block, 'NAME', Order.NONE);
|
| 341 |
const json = generator.valueToCode(block, 'JSON', Order.NONE);
|
| 342 |
|
| 343 |
// Generate code to call an LLM model with a prompt
|
project/src/toolbox.js
CHANGED
|
@@ -57,6 +57,16 @@ export const toolbox = {
|
|
| 57 |
{
|
| 58 |
kind: 'block',
|
| 59 |
type: 'in_json',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
},
|
| 61 |
{
|
| 62 |
kind: 'block',
|
|
|
|
| 57 |
{
|
| 58 |
kind: 'block',
|
| 59 |
type: 'in_json',
|
| 60 |
+
inputs: {
|
| 61 |
+
NAME: {
|
| 62 |
+
shadow: {
|
| 63 |
+
type: 'text',
|
| 64 |
+
fields: {
|
| 65 |
+
text: "10",
|
| 66 |
+
},
|
| 67 |
+
},
|
| 68 |
+
},
|
| 69 |
+
},
|
| 70 |
},
|
| 71 |
{
|
| 72 |
kind: 'block',
|