Spaces:
Build error
Build error
Daniel Marques commited on
Commit ·
1427f9d
1
Parent(s): 5040d62
feat: add websocket
Browse files
main.py
CHANGED
|
@@ -214,7 +214,7 @@ async def create_upload_file(file: UploadFile):
|
|
| 214 |
|
| 215 |
@api_app.websocket("/ws/{user_id}")
|
| 216 |
async def websocket_endpoint_student(websocket: WebSocket, user_id: str):
|
| 217 |
-
|
| 218 |
persist_directory=PERSIST_DIRECTORY,
|
| 219 |
embedding_function=EMBEDDINGS,
|
| 220 |
client_settings=CHROMA_SETTINGS,
|
|
@@ -222,7 +222,7 @@ async def websocket_endpoint_student(websocket: WebSocket, user_id: str):
|
|
| 222 |
|
| 223 |
RETRIEVER = DB.as_retriever()
|
| 224 |
|
| 225 |
-
|
| 226 |
llm=LLM,
|
| 227 |
chain_type="stuff",
|
| 228 |
retriever=RETRIEVER,
|
|
@@ -233,9 +233,6 @@ async def websocket_endpoint_student(websocket: WebSocket, user_id: str):
|
|
| 233 |
},
|
| 234 |
)
|
| 235 |
|
| 236 |
-
|
| 237 |
-
QA = socket_manager.get_instance_qa(user_id, newInstanceQA)
|
| 238 |
-
|
| 239 |
message = {
|
| 240 |
"message": f"Student {user_id} connected"
|
| 241 |
}
|
|
@@ -264,7 +261,7 @@ async def websocket_endpoint_student(websocket: WebSocket, user_id: str):
|
|
| 264 |
|
| 265 |
@api_app.websocket("/ws/{room_id}/{user_id}")
|
| 266 |
async def websocket_endpoint_room(websocket: WebSocket, room_id: str, user_id: str):
|
| 267 |
-
|
| 268 |
persist_directory=PERSIST_DIRECTORY,
|
| 269 |
embedding_function=EMBEDDINGS,
|
| 270 |
client_settings=CHROMA_SETTINGS,
|
|
@@ -272,7 +269,7 @@ async def websocket_endpoint_room(websocket: WebSocket, room_id: str, user_id: s
|
|
| 272 |
|
| 273 |
RETRIEVER = DB.as_retriever()
|
| 274 |
|
| 275 |
-
|
| 276 |
llm=LLM,
|
| 277 |
chain_type="stuff",
|
| 278 |
retriever=RETRIEVER,
|
|
@@ -283,8 +280,6 @@ async def websocket_endpoint_room(websocket: WebSocket, room_id: str, user_id: s
|
|
| 283 |
},
|
| 284 |
)
|
| 285 |
|
| 286 |
-
QA = socket_manager.get_instance_qa(room_id, newInstanceQA)
|
| 287 |
-
|
| 288 |
message = {
|
| 289 |
"message": f"Student {user_id} connected to the classroom"
|
| 290 |
}
|
|
|
|
| 214 |
|
| 215 |
@api_app.websocket("/ws/{user_id}")
|
| 216 |
async def websocket_endpoint_student(websocket: WebSocket, user_id: str):
|
| 217 |
+
DB_USER = Chroma(
|
| 218 |
persist_directory=PERSIST_DIRECTORY,
|
| 219 |
embedding_function=EMBEDDINGS,
|
| 220 |
client_settings=CHROMA_SETTINGS,
|
|
|
|
| 222 |
|
| 223 |
RETRIEVER = DB.as_retriever()
|
| 224 |
|
| 225 |
+
QA = RetrievalQA.from_chain_type(
|
| 226 |
llm=LLM,
|
| 227 |
chain_type="stuff",
|
| 228 |
retriever=RETRIEVER,
|
|
|
|
| 233 |
},
|
| 234 |
)
|
| 235 |
|
|
|
|
|
|
|
|
|
|
| 236 |
message = {
|
| 237 |
"message": f"Student {user_id} connected"
|
| 238 |
}
|
|
|
|
| 261 |
|
| 262 |
@api_app.websocket("/ws/{room_id}/{user_id}")
|
| 263 |
async def websocket_endpoint_room(websocket: WebSocket, room_id: str, user_id: str):
|
| 264 |
+
DB_ROOM = Chroma(
|
| 265 |
persist_directory=PERSIST_DIRECTORY,
|
| 266 |
embedding_function=EMBEDDINGS,
|
| 267 |
client_settings=CHROMA_SETTINGS,
|
|
|
|
| 269 |
|
| 270 |
RETRIEVER = DB.as_retriever()
|
| 271 |
|
| 272 |
+
QA = RetrievalQA.from_chain_type(
|
| 273 |
llm=LLM,
|
| 274 |
chain_type="stuff",
|
| 275 |
retriever=RETRIEVER,
|
|
|
|
| 280 |
},
|
| 281 |
)
|
| 282 |
|
|
|
|
|
|
|
| 283 |
message = {
|
| 284 |
"message": f"Student {user_id} connected to the classroom"
|
| 285 |
}
|