Spaces:
Running
Running
GitHub Actions commited on
Commit ·
3ea15ff
1
Parent(s): efdd22e
Deploy e083e31
Browse files
app/services/gemini_client.py
CHANGED
|
@@ -65,9 +65,17 @@ class GeminiClient:
|
|
| 65 |
|
| 66 |
def _load_context(self, path: str) -> None:
|
| 67 |
p = Path(path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
if p.exists():
|
| 69 |
self._context = p.read_text(encoding="utf-8")
|
| 70 |
-
logger.info("Gemini context loaded: %d chars from %s", len(self._context),
|
| 71 |
else:
|
| 72 |
logger.warning(
|
| 73 |
"Gemini context file not found at %s — run refresh_gemini_context.py "
|
|
|
|
| 65 |
|
| 66 |
def _load_context(self, path: str) -> None:
|
| 67 |
p = Path(path)
|
| 68 |
+
if not p.exists():
|
| 69 |
+
# In the HF Space container WORKDIR is /app and the backend source is
|
| 70 |
+
# copied as /app/app/..., so a repo-root-relative path like
|
| 71 |
+
# 'backend/app/services/gemini_context.toon' won't resolve from CWD.
|
| 72 |
+
# Fall back to the directory that contains this file — both the client
|
| 73 |
+
# and the context file live in app/services/, so Path(__file__).parent
|
| 74 |
+
# always points at the right place regardless of CWD.
|
| 75 |
+
p = Path(__file__).parent / Path(path).name
|
| 76 |
if p.exists():
|
| 77 |
self._context = p.read_text(encoding="utf-8")
|
| 78 |
+
logger.info("Gemini context loaded: %d chars from %s", len(self._context), p)
|
| 79 |
else:
|
| 80 |
logger.warning(
|
| 81 |
"Gemini context file not found at %s — run refresh_gemini_context.py "
|