yetessam commited on
Commit
ced35f5
·
verified ·
1 Parent(s): 2776f22

Update ContentGradio.py

Browse files
Files changed (1) hide show
  1. ContentGradio.py +22 -1
ContentGradio.py CHANGED
@@ -6,7 +6,25 @@ def process_input(user_input):
6
 
7
  # Function to generate predefined examples
8
  def get_example(example):
9
- return f"You selected: {example}"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
  # Create the header section
12
  def create_header():
@@ -29,6 +47,9 @@ def create_main():
29
 
30
  # Create the examples section
31
  def create_examples(output):
 
 
 
32
  with gr.Row():
33
  gr.Markdown("<div id='examples'>Try one of these examples:</div>")
34
  example_radio = gr.Radio(choices=examples, label="Select an Example")
 
6
 
7
  # Function to generate predefined examples
8
  def get_example(example):
9
+
10
+ example_root = os.path.join(os.path.dirname(__file__), "examples")
11
+ # Get list of all example text paths
12
+ example_files = [os.path.join(example_root, _) for _ in os.listdir(example_root) if _.endswith("txt")]
13
+
14
+
15
+ # Read the content of each file (assuming they're text-based PDFs or plain text files)
16
+ examples = []
17
+
18
+ for file_path in example_files:
19
+ example_content = ""
20
+ with open(file_path, "r", encoding="utf-8", errors="ignore") as f:
21
+ example_content = f.read()
22
+
23
+ examples.append(example_content) # Read the content and append it to the list
24
+
25
+
26
+ return examples
27
+
28
 
29
  # Create the header section
30
  def create_header():
 
47
 
48
  # Create the examples section
49
  def create_examples(output):
50
+
51
+ examples = get_example
52
+
53
  with gr.Row():
54
  gr.Markdown("<div id='examples'>Try one of these examples:</div>")
55
  example_radio = gr.Radio(choices=examples, label="Select an Example")