Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -112,6 +112,25 @@ def process_files(uploaded_files, lang="eng"):
|
|
| 112 |
ocr_text = extract_text_from_images(images, lang)
|
| 113 |
return combined_text + "\n" + ocr_text
|
| 114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
# Refined function to generate answers
|
| 116 |
def generate_answers(questions, syllabus_text):
|
| 117 |
answers = {}
|
|
|
|
| 112 |
ocr_text = extract_text_from_images(images, lang)
|
| 113 |
return combined_text + "\n" + ocr_text
|
| 114 |
|
| 115 |
+
# Function to generate questions
|
| 116 |
+
def generate_questions(question_type, syllabus_text, num_questions, difficulty, prompt_template):
|
| 117 |
+
# Create a prompt based on user inputs
|
| 118 |
+
prompt = prompt_template.format(
|
| 119 |
+
num_questions=num_questions,
|
| 120 |
+
question_type=question_type,
|
| 121 |
+
syllabus_text=syllabus_text,
|
| 122 |
+
**difficulty
|
| 123 |
+
)
|
| 124 |
+
|
| 125 |
+
# Pass the prompt to the LLM
|
| 126 |
+
chain = (ChatPromptTemplate.from_template(prompt) | llm | StrOutputParser())
|
| 127 |
+
try:
|
| 128 |
+
questions = chain.invoke({})
|
| 129 |
+
return questions
|
| 130 |
+
except Exception as e:
|
| 131 |
+
logging.error(f"Error generating questions: {e}")
|
| 132 |
+
return ""
|
| 133 |
+
|
| 134 |
# Refined function to generate answers
|
| 135 |
def generate_answers(questions, syllabus_text):
|
| 136 |
answers = {}
|