Update app.py
Browse files
app.py
CHANGED
|
@@ -323,63 +323,63 @@ CAP_BLOCKS_PATH = BLOCKS_DIR / "cap_blocks.json"
|
|
| 323 |
|
| 324 |
# Load the block catalogs from their respective JSON files
|
| 325 |
hat_block_data = _load_block_catalog(HAT_BLOCKS_PATH)
|
| 326 |
-
hat_description = hat_block_data["description"]
|
| 327 |
-
|
| 328 |
# hat_opcodes_functionalities = "\n".join([f" - Opcode: {block['op_code']}, functionality: {block['functionality']} example: standalone use: {block['example_standalone']}" for block in hat_block_data["blocks"]])
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
hat_opcodes_functionalities = os.path.join(BLOCKS_DIR, "hat_blocks.txt")
|
| 334 |
print("Hat blocks loaded successfully.", hat_description)
|
| 335 |
|
| 336 |
boolean_block_data = _load_block_catalog(BOOLEAN_BLOCKS_PATH)
|
| 337 |
boolean_description = boolean_block_data["description"]
|
| 338 |
# boolean_opcodes_functionalities = "\n".join([f" - Opcode: {block['op_code']}, functionality: {block['functionality']} example: standalone use: {block['example_standalone']}" for block in boolean_block_data["blocks"]])
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
boolean_opcodes_functionalities = os.path.join(BLOCKS_DIR, "boolean_blocks.txt")
|
| 344 |
|
| 345 |
c_block_data = _load_block_catalog(C_BLOCKS_PATH)
|
| 346 |
c_description = c_block_data["description"]
|
| 347 |
# c_opcodes_functionalities = "\n".join([f" - Opcode: {block['op_code']}, functionality: {block['functionality']} example: standalone use: {block['example_standalone']}" for block in c_block_data["blocks"]])
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
c_opcodes_functionalities = os.path.join(BLOCKS_DIR, "c_blocks.txt")
|
| 353 |
|
| 354 |
cap_block_data = _load_block_catalog(CAP_BLOCKS_PATH)
|
| 355 |
cap_description = cap_block_data["description"]
|
| 356 |
# cap_opcodes_functionalities = "\n".join([f" - Opcode: {block['op_code']}, functionality: {block['functionality']} example: standalone use: {block['example_standalone']}" for block in cap_block_data["blocks"]])
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
cap_opcodes_functionalities = os.path.join(BLOCKS_DIR, "cap_blocks.txt")
|
| 362 |
|
| 363 |
reporter_block_data = _load_block_catalog(REPORTER_BLOCKS_PATH)
|
| 364 |
reporter_description = reporter_block_data["description"]
|
| 365 |
# reporter_opcodes_functionalities = "\n".join([f" - Opcode: {block['op_code']}, functionality: {block['functionality']} example: standalone use: {block['example_standalone']}" for block in reporter_block_data["blocks"]])
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
reporter_opcodes_functionalities = os.path.join(BLOCKS_DIR, "reporter_blocks.txt")
|
| 371 |
|
| 372 |
stack_block_data = _load_block_catalog(STACK_BLOCKS_PATH)
|
| 373 |
stack_description = stack_block_data["description"]
|
| 374 |
# stack_opcodes_functionalities = "\n".join([f" - Opcode: {block['op_code']}, functionality: {block['functionality']} example: standalone use: {block['example_standalone']}" for block in stack_block_data["blocks"]])
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
stack_opcodes_functionalities = os.path.join(BLOCKS_DIR, "stack_blocks.txt")
|
| 380 |
|
| 381 |
# This makes ALL_SCRATCH_BLOCKS_CATALOG available globally
|
| 382 |
-
|
| 383 |
|
| 384 |
# Helper function to extract JSON from LLM response
|
| 385 |
def extract_json_from_llm_response(raw_response: str) -> dict:
|
|
|
|
| 323 |
|
| 324 |
# Load the block catalogs from their respective JSON files
|
| 325 |
hat_block_data = _load_block_catalog(HAT_BLOCKS_PATH)
|
| 326 |
+
# hat_description = hat_block_data["description"]
|
| 327 |
+
hat_description = hat_block_data.get("description", "No description available")
|
| 328 |
# hat_opcodes_functionalities = "\n".join([f" - Opcode: {block['op_code']}, functionality: {block['functionality']} example: standalone use: {block['example_standalone']}" for block in hat_block_data["blocks"]])
|
| 329 |
+
hat_opcodes_functionalities = "\n".join([
|
| 330 |
+
f" - Opcode: {block.get('op_code', 'N/A')}, functionality: {block.get('functionality', 'N/A')}, example: standalone use {block.get('example_standalone', 'N/A')}"
|
| 331 |
+
for block in hat_block_data.get("blocks", [])
|
| 332 |
+
]) if isinstance(hat_block_data.get("blocks"), list) else " No blocks information available."
|
| 333 |
hat_opcodes_functionalities = os.path.join(BLOCKS_DIR, "hat_blocks.txt")
|
| 334 |
print("Hat blocks loaded successfully.", hat_description)
|
| 335 |
|
| 336 |
boolean_block_data = _load_block_catalog(BOOLEAN_BLOCKS_PATH)
|
| 337 |
boolean_description = boolean_block_data["description"]
|
| 338 |
# boolean_opcodes_functionalities = "\n".join([f" - Opcode: {block['op_code']}, functionality: {block['functionality']} example: standalone use: {block['example_standalone']}" for block in boolean_block_data["blocks"]])
|
| 339 |
+
boolean_opcodes_functionalities = "\n".join([
|
| 340 |
+
f" - Opcode: {block.get('op_code', 'N/A')}, functionality: {block.get('functionality', 'N/A')}, example: standalone use {block.get('example_standalone', 'N/A')}"
|
| 341 |
+
for block in boolean_block_data.get("blocks", [])
|
| 342 |
+
]) if isinstance(boolean_block_data.get("blocks"), list) else " No blocks information available."
|
| 343 |
boolean_opcodes_functionalities = os.path.join(BLOCKS_DIR, "boolean_blocks.txt")
|
| 344 |
|
| 345 |
c_block_data = _load_block_catalog(C_BLOCKS_PATH)
|
| 346 |
c_description = c_block_data["description"]
|
| 347 |
# c_opcodes_functionalities = "\n".join([f" - Opcode: {block['op_code']}, functionality: {block['functionality']} example: standalone use: {block['example_standalone']}" for block in c_block_data["blocks"]])
|
| 348 |
+
c_opcodes_functionalities = "\n".join([
|
| 349 |
+
f" - Opcode: {block.get('op_code', 'N/A')}, functionality: {block.get('functionality', 'N/A')}, example: standalone use {block.get('example_standalone', 'N/A')}"
|
| 350 |
+
for block in c_block_data.get("blocks", [])
|
| 351 |
+
]) if isinstance(c_block_data.get("blocks"), list) else " No blocks information available."
|
| 352 |
c_opcodes_functionalities = os.path.join(BLOCKS_DIR, "c_blocks.txt")
|
| 353 |
|
| 354 |
cap_block_data = _load_block_catalog(CAP_BLOCKS_PATH)
|
| 355 |
cap_description = cap_block_data["description"]
|
| 356 |
# cap_opcodes_functionalities = "\n".join([f" - Opcode: {block['op_code']}, functionality: {block['functionality']} example: standalone use: {block['example_standalone']}" for block in cap_block_data["blocks"]])
|
| 357 |
+
cap_opcodes_functionalities = "\n".join([
|
| 358 |
+
f" - Opcode: {block.get('op_code', 'N/A')}, functionality: {block.get('functionality', 'N/A')}, example: standalone use {block.get('example_standalone', 'N/A')}"
|
| 359 |
+
for block in cap_block_data.get("blocks", [])
|
| 360 |
+
]) if isinstance(cap_block_data.get("blocks"), list) else " No blocks information available."
|
| 361 |
cap_opcodes_functionalities = os.path.join(BLOCKS_DIR, "cap_blocks.txt")
|
| 362 |
|
| 363 |
reporter_block_data = _load_block_catalog(REPORTER_BLOCKS_PATH)
|
| 364 |
reporter_description = reporter_block_data["description"]
|
| 365 |
# reporter_opcodes_functionalities = "\n".join([f" - Opcode: {block['op_code']}, functionality: {block['functionality']} example: standalone use: {block['example_standalone']}" for block in reporter_block_data["blocks"]])
|
| 366 |
+
reporter_opcodes_functionalities = "\n".join([
|
| 367 |
+
f" - Opcode: {block.get('op_code', 'N/A')}, functionality: {block.get('functionality', 'N/A')}, example: standalone use {block.get('example_standalone', 'N/A')}"
|
| 368 |
+
for block in reporter_block_data.get("blocks", [])
|
| 369 |
+
]) if isinstance(reporter_block_data.get("blocks"), list) else " No blocks information available."
|
| 370 |
reporter_opcodes_functionalities = os.path.join(BLOCKS_DIR, "reporter_blocks.txt")
|
| 371 |
|
| 372 |
stack_block_data = _load_block_catalog(STACK_BLOCKS_PATH)
|
| 373 |
stack_description = stack_block_data["description"]
|
| 374 |
# stack_opcodes_functionalities = "\n".join([f" - Opcode: {block['op_code']}, functionality: {block['functionality']} example: standalone use: {block['example_standalone']}" for block in stack_block_data["blocks"]])
|
| 375 |
+
stack_opcodes_functionalities = "\n".join([
|
| 376 |
+
f" - Opcode: {block.get('op_code', 'N/A')}, functionality: {block.get('functionality', 'N/A')}, example: standalone use {block.get('example_standalone', 'N/A')}"
|
| 377 |
+
for block in stack_block_data.get("blocks", [])
|
| 378 |
+
]) if isinstance(stack_block_data.get("blocks"), list) else " No blocks information available."
|
| 379 |
stack_opcodes_functionalities = os.path.join(BLOCKS_DIR, "stack_blocks.txt")
|
| 380 |
|
| 381 |
# This makes ALL_SCRATCH_BLOCKS_CATALOG available globally
|
| 382 |
+
ALL_SCRATCH_BLOCKS_CATALOG = _load_block_catalog(BLOCK_CATALOG_PATH)
|
| 383 |
|
| 384 |
# Helper function to extract JSON from LLM response
|
| 385 |
def extract_json_from_llm_response(raw_response: str) -> dict:
|