Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,17 +10,30 @@ def respond(message, history):
|
|
| 10 |
if history :
|
| 11 |
messages.extend(history)
|
| 12 |
messages.append({"role":"user","content": message})
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
|
| 16 |
-
|
| 17 |
|
| 18 |
|
| 19 |
-
def random_message (message, history):
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
theme = soft
|
| 23 |
-
|
| 24 |
|
| 25 |
|
| 26 |
chatbot = gr.ChatInterface(respond, type = "messages", title = "chatty")
|
|
|
|
| 10 |
if history :
|
| 11 |
messages.extend(history)
|
| 12 |
messages.append({"role":"user","content": message})
|
| 13 |
+
|
| 14 |
+
response = ""
|
| 15 |
+
|
| 16 |
+
for message in client.chat_completion(
|
| 17 |
+
messages,
|
| 18 |
+
max_tokens = 400,
|
| 19 |
+
stream = True)
|
| 20 |
+
token = message.choices[0].delta.content
|
| 21 |
+
response += token
|
| 22 |
+
yield response
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
# top_p & temperature
|
| 26 |
+
|
| 27 |
|
| 28 |
|
| 29 |
+
#return response["choices"][0]["message"]["content"].strip()
|
| 30 |
|
| 31 |
|
| 32 |
+
#def random_message (message, history):
|
| 33 |
+
# choices = ('yes','no','i dont think so','be so for real','yep', 'woooow', 'hmmmm', 'idk', 'idc', 'yaaay', 'why would i know')
|
| 34 |
+
# wow = random.choice(choices)
|
| 35 |
+
# theme = soft
|
| 36 |
+
# return wow
|
| 37 |
|
| 38 |
|
| 39 |
chatbot = gr.ChatInterface(respond, type = "messages", title = "chatty")
|