Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,16 +16,22 @@ def answer_chatgpt(api_key, message, history):
|
|
| 16 |
]
|
| 17 |
)
|
| 18 |
# Displaying the answer on the screen
|
| 19 |
-
answer = response["choices"][0]["message"]["content"]
|
| 20 |
history.append((message, answer))
|
| 21 |
return history, history
|
| 22 |
|
| 23 |
# User input
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
)
|
| 31 |
-
chatbot.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
]
|
| 17 |
)
|
| 18 |
# Displaying the answer on the screen
|
| 19 |
+
answer = response["choices"][0]["message"]["content"]
|
| 20 |
history.append((message, answer))
|
| 21 |
return history, history
|
| 22 |
|
| 23 |
# User input
|
| 24 |
+
block = gr.Blocks()
|
| 25 |
+
|
| 26 |
+
with block:
|
| 27 |
+
gr.Markdown("""<h1><center>π€ ChatGPT-Assistant π</center></h1>
|
| 28 |
+
<p><center>ChatGPT-Assistant is a chatbot that uses the gpt-3.5-turbo model</center></p>
|
| 29 |
+
""")
|
| 30 |
+
api_key = gr.Textbox(placeholder="api_key")
|
| 31 |
+
chatbot = gr.Chatbot()
|
| 32 |
+
message = gr.Textbox(placeholder="message")
|
| 33 |
+
state = gr.State()
|
| 34 |
+
submit = gr.Button("Send")
|
| 35 |
+
submit.click(answer_chatgpt, inputs=[api_key, message, state], outputs=[chatbot, state])
|
| 36 |
+
|
| 37 |
+
block.launch(debug=True)
|