CognitiveScience commited on
Commit
ca316f4
1 Parent(s): 639a183

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -9
app.py CHANGED
@@ -1,11 +1,22 @@
1
  import gradio as gr
 
2
 
3
- with gr.Blocks() as demo:
4
- with gr.Box():
5
- chat = gr.Chatbot(label="Chat")
6
- with gr.Row():
7
- msg_box = gr.Textbox(show_label=False, placeholder="Type a message.", scale=5, container=False)
8
- submit_btn = gr.Button("Send", scale=1, variant='primary')
9
-
10
- if __name__ == "__main__":
11
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
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()