Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -143,11 +143,18 @@ def answer_question(prompt):
|
|
143 |
return generated_answer
|
144 |
|
145 |
|
146 |
-
def process_inputs(llm,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
# Save questions to a CSV file
|
148 |
-
questions_list = questions.split('\n')
|
149 |
df = pd.DataFrame(questions_list, columns=["Questions"])
|
150 |
-
csv_file = "
|
151 |
df.to_csv(csv_file, index=False)
|
152 |
|
153 |
# Email the CSV file
|
@@ -177,7 +184,7 @@ def process_inputs(llm, questions, relevance, diversity, email):
|
|
177 |
server.sendmail(sender_email, receiver_email, text)
|
178 |
server.quit()
|
179 |
|
180 |
-
return
|
181 |
|
182 |
|
183 |
text_list = []
|
@@ -286,15 +293,14 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
286 |
gr.Markdown("Upon completion, please provide your email address. We will compile and send the answers to you promptly.")
|
287 |
|
288 |
llm_dropdown = gr.Dropdown([("Llama", "TheBloke/Llama-2-7B-Chat-GGML"), ("Falcon", "TheBloke/Falcon-180B-Chat-GGUF"), ("Zephyr", "TheBloke/zephyr-quiklang-3b-4K-GGUF"), ("Vicuna", "TheBloke/vicuna-33B-GGUF"), ("Claude", "TheBloke/claude2-alpaca-13B-GGUF"), ("Alpaca", "TheBloke/LeoScorpius-GreenNode-Alpaca-7B-v1-GGUF")], label="Large Language Model")
|
289 |
-
|
290 |
-
file_upload = gr.File(label="Or You Can Click to Upload a File")
|
291 |
relevance_slider = gr.Slider(0, 100, value=70, step=1, label="Relevance")
|
292 |
diversity_slider = gr.Slider(0, 100, value=25, step=1, label="Diversity")
|
293 |
email_input = gr.Textbox(label="Enter your email address", placeholder="[email protected]")
|
294 |
|
295 |
submit_button = gr.Button("Submit")
|
296 |
output_textbox = gr.Textbox(label="Output")
|
297 |
-
submit_button.click(fn=process_inputs, inputs=[llm_dropdown,
|
298 |
|
299 |
|
300 |
|
|
|
143 |
return generated_answer
|
144 |
|
145 |
|
146 |
+
def process_inputs(llm, file, relevance, diversity, email):
|
147 |
+
# Check if file is uploaded
|
148 |
+
if file is not None:
|
149 |
+
# Read questions from the uploaded file
|
150 |
+
df = pd.read_csv(file.name)
|
151 |
+
questions_list = df.iloc[:, 0].tolist()
|
152 |
+
else:
|
153 |
+
return "No questions provided."
|
154 |
+
|
155 |
# Save questions to a CSV file
|
|
|
156 |
df = pd.DataFrame(questions_list, columns=["Questions"])
|
157 |
+
csv_file = "questions.csv"
|
158 |
df.to_csv(csv_file, index=False)
|
159 |
|
160 |
# Email the CSV file
|
|
|
184 |
server.sendmail(sender_email, receiver_email, text)
|
185 |
server.quit()
|
186 |
|
187 |
+
return "Submitted"
|
188 |
|
189 |
|
190 |
text_list = []
|
|
|
293 |
gr.Markdown("Upon completion, please provide your email address. We will compile and send the answers to you promptly.")
|
294 |
|
295 |
llm_dropdown = gr.Dropdown([("Llama", "TheBloke/Llama-2-7B-Chat-GGML"), ("Falcon", "TheBloke/Falcon-180B-Chat-GGUF"), ("Zephyr", "TheBloke/zephyr-quiklang-3b-4K-GGUF"), ("Vicuna", "TheBloke/vicuna-33B-GGUF"), ("Claude", "TheBloke/claude2-alpaca-13B-GGUF"), ("Alpaca", "TheBloke/LeoScorpius-GreenNode-Alpaca-7B-v1-GGUF")], label="Large Language Model")
|
296 |
+
file_upload = gr.File(label="Upload a File with Questions", file_types=["csv"])
|
|
|
297 |
relevance_slider = gr.Slider(0, 100, value=70, step=1, label="Relevance")
|
298 |
diversity_slider = gr.Slider(0, 100, value=25, step=1, label="Diversity")
|
299 |
email_input = gr.Textbox(label="Enter your email address", placeholder="[email protected]")
|
300 |
|
301 |
submit_button = gr.Button("Submit")
|
302 |
output_textbox = gr.Textbox(label="Output")
|
303 |
+
submit_button.click(fn=process_inputs, inputs=[llm_dropdown, file_upload, relevance_slider, diversity_slider, email_input], outputs=output_textbox)
|
304 |
|
305 |
|
306 |
|