Spaces:
Running
Running
Update Gradio_UI.py
Browse files- Gradio_UI.py +9 -7
Gradio_UI.py
CHANGED
@@ -48,19 +48,20 @@ agent_footer = """
|
|
48 |
"""
|
49 |
|
50 |
def get_examples():
|
51 |
-
|
52 |
# Get list of all example text paths
|
53 |
-
|
54 |
|
55 |
|
56 |
# Read the content of each file (assuming they're text-based PDFs or plain text files)
|
57 |
examples = []
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
|
|
|
|
|
62 |
|
63 |
-
examples.append("test")
|
64 |
|
65 |
return examples
|
66 |
|
@@ -345,7 +346,8 @@ class GradioUI:
|
|
345 |
).then(self.interact_with_agent, [stored_messages, chatbot], [chatbot])
|
346 |
gr.Examples(
|
347 |
examples=get_examples(),
|
348 |
-
inputs=text_input
|
|
|
349 |
)
|
350 |
gr.Markdown( agent_footer )
|
351 |
|
|
|
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 |
|
59 |
+
for file_path in example_files:
|
60 |
+
example_content = ""
|
61 |
+
with open(file_path, "r", encoding="utf-8", errors="ignore") as f:
|
62 |
+
example_content = f.read()
|
63 |
+
examples.append(example_content) # Read the content and append it to the list
|
64 |
|
|
|
65 |
|
66 |
return examples
|
67 |
|
|
|
346 |
).then(self.interact_with_agent, [stored_messages, chatbot], [chatbot])
|
347 |
gr.Examples(
|
348 |
examples=get_examples(),
|
349 |
+
inputs=text_input,
|
350 |
+
label="Example Text"
|
351 |
)
|
352 |
gr.Markdown( agent_footer )
|
353 |
|