new file: .dockerignore
new file: .env.example new file: Dockerfile new file: app.py new file: blueprints/__init__.py new file: blueprints/auth.py new file: blueprints/chat.py new file: blueprints/context.py new file: blueprints/documents.py new file: blueprints/main.py new file: config.py new file: docker-compose.yml new file: models/__init__.py new file: models/chat_session.py new file: models/document.py new file: models/user.py new file: requirements.txt new file: services/__init__.py new file: services/document_parser.py new file: services/llm_service.py new file: services/rag_service.py new file: services/url_scraper.py new file: static/css/style.css new file: static/js/chat.js new file: static/js/inline_chat.js new file: static/js/main.js new file: templates/base.html new file: templates/document_view.html new file: templates/index.html new file: templates/login.html new file: templates/register.html
This commit is contained in:
56
app.py
Normal file
56
app.py
Normal file
@@ -0,0 +1,56 @@
|
||||
import os
|
||||
from flask import Flask
|
||||
from flask_login import LoginManager
|
||||
from config import Config
|
||||
from models import db, User
|
||||
|
||||
|
||||
login_manager = LoginManager()
|
||||
|
||||
|
||||
def create_app(config_class=Config):
|
||||
app = Flask(__name__)
|
||||
app.config.from_object(config_class)
|
||||
|
||||
# Ensure required directories exist
|
||||
os.makedirs(app.config["UPLOAD_FOLDER"], exist_ok=True)
|
||||
os.makedirs(app.config["VECTORDB_PATH"], exist_ok=True)
|
||||
os.makedirs(app.config["TRANSFORMERS_CACHE"], exist_ok=True)
|
||||
|
||||
# Set HuggingFace cache env so sentence-transformers respects it
|
||||
os.environ["TRANSFORMERS_CACHE"] = app.config["TRANSFORMERS_CACHE"]
|
||||
os.environ["HF_HOME"] = app.config["TRANSFORMERS_CACHE"]
|
||||
|
||||
# Extensions
|
||||
db.init_app(app)
|
||||
login_manager.init_app(app)
|
||||
login_manager.login_view = "auth.login"
|
||||
login_manager.login_message_category = "info"
|
||||
|
||||
@login_manager.user_loader
|
||||
def load_user(user_id):
|
||||
return User.query.get(int(user_id))
|
||||
|
||||
# Blueprints
|
||||
from blueprints.auth import auth_bp
|
||||
from blueprints.documents import documents_bp
|
||||
from blueprints.context import context_bp
|
||||
from blueprints.chat import chat_bp
|
||||
from blueprints.main import main_bp
|
||||
|
||||
app.register_blueprint(auth_bp)
|
||||
app.register_blueprint(documents_bp)
|
||||
app.register_blueprint(context_bp)
|
||||
app.register_blueprint(chat_bp)
|
||||
app.register_blueprint(main_bp)
|
||||
|
||||
# Create DB tables
|
||||
with app.app_context():
|
||||
db.create_all()
|
||||
|
||||
return app
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = create_app()
|
||||
app.run(host="0.0.0.0", port=5000)
|
||||
Reference in New Issue
Block a user