Artin2009 commited on
Commit
cd96b1a
1 Parent(s): bf9cd6b

Update chain_app.py

Browse files
Files changed (1) hide show
  1. chain_app.py +18 -8
chain_app.py CHANGED
@@ -64,7 +64,7 @@ async def set_starters():
64
  @cl.step(type="tool")
65
  async def tool():
66
  # Simulate a running task
67
- await cl.sleep(1)
68
 
69
  return "Response from the tool!"
70
 
@@ -2601,14 +2601,24 @@ async def main(message: cl.Message):
2601
  token=f'{hf_token_llama_3_1}',
2602
  )
2603
  tool_res = await tool()
2604
- result = client.chat_completion(
2605
- messages=[{"role": "user", "content": message.content}],
2606
- max_tokens=500,
2607
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
2608
 
2609
- await cl.Message(
2610
- content=result.choices[0].message.content,
2611
- ).send()
2612
 
2613
  # elif chat_profile == 'Toka-353M':
2614
  # output = query({
 
64
  @cl.step(type="tool")
65
  async def tool():
66
  # Simulate a running task
67
+ await cl.sleep(0.5)
68
 
69
  return "Response from the tool!"
70
 
 
2601
  token=f'{hf_token_llama_3_1}',
2602
  )
2603
  tool_res = await tool()
2604
+ msg = cl.Message(content="")
2605
+ await msg.send()
2606
+ # result = client.chat_completion(
2607
+ # messages=[{"role": "user", "content": message.content}],
2608
+ # max_tokens=500,
2609
+ # )
2610
+
2611
+ # await cl.Message(
2612
+ # content=result.choices[0].message.content,
2613
+ # ).send()
2614
+ async for message in client.chat_completion(
2615
+ messages=[{"role": "user", "content": "What is the capital of France?"}],
2616
+ max_tokens=500,
2617
+ stream=True,
2618
+ ):
2619
+ if token := part.choices[0].delta.content or "":
2620
+ await msg.stream_token(token)
2621
 
 
 
 
2622
 
2623
  # elif chat_profile == 'Toka-353M':
2624
  # output = query({