Artin2009 commited on
Commit
2906f9e
1 Parent(s): 5cfbf32

Update chain_app.py

Browse files
Files changed (1) hide show
  1. chain_app.py +18 -18
chain_app.py CHANGED
@@ -2555,7 +2555,7 @@ async def main(message: cl.Message):
2555
  stream=True,
2556
  ):
2557
  if res.choices[0].delta.content is not None:
2558
- await msg.stream_token(res.choices[0].delta.conten)
2559
 
2560
  elif chat_profile == 'Yi-1.5-34B':
2561
  final_answer = await cl.Message(content="").send()
@@ -2604,11 +2604,12 @@ async def main(message: cl.Message):
2604
  connectors=[],
2605
  )
2606
 
2607
- complete_content = ''
2608
  for event in stream:
2609
  if event.event_type == 'text-generation':
2610
- complete_content += event.text
2611
- await cl.Message(content=complete_content).send()
 
2612
 
2613
  elif chat_profile == 'Aya-35B':
2614
  stream = co.chat_stream(
@@ -2623,8 +2624,8 @@ async def main(message: cl.Message):
2623
  complete_content = ''
2624
  for event in stream:
2625
  if event.event_type == 'text-generation':
2626
- complete_content += event.text
2627
- await cl.Message(content=complete_content).send()
2628
 
2629
  elif chat_profile == 'Command-R-Plus':
2630
  stream = co.chat_stream(
@@ -2637,8 +2638,8 @@ async def main(message: cl.Message):
2637
  complete_content = ''
2638
  for event in stream:
2639
  if event.event_type == 'text-generation':
2640
- complete_content += event.text
2641
- await cl.Message(content=complete_content).send()
2642
 
2643
  elif chat_profile == 'Command-R':
2644
  stream = co.chat_stream(
@@ -2651,8 +2652,8 @@ async def main(message: cl.Message):
2651
  complete_content = ''
2652
  for event in stream:
2653
  if event.event_type == 'text-generation':
2654
- complete_content += event.text
2655
- await cl.Message(content=complete_content).send()
2656
 
2657
  elif chat_profile == 'Command':
2658
  stream = co.chat_stream(
@@ -2665,8 +2666,8 @@ async def main(message: cl.Message):
2665
  complete_content = ''
2666
  for event in stream:
2667
  if event.event_type == 'text-generation':
2668
- complete_content += event.text
2669
- await cl.Message(content=complete_content).send()
2670
 
2671
  elif chat_profile == 'Command-Light':
2672
  stream = co.chat_stream(
@@ -2679,8 +2680,7 @@ async def main(message: cl.Message):
2679
  complete_content = ''
2680
  for event in stream:
2681
  if event.event_type == 'text-generation':
2682
- complete_content += event.text
2683
- await cl.Message(content=complete_content).send()
2684
 
2685
  elif chat_profile == 'Command-Light-Nightly':
2686
  stream = co.chat_stream(
@@ -2693,8 +2693,8 @@ async def main(message: cl.Message):
2693
  complete_content = ''
2694
  for event in stream:
2695
  if event.event_type == 'text-generation':
2696
- complete_content += event.text
2697
- await cl.Message(content=complete_content).send()
2698
 
2699
  elif chat_profile == 'Command-Nightly':
2700
  stream = co.chat_stream(
@@ -2707,8 +2707,8 @@ async def main(message: cl.Message):
2707
  complete_content = ''
2708
  for event in stream:
2709
  if event.event_type == 'text-generation':
2710
- complete_content += event.text
2711
- await cl.Message(content=complete_content).send()
2712
 
2713
 
2714
  @cl.on_settings_update
 
2555
  stream=True,
2556
  ):
2557
  if res.choices[0].delta.content is not None:
2558
+ await msg.stream_token(res.choices[0].delta.content)
2559
 
2560
  elif chat_profile == 'Yi-1.5-34B':
2561
  final_answer = await cl.Message(content="").send()
 
2604
  connectors=[],
2605
  )
2606
 
2607
+ # complete_content = ''
2608
  for event in stream:
2609
  if event.event_type == 'text-generation':
2610
+ await msg.stream_token(event)
2611
+ # complete_content += event.text
2612
+ # await cl.Message(content=complete_content).send()
2613
 
2614
  elif chat_profile == 'Aya-35B':
2615
  stream = co.chat_stream(
 
2624
  complete_content = ''
2625
  for event in stream:
2626
  if event.event_type == 'text-generation':
2627
+ await msg.stream_token(event)
2628
+
2629
 
2630
  elif chat_profile == 'Command-R-Plus':
2631
  stream = co.chat_stream(
 
2638
  complete_content = ''
2639
  for event in stream:
2640
  if event.event_type == 'text-generation':
2641
+ await msg.stream_token(event)
2642
+
2643
 
2644
  elif chat_profile == 'Command-R':
2645
  stream = co.chat_stream(
 
2652
  complete_content = ''
2653
  for event in stream:
2654
  if event.event_type == 'text-generation':
2655
+ await msg.stream_token(event)
2656
+
2657
 
2658
  elif chat_profile == 'Command':
2659
  stream = co.chat_stream(
 
2666
  complete_content = ''
2667
  for event in stream:
2668
  if event.event_type == 'text-generation':
2669
+ await msg.stream_token(event)
2670
+
2671
 
2672
  elif chat_profile == 'Command-Light':
2673
  stream = co.chat_stream(
 
2680
  complete_content = ''
2681
  for event in stream:
2682
  if event.event_type == 'text-generation':
2683
+ await msg.stream_token(event)
 
2684
 
2685
  elif chat_profile == 'Command-Light-Nightly':
2686
  stream = co.chat_stream(
 
2693
  complete_content = ''
2694
  for event in stream:
2695
  if event.event_type == 'text-generation':
2696
+ await msg.stream_token(event)
2697
+
2698
 
2699
  elif chat_profile == 'Command-Nightly':
2700
  stream = co.chat_stream(
 
2707
  complete_content = ''
2708
  for event in stream:
2709
  if event.event_type == 'text-generation':
2710
+ await msg.stream_token(event)
2711
+
2712
 
2713
 
2714
  @cl.on_settings_update