feedback in chat added

This commit is contained in:
OwusuBlessing
2025-02-08 02:39:43 +01:00
parent ed55e5e48e
commit cf00443a75
8 changed files with 1081 additions and 167 deletions
+31 -2
View File
@@ -6,9 +6,10 @@ from PyPDF2 import PdfReader
base_path = os.path.join("data", "config_files")
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)
def delete_file(file_path):
try:
os.remove(file_path)
@@ -70,4 +71,32 @@ def download_pdf_and_extract_text(url: str) -> str:
# Delete the temporary file
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: