Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the conversation does not support concurrency #1914

Open
Andy1018 opened this issue Feb 20, 2025 · 0 comments
Open

the conversation does not support concurrency #1914

Andy1018 opened this issue Feb 20, 2025 · 0 comments
Labels
bug Something isn't working needs-triage

Comments

@Andy1018
Copy link

The conversation does not support concurrency. When uploading a file in the dialog box and the file is being vectorized, it is impossible to have a conversation in another window because the main thread is blocked. How can this problem be solved?

@cl.on_message
async def main(message: cl.Message):
msg = cl.Message(content="", author="Assistant")
chat_mode = cl.user_session.get("chat_profile", "A")
history = cl.user_session.get("history", [])

if chat_mode == "A":
await view_pdf(message.elements)
files = []
file_names = []
for element in message.elements:
if isinstance(element, cl.File) or isinstance(element, cl.Image):
files.append(element.path)
file_names.append(element.name)
m = cl.user_session.get("settings", False)
multimodal = m.get('multimodal', False)
if multimodal and len(files) > 0:
rag = TraditionalRAG(files=files, file_names=file_names, ocr_enabled=multimodal)
index = await rag.create_index_local()
chat_engine = index.as_chat_engine(chat_mode=ChatMode.CONTEXT, similarity_top_k=6)
cl.user_session.set("chat_engine", chat_engine)

elif len(files) > 0:
rag = TraditionalRAG(files=files, file_names=file_names, ocr_enabled=False)
index = await rag.create_index_local()
chat_engine = index.as_chat_engine(chat_mode=ChatMode.CONTEXT, similarity_top_k=6)
cl.user_session.set("chat_engine", chat_engine)

chat_engine = cl.user_session.get("chat_engine")

res = await cl.make_async(chat_engine.stream_chat)(message.content)

for token in res.response_gen:
    await msg.stream_token(token)
await msg.send()
@dosubot dosubot bot added the bug Something isn't working label Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-triage
Projects
None yet
Development

No branches or pull requests

1 participant