fix mixup
This commit is contained in:
@@ -17,4 +17,7 @@ QUIZ_TYPES = {
|
|||||||
{"question": "Your question here", "options": ["True", "False"], "correct_answer": "True or False"}
|
{"question": "Your question here", "options": ["True", "False"], "correct_answer": "True or False"}
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MODEL = "gpt-4o-mini"
|
||||||
|
TEMPERATURE = 0.7
|
||||||
+31
-2
@@ -6,9 +6,10 @@ from PyPDF2 import PdfReader
|
|||||||
base_path = os.path.join("data", "config_files")
|
base_path = os.path.join("data", "config_files")
|
||||||
THEME_CONTEXT_PATH = os.path.join(base_path, "theme_context.json")
|
THEME_CONTEXT_PATH = os.path.join(base_path, "theme_context.json")
|
||||||
|
|
||||||
with open(THEME_CONTEXT_PATH, "r") as f:
|
with open(THEME_CONTEXT_PATH, "r", encoding="utf-8") as f:
|
||||||
themes = json.load(f)
|
themes = json.load(f)
|
||||||
|
|
||||||
|
|
||||||
def delete_file(file_path):
|
def delete_file(file_path):
|
||||||
try:
|
try:
|
||||||
os.remove(file_path)
|
os.remove(file_path)
|
||||||
@@ -70,4 +71,32 @@ def download_pdf_and_extract_text(url: str) -> str:
|
|||||||
# Delete the temporary file
|
# Delete the temporary file
|
||||||
os.remove(temp_file_path)
|
os.remove(temp_file_path)
|
||||||
|
|
||||||
return combined_text
|
return combined_text
|
||||||
|
|
||||||
|
|
||||||
|
def format_qna_json_text(json_data):
|
||||||
|
"""
|
||||||
|
Format a list of Q&A JSON data into a text string with dashes.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
- json_data (list): A list of Q&A dictionaries with 'question' and 'answer' keys.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
- str: A formatted text string.
|
||||||
|
"""
|
||||||
|
formatted_text = ""
|
||||||
|
|
||||||
|
# Check if input is a list of Q&A dictionaries
|
||||||
|
if isinstance(json_data, list):
|
||||||
|
for item in json_data:
|
||||||
|
if 'question' in item and 'answer' in item:
|
||||||
|
formatted_text += f"- Question: {item['question']}\n"
|
||||||
|
formatted_text += f" Answer: {item['answer']}\n"
|
||||||
|
else:
|
||||||
|
formatted_text += "- Incomplete Q&A entry\n"
|
||||||
|
|
||||||
|
return formatted_text.strip()
|
||||||
|
|
||||||
|
# Example usage:
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user