Spaces:
Sleeping
Sleeping
feat: Added support for subdirectories
Browse files
app.py
CHANGED
@@ -107,23 +107,23 @@ def predict(query, max_characters) -> str:
|
|
107 |
return relevant_chunks
|
108 |
|
109 |
|
110 |
-
|
111 |
docs = {}
|
112 |
|
113 |
-
for
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
|
|
127 |
|
128 |
gr.Interface(
|
129 |
predict,
|
|
|
107 |
return relevant_chunks
|
108 |
|
109 |
|
|
|
110 |
docs = {}
|
111 |
|
112 |
+
for root, _, files in os.walk("sources"):
|
113 |
+
for filename in files:
|
114 |
+
filename = os.path.join(root, filename)
|
115 |
+
if filename.endswith("add_your_files_here"):
|
116 |
+
continue
|
117 |
+
|
118 |
+
converted_doc = convert(filename)
|
119 |
+
|
120 |
+
chunks = chunk_to_length(converted_doc, chunk_size)
|
121 |
+
embeddings = model.encode(chunks)
|
122 |
+
|
123 |
+
docs[filename] = {
|
124 |
+
"chunks": chunks,
|
125 |
+
"embeddings": embeddings,
|
126 |
+
}
|
127 |
|
128 |
gr.Interface(
|
129 |
predict,
|