MCPcopy Create free account
hub / github.com/The-Pocket/PocketFlow-Tutorial-Codebase-Knowledge / prep

Method prep

nodes.py:411–452  ·  view source on GitHub ↗
(self, shared)

Source from the content-addressed store, hash-verified

409
410class OrderChapters(Node):
411 def prep(self, shared):
412 abstractions = shared["abstractions"] # Name/description might be translated
413 relationships = shared["relationships"] # Summary/label might be translated
414 project_name = shared["project_name"] # Get project name
415 language = shared.get("language", "english") # Get language
416 use_cache = shared.get("use_cache", True) # Get use_cache flag, default to True
417
418 # Prepare context for the LLM
419 abstraction_info_for_prompt = []
420 for i, a in enumerate(abstractions):
421 abstraction_info_for_prompt.append(
422 f"- {i} # {a['name']}"
423 ) # Use potentially translated name
424 abstraction_listing = "\n".join(abstraction_info_for_prompt)
425
426 # Use potentially translated summary and labels
427 summary_note = ""
428 if language.lower() != "english":
429 summary_note = (
430 f" (Note: Project Summary might be in {language.capitalize()})"
431 )
432
433 context = f"Project Summary{summary_note}:\n{relationships['summary']}\n\n"
434 context += "Relationships (Indices refer to abstractions above):\n"
435 for rel in relationships["details"]:
436 from_name = abstractions[rel["from"]]["name"]
437 to_name = abstractions[rel["to"]]["name"]
438 # Use potentially translated 'label'
439 context += f"- From {rel['from']} ({from_name}) to {rel['to']} ({to_name}): {rel['label']}\n" # Label might be translated
440
441 list_lang_note = ""
442 if language.lower() != "english":
443 list_lang_note = f" (Names might be in {language.capitalize()})"
444
445 return (
446 abstraction_listing,
447 context,
448 len(abstractions),
449 project_name,
450 list_lang_note,
451 use_cache,
452 ) # Return use_cache
453
454 def exec(self, prep_res):
455 (

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected