Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
print("eeeh")
|
| 2 |
import asyncio
|
| 3 |
import json
|
| 4 |
from websockets.server import serve
|
|
@@ -27,6 +26,7 @@ print("started")
|
|
| 27 |
print("-------")
|
| 28 |
|
| 29 |
async def echo(websocket):
|
|
|
|
| 30 |
async for message in websocket:
|
| 31 |
data = json.loads(message)
|
| 32 |
if not "message" in message:
|
|
@@ -36,7 +36,6 @@ async def echo(websocket):
|
|
| 36 |
m = data["message"]
|
| 37 |
token = data["token"]
|
| 38 |
docs = retriever.get_relevant_documents(m)
|
| 39 |
-
userData[token]["docs"] = str(docs)
|
| 40 |
response = conversational_rag_chain.invoke(
|
| 41 |
{"input": m},
|
| 42 |
config={
|
|
@@ -49,6 +48,7 @@ async def main():
|
|
| 49 |
async with serve(echo, "0.0.0.0", 7860):
|
| 50 |
await asyncio.Future()
|
| 51 |
def g():
|
|
|
|
| 52 |
if not os.path.isdir('database'):
|
| 53 |
os.system("unzip database.zip")
|
| 54 |
|
|
@@ -156,7 +156,6 @@ def g():
|
|
| 156 |
history_messages_key="chat_history",
|
| 157 |
output_messages_key="answer",
|
| 158 |
)
|
| 159 |
-
globals().update(locals())
|
| 160 |
|
| 161 |
def f():
|
| 162 |
asyncio.run(main())
|
|
|
|
|
|
|
| 1 |
import asyncio
|
| 2 |
import json
|
| 3 |
from websockets.server import serve
|
|
|
|
| 26 |
print("-------")
|
| 27 |
|
| 28 |
async def echo(websocket):
|
| 29 |
+
global userData
|
| 30 |
async for message in websocket:
|
| 31 |
data = json.loads(message)
|
| 32 |
if not "message" in message:
|
|
|
|
| 36 |
m = data["message"]
|
| 37 |
token = data["token"]
|
| 38 |
docs = retriever.get_relevant_documents(m)
|
|
|
|
| 39 |
response = conversational_rag_chain.invoke(
|
| 40 |
{"input": m},
|
| 41 |
config={
|
|
|
|
| 48 |
async with serve(echo, "0.0.0.0", 7860):
|
| 49 |
await asyncio.Future()
|
| 50 |
def g():
|
| 51 |
+
global retriever, conversational_rag_chain
|
| 52 |
if not os.path.isdir('database'):
|
| 53 |
os.system("unzip database.zip")
|
| 54 |
|
|
|
|
| 156 |
history_messages_key="chat_history",
|
| 157 |
output_messages_key="answer",
|
| 158 |
)
|
|
|
|
| 159 |
|
| 160 |
def f():
|
| 161 |
asyncio.run(main())
|