Spaces:
Paused
Paused
Daniel Marques
commited on
Commit
•
25121ae
1
Parent(s):
8e1e4b4
feat: add backend
Browse files
main.py
CHANGED
@@ -74,8 +74,7 @@ class MyCustomSyncHandler(BaseCallbackHandler):
|
|
74 |
|
75 |
handlerToken = MyCustomSyncHandler()
|
76 |
|
77 |
-
|
78 |
-
LLM = load_model(device_type=DEVICE_TYPE, model_id=MODEL_ID, model_basename=MODEL_BASENAME, stream=True, callbacks=[handlerToken])
|
79 |
|
80 |
template = """You are a helpful, respectful and honest assistant. You should only use the documents provided in the context to answer the questions.
|
81 |
You should only respond only topics that contains in documents use to training. Use the following pieces of context to answer the question at the end.
|
@@ -97,6 +96,7 @@ QA = RetrievalQA.from_chain_type(
|
|
97 |
return_source_documents=SHOW_SOURCES,
|
98 |
chain_type_kwargs={
|
99 |
"prompt": QA_CHAIN_PROMPT,
|
|
|
100 |
},
|
101 |
)
|
102 |
|
@@ -253,14 +253,9 @@ async def websocket_endpoint(websocket: WebSocket):
|
|
253 |
while True:
|
254 |
data = await websocket.receive_text()
|
255 |
|
256 |
-
QA(data)
|
|
|
|
|
257 |
|
258 |
-
finish = False
|
259 |
-
while finish == False:
|
260 |
-
finish = handlerToken.end
|
261 |
-
token = handlerToken.token
|
262 |
-
print(token)
|
263 |
-
print(finish)
|
264 |
-
await websocket.send_text(f"result: {token}")
|
265 |
|
266 |
|
|
|
74 |
|
75 |
handlerToken = MyCustomSyncHandler()
|
76 |
|
77 |
+
LLM = load_model(device_type=DEVICE_TYPE, model_id=MODEL_ID, model_basename=MODEL_BASENAME, stream=True, callbacks=[])
|
|
|
78 |
|
79 |
template = """You are a helpful, respectful and honest assistant. You should only use the documents provided in the context to answer the questions.
|
80 |
You should only respond only topics that contains in documents use to training. Use the following pieces of context to answer the question at the end.
|
|
|
96 |
return_source_documents=SHOW_SOURCES,
|
97 |
chain_type_kwargs={
|
98 |
"prompt": QA_CHAIN_PROMPT,
|
99 |
+
"callbacks": [handlerToken]
|
100 |
},
|
101 |
)
|
102 |
|
|
|
253 |
while True:
|
254 |
data = await websocket.receive_text()
|
255 |
|
256 |
+
res = QA(data)
|
257 |
+
|
258 |
+
await websocket.send_text(f"result: {res}")
|
259 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
260 |
|
261 |
|