Spaces:
Sleeping
Sleeping
Commit ·
bacf4fe
1
Parent(s): fd5d9f1
Refactor app.py to improve module import handling and error reporting. Added current directory to Python path for better module accessibility. Implemented try-except block for importing dvd_evaluator, enhancing robustness by providing clear error messages and exiting gracefully on failure.
Browse files- __init__.py +0 -0
- app.py +19 -10
__init__.py
ADDED
|
File without changes
|
app.py
CHANGED
|
@@ -1,5 +1,10 @@
|
|
| 1 |
-
from flask import Flask, render_template, request, jsonify, send_from_directory
|
| 2 |
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
import tempfile
|
| 4 |
import pandas as pd
|
| 5 |
from werkzeug.utils import secure_filename
|
|
@@ -12,15 +17,19 @@ from langchain_core.messages import HumanMessage, SystemMessage
|
|
| 12 |
import tiktoken
|
| 13 |
import json
|
| 14 |
from dotenv import load_dotenv
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
# Define data models
|
| 26 |
class MCQ(BaseModel):
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
+
import sys
|
| 3 |
+
|
| 4 |
+
# Add the current directory to Python path
|
| 5 |
+
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
| 6 |
+
|
| 7 |
+
from flask import Flask, render_template, request, jsonify, send_from_directory
|
| 8 |
import tempfile
|
| 9 |
import pandas as pd
|
| 10 |
from werkzeug.utils import secure_filename
|
|
|
|
| 17 |
import tiktoken
|
| 18 |
import json
|
| 19 |
from dotenv import load_dotenv
|
| 20 |
+
try:
|
| 21 |
+
from dvd_evaluator import (
|
| 22 |
+
generate_mcqs_for_note,
|
| 23 |
+
present_mcqs_to_content,
|
| 24 |
+
MCQ,
|
| 25 |
+
Document
|
| 26 |
+
)
|
| 27 |
+
print("Successfully imported dvd_evaluator")
|
| 28 |
+
|
| 29 |
+
except Exception as e:
|
| 30 |
+
print(f"Error importing dvd_evaluator: {str(e)}")
|
| 31 |
+
sys.exit(1)
|
| 32 |
+
|
| 33 |
|
| 34 |
# Define data models
|
| 35 |
class MCQ(BaseModel):
|