Spaces:
Runtime error
Runtime error
File size: 702 Bytes
75df934 9235b6d 75df934 9235b6d 75df934 f7e0e10 75df934 f7e0e10 75df934 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import json
from . import model_manage as md
from chat.arxiv_bot.arxiv_bot_utils import ArxivSQL
from channels.generic.websocket import WebsocketConsumer
class ChatConsumer(WebsocketConsumer):
def connect(self):
self.accept()
self.db_instance = ArxivSQL()
def disconnect(self, close_code):
pass
def receive(self, text_data):
text_data_json = json.loads(text_data)
message = text_data_json["messages"]
print(message)
record, messagee = md.full_chain_history_question(message, self.db_instance)
print("First answer: ",record)
self.send(text_data=json.dumps({"message": messagee}))
|