Artin2009 commited on
Commit
92a4b29
1 Parent(s): 3eec83e

Update chain_app.py

Browse files
Files changed (1) hide show
  1. chain_app.py +28 -2
chain_app.py CHANGED
@@ -72,8 +72,8 @@ async def tool():
72
  async def chat_profile():
73
  return [
74
  cl.ChatProfile(
75
- name="None",
76
- markdown_description="None",
77
  ),
78
  cl.ChatProfile(
79
  name="neural-brain-AI",
@@ -1112,6 +1112,18 @@ async def chat_profile():
1112
  @cl.on_chat_start
1113
  async def on_chat_start():
1114
  chat_profile = cl.user_session.get("chat_profile")
 
 
 
 
 
 
 
 
 
 
 
 
1115
  if chat_profile == 'neural-brain-AI':
1116
  await cl.ChatSettings(
1117
  [
@@ -2062,6 +2074,20 @@ async def main(message: cl.Message):
2062
  chat_profile = cl.user_session.get("chat_profile")
2063
  msg = cl.Message(content="")
2064
  await msg.send()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2065
 
2066
  if chat_profile == 'neural-brain-AI':
2067
  stream = completion = openai_client.chat.completions.create(
 
72
  async def chat_profile():
73
  return [
74
  cl.ChatProfile(
75
+ name="default",
76
+ markdown_description="default model",
77
  ),
78
  cl.ChatProfile(
79
  name="neural-brain-AI",
 
1112
  @cl.on_chat_start
1113
  async def on_chat_start():
1114
  chat_profile = cl.user_session.get("chat_profile")
1115
+ if chat_profile == 'default':
1116
+ await cl.ChatSettings(
1117
+ [
1118
+ Select(
1119
+ id="NB-Model",
1120
+ label="NeuralBrain - Models",
1121
+ values=["default-gpt4-o-mini"],
1122
+ initial_index=0,
1123
+ )
1124
+ ]
1125
+ ).send()
1126
+
1127
  if chat_profile == 'neural-brain-AI':
1128
  await cl.ChatSettings(
1129
  [
 
2074
  chat_profile = cl.user_session.get("chat_profile")
2075
  msg = cl.Message(content="")
2076
  await msg.send()
2077
+
2078
+ if chat_profile == 'default':
2079
+ stream = completion = openai_client.chat.completions.create(
2080
+ model="gpt-4o-mini",
2081
+ messages=[
2082
+ {"role": "system", "content": f"You are neural nexus official chatbot, you are made by Artin Daneshvar and Sadra Noadoust and you are here to help people"},
2083
+ {"role": "user", "content": message.content}
2084
+ ],
2085
+ stream=True
2086
+ )
2087
+
2088
+ for part in stream:
2089
+ if token := part.choices[0].delta.content or "":
2090
+ await msg.stream_token(token)
2091
 
2092
  if chat_profile == 'neural-brain-AI':
2093
  stream = completion = openai_client.chat.completions.create(