mirror of
https://github.com/The-Pocket/PocketFlow-Tutorial-Codebase-Knowledge.git
synced 2026-08-29 08:34:31 +08:00
Add language parameter for multi-language support
This commit is contained in:
@@ -441,6 +441,9 @@ class WriteChapters(BatchNode):
|
||||
next_idx = chapter_order[i+1]
|
||||
next_chapter = chapter_filenames[next_idx]
|
||||
|
||||
# Get language from shared store, default to English
|
||||
language = shared.get("language", "english")
|
||||
|
||||
items_to_process.append({
|
||||
"chapter_num": i + 1,
|
||||
"abstraction_index": abstraction_index,
|
||||
@@ -451,6 +454,7 @@ class WriteChapters(BatchNode):
|
||||
"chapter_filenames": chapter_filenames, # Add chapter filenames mapping
|
||||
"prev_chapter": prev_chapter, # Add previous chapter info
|
||||
"next_chapter": next_chapter, # Add next chapter info
|
||||
"language": language, # Add language for multi-language support
|
||||
# previous_chapters_summary will be added dynamically in exec
|
||||
})
|
||||
else:
|
||||
@@ -476,8 +480,16 @@ class WriteChapters(BatchNode):
|
||||
# Use the temporary instance variable
|
||||
previous_chapters_summary = "\n---\n".join(self.chapters_written_so_far)
|
||||
|
||||
# Get language from item, default to English
|
||||
language = item.get("language", "english")
|
||||
|
||||
# Add language instruction if not English
|
||||
language_instruction = ""
|
||||
if language.lower() != "english":
|
||||
language_instruction = f"Write this tutorial chapter in {language}. Ensure all explanations, examples, and comments are in {language}.\n\n"
|
||||
|
||||
prompt = f"""
|
||||
{language_instruction}
|
||||
Write a very beginner-friendly tutorial chapter (in Markdown format) for the project `{project_name}` about the concept: "{abstraction_name}". This is Chapter {chapter_num}.
|
||||
|
||||
Concept Details:
|
||||
|
||||
Reference in New Issue
Block a user