mike dupont
commited on
Commit
·
f9be86e
1
Parent(s):
5427767
adding file scanner
Browse files
app.py
CHANGED
|
@@ -14,7 +14,7 @@ prompt = st.text_input("prompt",value="Consider this text as a creative writing
|
|
| 14 |
|
| 15 |
source_data = st.selectbox(
|
| 16 |
'What data source should we read',
|
| 17 |
-
(
|
| 18 |
'/data',
|
| 19 |
'/mnt/data1/2024/02/12/meta-coq-common/',
|
| 20 |
))
|
|
@@ -43,7 +43,7 @@ if len(files) > limit:
|
|
| 43 |
mode = st.selectbox("mode", [
|
| 44 |
"--ollama",
|
| 45 |
"--openai",
|
| 46 |
-
|
| 47 |
])
|
| 48 |
model = st.selectbox("model", ["mistral","mixtral"])
|
| 49 |
|
|
@@ -58,8 +58,46 @@ if st.button("Process data"):
|
|
| 58 |
url,
|
| 59 |
mode,
|
| 60 |
model,
|
| 61 |
-
"\"{prompt}\""]
|
| 62 |
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
| 63 |
-
|
| 64 |
for line in proc.stdout:
|
| 65 |
st.write(line)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
source_data = st.selectbox(
|
| 16 |
'What data source should we read',
|
| 17 |
+
(
|
| 18 |
'/data',
|
| 19 |
'/mnt/data1/2024/02/12/meta-coq-common/',
|
| 20 |
))
|
|
|
|
| 43 |
mode = st.selectbox("mode", [
|
| 44 |
"--ollama",
|
| 45 |
"--openai",
|
| 46 |
+
|
| 47 |
])
|
| 48 |
model = st.selectbox("model", ["mistral","mixtral"])
|
| 49 |
|
|
|
|
| 58 |
url,
|
| 59 |
mode,
|
| 60 |
model,
|
| 61 |
+
"\"{prompt}\""]
|
| 62 |
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
| 63 |
+
|
| 64 |
for line in proc.stdout:
|
| 65 |
st.write(line)
|
| 66 |
+
|
| 67 |
+
def get_out_files(path='.'):
|
| 68 |
+
"""Recursive function to find all files in given directory path."""
|
| 69 |
+
files = []
|
| 70 |
+
for item in os.listdir(path):
|
| 71 |
+
fp = os.path.join(path, item)
|
| 72 |
+
if os.path.isdir(fp):
|
| 73 |
+
files.append(fp)
|
| 74 |
+
files += get_out_files(fp)
|
| 75 |
+
else:
|
| 76 |
+
if fp.endswith(".test"):
|
| 77 |
+
files.append(fp)
|
| 78 |
+
#st.write(fp)
|
| 79 |
+
else:
|
| 80 |
+
#st.write("skip"+fp)
|
| 81 |
+
pass
|
| 82 |
+
return files
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
if st.button(f"Scan output {input_dir}"):
|
| 86 |
+
st.write('Going to scan')
|
| 87 |
+
outfiles = get_out_files(input_dir)
|
| 88 |
+
if len(outfiles) > limit:
|
| 89 |
+
outfiles = outfiles[0:limit]
|
| 90 |
+
#st.write(outfiles)
|
| 91 |
+
|
| 92 |
+
for x in outfiles:
|
| 93 |
+
if os.path.isdir(x):
|
| 94 |
+
pass
|
| 95 |
+
else:
|
| 96 |
+
(p,f) =os.path.split(x)
|
| 97 |
+
with open(x, "r") as fp:
|
| 98 |
+
btn = st.download_button(
|
| 99 |
+
label="Download text" + f,
|
| 100 |
+
data=fp,
|
| 101 |
+
file_name=f,
|
| 102 |
+
mime="application/text"
|
| 103 |
+
)
|