nikshep01 commited on
Commit
af2e7c9
·
verified ·
1 Parent(s): 7af4b2b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -9
app.py CHANGED
@@ -119,17 +119,40 @@
119
  # clear_btn="Clear",
120
  # ).launch()
121
 
 
 
122
 
123
- import gradio as gr
 
 
 
 
 
 
 
 
 
 
124
 
125
- def count_files(files):
126
- num_files = len(files)
127
- return f"You uploaded {num_files} file(s)"
128
 
129
- with gr.Blocks() as demo:
130
- with gr.Row():
131
- chatbot = gr.Chatbot()
132
- file_input = gr.Files(label="Upload Files")
133
- file_input.change(count_files, inputs=file_input, outputs=chatbot)
 
 
 
 
 
 
 
 
 
 
 
 
 
134
 
135
  demo.launch()
 
 
119
  # clear_btn="Clear",
120
  # ).launch()
121
 
122
+ # below code is not working
123
+ # import gradio as gr
124
 
125
+ # def count_files(files):
126
+ # num_files = len(files)
127
+ # return f"You uploaded {num_files} file(s)"
128
+
129
+ # with gr.Blocks() as demo:
130
+ # with gr.Row():
131
+ # chatbot = gr.Chatbot()
132
+ # file_input = gr.Files(label="Upload Files")
133
+ # file_input.change(count_files, inputs=file_input, outputs=chatbot)
134
+
135
+ # demo.launch()
136
 
 
 
 
137
 
138
+ # new code
139
+ import gradio as gr
140
+ import time
141
+
142
+ def echo(message, history, system_prompt, tokens):
143
+ response = f"System prompt: {system_prompt}\n Message: {message}."
144
+ for i in range(min(len(response), int(tokens))):
145
+ time.sleep(0.05)
146
+ yield response[: i + 1]
147
+
148
+ demo = gr.ChatInterface(
149
+ echo,
150
+
151
+ additional_inputs=[
152
+ gr.Textbox("You are helpful AI.", label="System Prompt"),
153
+ gr.Slider(10, 100),
154
+ ],
155
+ )
156
 
157
  demo.launch()
158
+