fix mixup
This commit is contained in:
@@ -18,3 +18,6 @@ QUIZ_TYPES = {
|
|||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MODEL = "gpt-4o-mini"
|
||||||
|
TEMPERATURE = 0.7
|
||||||
+30
-1
@@ -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)
|
||||||
@@ -71,3 +72,31 @@ def download_pdf_and_extract_text(url: str) -> str:
|
|||||||
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