Spaces:
Runtime error
Runtime error
Harsh Upadhyay
commited on
Commit
·
718633d
1
Parent(s):
0dbc2fd
made the relative imports work.
Browse files- backend/app/__init__.py +1 -1
- backend/app/database.py +0 -1
- backend/app/nlp/qa.py +2 -2
- backend/app/routes/routes.py +13 -13
- backend/app/utils/summarizer.py +1 -1
- backend/tests/conftest.py +1 -1
- backend/tests/test_cache.py +2 -2
- backend/tests/test_endpoints.py +1 -1
backend/app/__init__.py
CHANGED
|
@@ -2,7 +2,7 @@ import os
|
|
| 2 |
from flask import Flask
|
| 3 |
from flask_jwt_extended import JWTManager
|
| 4 |
from flask_cors import CORS
|
| 5 |
-
from
|
| 6 |
import logging
|
| 7 |
|
| 8 |
jwt = JWTManager()
|
|
|
|
| 2 |
from flask import Flask
|
| 3 |
from flask_jwt_extended import JWTManager
|
| 4 |
from flask_cors import CORS
|
| 5 |
+
from .routes.routes import main # Changed to relative import
|
| 6 |
import logging
|
| 7 |
|
| 8 |
jwt = JWTManager()
|
backend/app/database.py
CHANGED
|
@@ -11,7 +11,6 @@ from dotenv import load_dotenv
|
|
| 11 |
import re
|
| 12 |
|
| 13 |
load_dotenv(dotenv_path=os.path.join(os.path.dirname(__file__), '..', '.env'))
|
| 14 |
-
print("DEBUG: DATABASE_URL from os.environ:", os.environ.get('DATABASE_URL'))
|
| 15 |
|
| 16 |
# SQLAlchemy setup
|
| 17 |
DATABASE_URL = os.environ.get('DATABASE_URL')
|
|
|
|
| 11 |
import re
|
| 12 |
|
| 13 |
load_dotenv(dotenv_path=os.path.join(os.path.dirname(__file__), '..', '.env'))
|
|
|
|
| 14 |
|
| 15 |
# SQLAlchemy setup
|
| 16 |
DATABASE_URL = os.environ.get('DATABASE_URL')
|
backend/app/nlp/qa.py
CHANGED
|
@@ -2,9 +2,9 @@ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
|
| 2 |
from sklearn.feature_extraction.text import TfidfVectorizer
|
| 3 |
import numpy as np
|
| 4 |
import logging
|
| 5 |
-
from
|
| 6 |
import torch
|
| 7 |
-
from
|
| 8 |
|
| 9 |
# Check GPU availability
|
| 10 |
if torch.cuda.is_available():
|
|
|
|
| 2 |
from sklearn.feature_extraction.text import TfidfVectorizer
|
| 3 |
import numpy as np
|
| 4 |
import logging
|
| 5 |
+
from ..utils.cache import cache_qa_result
|
| 6 |
import torch
|
| 7 |
+
from ..utils.enhanced_models import enhanced_model_manager
|
| 8 |
|
| 9 |
# Check GPU availability
|
| 10 |
if torch.cuda.is_available():
|
backend/app/routes/routes.py
CHANGED
|
@@ -1,24 +1,24 @@
|
|
| 1 |
import os
|
| 2 |
from flask import Blueprint, request, jsonify, send_file
|
| 3 |
from werkzeug.utils import secure_filename
|
| 4 |
-
from
|
| 5 |
-
from
|
| 6 |
-
from
|
| 7 |
-
from
|
| 8 |
-
from
|
| 9 |
-
from
|
| 10 |
-
from
|
| 11 |
from flask_jwt_extended import create_access_token, jwt_required, get_jwt_identity, exceptions as jwt_exceptions
|
| 12 |
from flask_jwt_extended.exceptions import JWTDecodeError as JWTError
|
| 13 |
from werkzeug.security import generate_password_hash, check_password_hash
|
| 14 |
-
from
|
| 15 |
-
from
|
| 16 |
-
from
|
| 17 |
-
from
|
| 18 |
import logging
|
| 19 |
import textract
|
| 20 |
-
from
|
| 21 |
-
from
|
| 22 |
from sqlalchemy.exc import IntegrityError
|
| 23 |
from sqlalchemy import or_, Index
|
| 24 |
import io
|
|
|
|
| 1 |
import os
|
| 2 |
from flask import Blueprint, request, jsonify, send_file
|
| 3 |
from werkzeug.utils import secure_filename
|
| 4 |
+
from ..utils.extract_text import extract_text_from_pdf
|
| 5 |
+
from ..utils.summarizer import generate_summary
|
| 6 |
+
from ..utils.clause_detector import detect_clauses
|
| 7 |
+
from ..database import save_document, delete_document, Document
|
| 8 |
+
from ..database import get_all_documents, get_document_by_id
|
| 9 |
+
from ..database import search_documents, save_question_answer, search_questions_answers
|
| 10 |
+
from ..nlp.qa import answer_question
|
| 11 |
from flask_jwt_extended import create_access_token, jwt_required, get_jwt_identity, exceptions as jwt_exceptions
|
| 12 |
from flask_jwt_extended.exceptions import JWTDecodeError as JWTError
|
| 13 |
from werkzeug.security import generate_password_hash, check_password_hash
|
| 14 |
+
from ..utils.error_handler import handle_errors
|
| 15 |
+
from ..utils.enhanced_legal_processor import EnhancedLegalProcessor
|
| 16 |
+
from ..utils.legal_domain_features import LegalDomainFeatures
|
| 17 |
+
from ..utils.context_understanding import ContextUnderstanding
|
| 18 |
import logging
|
| 19 |
import textract
|
| 20 |
+
from ..database import get_user_profile, update_user_profile, change_user_password
|
| 21 |
+
from ..database import SessionLocal, User
|
| 22 |
from sqlalchemy.exc import IntegrityError
|
| 23 |
from sqlalchemy import or_, Index
|
| 24 |
import io
|
backend/app/utils/summarizer.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from
|
| 2 |
|
| 3 |
def generate_summary(text, max_length=4096, min_length=200):
|
| 4 |
"""
|
|
|
|
| 1 |
+
from .enhanced_models import enhanced_model_manager
|
| 2 |
|
| 3 |
def generate_summary(text, max_length=4096, min_length=200):
|
| 4 |
"""
|
backend/tests/conftest.py
CHANGED
|
@@ -8,7 +8,7 @@ import shutil
|
|
| 8 |
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
|
| 9 |
|
| 10 |
from app import create_app
|
| 11 |
-
from app.database import init_db
|
| 12 |
|
| 13 |
@pytest.fixture(scope='session')
|
| 14 |
def app():
|
|
|
|
| 8 |
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
|
| 9 |
|
| 10 |
from app import create_app
|
| 11 |
+
from backend.app.database import init_db
|
| 12 |
|
| 13 |
@pytest.fixture(scope='session')
|
| 14 |
def app():
|
backend/tests/test_cache.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import pytest
|
| 2 |
import time
|
| 3 |
-
from app.utils.cache import QACache, cache_qa_result
|
| 4 |
-
from app.nlp.qa import answer_question
|
| 5 |
|
| 6 |
def test_cache_basic():
|
| 7 |
# Create a new cache instance
|
|
|
|
| 1 |
import pytest
|
| 2 |
import time
|
| 3 |
+
from backend.app.utils.cache import QACache, cache_qa_result
|
| 4 |
+
from backend.app.nlp.qa import answer_question
|
| 5 |
|
| 6 |
def test_cache_basic():
|
| 7 |
# Create a new cache instance
|
backend/tests/test_endpoints.py
CHANGED
|
@@ -11,7 +11,7 @@ import uuid
|
|
| 11 |
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
|
| 12 |
|
| 13 |
from app import create_app
|
| 14 |
-
from app.database import init_db
|
| 15 |
|
| 16 |
@pytest.fixture
|
| 17 |
def app():
|
|
|
|
| 11 |
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
|
| 12 |
|
| 13 |
from app import create_app
|
| 14 |
+
from backend.app.database import init_db
|
| 15 |
|
| 16 |
@pytest.fixture
|
| 17 |
def app():
|