Let an AI read the workflows it is offered

A run with Gemini 3.8 Flash asked for picture to picture and built it node by node, 13 failed calls on the way, with an official example ready:

- list_workflows was 23,630 characters on 17 cards, 21,033 of them settings. Antigravity files an answer over about 4,000 away, unread. A list of more than 3 now goes with name, route, tags and short notes.
- Examples showed only when no saved workflow matched, and only by English words: 图生图 found nothing. They are always named now, and found by their Chinese titles, img2img, txt2img and inpaint.
- Every card's route line was empty, and cards_of found nothing, since c84b596: _list_recipes leaves the graph out, and the tests fed cards that had one. Both ask for it now, with a test on a file on disk.

A waiting task the user wrote to also takes its name from what they wrote, instead of the AI's "take the task".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
DemonGatanjieu
2026-11-06 17:51:12 +08:00
co-authored by Claude Opus 5.5
parent ad41beaa5a
commit 2280e55fde
15 changed files with 82 additions and 18 deletions
+22 -1
View File
@@ -21,6 +21,8 @@ LOADERS = ("CheckpointLoaderSimple", "UNETLoader", "CLIPLoader", "VAELoader", "A
FAMILIES = {"sd": ("SDXL", "SD 1.x"), "anima": ("anima",)} # what the examples' settings suit
FOR_MODELS = {"sd": "SDXL, SD 1.5", "anima": "Anima"}
LOOK_AT = 40 # files looked at for a model of a family
MAX_WITH_SETTINGS = 3 # saved workflows listed in full for an AI: an AI app files a long answer away, unread
SHORT_NOTES = 120 # characters of a card's notes in a longer list
PICTURES = (".png", ".jpg", ".jpeg", ".webp")
@@ -107,10 +109,29 @@ def for_ai():
"""The examples that can run here, as list_workflows gives saved workflows."""
info = _here()
fills = _fills(info)
return [{"name": item["name"], "example": True, "for_models": FOR_MODELS[item["family"]], "route": workflow_route.line(item["workflow"]), "notes": item["ai"]}
return [{"name": item["name"], "title": item["title"]["zh"], "example": True, "for_models": FOR_MODELS[item["family"]],
"route": workflow_route.line(item["workflow"]), "notes": item["ai"]}
for item in EXAMPLES.values() if not _lacks(item, info, fills)]
def _short(card):
"""A saved workflow in a longer list: what tells it apart."""
shown = {key: value for key, value in card.items() if value and key not in ("settings", "saved")}
return {**shown, "notes": shown["notes"][:SHORT_NOTES]} if "notes" in shown else shown
def answer(found, fits, limit):
"""What list_workflows gives: the saved workflows `found`, cut short when they are many, or else the examples
that `fits`. The other examples go by name, so an AI with no card for the job knows of them."""
examples = for_ai()
fitting = [] if found else [item for item in examples if fits(item)]
if len(found) > MAX_WITH_SETTINGS:
found = [_short(card) for card in found]
listed = found or fitting
others = [item["name"] for item in examples if item not in fitting]
return {"total_matches": len(listed), "workflows": listed[:limit], **({"examples": others} if others else {})}
def file_of(name):
"""The file name open_workflow and run_workflow take for the example called `name`, or None."""
return next((PREFIX + key for key, item in EXAMPLES.items() if item["name"] == name), None)