Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
update example loading
Browse filesSigned-off-by: peter szemraj <[email protected]>
utils.py
CHANGED
@@ -31,7 +31,7 @@ def truncate_word_count(text, max_words=512):
|
|
31 |
return processed
|
32 |
|
33 |
|
34 |
-
def load_examples(src):
|
35 |
"""
|
36 |
load_examples - a helper function for the gradio module to load examples
|
37 |
Returns:
|
@@ -39,14 +39,14 @@ def load_examples(src):
|
|
39 |
"""
|
40 |
src = Path(src)
|
41 |
src.mkdir(exist_ok=True)
|
42 |
-
examples = [f for f in src.
|
43 |
examples = natsorted(examples)
|
44 |
# load the examples into a list
|
45 |
text_examples = []
|
46 |
for example in examples:
|
47 |
with open(example, "r") as f:
|
48 |
text = f.read()
|
49 |
-
text_examples.append([text, "
|
50 |
|
51 |
return text_examples
|
52 |
|
|
|
31 |
return processed
|
32 |
|
33 |
|
34 |
+
def load_examples(src, filetypes=[".txt", ".pdf"]):
|
35 |
"""
|
36 |
load_examples - a helper function for the gradio module to load examples
|
37 |
Returns:
|
|
|
39 |
"""
|
40 |
src = Path(src)
|
41 |
src.mkdir(exist_ok=True)
|
42 |
+
examples = [f for f in src.iterdir() if f.suffix in filetypes]
|
43 |
examples = natsorted(examples)
|
44 |
# load the examples into a list
|
45 |
text_examples = []
|
46 |
for example in examples:
|
47 |
with open(example, "r") as f:
|
48 |
text = f.read()
|
49 |
+
text_examples.append([text, "base", 2, 1024, 0.7, 3.5, 3])
|
50 |
|
51 |
return text_examples
|
52 |
|