Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Epic 7.3.1 : Worksheet Generator - Squad Robo Rebels #88

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
4 changes: 4 additions & 0 deletions app/api/tools_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@
"1": {
"path": "features.dynamo.core",
"metadata_file": "metadata.json"
},
"2": {
"path": "features.worksheet_generator.core",
"metadata_file": "metadata.json"
}
}
31 changes: 31 additions & 0 deletions app/features/worksheet_generator/core.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from app.services.tool_registry import WorkSheetQuestionType
from services.logger import setup_logger
from app.features.worksheet_generator.tools import WorksheetGenerator
from app.api.error_utilities import LoaderError, ToolExecutorError

logger = setup_logger()

def executor(grade_level : int, topic: str, difficulty_level: str, question_types: list[WorkSheetQuestionType], lang: str, verbose=False):

try:
if verbose: logger.debug(f"grade_level: {grade_level}, topic: {topic}, difficulty_level: {difficulty_level}, question_types: {question_types}, lang: {lang}")

params = {"grade_level": grade_level, "topic": topic, "difficulty_level": difficulty_level, "question_types": question_types, "lang": lang, "verbose": verbose}

# Create and return the questions for the worksheet
output = WorksheetGenerator(**params).create_worksheet()

# Try-Except blocks on custom defined exceptions to provide better logging

except LoaderError as e:
error_message = e
logger.error(f"Error in RAGPipeline -> {error_message}")
raise ToolExecutorError(error_message)

# These help differentiate user-input errors and internal errors. Use 4XX and 5XX status respectively.
except Exception as e:
error_message = f"Error in executor: {e}"
logger.error(error_message)
raise ValueError(error_message)

return output
29 changes: 29 additions & 0 deletions app/features/worksheet_generator/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"inputs": [
{
"label": "Grade Level",
"name": "grade_level",
"type": "number"
},
{
"label": "Topic",
"name": "topic",
"type": "text"
},
{
"label": "Difficulty Level",
"name": "difficulty_level",
"type": "text"
},
{
"label": "Question Types",
"name": "question_types",
"type": "list"
},
{
"label": "ISO 639-1 Language Code",
"name": "lang",
"type": "text"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
You are a subject matter expert on the topic:
{topic} in grade level: {grade_level} with difficulty level: {difficulty_level}

Follow the instructions to create a fill-in-the-balnk question:
1. Generate a fill-in-the-blank question based on the topic and grdae level provided as key "question"
2. The question should include one blank space defined by an underscore(_) to be filled.
3. Provide the correct answer for the question as key "answer"

You must respond as a JSON object:
{format_instructions}

You must provide the response in {lang} language.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
You are a subject matter expert on the topic:
{topic} in grade level: {grade_level} with difficulty level: {difficulty_level}

Follow the instructions to create a quiz question:
1. Generate a question based on the topic provided and context as key "question"
2. Provide 4 multiple choice answers to the question as a list of key-value pairs "choices"
3. Provide the correct answer for the question from the list of answers as key "answer"

You must respond as a JSON object:
{format_instructions}

You must provide the response in {lang} language.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
You are a subject matter expert on the topic:
{topic} in grade level: {grade_level} with difficulty level: {difficulty_level}

Follow the instructions to create an open ended question:
1. Generate an open-ended question based on the topic and grade level provided as key "question"
2. Provide the correct answer for the question in minimum of one and maximum of two sentenses as key "answer"

You must respond as a JSON object:
{format_instructions}

You must provide the response in {lang} language.
Loading