Spaces:
Runtime error
Runtime error
Update chain_app.py
Browse files- chain_app.py +28 -24
chain_app.py
CHANGED
|
@@ -2090,17 +2090,18 @@ async def main(message: cl.Message):
|
|
| 2090 |
for token in stream_list:
|
| 2091 |
await msg.stream_token(token)
|
| 2092 |
elif chat_profile == "gpt4-o-mini":
|
| 2093 |
-
completion = openai_client.chat.completions.create(
|
| 2094 |
model="gpt-4o-mini",
|
| 2095 |
messages=[
|
| 2096 |
{"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"},
|
| 2097 |
{"role": "user", "content": message.content}
|
| 2098 |
-
]
|
|
|
|
| 2099 |
)
|
| 2100 |
-
|
| 2101 |
-
|
| 2102 |
-
content
|
| 2103 |
-
|
| 2104 |
# elif chat_profile == 'Image-Generation':
|
| 2105 |
# result = hf_image_client.predict(
|
| 2106 |
# prompt=message.content,
|
|
@@ -2119,42 +2120,45 @@ async def main(message: cl.Message):
|
|
| 2119 |
# elements=[image],
|
| 2120 |
# ).send()
|
| 2121 |
elif chat_profile == 'GPT-4':
|
| 2122 |
-
completion = openai_client.chat.completions.create(
|
| 2123 |
model="gpt-4",
|
| 2124 |
messages=[
|
| 2125 |
{"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"},
|
| 2126 |
{"role": "user", "content": message.content}
|
| 2127 |
-
]
|
|
|
|
| 2128 |
)
|
| 2129 |
-
|
| 2130 |
-
|
| 2131 |
-
content
|
| 2132 |
-
|
| 2133 |
|
| 2134 |
elif chat_profile == 'gpt-3.5-turbo':
|
| 2135 |
-
completion = openai_client.chat.completions.create(
|
| 2136 |
model="gpt-3.5-turbo",
|
| 2137 |
messages=[
|
| 2138 |
{"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"},
|
| 2139 |
{"role": "user", "content": message.content}
|
| 2140 |
-
]
|
|
|
|
| 2141 |
)
|
| 2142 |
-
|
| 2143 |
-
|
| 2144 |
-
content
|
| 2145 |
-
|
| 2146 |
elif chat_profile == 'GPT-3.5-turbo-0125':
|
| 2147 |
-
completion = openai_client.chat.completions.create(
|
| 2148 |
model="GPT-3.5-turbo-0125",
|
| 2149 |
messages=[
|
| 2150 |
{"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"},
|
| 2151 |
{"role": "user", "content": message.content}
|
| 2152 |
-
]
|
|
|
|
| 2153 |
)
|
| 2154 |
-
|
| 2155 |
-
|
| 2156 |
-
content
|
| 2157 |
-
|
| 2158 |
elif chat_profile == 'gpt-3.5-turbo-1106':
|
| 2159 |
completion = openai_client.chat.completions.create(
|
| 2160 |
model="gpt-3.5-turbo-1106",
|
|
|
|
| 2090 |
for token in stream_list:
|
| 2091 |
await msg.stream_token(token)
|
| 2092 |
elif chat_profile == "gpt4-o-mini":
|
| 2093 |
+
stream = completion = openai_client.chat.completions.create(
|
| 2094 |
model="gpt-4o-mini",
|
| 2095 |
messages=[
|
| 2096 |
{"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"},
|
| 2097 |
{"role": "user", "content": message.content}
|
| 2098 |
+
],
|
| 2099 |
+
stream=True
|
| 2100 |
)
|
| 2101 |
+
|
| 2102 |
+
for part in stream:
|
| 2103 |
+
if token := part.choices[0].delta.content or "":
|
| 2104 |
+
await msg.stream_token(token)
|
| 2105 |
# elif chat_profile == 'Image-Generation':
|
| 2106 |
# result = hf_image_client.predict(
|
| 2107 |
# prompt=message.content,
|
|
|
|
| 2120 |
# elements=[image],
|
| 2121 |
# ).send()
|
| 2122 |
elif chat_profile == 'GPT-4':
|
| 2123 |
+
stream = completion = openai_client.chat.completions.create(
|
| 2124 |
model="gpt-4",
|
| 2125 |
messages=[
|
| 2126 |
{"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"},
|
| 2127 |
{"role": "user", "content": message.content}
|
| 2128 |
+
],
|
| 2129 |
+
stream=True
|
| 2130 |
)
|
| 2131 |
+
|
| 2132 |
+
for part in stream:
|
| 2133 |
+
if token := part.choices[0].delta.content or "":
|
| 2134 |
+
await msg.stream_token(token)
|
| 2135 |
|
| 2136 |
elif chat_profile == 'gpt-3.5-turbo':
|
| 2137 |
+
stream = completion = openai_client.chat.completions.create(
|
| 2138 |
model="gpt-3.5-turbo",
|
| 2139 |
messages=[
|
| 2140 |
{"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"},
|
| 2141 |
{"role": "user", "content": message.content}
|
| 2142 |
+
],
|
| 2143 |
+
stream=True
|
| 2144 |
)
|
| 2145 |
+
|
| 2146 |
+
for part in stream:
|
| 2147 |
+
if token := part.choices[0].delta.content or "":
|
| 2148 |
+
await msg.stream_token(token)
|
| 2149 |
elif chat_profile == 'GPT-3.5-turbo-0125':
|
| 2150 |
+
stream = completion = openai_client.chat.completions.create(
|
| 2151 |
model="GPT-3.5-turbo-0125",
|
| 2152 |
messages=[
|
| 2153 |
{"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"},
|
| 2154 |
{"role": "user", "content": message.content}
|
| 2155 |
+
],
|
| 2156 |
+
stream=True
|
| 2157 |
)
|
| 2158 |
+
|
| 2159 |
+
for part in stream:
|
| 2160 |
+
if token := part.choices[0].delta.content or "":
|
| 2161 |
+
await msg.stream_token(token)
|
| 2162 |
elif chat_profile == 'gpt-3.5-turbo-1106':
|
| 2163 |
completion = openai_client.chat.completions.create(
|
| 2164 |
model="gpt-3.5-turbo-1106",
|