Download scripts/entrypoint.sh from Pavlishenku/PCP-Assistant-v4: direct link, hf CLI and curl.
- Browser
- Download file 1.96 kB
-
https://huggingface.co/spaces/Pavlishenku/PCP-Assistant-v4/resolve/main/scripts/entrypoint.sh
- Command line
-
hf download hf://spaces/Pavlishenku/PCP-Assistant-v4/scripts/entrypoint.sh
-
curl -L -o entrypoint.sh https://huggingface.co/spaces/Pavlishenku/PCP-Assistant-v4/resolve/main/scripts/entrypoint.sh
1.96 kB
| # Demarrage du Space : telecharge l'index (dataset HF prive) si absent, puis lance l'app. | |
| set -e | |
| INDEX_DIR="/app/pcp/data/index" | |
| if [ ! -f "${INDEX_DIR}/embeddings.npy" ] && [ -n "${PCP_INDEX_DATASET}" ]; then | |
| echo "[entrypoint] telechargement de l'index depuis ${PCP_INDEX_DATASET}..." | |
| python - <<'PY' | |
| import os | |
| from huggingface_hub import snapshot_download | |
| repo = os.environ["PCP_INDEX_DATASET"] | |
| token = os.environ.get("HF_TOKEN") or None | |
| dst = "/app/pcp/data/index" | |
| os.makedirs(dst, exist_ok=True) | |
| snapshot_download(repo_id=repo, repo_type="dataset", local_dir=dst, token=token, | |
| allow_patterns=["chunks.json", "embeddings.npy", "meta.json", | |
| "catalogue_vecs.npy", "catalogue_vecs_meta.json", | |
| "example_vecs.npy", "example_blocks.json"]) | |
| print("[entrypoint] index telecharge ->", os.listdir(dst)) | |
| PY | |
| fi | |
| # v4 : base de connaissances + corpus anonymise (boucle agentique). | |
| # NE DOIT PAS faire echouer le demarrage : sans kb/ l'app sert le mode v2/v3 | |
| # et /api/agent repondra "kb absente" (degradation propre, pas de crash-loop). | |
| KB_DIR="/app/pcp/data/kb" | |
| if [ ! -f "${KB_DIR}/core_context.md" ] && [ -n "${PCP_INDEX_DATASET}" ]; then | |
| echo "[entrypoint] telechargement de la KB v4 depuis ${PCP_INDEX_DATASET}..." | |
| python - <<'PY' || echo "[entrypoint] AVERTISSEMENT : KB v4 indisponible (voir ci-dessus), demarrage sans" | |
| import os | |
| from huggingface_hub import snapshot_download | |
| repo = os.environ["PCP_INDEX_DATASET"] | |
| token = os.environ.get("HF_TOKEN") or None | |
| snapshot_download(repo_id=repo, repo_type="dataset", local_dir="/app/pcp/data", | |
| token=token, allow_patterns=["kb/**", "corpus_anon/**"]) | |
| kb = "/app/pcp/data/kb" | |
| if os.path.isdir(kb): | |
| print("[entrypoint] kb:", len(os.listdir(kb)), "entrees") | |
| else: | |
| raise SystemExit("kb/ absent du dataset " + repo) | |
| PY | |
| fi | |
| exec uvicorn pcp.server:app --host 0.0.0.0 --port 7860 | |