Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions graphgen/models/generator/quiz_generator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from typing import Any

from graphgen.bases import BaseGenerator
from graphgen.templates import AGGREGATED_GENERATION_PROMPT
from graphgen.utils import detect_main_language, logger


class QuizGenerator(BaseGenerator):
"""
Quiz Generator rephrases given descriptions to create quiz questions.
"""

@staticmethod
def build_prompt(description: str) -> str:
"""
Build prompt for rephrasing the description.
:param description:
:return:
"""
language = detect_main_language(description)
prompt = AGGREGATED_GENERATION_PROMPT[language][
"DESCRIPTION_REPHRASING"
].format(description=description)
return prompt

@staticmethod
def parse_rephrased_text(response: str) -> str:
"""
Parse the rephrased text from the response.
:param response:
:return:
"""
rephrased_text = response.strip().strip('"')
logger.debug("Rephrased Text: %s", rephrased_text)
return rephrased_text

@staticmethod
def parse_response(response: str) -> Any:
pass
3 changes: 1 addition & 2 deletions graphgen/operators/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from .build_kg import build_kg
from .generate import generate_qas
from .init import init_llm
from .judge import judge_statement
from .partition import partition_kg
from .quiz import quiz
from .quiz_and_judge import judge_statement, quiz
from .read import read_files
from .search import search_all
from .split import chunk_documents
2 changes: 2 additions & 0 deletions graphgen/operators/quiz_and_judge/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .judge import judge_statement
from .quiz import quiz
File renamed without changes.
File renamed without changes.
Loading