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

Fix JSON Serialization Error by Correctly Handling cl.Message Type #3

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions langchain_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ def main():
cl.user_session.set("llm_chain",llm_chain)

@cl.on_message
async def main(message : str):
async def main(message : cl.Message):
llm_chain = cl.user_session.get("llm_chain")

res = await llm_chain.acall(message, callbacks=[cl.AsyncLangchainCallbackHandler()])
res = await llm_chain.acall(message.content, callbacks=[cl.AsyncLangchainCallbackHandler()])

await cl.Message(content=res["text"]).send()

Expand Down
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def get_gpt_output(user_message):
return response

@cl.on_message
async def main(message : str):
await cl.Message(content = f"{get_gpt_output(message)['choices'][0]['message']['content']}",).send()
async def main(message: cl.Message):
await cl.Message(content = f"{get_gpt_output(message.content)['choices'][0]['message']['content']}",).send()