Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -133,11 +133,11 @@ def process_directory(directory, partial_paths=None, file_paths=None):
|
|
| 133 |
with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
|
| 134 |
zip_ref.extractall(tmpdirname)
|
| 135 |
print(f"Extracted {zip_file_path} to {tmpdirname}")
|
| 136 |
-
|
|
|
|
| 137 |
if partial_paths:
|
| 138 |
files = get_all_files_in_folder(tmpdirname, partial_paths)
|
| 139 |
else:
|
| 140 |
-
files = []
|
| 141 |
for root, _, files_list in os.walk(tmpdirname):
|
| 142 |
for file in files_list:
|
| 143 |
files.append(os.path.join(root, file))
|
|
@@ -155,7 +155,7 @@ def process_directory(directory, partial_paths=None, file_paths=None):
|
|
| 155 |
with open(file_path, 'rb') as f:
|
| 156 |
if file_ext in ['.rst', '.md', '.txt', '.html', '.json', '.yaml', '.py']:
|
| 157 |
text = f.read().decode('utf-8')
|
| 158 |
-
print(f"Extracted text from {file_path}:\n{text[:200]}...\n")
|
| 159 |
elif file_ext in ['.svg']:
|
| 160 |
text = f"SVG file content from {file_path}"
|
| 161 |
elif file_ext in ['.png', '.ico']:
|
|
@@ -225,13 +225,14 @@ def rag_workflow(query):
|
|
| 225 |
def initialize():
|
| 226 |
global vectorstore, chunks, llm
|
| 227 |
|
| 228 |
-
download_gitlab_repo()
|
| 229 |
partial_paths = ['kadi-apy-master/source/docs/setup/', 'kadi-apy-master/docs/source/usage/', 'kadi-apy-master/kadi_apy/lib/']
|
| 230 |
file_paths = ['kadi-apy-master/docs/source/usage/lib.rst']
|
| 231 |
-
all_texts, file_references = process_directory(
|
| 232 |
-
chunks = split_into_chunks(all_texts, file_references,
|
| 233 |
-
|
| 234 |
-
|
|
|
|
|
|
|
| 235 |
|
| 236 |
initialize()
|
| 237 |
|
|
|
|
| 133 |
with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
|
| 134 |
zip_ref.extractall(tmpdirname)
|
| 135 |
print(f"Extracted {zip_file_path} to {tmpdirname}")
|
| 136 |
+
|
| 137 |
+
files = []
|
| 138 |
if partial_paths:
|
| 139 |
files = get_all_files_in_folder(tmpdirname, partial_paths)
|
| 140 |
else:
|
|
|
|
| 141 |
for root, _, files_list in os.walk(tmpdirname):
|
| 142 |
for file in files_list:
|
| 143 |
files.append(os.path.join(root, file))
|
|
|
|
| 155 |
with open(file_path, 'rb') as f:
|
| 156 |
if file_ext in ['.rst', '.md', '.txt', '.html', '.json', '.yaml', '.py']:
|
| 157 |
text = f.read().decode('utf-8')
|
| 158 |
+
#print(f"Extracted text from {file_path}:\n{text[:200]}...\n")
|
| 159 |
elif file_ext in ['.svg']:
|
| 160 |
text = f"SVG file content from {file_path}"
|
| 161 |
elif file_ext in ['.png', '.ico']:
|
|
|
|
| 225 |
def initialize():
|
| 226 |
global vectorstore, chunks, llm
|
| 227 |
|
|
|
|
| 228 |
partial_paths = ['kadi-apy-master/source/docs/setup/', 'kadi-apy-master/docs/source/usage/', 'kadi-apy-master/kadi_apy/lib/']
|
| 229 |
file_paths = ['kadi-apy-master/docs/source/usage/lib.rst']
|
| 230 |
+
all_texts, file_references = process_directory(r'C:\Users\Anwender\Downloads\Neuer Ordner', partial_paths, file_paths)
|
| 231 |
+
chunks = split_into_chunks(all_texts, file_references, 512, 0)
|
| 232 |
+
print(f"Total number of chunks: {len(chunks)}")
|
| 233 |
+
# vectorstore = setup_chroma(chunks, EMBEDDING_MODEL_NAME, PERSIST_DIRECTORY)
|
| 234 |
+
# llm = setup_llm(LLM_MODEL_NAME, LLM_TEMPERATURE, GROQ_API_KEY)
|
| 235 |
+
|
| 236 |
|
| 237 |
initialize()
|
| 238 |
|