Artin2009 commited on
Commit
8463f88
1 Parent(s): 99aa8b5

Update chain_app.py

Browse files
Files changed (1) hide show
  1. chain_app.py +9 -7
chain_app.py CHANGED
@@ -19,7 +19,7 @@ fireworks_api_key = os.environ.get('FIREWORKS_API_KEY')
19
 
20
  hf_text_client = Client("Artin2009/text-generation", hf_token=hf_token)
21
  # hf_image_client = Client('Artin2009/image-generation')
22
- openai_client = OpenAI(api_key=openai_api_key)
23
  groq_client = Groq(api_key=groq_api_key)
24
 
25
  co = cohere.Client(
@@ -2078,18 +2078,20 @@ async def main(message: cl.Message):
2078
  await msg.stream_token(token)
2079
 
2080
  elif chat_profile == "Dorna-AI":
2081
- result = hf_text_client.predict(
 
 
 
2082
  message=message.content,
2083
  request=f"You are neural nexus official chatbot, you are made by Artin Daneshvar and Sadra Noadoust and you are here to help people",
2084
  param_3=512,
2085
  param_4=0.7,
2086
  param_5=0.95,
2087
  api_name="/chat"
2088
- )
2089
- model_response = result.strip("</s>")
2090
- await cl.Message(
2091
- content=model_response
2092
- ).send()
2093
  elif chat_profile == "gpt4-o-mini":
2094
  completion = openai_client.chat.completions.create(
2095
  model="gpt-4o-mini",
 
19
 
20
  hf_text_client = Client("Artin2009/text-generation", hf_token=hf_token)
21
  # hf_image_client = Client('Artin2009/image-generation')
22
+ openai_client = OpenAI(api_key=openai_api_key, streaming=True)
23
  groq_client = Groq(api_key=groq_api_key)
24
 
25
  co = cohere.Client(
 
2078
  await msg.stream_token(token)
2079
 
2080
  elif chat_profile == "Dorna-AI":
2081
+ stream_list = []
2082
+ msg = cl.Message(content="")
2083
+ await msg.send()
2084
+ for res in hf_text_client.predict(
2085
  message=message.content,
2086
  request=f"You are neural nexus official chatbot, you are made by Artin Daneshvar and Sadra Noadoust and you are here to help people",
2087
  param_3=512,
2088
  param_4=0.7,
2089
  param_5=0.95,
2090
  api_name="/chat"
2091
+ ):
2092
+ stream_list.appened(res)
2093
+ for token in stream_list:
2094
+ await msg.stream_token(token)
 
2095
  elif chat_profile == "gpt4-o-mini":
2096
  completion = openai_client.chat.completions.create(
2097
  model="gpt-4o-mini",