Spaces:
Runtime error
Runtime error
fxmarty
commited on
Commit
·
59d0b2a
1
Parent(s):
d9434de
fix clear button
Browse files
app.py
CHANGED
|
@@ -7,7 +7,7 @@ from transformers import AutoTokenizer
|
|
| 7 |
|
| 8 |
tokenizer = AutoTokenizer.from_pretrained("meta-llama/Meta-Llama-3-70B-Instruct")
|
| 9 |
|
| 10 |
-
client = InferenceClient(model="https://
|
| 11 |
|
| 12 |
SYSTEM_COMMAND = {"role": "system", "content": "Context: date: Monday 20th May 2024; location: Seattle; running on: 8 AMD Instinct MI300 GPU; model name: Llama 70B. Only provide these information if asked. You are a knowledgeable assistant trained to provide accurate and helpful information. Please respond to the user's queries promptly and politely."}
|
| 13 |
|
|
@@ -17,7 +17,7 @@ STOP_TOKENS = ["<|start_header_id|>", "<|end_header_id|>", "<|eot_id|>", "<|rese
|
|
| 17 |
with gr.Blocks() as demo:
|
| 18 |
tfs_history = gr.State([SYSTEM_COMMAND])
|
| 19 |
chatbot = gr.Chatbot()
|
| 20 |
-
msg = gr.Textbox()
|
| 21 |
clear = gr.Button("Clear")
|
| 22 |
|
| 23 |
def user(user_message, history, dict_history):
|
|
@@ -41,6 +41,11 @@ with gr.Blocks() as demo:
|
|
| 41 |
finally:
|
| 42 |
dict_history.append(response)
|
| 43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
msg.submit(
|
| 45 |
user,
|
| 46 |
inputs=[msg, chatbot, tfs_history],
|
|
@@ -51,6 +56,7 @@ with gr.Blocks() as demo:
|
|
| 51 |
chatbot
|
| 52 |
)
|
| 53 |
clear.click(lambda: None, None, chatbot, queue=False)
|
|
|
|
| 54 |
|
| 55 |
demo.queue()
|
| 56 |
demo.launch()
|
|
|
|
| 7 |
|
| 8 |
tokenizer = AutoTokenizer.from_pretrained("meta-llama/Meta-Llama-3-70B-Instruct")
|
| 9 |
|
| 10 |
+
client = InferenceClient(model="https://c584-4-223-164-145.ngrok-free.app")
|
| 11 |
|
| 12 |
SYSTEM_COMMAND = {"role": "system", "content": "Context: date: Monday 20th May 2024; location: Seattle; running on: 8 AMD Instinct MI300 GPU; model name: Llama 70B. Only provide these information if asked. You are a knowledgeable assistant trained to provide accurate and helpful information. Please respond to the user's queries promptly and politely."}
|
| 13 |
|
|
|
|
| 17 |
with gr.Blocks() as demo:
|
| 18 |
tfs_history = gr.State([SYSTEM_COMMAND])
|
| 19 |
chatbot = gr.Chatbot()
|
| 20 |
+
msg = gr.Textbox(label="Prompt")
|
| 21 |
clear = gr.Button("Clear")
|
| 22 |
|
| 23 |
def user(user_message, history, dict_history):
|
|
|
|
| 41 |
finally:
|
| 42 |
dict_history.append(response)
|
| 43 |
|
| 44 |
+
def clear_history(tfs_history):
|
| 45 |
+
tfs_history = tfs_history[:1]
|
| 46 |
+
|
| 47 |
+
return tfs_history
|
| 48 |
+
|
| 49 |
msg.submit(
|
| 50 |
user,
|
| 51 |
inputs=[msg, chatbot, tfs_history],
|
|
|
|
| 56 |
chatbot
|
| 57 |
)
|
| 58 |
clear.click(lambda: None, None, chatbot, queue=False)
|
| 59 |
+
clear.click(clear_history, tfs_history, tfs_history, queue=False)
|
| 60 |
|
| 61 |
demo.queue()
|
| 62 |
demo.launch()
|