Spaces:
Sleeping
Sleeping
Юра Цепліцький commited on
Commit ·
03ed0d1
1
Parent(s): 961c967
Edit interfaces
Browse files
app.py
CHANGED
|
@@ -2,7 +2,6 @@ import gradio as gr
|
|
| 2 |
from main import (
|
| 3 |
answer_query,
|
| 4 |
set_keys,
|
| 5 |
-
process_file,
|
| 6 |
handle_file
|
| 7 |
)
|
| 8 |
|
|
|
|
| 2 |
from main import (
|
| 3 |
answer_query,
|
| 4 |
set_keys,
|
|
|
|
| 5 |
handle_file
|
| 6 |
)
|
| 7 |
|
main.py
CHANGED
|
@@ -14,25 +14,6 @@ def set_keys(co_api_key: str, llama_cloud_api_key: str) -> str:
|
|
| 14 |
except Exception as e:
|
| 15 |
return str(e)
|
| 16 |
|
| 17 |
-
def process_file(file) -> str:
|
| 18 |
-
file_path = os.path.join("uploaded_files", file.name)
|
| 19 |
-
|
| 20 |
-
os.makedirs(os.path.dirname(file_path), exist_ok=True)
|
| 21 |
-
|
| 22 |
-
if not os.path.exists(file_path):
|
| 23 |
-
return f"File {file_path} does not exist after writing."
|
| 24 |
-
|
| 25 |
-
try:
|
| 26 |
-
filepath = Path(file_path)
|
| 27 |
-
|
| 28 |
-
if not filepath.parent.exists():
|
| 29 |
-
return f"Directory {filepath.parent} does not exist."
|
| 30 |
-
|
| 31 |
-
create_index(filepath, INDEX_PATH)
|
| 32 |
-
return "File indexed successfully"
|
| 33 |
-
except Exception as e:
|
| 34 |
-
return str(e)
|
| 35 |
-
|
| 36 |
def handle_file(uploaded_file):
|
| 37 |
try:
|
| 38 |
|
|
|
|
| 14 |
except Exception as e:
|
| 15 |
return str(e)
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
def handle_file(uploaded_file):
|
| 18 |
try:
|
| 19 |
|