Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -20,9 +20,12 @@ model = (
|
|
| 20 |
.to(device)
|
| 21 |
.eval()
|
| 22 |
)
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
| 24 |
#prompt = "Write a python function to sort the following array in ascending order, don't use any built in sorting methods: [9,2,8,1,5]"
|
| 25 |
-
prompt_input = fmt_prompt(
|
| 26 |
inputs = tokenizer(prompt_input, return_tensors="pt").to(model.device)
|
| 27 |
input_ids_cutoff = inputs.input_ids.size(dim=1)
|
| 28 |
|
|
@@ -42,15 +45,17 @@ def chat_fn(prompt):
|
|
| 42 |
generated_ids[0][input_ids_cutoff:],
|
| 43 |
skip_special_tokens=True,
|
| 44 |
)
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
return
|
| 48 |
|
| 49 |
with gr.Blocks() as app:
|
| 50 |
-
inp = gr.Textbox(label = "Input Prompt")
|
| 51 |
-
outp = gr.Textbox(label = "Response", lines =6)
|
| 52 |
-
btn = gr.Button()
|
| 53 |
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
app.launch()
|
|
|
|
| 20 |
.to(device)
|
| 21 |
.eval()
|
| 22 |
)
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def respond(message, chat_history):
|
| 26 |
+
|
| 27 |
#prompt = "Write a python function to sort the following array in ascending order, don't use any built in sorting methods: [9,2,8,1,5]"
|
| 28 |
+
prompt_input = fmt_prompt(message)
|
| 29 |
inputs = tokenizer(prompt_input, return_tensors="pt").to(model.device)
|
| 30 |
input_ids_cutoff = inputs.input_ids.size(dim=1)
|
| 31 |
|
|
|
|
| 45 |
generated_ids[0][input_ids_cutoff:],
|
| 46 |
skip_special_tokens=True,
|
| 47 |
)
|
| 48 |
+
chat_history.append((message, completion))
|
| 49 |
+
time.sleep(2)
|
| 50 |
+
return "", chat_history
|
| 51 |
|
| 52 |
with gr.Blocks() as app:
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
+
chatbot = gr.Chatbot()
|
| 55 |
+
msg = gr.Textbox("Input")
|
| 56 |
+
clear = gr.ClearButton([msg, chatbot])
|
| 57 |
+
|
| 58 |
+
msg.submit(respond, [msg, chatbot], [msg, chatbot])
|
| 59 |
+
|
| 60 |
|
| 61 |
app.launch()
|