Spaces:
Runtime error
Runtime error
Commit
·
ca316f4
1
Parent(s):
639a183
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,11 +1,22 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
message=[{ "role" : "system" , "content" : "You are a helpful and kind AI Assistant." }]
|
| 3 |
|
| 4 |
+
def user_input(input):
|
| 5 |
+
if input:
|
| 6 |
+
input_message={"role" : "user" , "content" : input}
|
| 7 |
+
message.append(input_message)
|
| 8 |
+
chat = message
|
| 9 |
+
reply=chat.choices[0].message.content
|
| 10 |
+
output_message={"role" : "assistant" , "content" : reply}
|
| 11 |
+
message.append(output_message)
|
| 12 |
+
|
| 13 |
+
return reply
|
| 14 |
+
|
| 15 |
+
input=gr.inputs.Textbox(lines=7 , label='Chat with AI')
|
| 16 |
+
output=gr.outputs.Textbox(label='replay')
|
| 17 |
+
|
| 18 |
+
interface=gr.Interface(fn=user_input, inputs=input, outputs=output, title="AI Chatbot",
|
| 19 |
+
description="Ask anything you want",
|
| 20 |
+
theme="compact")
|
| 21 |
+
|
| 22 |
+
interface.launch()
|