Upload 11 files
Browse files- CHANGELOG_4.3.0.md +22 -0
- DEPLOYMENT_GUIDE.md +103 -103
- README.md +45 -45
CHANGELOG_4.3.0.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# LibBee 4.3.0 (27 Nov 2026)
|
| 2 |
+
|
| 3 |
+
## Changed files
|
| 4 |
+
- `src/agentcore/utils.py`: phrase-quote audit, quote relaxation, rule-based Boolean fallback no longer invents phrases
|
| 5 |
+
- `src/agentcore/constants.py`: Boolean and search-plan prompts quote only established terms; classifier prompt adds follow-up judgement and explain/find mode; `HISTORY_WINDOW` 6 β 10
|
| 6 |
+
- `src/agentcore/classify.py`: classifier reads the last six exchanges and returns `follow_up`, `refers_to`, `standalone_question`, `search_mode`; 6 s timeout
|
| 7 |
+
- `src/agentcore/intents_search.py`: book requests search articles and books together with a Books-filter tip; explain mode; clarification buttons are not refinements
|
| 8 |
+
- `src/agentcore/primo_chat.py`: an empty phrase search is retried once with phrase quotes removed (needs `PRIMO_API_KEY`)
|
| 9 |
+
- `src/agentcore/orchestrator.py`: asks when a follow-up or explain/find is unclear, never twice in a row; notes an assumed follow-up
|
| 10 |
+
- `src/api/agent.py`: no announcement banner on clarifying questions
|
| 11 |
+
- `src/config.py`, `README.md`, `DEPLOYMENT_GUIDE.md`: version 4.3.0
|
| 12 |
+
- `tests/test_search_regressions.py`: two expectations updated for the new behaviour
|
| 13 |
+
- `tests/test_v430_regressions.py`: new, 30 tests
|
| 14 |
+
|
| 15 |
+
## Front end
|
| 16 |
+
`libbee-libguide-2026.11.27.html` replaces the LibGuides page code. It needs 4.3.0 for the clarifying buttons; older pages keep working against 4.3.0.
|
| 17 |
+
|
| 18 |
+
## Tests
|
| 19 |
+
186 pass. Three failures existed before this release and are unrelated:
|
| 20 |
+
`test_sanitize_boolean_normalizes_quotes_and_year_groups`,
|
| 21 |
+
`test_uploaded_knowledge_has_no_duplicate_titles` (the two "(1)" knowledge files),
|
| 22 |
+
`test_primo_total_request_deadline_cancels_slow_provider`.
|
DEPLOYMENT_GUIDE.md
CHANGED
|
@@ -1,103 +1,103 @@
|
|
| 1 |
-
# Deployment and loading-speed guide
|
| 2 |
-
|
| 3 |
-
If using the standalone HF zip, its root already contains the HF application; omit the `cd hf` step below. Frontend/assets are in the complete package.
|
| 4 |
-
|
| 5 |
-
## 1. Keep a rollback copy
|
| 6 |
-
|
| 7 |
-
Export the current HF Space files, keep the current LibGuides source block, and back up any runtime configuration/feedback/metrics you need. Never place real secrets in the replacement archive, LibGuides JavaScript, or a public repository.
|
| 8 |
-
|
| 9 |
-
## 2. Upload the HF source
|
| 10 |
-
|
| 11 |
-
Copy the **contents of `hf/`** into the root of the existing Docker Space. Preserve the Space's settings and secrets. `app.py`, `Dockerfile`, `requirements.txt`, `README.md`, and `src/` must be at the repository root, not nested under an extra `hf/` folder.
|
| 12 |
-
|
| 13 |
-
Use the complete supplied knowledge directory. Duplicate `(1).txt` variants have been merged into their canonical files; remove those old duplicate files from the destination so they are not indexed again. Empty placeholder files and git/test caches are not deployment inputs.
|
| 14 |
-
|
| 15 |
-
The container runs as UID 1000 on port 7860. `Dockerfile` uses the liveness endpoint for its health check. Initial semantic-index creation happens in the background; local keyword retrieval becomes available first.
|
| 16 |
-
|
| 17 |
-
## 3. Check configuration
|
| 18 |
-
|
| 19 |
-
| Secret/variable | Required use |
|
| 20 |
-
|---|---|
|
| 21 |
-
| `ENVIRONMENT` | `production` for the deployed Space. |
|
| 22 |
-
| `ORIGIN_TOKEN` | Must match your Worker's `HF_ORIGIN_TOKEN`. Protected origin routes reject missing/wrong tokens. |
|
| 23 |
-
| `OPENAI_API_KEY` | Needed for the configured GPT answers, classification and semantic embeddings. Without it, some deterministic library responses/local retrieval can still work, but the model service is degraded. |
|
| 24 |
-
| `ADMIN_PASSWORD` | Required to log in to the HF admin page. |
|
| 25 |
-
| `CLOUDFLARE_WORKER_URL` | Existing gateway URL; keep it consistent with frontend `API_URL`. |
|
| 26 |
-
| `CLOUDFLARE_ADMIN_TOKEN` | Must match Worker `ADMIN_TOKEN`; used for the existing admin/analytics token contract. |
|
| 27 |
-
| `LIBCAL_CLIENT_ID`, `LIBCAL_CLIENT_SECRET` | Required for live library hours. |
|
| 28 |
-
| `LIBCAL_EVENTS_CLIENT_ID`, `LIBCAL_EVENTS_CLIENT_SECRET` | Optional separate events credentials; otherwise main LibCal credentials are reused. |
|
| 29 |
-
| `PRIMO_API_KEY` | Enables your existing direct PRIMO API integration where configured. |
|
| 30 |
-
| `ANTHROPIC_API_KEY` | Optional; needed if you enable Claude. |
|
| 31 |
-
| `OPENALEX_API_KEY` | Optional server-side key for the existing scholarly fallback. Basic anonymous usage remains supported. |
|
| 32 |
-
| `CONTACT_EMAIL` | Institutional contact for scholarly API requests. |
|
| 33 |
-
| `RUNTIME_DIR` | A writable runtime directory; use `/data/libbee_runtime` only if that path is your configured durable mount. |
|
| 34 |
-
| `ALLOWED_CORS_ORIGINS` | Explicit browser origins if directly calling permitted HF endpoints from a separate site; the intended student chat path remains through the Worker. |
|
| 35 |
-
|
| 36 |
-
See `hf/.env.example` for supported examples and request limits. It contains placeholders, not credentials. Do not upload a filled `.env` to a public repository.
|
| 37 |
-
|
| 38 |
-
Creating `/data` in a Docker build does **not** make it persistent. Verify your Space's actual mounted durable storage and its UID-1000 permissions. On ephemeral disk, restarts lose cache/runtime data. Current HF Docker documentation describes runtime persistence options and permissions: [Docker Spaces](https://huggingface.co/docs/hub/spaces-sdks-docker).
|
| 39 |
-
|
| 40 |
-
## 4. Check the existing Worker contract
|
| 41 |
-
|
| 42 |
-
The Worker code was not supplied. Confirm these against it before live rollout:
|
| 43 |
-
|
| 44 |
-
- Browser requests use `/agent`, `/feedback`, and `/config` at `API_URL`; JSON chat/feedback requests include the existing `X-LibBee-Session` header.
|
| 45 |
-
- The Worker adds `X-LibBee-Origin-Token` only on its server-to-HF calls. The permanent origin and admin secrets must never appear in student JavaScript.
|
| 46 |
-
- Forward the HF agent JSON fields expected by the frontend: `answer`, `request_id`, intent/tools, source links, search context, and follow-up suggestions.
|
| 47 |
-
- Preserve useful HTTP status codes for malformed requests, busy/maintenance states and provider failures. Do not cache chat or feedback responses.
|
| 48 |
-
- The Worker owns persistent analytics and session enforcement. Confirm feedback ownership, analytics writes, rate limits and D1 schema using its actual source.
|
| 49 |
-
- Allow the actual KU LibGuides origin in Worker CORS, including JSON requests and the session header.
|
| 50 |
-
- Verify that the current Worker accepts the HF admin's existing short-lived signed `analytics:read` token format. The permanent secret remains server-side.
|
| 51 |
-
- If `/config` reaches a sleeping HF Space, the revised front end still renders and permits typing without waiting for configuration to return.
|
| 52 |
-
|
| 53 |
-
## 5. Replace the LibGuides block
|
| 54 |
-
|
| 55 |
-
On a staging page, replace the old source block with all of `frontend/libbee-libguides.html`. The block contains its own CSS, HTML, JavaScript and small embedded images; no image hosting setup is needed. Keep the normal LibGuides page wrapper.
|
| 56 |
-
|
| 57 |
-
The default `API_URL` remains the gateway found in your supplied files. Change this one configuration value only if you are moving to a different gateway. Add the staging/production page origins to the Worker's CORS allowlist as needed.
|
| 58 |
-
|
| 59 |
-
Do not paste both the old and new blocks into one page. Duplicate IDs or event handlers can submit a question twice. The revised layout stays within the chatbot container and does not force the whole LibGuides page to become full width.
|
| 60 |
-
|
| 61 |
-
## 6. Validate before switching users
|
| 62 |
-
|
| 63 |
-
In an environment with package/network access:
|
| 64 |
-
|
| 65 |
-
```bash
|
| 66 |
-
cd hf
|
| 67 |
-
python -m pip install -r requirements-dev.txt
|
| 68 |
-
python -m pip check
|
| 69 |
-
python -m compileall -q app.py src tests
|
| 70 |
-
pytest -q
|
| 71 |
-
```
|
| 72 |
-
|
| 73 |
-
Run a current dependency-vulnerability scan against the resolved environment, then lock and retest compatible patched packages. This review retained the supplied dependency pins to avoid an untested framework migration; it does not certify that those old pins or their transitive resolution are current or vulnerability-free.
|
| 74 |
-
|
| 75 |
-
Start the container/Space and check:
|
| 76 |
-
|
| 77 |
-
| Check | Expected result |
|
| 78 |
-
|---|---|
|
| 79 |
-
| `/health/live` | HTTP 200 once the application is listening; version 4.
|
| 80 |
-
| `/config` while embeddings are initializing | Responds without waiting for semantic index construction. |
|
| 81 |
-
| `/health/ready` | HTTP 503 while retrieval is unavailable or origin configuration is invalid; reports readiness/degraded state honestly once local retrieval is available. |
|
| 82 |
-
| Direct `/agent` request without the origin token | Rejected in production. |
|
| 83 |
-
| Gateway chat | Greeting, opening hours, staff, database help, article search, books, PubMed, and follow-ups work using real credentials. |
|
| 84 |
-
| Cancel/Clear/Home during a slow answer | No late answer appears in a new/cleared conversation. |
|
| 85 |
-
| Unavailable gateway/slow request | Visible progress/error/retry controls; no silent frozen composer. |
|
| 86 |
-
| Feedback | Save one up/down vote through the Worker and confirm the expected analytics ownership. |
|
| 87 |
-
| Admin login/logout | Logged-out session stays invalid, including after reloading persisted sessions. |
|
| 88 |
-
| Maintenance | Normal submission, suggested questions and follow-ups respect maintenance. |
|
| 89 |
-
| Real browser | Desktop + narrow mobile; keyboard focus; sources/copy/expand controls; no console errors or page-wide style changes. |
|
| 90 |
-
|
| 91 |
-
Admin's write canary is now an explicit POST action. Read-only health GETs do not run paid/write diagnostics. Verify the actual Worker canary endpoint separately if used.
|
| 92 |
-
|
| 93 |
-
## 7. Understand what still controls loading speed
|
| 94 |
-
|
| 95 |
-
The revised front end is smaller and does not wait for configuration before displaying the interface. HF no longer waits for remote embeddings to finish before serving basic endpoints. Stable content hashes let the semantic cache survive ordinary rebuilds **when stored on a durable mount**. The new cache schema forces one rebuild of older cache files.
|
| 96 |
-
|
| 97 |
-
A sleeping HF Space still needs to wake. HF documents that CPU Basic sleeps after inactivity and upgraded hardware can remain running. Check the current Space hardware/sleep settings if the first visit after a long idle period remains slow; changing hardware was not performed during this review. [HF sleep settings](https://huggingface.co/docs/hub/spaces-gpus#set-a-custom-sleep-time).
|
| 98 |
-
|
| 99 |
-
Measure the warm and idle-first-visit cases separately in browser Network tools: document download, `/config`, first `/agent` request, and later `/agent` requests. No production latency reduction in seconds is claimed by this package because deployed timing data was not available.
|
| 100 |
-
|
| 101 |
-
## Rollback
|
| 102 |
-
|
| 103 |
-
Restore the previous HF source and the previous LibGuides source block together, retaining the matching Worker tokens and endpoint URL. Restore runtime-data backups if needed. New signed caches can be discarded and rebuilt; never accept an unsigned pickle/index file to make rollback appear faster.
|
|
|
|
| 1 |
+
# Deployment and loading-speed guide
|
| 2 |
+
|
| 3 |
+
If using the standalone HF zip, its root already contains the HF application; omit the `cd hf` step below. Frontend/assets are in the complete package.
|
| 4 |
+
|
| 5 |
+
## 1. Keep a rollback copy
|
| 6 |
+
|
| 7 |
+
Export the current HF Space files, keep the current LibGuides source block, and back up any runtime configuration/feedback/metrics you need. Never place real secrets in the replacement archive, LibGuides JavaScript, or a public repository.
|
| 8 |
+
|
| 9 |
+
## 2. Upload the HF source
|
| 10 |
+
|
| 11 |
+
Copy the **contents of `hf/`** into the root of the existing Docker Space. Preserve the Space's settings and secrets. `app.py`, `Dockerfile`, `requirements.txt`, `README.md`, and `src/` must be at the repository root, not nested under an extra `hf/` folder.
|
| 12 |
+
|
| 13 |
+
Use the complete supplied knowledge directory. Duplicate `(1).txt` variants have been merged into their canonical files; remove those old duplicate files from the destination so they are not indexed again. Empty placeholder files and git/test caches are not deployment inputs.
|
| 14 |
+
|
| 15 |
+
The container runs as UID 1000 on port 7860. `Dockerfile` uses the liveness endpoint for its health check. Initial semantic-index creation happens in the background; local keyword retrieval becomes available first.
|
| 16 |
+
|
| 17 |
+
## 3. Check configuration
|
| 18 |
+
|
| 19 |
+
| Secret/variable | Required use |
|
| 20 |
+
|---|---|
|
| 21 |
+
| `ENVIRONMENT` | `production` for the deployed Space. |
|
| 22 |
+
| `ORIGIN_TOKEN` | Must match your Worker's `HF_ORIGIN_TOKEN`. Protected origin routes reject missing/wrong tokens. |
|
| 23 |
+
| `OPENAI_API_KEY` | Needed for the configured GPT answers, classification and semantic embeddings. Without it, some deterministic library responses/local retrieval can still work, but the model service is degraded. |
|
| 24 |
+
| `ADMIN_PASSWORD` | Required to log in to the HF admin page. |
|
| 25 |
+
| `CLOUDFLARE_WORKER_URL` | Existing gateway URL; keep it consistent with frontend `API_URL`. |
|
| 26 |
+
| `CLOUDFLARE_ADMIN_TOKEN` | Must match Worker `ADMIN_TOKEN`; used for the existing admin/analytics token contract. |
|
| 27 |
+
| `LIBCAL_CLIENT_ID`, `LIBCAL_CLIENT_SECRET` | Required for live library hours. |
|
| 28 |
+
| `LIBCAL_EVENTS_CLIENT_ID`, `LIBCAL_EVENTS_CLIENT_SECRET` | Optional separate events credentials; otherwise main LibCal credentials are reused. |
|
| 29 |
+
| `PRIMO_API_KEY` | Enables your existing direct PRIMO API integration where configured. |
|
| 30 |
+
| `ANTHROPIC_API_KEY` | Optional; needed if you enable Claude. |
|
| 31 |
+
| `OPENALEX_API_KEY` | Optional server-side key for the existing scholarly fallback. Basic anonymous usage remains supported. |
|
| 32 |
+
| `CONTACT_EMAIL` | Institutional contact for scholarly API requests. |
|
| 33 |
+
| `RUNTIME_DIR` | A writable runtime directory; use `/data/libbee_runtime` only if that path is your configured durable mount. |
|
| 34 |
+
| `ALLOWED_CORS_ORIGINS` | Explicit browser origins if directly calling permitted HF endpoints from a separate site; the intended student chat path remains through the Worker. |
|
| 35 |
+
|
| 36 |
+
See `hf/.env.example` for supported examples and request limits. It contains placeholders, not credentials. Do not upload a filled `.env` to a public repository.
|
| 37 |
+
|
| 38 |
+
Creating `/data` in a Docker build does **not** make it persistent. Verify your Space's actual mounted durable storage and its UID-1000 permissions. On ephemeral disk, restarts lose cache/runtime data. Current HF Docker documentation describes runtime persistence options and permissions: [Docker Spaces](https://huggingface.co/docs/hub/spaces-sdks-docker).
|
| 39 |
+
|
| 40 |
+
## 4. Check the existing Worker contract
|
| 41 |
+
|
| 42 |
+
The Worker code was not supplied. Confirm these against it before live rollout:
|
| 43 |
+
|
| 44 |
+
- Browser requests use `/agent`, `/feedback`, and `/config` at `API_URL`; JSON chat/feedback requests include the existing `X-LibBee-Session` header.
|
| 45 |
+
- The Worker adds `X-LibBee-Origin-Token` only on its server-to-HF calls. The permanent origin and admin secrets must never appear in student JavaScript.
|
| 46 |
+
- Forward the HF agent JSON fields expected by the frontend: `answer`, `request_id`, intent/tools, source links, search context, and follow-up suggestions.
|
| 47 |
+
- Preserve useful HTTP status codes for malformed requests, busy/maintenance states and provider failures. Do not cache chat or feedback responses.
|
| 48 |
+
- The Worker owns persistent analytics and session enforcement. Confirm feedback ownership, analytics writes, rate limits and D1 schema using its actual source.
|
| 49 |
+
- Allow the actual KU LibGuides origin in Worker CORS, including JSON requests and the session header.
|
| 50 |
+
- Verify that the current Worker accepts the HF admin's existing short-lived signed `analytics:read` token format. The permanent secret remains server-side.
|
| 51 |
+
- If `/config` reaches a sleeping HF Space, the revised front end still renders and permits typing without waiting for configuration to return.
|
| 52 |
+
|
| 53 |
+
## 5. Replace the LibGuides block
|
| 54 |
+
|
| 55 |
+
On a staging page, replace the old source block with all of `frontend/libbee-libguides.html`. The block contains its own CSS, HTML, JavaScript and small embedded images; no image hosting setup is needed. Keep the normal LibGuides page wrapper.
|
| 56 |
+
|
| 57 |
+
The default `API_URL` remains the gateway found in your supplied files. Change this one configuration value only if you are moving to a different gateway. Add the staging/production page origins to the Worker's CORS allowlist as needed.
|
| 58 |
+
|
| 59 |
+
Do not paste both the old and new blocks into one page. Duplicate IDs or event handlers can submit a question twice. The revised layout stays within the chatbot container and does not force the whole LibGuides page to become full width.
|
| 60 |
+
|
| 61 |
+
## 6. Validate before switching users
|
| 62 |
+
|
| 63 |
+
In an environment with package/network access:
|
| 64 |
+
|
| 65 |
+
```bash
|
| 66 |
+
cd hf
|
| 67 |
+
python -m pip install -r requirements-dev.txt
|
| 68 |
+
python -m pip check
|
| 69 |
+
python -m compileall -q app.py src tests
|
| 70 |
+
pytest -q
|
| 71 |
+
```
|
| 72 |
+
|
| 73 |
+
Run a current dependency-vulnerability scan against the resolved environment, then lock and retest compatible patched packages. This review retained the supplied dependency pins to avoid an untested framework migration; it does not certify that those old pins or their transitive resolution are current or vulnerability-free.
|
| 74 |
+
|
| 75 |
+
Start the container/Space and check:
|
| 76 |
+
|
| 77 |
+
| Check | Expected result |
|
| 78 |
+
|---|---|
|
| 79 |
+
| `/health/live` | HTTP 200 once the application is listening; version 4.3.0. |
|
| 80 |
+
| `/config` while embeddings are initializing | Responds without waiting for semantic index construction. |
|
| 81 |
+
| `/health/ready` | HTTP 503 while retrieval is unavailable or origin configuration is invalid; reports readiness/degraded state honestly once local retrieval is available. |
|
| 82 |
+
| Direct `/agent` request without the origin token | Rejected in production. |
|
| 83 |
+
| Gateway chat | Greeting, opening hours, staff, database help, article search, books, PubMed, and follow-ups work using real credentials. |
|
| 84 |
+
| Cancel/Clear/Home during a slow answer | No late answer appears in a new/cleared conversation. |
|
| 85 |
+
| Unavailable gateway/slow request | Visible progress/error/retry controls; no silent frozen composer. |
|
| 86 |
+
| Feedback | Save one up/down vote through the Worker and confirm the expected analytics ownership. |
|
| 87 |
+
| Admin login/logout | Logged-out session stays invalid, including after reloading persisted sessions. |
|
| 88 |
+
| Maintenance | Normal submission, suggested questions and follow-ups respect maintenance. |
|
| 89 |
+
| Real browser | Desktop + narrow mobile; keyboard focus; sources/copy/expand controls; no console errors or page-wide style changes. |
|
| 90 |
+
|
| 91 |
+
Admin's write canary is now an explicit POST action. Read-only health GETs do not run paid/write diagnostics. Verify the actual Worker canary endpoint separately if used.
|
| 92 |
+
|
| 93 |
+
## 7. Understand what still controls loading speed
|
| 94 |
+
|
| 95 |
+
The revised front end is smaller and does not wait for configuration before displaying the interface. HF no longer waits for remote embeddings to finish before serving basic endpoints. Stable content hashes let the semantic cache survive ordinary rebuilds **when stored on a durable mount**. The new cache schema forces one rebuild of older cache files.
|
| 96 |
+
|
| 97 |
+
A sleeping HF Space still needs to wake. HF documents that CPU Basic sleeps after inactivity and upgraded hardware can remain running. Check the current Space hardware/sleep settings if the first visit after a long idle period remains slow; changing hardware was not performed during this review. [HF sleep settings](https://huggingface.co/docs/hub/spaces-gpus#set-a-custom-sleep-time).
|
| 98 |
+
|
| 99 |
+
Measure the warm and idle-first-visit cases separately in browser Network tools: document download, `/config`, first `/agent` request, and later `/agent` requests. No production latency reduction in seconds is claimed by this package because deployed timing data was not available.
|
| 100 |
+
|
| 101 |
+
## Rollback
|
| 102 |
+
|
| 103 |
+
Restore the previous HF source and the previous LibGuides source block together, retaining the matching Worker tokens and endpoint URL. Restore runtime-data backups if needed. New signed caches can be discarded and rebuilt; never accept an unsigned pickle/index file to make rollback appear faster.
|
README.md
CHANGED
|
@@ -1,45 +1,45 @@
|
|
| 1 |
-
---
|
| 2 |
-
title: LibBee
|
| 3 |
-
emoji: π
|
| 4 |
-
colorFrom: blue
|
| 5 |
-
colorTo: yellow
|
| 6 |
-
sdk: docker
|
| 7 |
-
app_port: 7860
|
| 8 |
-
pinned: false
|
| 9 |
-
---
|
| 10 |
-
|
| 11 |
-
# LibBee 4.
|
| 12 |
-
|
| 13 |
-
FastAPI origin for the existing Cloudflare gateway and KU LibGuides chatbot.
|
| 14 |
-
|
| 15 |
-
## Configuration
|
| 16 |
-
|
| 17 |
-
Set real credentials in Space secrets. `.env.example` documents placeholders and optional settings. Keep `ORIGIN_TOKEN` equal to the Worker's `HF_ORIGIN_TOKEN`, and `CLOUDFLARE_ADMIN_TOKEN` equal to its `ADMIN_TOKEN`.
|
| 18 |
-
|
| 19 |
-
`OPENAI_API_KEY` enables GPT and semantic embeddings. `ANTHROPIC_API_KEY`, `PRIMO_API_KEY`, and `OPENALEX_API_KEY` are optional integration keys. Live hours/events need LibCal credentials; separate events credentials are optional. `ADMIN_PASSWORD` protects the admin dashboard.
|
| 20 |
-
|
| 21 |
-
The Docker runtime uses UID 1000 and port 7860. Set `RUNTIME_DIR` to a writable durable mount if configuration, metrics, feedback and signed embeddings should survive restarts. A folder named `/data` alone does not guarantee persistent storage.
|
| 22 |
-
|
| 23 |
-
## Startup and request behavior
|
| 24 |
-
|
| 25 |
-
- `/health/live` and `/config` can respond while knowledge initialization runs in the background.
|
| 26 |
-
- Keyword retrieval initializes locally first; semantic retrieval joins when a valid cache loads or embeddings finish. Semantic failure leaves local retrieval available.
|
| 27 |
-
- `/health/ready` returns 503 when retrieval is unavailable, maintenance is on, or the production origin token is missing. It distinguishes missing model credentials from a fully configured service.
|
| 28 |
-
- `/agent` and its diagnostic subpaths, `/search`, and `/feedback` require the origin token in production. Student browsers call the Worker; the Worker adds this token server-side.
|
| 29 |
-
- The 512 KiB default whole-body limit covers bounded Unicode histories and search contexts; request models still enforce individual field limits.
|
| 30 |
-
- Generated answer HTML is sanitized. Credentials stay out of student HTML, provider request URLs and operational query logs.
|
| 31 |
-
- Signed semantic caches are invalidated by KB content and indexing settings. Older cache schemas rebuild once; modified or unsigned caches are ignored.
|
| 32 |
-
- Admin logout revokes persisted sessions; write diagnostics are explicit POST actions. The Worker analytics token contract remains unchanged and needs verification against your Worker source.
|
| 33 |
-
|
| 34 |
-
## Validation
|
| 35 |
-
|
| 36 |
-
```bash
|
| 37 |
-
python -m pip install -r requirements-dev.txt
|
| 38 |
-
python -m pip check
|
| 39 |
-
python -m compileall -q app.py src tests
|
| 40 |
-
pytest -q
|
| 41 |
-
```
|
| 42 |
-
|
| 43 |
-
The supplied offline tests/harnesses document their mocks and skipped integration checks. They do not replace full dependency, browser, or live-provider testing. This review did not update the supplied dependency pins; validate compatible security updates and freeze the resolved dependency set in staging.
|
| 44 |
-
|
| 45 |
-
See `DEPLOYMENT_GUIDE.md` and the complete package's `AUDIT_REPORT.md` for rollout instructions and limitations. The supplied files do not include the actual Worker or D1 schema.
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: LibBee
|
| 3 |
+
emoji: π
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: yellow
|
| 6 |
+
sdk: docker
|
| 7 |
+
app_port: 7860
|
| 8 |
+
pinned: false
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# LibBee 4.3.0 β KU Library Assistant
|
| 12 |
+
|
| 13 |
+
FastAPI origin for the existing Cloudflare gateway and KU LibGuides chatbot.
|
| 14 |
+
|
| 15 |
+
## Configuration
|
| 16 |
+
|
| 17 |
+
Set real credentials in Space secrets. `.env.example` documents placeholders and optional settings. Keep `ORIGIN_TOKEN` equal to the Worker's `HF_ORIGIN_TOKEN`, and `CLOUDFLARE_ADMIN_TOKEN` equal to its `ADMIN_TOKEN`.
|
| 18 |
+
|
| 19 |
+
`OPENAI_API_KEY` enables GPT and semantic embeddings. `ANTHROPIC_API_KEY`, `PRIMO_API_KEY`, and `OPENALEX_API_KEY` are optional integration keys. Live hours/events need LibCal credentials; separate events credentials are optional. `ADMIN_PASSWORD` protects the admin dashboard.
|
| 20 |
+
|
| 21 |
+
The Docker runtime uses UID 1000 and port 7860. Set `RUNTIME_DIR` to a writable durable mount if configuration, metrics, feedback and signed embeddings should survive restarts. A folder named `/data` alone does not guarantee persistent storage.
|
| 22 |
+
|
| 23 |
+
## Startup and request behavior
|
| 24 |
+
|
| 25 |
+
- `/health/live` and `/config` can respond while knowledge initialization runs in the background.
|
| 26 |
+
- Keyword retrieval initializes locally first; semantic retrieval joins when a valid cache loads or embeddings finish. Semantic failure leaves local retrieval available.
|
| 27 |
+
- `/health/ready` returns 503 when retrieval is unavailable, maintenance is on, or the production origin token is missing. It distinguishes missing model credentials from a fully configured service.
|
| 28 |
+
- `/agent` and its diagnostic subpaths, `/search`, and `/feedback` require the origin token in production. Student browsers call the Worker; the Worker adds this token server-side.
|
| 29 |
+
- The 512 KiB default whole-body limit covers bounded Unicode histories and search contexts; request models still enforce individual field limits.
|
| 30 |
+
- Generated answer HTML is sanitized. Credentials stay out of student HTML, provider request URLs and operational query logs.
|
| 31 |
+
- Signed semantic caches are invalidated by KB content and indexing settings. Older cache schemas rebuild once; modified or unsigned caches are ignored.
|
| 32 |
+
- Admin logout revokes persisted sessions; write diagnostics are explicit POST actions. The Worker analytics token contract remains unchanged and needs verification against your Worker source.
|
| 33 |
+
|
| 34 |
+
## Validation
|
| 35 |
+
|
| 36 |
+
```bash
|
| 37 |
+
python -m pip install -r requirements-dev.txt
|
| 38 |
+
python -m pip check
|
| 39 |
+
python -m compileall -q app.py src tests
|
| 40 |
+
pytest -q
|
| 41 |
+
```
|
| 42 |
+
|
| 43 |
+
The supplied offline tests/harnesses document their mocks and skipped integration checks. They do not replace full dependency, browser, or live-provider testing. This review did not update the supplied dependency pins; validate compatible security updates and freeze the resolved dependency set in staging.
|
| 44 |
+
|
| 45 |
+
See `DEPLOYMENT_GUIDE.md` and the complete package's `AUDIT_REPORT.md` for rollout instructions and limitations. The supplied files do not include the actual Worker or D1 schema.
|