Spaces:
Paused
Paused
themissingCRAM
commited on
Commit
·
ccfea6c
1
Parent(s):
d4e94c6
ui and clear button
Browse files
app.py
CHANGED
|
@@ -136,19 +136,10 @@ if __name__ == "__main__":
|
|
| 136 |
conversation_history.append(msg)
|
| 137 |
yield "", conversation_history
|
| 138 |
|
| 139 |
-
|
| 140 |
def clear_message(chat_history: list):
|
|
|
|
| 141 |
return chat_history.clear(), ""
|
| 142 |
|
| 143 |
-
|
| 144 |
-
def stop_gen():
|
| 145 |
-
agent = CodeAgent(
|
| 146 |
-
tools=[retriever_tool],
|
| 147 |
-
model=model,
|
| 148 |
-
max_steps=10,
|
| 149 |
-
verbosity_level=10,
|
| 150 |
-
)
|
| 151 |
-
|
| 152 |
with gr.Blocks() as b:
|
| 153 |
gr.Markdown("# Demo agentic rag on some general knowledge.")
|
| 154 |
chatbot = gr.Chatbot(type="messages", height=1000)
|
|
@@ -159,8 +150,9 @@ if __name__ == "__main__":
|
|
| 159 |
stop_generating_button = gr.Button("stop generating")
|
| 160 |
enter_button = gr.Button("enter")
|
| 161 |
reply_button_click_event = enter_button.click(enter_message, [textbox, chatbot], [textbox, chatbot])
|
| 162 |
-
textbox.submit(enter_message, [textbox, chatbot], [textbox, chatbot])
|
| 163 |
-
clear_messages_button.click(fn=clear_message, inputs=chatbot, outputs=[chatbot, textbox],
|
| 164 |
-
|
|
|
|
| 165 |
|
| 166 |
b.launch()
|
|
|
|
| 136 |
conversation_history.append(msg)
|
| 137 |
yield "", conversation_history
|
| 138 |
|
|
|
|
| 139 |
def clear_message(chat_history: list):
|
| 140 |
+
agent.memory.reset()
|
| 141 |
return chat_history.clear(), ""
|
| 142 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
with gr.Blocks() as b:
|
| 144 |
gr.Markdown("# Demo agentic rag on some general knowledge.")
|
| 145 |
chatbot = gr.Chatbot(type="messages", height=1000)
|
|
|
|
| 150 |
stop_generating_button = gr.Button("stop generating")
|
| 151 |
enter_button = gr.Button("enter")
|
| 152 |
reply_button_click_event = enter_button.click(enter_message, [textbox, chatbot], [textbox, chatbot])
|
| 153 |
+
submit_event = textbox.submit(enter_message, [textbox, chatbot], [textbox, chatbot])
|
| 154 |
+
clear_messages_button.click(fn=clear_message, inputs=chatbot, outputs=[chatbot, textbox],
|
| 155 |
+
cancels=[reply_button_click_event, submit_event])
|
| 156 |
+
stop_generating_button.click(cancels=[reply_button_click_event, submit_event])
|
| 157 |
|
| 158 |
b.launch()
|