MCPcopy Index your code
hub / github.com/The-Pocket/PocketFlow-Tutorial-Codebase-Knowledge / IdentifyAbstractions

Class IdentifyAbstractions

nodes.py:84–237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82
83
84class IdentifyAbstractions(Node):
85 def prep(self, shared):
86 files_data = shared["files"]
87 project_name = shared["project_name"] # Get project name
88 language = shared.get("language", "english") # Get language
89 use_cache = shared.get("use_cache", True) # Get use_cache flag, default to True
90 max_abstraction_num = shared.get("max_abstraction_num", 10) # Get max_abstraction_num, default to 10
91
92 # Helper to create context from files, respecting limits (basic example)
93 def create_llm_context(files_data):
94 context = ""
95 file_info = [] # Store tuples of (index, path)
96 for i, (path, content) in enumerate(files_data):
97 entry = f"--- File Index {i}: {path} ---\n{content}\n\n"
98 context += entry
99 file_info.append((i, path))
100
101 return context, file_info # file_info is list of (index, path)
102
103 context, file_info = create_llm_context(files_data)
104 # Format file info for the prompt (comment is just a hint for LLM)
105 file_listing_for_prompt = "\n".join(
106 [f"- {idx} # {path}" for idx, path in file_info]
107 )
108 return (
109 context,
110 file_listing_for_prompt,
111 len(files_data),
112 project_name,
113 language,
114 use_cache,
115 max_abstraction_num,
116 ) # Return all parameters
117
118 def exec(self, prep_res):
119 (
120 context,
121 file_listing_for_prompt,
122 file_count,
123 project_name,
124 language,
125 use_cache,
126 max_abstraction_num,
127 ) = prep_res # Unpack all parameters
128 print(f"Identifying abstractions using LLM...")
129
130 # Add language instruction and hints only if not English
131 language_instruction = ""
132 name_lang_hint = ""
133 desc_lang_hint = ""
134 if language.lower() != "english":
135 language_instruction = f"IMPORTANT: Generate the `name` and `description` for each abstraction in **{language.capitalize()}** language. Do NOT use English for these fields.\n\n"
136 # Keep specific hints here as name/description are primary targets
137 name_lang_hint = f" (value in {language.capitalize()})"
138 desc_lang_hint = f" (value in {language.capitalize()})"
139
140 prompt = f"""
141For the project `{project_name}`:

Callers 1

create_tutorial_flowFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected