Spaces:
Running
Running
Update Gradio_UI.py
Browse files- Gradio_UI.py +16 -0
Gradio_UI.py
CHANGED
@@ -47,6 +47,20 @@ agent_footer = """
|
|
47 |
Thanks for trying it out!
|
48 |
"""
|
49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
def pull_messages_from_step(
|
51 |
step_log: MemoryStep,
|
52 |
):
|
@@ -197,6 +211,7 @@ def stream_to_gradio(
|
|
197 |
yield gr.ChatMessage(role="assistant", content=f"**Final answer:** {str(final_answer)}")
|
198 |
|
199 |
|
|
|
200 |
class GradioUI:
|
201 |
"""A one-line interface to launch your agent in Gradio"""
|
202 |
|
@@ -211,6 +226,7 @@ class GradioUI:
|
|
211 |
if not os.path.exists(file_upload_folder):
|
212 |
os.mkdir(file_upload_folder)
|
213 |
|
|
|
214 |
def interact_with_agent(self, prompt, messages):
|
215 |
import gradio as gr
|
216 |
|
|
|
47 |
Thanks for trying it out!
|
48 |
"""
|
49 |
|
50 |
+
def get_examples():
|
51 |
+
example_root = os.path.join(os.path.dirname(__file__), "examples")
|
52 |
+
# Get list of all example text paths
|
53 |
+
example_files = [os.path.join(example_root, _) for _ in os.listdir(example_root) if _.endswith("txt")]
|
54 |
+
|
55 |
+
|
56 |
+
# Read the content of each file (assuming they're text-based PDFs or plain text files)
|
57 |
+
examples = []
|
58 |
+
for file_path in example_files:
|
59 |
+
with open(file_path, "r", encoding="utf-8", errors="ignore") as f:
|
60 |
+
examples.append(f.read()) # Read the content and append it to the list
|
61 |
+
|
62 |
+
return examples
|
63 |
+
|
64 |
def pull_messages_from_step(
|
65 |
step_log: MemoryStep,
|
66 |
):
|
|
|
211 |
yield gr.ChatMessage(role="assistant", content=f"**Final answer:** {str(final_answer)}")
|
212 |
|
213 |
|
214 |
+
|
215 |
class GradioUI:
|
216 |
"""A one-line interface to launch your agent in Gradio"""
|
217 |
|
|
|
226 |
if not os.path.exists(file_upload_folder):
|
227 |
os.mkdir(file_upload_folder)
|
228 |
|
229 |
+
|
230 |
def interact_with_agent(self, prompt, messages):
|
231 |
import gradio as gr
|
232 |
|