Skip to content

Commit 77ff068

Browse files
committed
Merge remote-tracking branch 'template/main'
2 parents 277c2c1 + c274bbe commit 77ff068

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/agents/utils/parse_json_context_to_prompt.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,15 @@ def __init__(
7676
publishedPartContent: Optional[str] = None,
7777
publishedPartAnswerContent: Optional[str] = None,
7878
publishedWorkedSolutionSections: Optional[List[dict]] = [],
79+
publishedStructuredTutorialSections: Optional[List[dict]] = [],
7980
publishedResponseAreas: Optional[List[Optional[ResponseAreaDetails]]] = [],
8081
):
8182
self.publishedPartId = publishedPartId
8283
self.publishedPartPosition = publishedPartPosition
8384
self.publishedPartContent = publishedPartContent
8485
self.publishedPartAnswerContent = publishedPartAnswerContent
8586
self.publishedWorkedSolutionSections = publishedWorkedSolutionSections
87+
self.publishedStructuredTutorialSections = publishedStructuredTutorialSections
8688
self.publishedResponseAreas = [ResponseAreaDetails(**publishedResponseArea) for publishedResponseArea in publishedResponseAreas]
8789

8890
class QuestionDetails:
@@ -277,9 +279,20 @@ def _format_single_part(
277279
'content': ws.get('content', ''),
278280
'position': ws.get('position', 0)
279281
})
282+
283+
# 6. Structured Tutorial Sections
284+
tutorial_data = []
285+
if part.publishedStructuredTutorialSections:
286+
for ts in part.publishedStructuredTutorialSections:
287+
tutorial_data.append({
288+
'title': ts.get('title', ''),
289+
'content': ts.get('content', ''),
290+
'position': ts.get('position', 0)
291+
})
280292

281293
part_sections.append(PromptFormatter.format_worked_solutions(solutions_data))
282-
294+
part_sections.append(PromptFormatter.format_structured_tutorials(tutorial_data))
295+
283296
return "\n".join(part_sections) + "\n---\n"
284297

285298

src/agents/utils/prompt_context_templates.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,22 @@ def format_worked_solutions(solutions: List[Dict[str, Any]]) -> str:
210210
211211
{"\n".join(solution_texts)}"""
212212

213+
@staticmethod
214+
def format_structured_tutorials(tutorials: List[Dict[str, Any]]) -> str:
215+
"""Format structured tutorials section."""
216+
if not tutorials:
217+
return "### Structured Tutorials\n\nNone available"
218+
219+
tutorial_texts = []
220+
for i, tutorial in enumerate(tutorials):
221+
title = tutorial.get('title', f'Tutorial {i + 1}')
222+
content = tutorial.get('content', '').strip() or 'No content available'
223+
tutorial_texts.append(f"#### {title}\n\n{content}")
224+
225+
return f"""### Structured Tutorials
226+
227+
{"\n".join(tutorial_texts)}"""
228+
213229
@staticmethod
214230
def format_complete_prompt(sections: List[str]) -> str:
215231
"""Combine all sections into a complete, well-structured prompt."""

0 commit comments

Comments
 (0)