mirror of
https://github.com/The-Pocket/PocketFlow-Tutorial-Codebase-Knowledge.git
synced 2026-08-30 09:00:32 +08:00
disable cache when retrying
This commit is contained in:
@@ -173,11 +173,10 @@ Format the output as a YAML list of dictionaries:
|
||||
- 5 # path/to/another.js
|
||||
# ... up to {max_abstraction_num} abstractions
|
||||
```"""
|
||||
response = call_llm(prompt, use_cache=use_cache) # Pass use_cache parameter
|
||||
response = call_llm(prompt, use_cache=(use_cache and self.cur_retry == 0)) # Use cache only if enabled and not retrying
|
||||
|
||||
# --- Validation ---
|
||||
yaml_str = response.strip().split("```yaml")[1].split("```")[0].strip()
|
||||
# add whitespace to fix llm generation error(except -)
|
||||
abstractions = yaml.safe_load(yaml_str)
|
||||
|
||||
if not isinstance(abstractions, list):
|
||||
@@ -345,7 +344,7 @@ relationships:
|
||||
|
||||
Now, provide the YAML output:
|
||||
"""
|
||||
response = call_llm(prompt, use_cache=use_cache)
|
||||
response = call_llm(prompt, use_cache=(use_cache and self.cur_retry == 0)) # Use cache only if enabled and not retrying
|
||||
|
||||
# --- Validation ---
|
||||
yaml_str = response.strip().split("```yaml")[1].split("```")[0].strip()
|
||||
@@ -487,7 +486,7 @@ Output the ordered list of abstraction indices, including the name in a comment
|
||||
|
||||
Now, provide the YAML output:
|
||||
"""
|
||||
response = call_llm(prompt)
|
||||
response = call_llm(prompt, use_cache=(use_cache and self.cur_retry == 0)) # Use cache only if enabled and not retrying
|
||||
|
||||
# --- Validation ---
|
||||
yaml_str = response.strip().split("```yaml")[1].split("```")[0].strip()
|
||||
@@ -616,6 +615,7 @@ class WriteChapters(BatchNode):
|
||||
"prev_chapter": prev_chapter, # Add previous chapter info (uses potentially translated name)
|
||||
"next_chapter": next_chapter, # Add next chapter info (uses potentially translated name)
|
||||
"language": language, # Add language for multi-language support
|
||||
"use_cache": use_cache, # Pass use_cache flag
|
||||
# previous_chapters_summary will be added dynamically in exec
|
||||
}
|
||||
)
|
||||
@@ -638,6 +638,7 @@ class WriteChapters(BatchNode):
|
||||
chapter_num = item["chapter_num"]
|
||||
project_name = item.get("project_name")
|
||||
language = item.get("language", "english")
|
||||
use_cache = item.get("use_cache", True) # Read use_cache from item
|
||||
print(f"Writing chapter {chapter_num} for: {abstraction_name} using LLM...")
|
||||
|
||||
# Prepare file context string from the map
|
||||
@@ -722,7 +723,7 @@ Instructions for the chapter (Generate content in {language.capitalize()} unless
|
||||
|
||||
Now, directly provide a super beginner-friendly Markdown output (DON'T need ```markdown``` tags):
|
||||
"""
|
||||
chapter_content = call_llm(prompt)
|
||||
chapter_content = call_llm(prompt, use_cache=(use_cache and self.cur_retry == 0)) # Use cache only if enabled and not retrying
|
||||
# Basic validation/cleanup
|
||||
actual_heading = f"# Chapter {chapter_num}: {abstraction_name}" # Use potentially translated name
|
||||
if not chapter_content.strip().startswith(f"# Chapter {chapter_num}"):
|
||||
|
||||
Reference in New Issue
Block a user