Skip to content

Commit

Permalink
Async and await functions for older version of chainlit.
Browse files Browse the repository at this point in the history
  • Loading branch information
simone-rizzo committed Jun 18, 2023
1 parent 272484d commit f0ba013
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def start_chat():


@cl.on_message
def main(message: str):
async def main(message: str):
message_history = cl.user_session.get("message_history")
message_history.append({"role": "user", "content": message})
msg = cl.Message(content="")
Expand All @@ -87,7 +87,7 @@ def main(message: str):
)
for resp in response:
token = resp.choices[0]["delta"].get("content", "")
msg.stream_token(token)
await msg.stream_token(token)

message_history.append({"role": "assistant", "content": msg.content})
msg.send()
await msg.send()

0 comments on commit f0ba013

Please sign in to comment.