aimanzoqi commited on
Commit
08f932d
·
1 Parent(s): e8edb00

syntax fix

Browse files
generate_module_activities.png ADDED
pipelines/generate_module_activities.py CHANGED
@@ -53,10 +53,10 @@ pipeline.add_component("llm", instance=generator)
53
  pipeline.connect("prompt_builder", "llm")
54
 
55
  # Save the pipeline as a YAML file and generate a diagram
56
- with open("./pipelines/generate_module_content.yml", "w") as file:
57
  pipeline.dump(file)
58
 
59
- pipeline.draw(path=Path("generate_module_content.png"))
60
 
61
  # Function to generate content for all modules in the outline
62
  def generate_content_for_outline(outline):
 
53
  pipeline.connect("prompt_builder", "llm")
54
 
55
  # Save the pipeline as a YAML file and generate a diagram
56
+ with open("./pipelines/generate_module_activities.yml", "w") as file:
57
  pipeline.dump(file)
58
 
59
+ pipeline.draw(path=Path("generate_module_activities.png"))
60
 
61
  # Function to generate content for all modules in the outline
62
  def generate_content_for_outline(outline):
pipelines/generate_module_activities.yml CHANGED
@@ -5,7 +5,7 @@ components:
5
  model: meta-llama/Llama-3.2-3B-Instruct
6
  api_type: serverless_inference_api
7
  generation_kwargs:
8
- max_new_tokens: 4000
9
  stop:
10
  - <stop>
11
  stop_sequences: []
@@ -19,19 +19,21 @@ components:
19
  prompt_builder:
20
  init_parameters:
21
  required_variables: null
22
- template: "\nYou are an instructional designer creating engaging activities\
23
- \ for training modules.\nYour task is to design one **interactive activity**\
24
- \ for each subtopic listed in the module below.\n\nModule Details:\n{{module}}\n\
25
- \nInstructions:\n- Return only valid Markdown output.\n- Include a brief description\
26
- \ of the activity, its objective, and how employees should complete it.\n\
27
- - Make sure each activity is relevant, creative, and suitable for adult learners.\n\
28
- - Enclose the response within <start> and <stop> tags without extra text.\n\
29
- \nExample Format:\n<start>\n## Activities\n\n### Subtopic 1: [Subtopic Name]\n\
30
- **Activity:** [Activity Name] \n**Objective:** [Learning objective of the\
31
- \ activity] \n**Instructions:** [Step-by-step guide on how to complete the\
32
- \ activity]\n\n### Subtopic 2: [Subtopic Name]\n**Activity:** [Activity Name]\
33
- \ \n**Objective:** [Learning objective of the activity] \n**Instructions:**\
34
- \ [Step-by-step guide on how to complete the activity]\n<stop>\n"
 
 
35
  variables: null
36
  type: haystack.components.builders.prompt_builder.PromptBuilder
37
  connections:
 
5
  model: meta-llama/Llama-3.2-3B-Instruct
6
  api_type: serverless_inference_api
7
  generation_kwargs:
8
+ max_new_tokens: 5000
9
  stop:
10
  - <stop>
11
  stop_sequences: []
 
19
  prompt_builder:
20
  init_parameters:
21
  required_variables: null
22
+ template: "\nYou are an instructional designer tasked with creating engaging\
23
+ \ and comprehensive content for training modules. \nYour goal is to generate\
24
+ \ detailed educational material that fully explains each sub module, ensuring\
25
+ \ that employees gain \na complete understanding of the subject matter.\n\n\
26
+ Task: Produce valid Markdown output containing the **content** for the following\
27
+ \ training module.\n\nModule Details:\n{{module}}\n\nInstructions:\n- Return\
28
+ \ only a Markdown document that follows the provided format (no extra text).\n\
29
+ - Do not include code fences or additional commentary.\n- Ensure that the\
30
+ \ content in each sub module is sufficiently detailed to properly educate\
31
+ \ an employee.\n\nExample Format:\n<start>\n## Content\n\n### Subtopic 1\n\
32
+ Detailed content explaining the topic comprehensively.\n\n### Subtopic 2\n\
33
+ In-depth explanation covering all necessary details.\n<stop>\n\n{% if invalid_replies\
34
+ \ and error_message %}\nYour previous Markdown output was invalid. Error:\
35
+ \ {{error_message}}. \nPlease return only valid Markdown, with no extra text,\
36
+ \ enclosed by <start> and <stop>.\n{% endif %}\n"
37
  variables: null
38
  type: haystack.components.builders.prompt_builder.PromptBuilder
39
  connections:
pipelines/generate_module_content.py CHANGED
@@ -3,7 +3,7 @@ from haystack.components.builders import PromptBuilder
3
  from haystack.components.generators import HuggingFaceAPIGenerator
4
  from haystack.utils import Secret
5
  from components.json_grabber import JSONGrabber
6
- from pathlib import Path # Fixed import
7
 
8
  # Template for generating detailed module content
9
  content_template = """
 
3
  from haystack.components.generators import HuggingFaceAPIGenerator
4
  from haystack.utils import Secret
5
  from components.json_grabber import JSONGrabber
6
+ from pathlib import Path
7
 
8
  # Template for generating detailed module content
9
  content_template = """
pipelines/generate_module_content.yml CHANGED
@@ -21,13 +21,13 @@ components:
21
  required_variables: null
22
  template: "\nYou are an instructional designer tasked with creating engaging\
23
  \ and comprehensive content for training modules. \nYour goal is to generate\
24
- \ detailed educational material that fully explains each sub module, ensuring\
25
  \ that employees gain \na complete understanding of the subject matter.\n\n\
26
  Task: Produce valid Markdown output containing the **content** for the following\
27
  \ training module.\n\nModule Details:\n{{module}}\n\nInstructions:\n- Return\
28
  \ only a Markdown document that follows the provided format (no extra text).\n\
29
  - Do not include code fences or additional commentary.\n- Ensure that the\
30
- \ content in each sub module is sufficiently detailed to properly educate\
31
  \ an employee.\n\nExample Format:\n<start>\n## Content\n\n### Subtopic 1\n\
32
  Detailed content explaining the topic comprehensively.\n\n### Subtopic 2\n\
33
  In-depth explanation covering all necessary details.\n<stop>\n\n{% if invalid_replies\
 
21
  required_variables: null
22
  template: "\nYou are an instructional designer tasked with creating engaging\
23
  \ and comprehensive content for training modules. \nYour goal is to generate\
24
+ \ detailed educational material that fully explains each sub-module, ensuring\
25
  \ that employees gain \na complete understanding of the subject matter.\n\n\
26
  Task: Produce valid Markdown output containing the **content** for the following\
27
  \ training module.\n\nModule Details:\n{{module}}\n\nInstructions:\n- Return\
28
  \ only a Markdown document that follows the provided format (no extra text).\n\
29
  - Do not include code fences or additional commentary.\n- Ensure that the\
30
+ \ content in each sub-module is sufficiently detailed to properly educate\
31
  \ an employee.\n\nExample Format:\n<start>\n## Content\n\n### Subtopic 1\n\
32
  Detailed content explaining the topic comprehensively.\n\n### Subtopic 2\n\
33
  In-depth explanation covering all necessary details.\n<stop>\n\n{% if invalid_replies\