mirror of
https://github.com/The-Pocket/PocketFlow-Tutorial-Codebase-Knowledge.git
synced 2026-08-29 08:34:31 +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
|
- 5 # path/to/another.js
|
||||||
# ... up to {max_abstraction_num} abstractions
|
# ... 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 ---
|
# --- Validation ---
|
||||||
yaml_str = response.strip().split("```yaml")[1].split("```")[0].strip()
|
yaml_str = response.strip().split("```yaml")[1].split("```")[0].strip()
|
||||||
# add whitespace to fix llm generation error(except -)
|
|
||||||
abstractions = yaml.safe_load(yaml_str)
|
abstractions = yaml.safe_load(yaml_str)
|
||||||
|
|
||||||
if not isinstance(abstractions, list):
|
if not isinstance(abstractions, list):
|
||||||
@@ -345,7 +344,7 @@ relationships:
|
|||||||
|
|
||||||
Now, provide the YAML output:
|
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 ---
|
# --- Validation ---
|
||||||
yaml_str = response.strip().split("```yaml")[1].split("```")[0].strip()
|
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:
|
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 ---
|
# --- Validation ---
|
||||||
yaml_str = response.strip().split("```yaml")[1].split("```")[0].strip()
|
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)
|
"prev_chapter": prev_chapter, # Add previous chapter info (uses potentially translated name)
|
||||||
"next_chapter": next_chapter, # Add next 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
|
"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
|
# previous_chapters_summary will be added dynamically in exec
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -638,6 +638,7 @@ class WriteChapters(BatchNode):
|
|||||||
chapter_num = item["chapter_num"]
|
chapter_num = item["chapter_num"]
|
||||||
project_name = item.get("project_name")
|
project_name = item.get("project_name")
|
||||||
language = item.get("language", "english")
|
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...")
|
print(f"Writing chapter {chapter_num} for: {abstraction_name} using LLM...")
|
||||||
|
|
||||||
# Prepare file context string from the map
|
# 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):
|
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
|
# Basic validation/cleanup
|
||||||
actual_heading = f"# Chapter {chapter_num}: {abstraction_name}" # Use potentially translated name
|
actual_heading = f"# Chapter {chapter_num}: {abstraction_name}" # Use potentially translated name
|
||||||
if not chapter_content.strip().startswith(f"# Chapter {chapter_num}"):
|
if not chapter_content.strip().startswith(f"# Chapter {chapter_num}"):
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import os
|
|||||||
import logging
|
import logging
|
||||||
import json
|
import json
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import requests
|
|
||||||
|
|
||||||
# Configure logging
|
# Configure logging
|
||||||
log_directory = os.getenv("LOG_DIR", "logs")
|
log_directory = os.getenv("LOG_DIR", "logs")
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ def crawl_github_files(
|
|||||||
return []
|
return []
|
||||||
|
|
||||||
if response.status_code != 200:
|
if response.status_code != 200:
|
||||||
print(f"Error fetching the branches of {owner}/{path}: {response.status_code} - {response.text}")
|
print(f"Error fetching the branches of {owner}/{repo}: {response.status_code} - {response.text}")
|
||||||
return []
|
return []
|
||||||
|
|
||||||
return response.json()
|
return response.json()
|
||||||
|
|||||||
Reference in New Issue
Block a user