Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,27 +1,11 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
messages = [{"role": "system", "content": "You are a friendly chatbot."}]
|
| 8 |
-
if history:
|
| 9 |
-
messages.extend(history)
|
| 10 |
-
messages.append({"role": "user", "content": message})
|
| 11 |
-
response = client.chat_completion(
|
| 12 |
-
messages,
|
| 13 |
-
max_tokens=100
|
| 14 |
-
|
| 15 |
-
)
|
| 16 |
-
print(response['choices'][0]['message']['content'].strip())
|
| 17 |
-
return response['choices'][0]['message']['content'].strip()
|
| 18 |
|
| 19 |
-
|
| 20 |
-
eight_ball_answers = ["yes","no","ehhh probably not the best idea","Sure why not!","idk","i seems not","hahahaha... no","yes of course!"]
|
| 21 |
-
random_choice = rd.choice(eight_ball_answers)
|
| 22 |
-
return random_choice
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
chatbot.launch()
|
| 27 |
-
|
|
|
|
| 1 |
+
with gr.Blocks(css=".chatbox-custom .chatbot {background-color: #e6ffe6;}") as demo:
|
| 2 |
+
with gr.Column(elem_classes="chatbox-custom"):
|
| 3 |
+
chatbot = gr.Chatbot()
|
| 4 |
+
msg = gr.Textbox()
|
| 5 |
|
| 6 |
+
def respond(message, chat_history):
|
| 7 |
+
return "", chat_history + [(message, "Hi there!")]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
+
msg.submit(respond, [msg, chatbot], [msg, chatbot])
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
+
demo.launch()
|
|
|
|
|
|
|
|
|