Add language parameter for multi-language support

This commit is contained in:
sublimegame
2025-04-16 15:37:01 +07:00
committed by GitHub
parent 449bf185f9
commit ad9573a7eb
+12
View File
@@ -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: