Setting up the chat client functionality using SocketIO - Start
This commit is contained in:
34
eveai_chat/views/chat_views.py
Normal file
34
eveai_chat/views/chat_views.py
Normal file
@@ -0,0 +1,34 @@
|
||||
# from . import user_bp
|
||||
import uuid
|
||||
from datetime import datetime as dt, timezone as tz
|
||||
from flask import request, redirect, url_for, flash, render_template, Blueprint, session, current_app
|
||||
from flask_security import hash_password, roles_required, roles_accepted
|
||||
from sqlalchemy.exc import SQLAlchemyError
|
||||
|
||||
from common.models.user import User, Tenant
|
||||
from common.models.interaction import ChatSession, Interaction, InteractionEmbedding
|
||||
from common.models.document import Embedding
|
||||
from common.extensions import db, socketio
|
||||
from common.utils.database import Database
|
||||
|
||||
chat_bp = Blueprint('chat_bp', __name__, url_prefix='/chat')
|
||||
|
||||
|
||||
@chat_bp.route('/', methods=['GET', 'POST'])
|
||||
def chat():
|
||||
return render_template('chat.html')
|
||||
|
||||
|
||||
@chat.record_once
|
||||
def on_register(state):
|
||||
# TODO: write initialisation code when the blueprint is registered (only once)
|
||||
# socketio.init_app(state.app)
|
||||
pass
|
||||
|
||||
|
||||
@socketio.on('message', namespace='/chat')
|
||||
def handle_message(message):
|
||||
# TODO: write message handling code to actually realise chat
|
||||
# print('Received message:', message)
|
||||
# socketio.emit('response', {'data': message}, namespace='/chat')
|
||||
pass
|
||||
Reference in New Issue
Block a user