Spaces:
Running
Running
Update describepdf/config.py
Browse files- describepdf/config.py +25 -25
describepdf/config.py
CHANGED
@@ -20,31 +20,31 @@ Resolve the path to the prompts directory with multiple fallback strategies.
|
|
20 |
Returns:
|
21 |
pathlib.Path: Path to the prompts directory
|
22 |
"""
|
23 |
-
# List of potential paths to check
|
24 |
-
potential_paths = [
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
]
|
38 |
-
|
39 |
-
# Try each path
|
40 |
-
for path in potential_paths:
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
# If no path is found
|
46 |
-
logger.error("Could not locate prompts directory. Using a temporary fallback.")
|
47 |
-
return pathlib.Path(__file__).parent / "prompts"
|
48 |
|
49 |
# Directory containing prompt templates (making path absolute by using current file location)
|
50 |
SCRIPT_DIR = pathlib.Path(__file__).parent.parent.absolute()
|
|
|
20 |
Returns:
|
21 |
pathlib.Path: Path to the prompts directory
|
22 |
"""
|
23 |
+
# List of potential paths to check
|
24 |
+
potential_paths = [
|
25 |
+
# Current file's parent directory
|
26 |
+
pathlib.Path(__file__).parent.parent / "prompts",
|
27 |
+
|
28 |
+
# Relative to the current working directory
|
29 |
+
pathlib.Path.cwd() / "prompts",
|
30 |
+
|
31 |
+
# Absolute path fallback (useful in deployment)
|
32 |
+
pathlib.Path("/app/prompts"),
|
33 |
+
pathlib.Path("/workspace/prompts"),
|
34 |
+
|
35 |
+
# Hugging Face Spaces specific path
|
36 |
+
pathlib.Path("/home/user/app/prompts")
|
37 |
+
]
|
38 |
+
|
39 |
+
# Try each path
|
40 |
+
for path in potential_paths:
|
41 |
+
if path.is_dir():
|
42 |
+
logger.info(f"Prompts directory found at: {path}")
|
43 |
+
return path
|
44 |
+
|
45 |
+
# If no path is found
|
46 |
+
logger.error("Could not locate prompts directory. Using a temporary fallback.")
|
47 |
+
return pathlib.Path(__file__).parent / "prompts"
|
48 |
|
49 |
# Directory containing prompt templates (making path absolute by using current file location)
|
50 |
SCRIPT_DIR = pathlib.Path(__file__).parent.parent.absolute()
|