Spaces:
Runtime error
Runtime error
Update tools.py
Browse files
tools.py
CHANGED
|
@@ -6,20 +6,21 @@ from pydantic import BaseModel, Field
|
|
| 6 |
|
| 7 |
from app import INDEX_PATH
|
| 8 |
|
| 9 |
-
def download_index_from_gdrive(self)
|
| 10 |
-
|
| 11 |
zip_path = "index.zip"
|
| 12 |
url = f"https://drive.google.com/uc?id={self.gdrive_index_id}"
|
| 13 |
gdown.download(url, zip_path, quiet=False)
|
| 14 |
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
|
| 15 |
zip_ref.extractall(".")
|
| 16 |
os.remove(zip_path)
|
| 17 |
-
return True
|
| 18 |
-
|
| 19 |
-
except Exception as e:
|
| 20 |
-
st.error(f"Failed to download index: {str(e)}")
|
| 21 |
-
return False
|
| 22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
class ReadTextArgs(BaseModel):
|
| 24 |
reference: str = Field(description="The reference to retrieve the text for. examples: 讘专讗砖讬转 讗 驻专拽 讗, Genesis 1:1")
|
| 25 |
|
|
|
|
| 6 |
|
| 7 |
from app import INDEX_PATH
|
| 8 |
|
| 9 |
+
def download_index_from_gdrive(self) :
|
| 10 |
+
|
| 11 |
zip_path = "index.zip"
|
| 12 |
url = f"https://drive.google.com/uc?id={self.gdrive_index_id}"
|
| 13 |
gdown.download(url, zip_path, quiet=False)
|
| 14 |
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
|
| 15 |
zip_ref.extractall(".")
|
| 16 |
os.remove(zip_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
if not os.path.exists(INDEX_PATH):
|
| 21 |
+
download_index_from_gdrive():
|
| 22 |
+
|
| 23 |
+
|
| 24 |
class ReadTextArgs(BaseModel):
|
| 25 |
reference: str = Field(description="The reference to retrieve the text for. examples: 讘专讗砖讬转 讗 驻专拽 讗, Genesis 1:1")
|
| 26 |
|