Spaces:
Runtime error
Runtime error
Commit History
-
Remove diagnostic startup print statements
Generated with Devin (https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>4492f1d -
Add startup print statements to diagnose Space hang
Generated with Devin (https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>d2c3c03 -
Fix startup hang: force CPU-only torch to avoid 2GB CUDA packages on CPU Space
sentence-transformers>=2.7.0 now pulls torch 2.12.1 + full CUDA toolkit (nvidia-cublas, nvidia-cudnn, nvidia-nccl, etc.) which hangs on HF Spaces CPU-basic hardware. Adding --extra-index-url for pytorch/whl/cpu ensures the CPU-only wheel is installed instead. Generated with Devin (https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>56cb087 -
Update recommendations.md with DeepInfra vs Novita comparison
Based on HF Inference Providers page for Qwen/Qwen2.5-72B-Instruct. DeepInfra is cheaper and has much lower latency than Novita. Generated with Devin (https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>de369d1 -
Add recommendations.md and ignore .code-workspace files
- recommendations.md captures current infrastructure thinking: hosting, GPU, cost, local testing - .gitignore updated to exclude *.code-workspace IDE files Generated with Devin (https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>8e41bf7 -
Switch streaming call to provider-aware chat_completion
Use client.chat_completion(..., stream=True) instead of client.chat.completions.create to ensure the Novita provider and Qwen/Qwen2.5-72B-Instruct model are resolved exactly as in the previous non-streaming version. Generated with Devin (https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>3a225d8 -
CHANGELOG: add commit hash for streaming change
Generated with Devin (https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>bd34e3d -
Enable streaming responses for Sanyu chatbot
- Convert respond() to a generator using client.chat.completions.create(..., stream=True) - Yield partial tokens as they arrive so the UI updates incrementally - Preserve retry logic for transient 503/429/overloaded errors before streaming starts - Avoid duplicate visible output: once streaming starts, errors fall back to a polite message - Log the full bot reply after the stream completes Generated with Devin (https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>cea783d
-
CHANGELOG: note HF token swap (Timothy Kintu) and credit incident
Atwine's credits depleted by GLM-5.2 test. Timothy Kintu's token now used for inference until end of July 2026 testing period. Dataset writes still use Atwine's DATASET_WRITE_TOKEN. Generated with Devin (https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>1564e73 -
Revert to Qwen2.5-72B-Instruct; GLM-5.2 depleted free credits
GLM-5.2 (753B) burned through monthly HF inference credits in minutes. Back to Qwen2.5-72B-Instruct which is credit-efficient and confirmed working. Will resume once HF_TOKEN is replaced with a fresh account. Generated with Devin (https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>116f2bd -
Test GLM-5.2 (753B MoE) on Novita; fallback is Qwen2.5-72B
User testing GLM-5.2 for quality and speed. If unsatisfactory, revert to Qwen/Qwen2.5-72B-Instruct (commit 0e9045f). Generated with Devin (https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>b3f8faa -
Revert to Qwen2.5-72B-Instruct; 8B failed prompt reasoning test
Llama-3.1-8B printed literal [name] placeholder and conflated first-time vs returning user greeting — not capable of following the 9K token v2 counselling prompt reliably. Qwen2.5-72B-Instruct is the confirmed working model on Novita. Generated with Devin (https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>0e9045f -
CHANGELOG: document model/prompt changes and pending 8B assessment
Generated with Devin (https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>f80e433 -
Try meta-llama/Llama-3.1-8B-Instruct on Novita; fallback is Qwen2.5-72B
Llama-3.1-8B-Instruct is confirmed on Novita's current model list. Testing it as a lighter/faster Meta Llama option before deciding on the permanent model choice. Generated with Devin (https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>bee8a73 -
Fix model not supported: switch to Qwen2.5-72B-Instruct on Novita
Novita dropped meta-llama/Llama-3.3-70B-Instruct from their router (confirmed via raw 400 body: 'Model not supported by provider novita'). Switch to Qwen/Qwen2.5-72B-Instruct which is confirmed available on Novita. Also removes the temporary httpx debug scaffolding and restores the clean InferenceClient call pattern. Generated with Devin (https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>9a39c3f -
Switch to raw httpx call to expose full Novita 400 error body
huggingface_hub swallows the response body before raising BadRequestError, making the root cause invisible. This diagnostic commit calls the Novita router endpoint directly via httpx and prints the raw response text on any non-200 status, so the actual Novita error message will appear in the Space logs. Generated with Devin (https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>6c2d7dc -
Add debug logging to capture full 400 response body from Novita
Temporary diagnostic: print the raw response text when a 400 error occurs so we can see what Novita is actually rejecting. Generated with Devin (https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>17d9a57 -
Fix 400 Bad Request: replace non-ASCII chars unsupported by Novita API
Remove arrow (U+2192) and warning emoji (U+26A0 + U+FE0F) introduced in the v2 META_PROMPT; replace with plain ASCII equivalents (-> and WARNING:). En-dashes, em-dashes, and ellipses are retained as they were present in the previous prompt without issue. Generated with Devin (https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>e8ae36b -
Upgrade META_PROMPT to v2 (counsellor-reviewed)
- Replace full system prompt with sanyu_metaprompt_v2_withcounsellors - Add ELICIT BEFORE PROVIDE as core operating principle - Add graded/calibrated empathy guardrails (empathy not sympathy) - Add one-option-at-a-time and safety appraisal rules - Add mental_health_monitoring and rehearsal protocols - Expand memory model: aspirations, progressive context, safety contact - Add structured referral_directory with verified contacts - Deepen adherence/disclosure/mental-health domain guidance - Update few-shot examples to reflect elicit-before-provide pattern - Strengthen session closing: user articulates take-home - Add sustained non-progress escalation trigger to scope_limits Generated with Devin (https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>83c6cef
-
Add CHANGELOG.md covering full project history
Groups all commits into milestones: initial build, LLM/provider exploration, RAG pipeline, UI/fixes, conversation logging, and feedback system. Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>ef18ba4 -
Add thumbs-up/down feedback system with comment form
- Add log_feedback() that writes JSONL to feedback/ folder in the same atwine/CAPS-Sanyu-conversations dataset (mirrors log_turn() pattern) - Set flagging_mode="never" on ChatInterface to disable its built-in like handler (which would have shadowed our own wiring) - Add feedback_options=("Like","Dislike") explicitly on gr.Chatbot so thumbs icons render (they are the default but now explicitly owned by us) - Inside gr.Blocks: add gr.State(_pending_like) to carry LikeData between the .like() event and the submit click - Hidden gr.Group (_feedback_panel) with a free-text comment Textbox and Submit / Cancel buttons appears below the chat on any thumbs click - chatbot.like() -> stores payload in State, shows panel - Submit -> calls log_feedback(), clears textbox, hides panel - Cancel -> clears State, hides panel without logging Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>7c14083 -
Add conversation logging to atwine/CAPS-Sanyu-conversations dataset
Each turn is logged as a timestamped JSONL file in the dataset repo: - session_id (8-char UUID prefix per Space restart, groups a conversation) - timestamp (UTC ISO 8601) - user_message - bot_reply - retrieval_returned_results (bool) - retrieved_chunks (source, section, pages, similarity score) Logging is fire-and-forget: exceptions are caught silently so a logging failure never interrupts the chat. Disabled automatically if DATASET_WRITE_TOKEN secret is not set. Requires DATASET_WRITE_TOKEN Space secret with write access to atwine/CAPS-Sanyu-conversations. Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>91ea307 -
Fix model not supported on Novita; fix Gradio 6 theme deprecation warning
- Switch model from Llama-3.1-70B-Instruct (not on Novita) to Llama-3.3-70B-Instruct (confirmed on Novita; newer/better model) - Move theme= from gr.Blocks() to demo.launch() per Gradio 6 API (gr.blocks.py:873 confirms launch() accepts theme param) Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>b801d99 -
Switch LLM to Llama-3.1-70B-Instruct
Upgrade from 8B to 70B for better reasoning and instruction-following, particularly for boundary tests and RAG synthesis quality. Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>bf814b4 -
Fix double system message bug; add RAG_INSTRUCTIONS; explicit empty-context fallback
- Merge META_PROMPT + RAG_INSTRUCTIONS into a single system message (Llama 3.1 only supports one system message; two caused unpredictable behaviour via the HF chat template) - Add RAG_INSTRUCTIONS as a new module-level variable (lines 383-392) so retrieval boundary rules can be maintained independently of the doctors' META_PROMPT - Move retrieved chunks from a second system message to a user/assistant pair with [RETRIEVED CONTEXT]...[END RETRIEVED CONTEXT] tags - Add explicit else branch when rag_results is empty: inject a "No relevant context was found" signal so the model gets a positive cue to apply rule 4, rather than relying on tag absence Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>01df85f -
Fix TypeError: move theme from ChatInterface to wrapping gr.Blocks
ChatInterface.__init__ has no theme parameter (verified from source: github.com/gradio-app/gradio/blob/main/gradio/chat_interface.py). Theme must be applied to a gr.Blocks wrapper instead. Restructure the launch block accordingly. Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>dd4b46d -
Fix TypeError: remove deprecated Chatbot params bubble_full_width and show_copy_button
Both were removed in newer Gradio versions. Replace show_copy_button=True with buttons=["copy"] per current gr.Chatbot API. Remove bubble_full_width entirely (no equivalent in current API). Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>011633d -
Improve UI: warm theme, Sanyu persona, starter prompts, layout tweaks
- Switch to gr.themes.Soft with teal/orange/stone palette - Add DM Sans Google Font - Custom gr.Chatbot with label "Sanyu", welcome placeholder, height=520, bubble_full_width=False, copy button - Custom gr.Textbox with friendlier placeholder - Rename title to "Sanyu — Peer Support Chatbot" - Add 4 contextual example starter prompts (labels shown, click-to-fill only) Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>029eab3 -
Fix 400 Bad Request: switch provider from hf-inference to novita
hf-inference no longer supports general-purpose LLMs (only 2 legacy models as of mid-2025). Switch to novita provider which hosts Llama-3.1-8B-Instruct. Also upgrade model from 3.2-3B (unavailable on any free provider) to 3.1-8B-Instruct (confirmed on Novita). Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>96f419b -
Switch LLM from Gemini to Llama-3.2-3B-Instruct via HF Inference API
- Replaces google-genai client with huggingface_hub InferenceClient - Uses meta-llama/Llama-3.2-3B-Instruct via provider='hf-inference' - Reads HF_TOKEN from Space secrets (set this in Space settings) - chat_completion() builds system + RAG context + history message list - Retry logic retained for 503/429 transient errors - requirements.txt: removes google-genai, adds huggingface_hub>=0.33.0 - README: updated setup instructions and LLM section Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>a937e6c -
Add retry logic for Gemini 503 UNAVAILABLE errors
Retries up to 3 times with exponential backoff (3s, 6s) on transient 503/UNAVAILABLE responses from the Gemini API. Returns a graceful user-facing message if all retries fail. Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>202fb68 -
Replace FAISS index with portable numpy embeddings in pkl
FAISS C++ objects are not safely picklable across OS/build environments (Windows pkl cannot be loaded on HF Space Linux). Fix: store raw L2-normalised numpy embeddings in the pkl and perform retrieval via a plain dot product. No FAISS dependency at runtime on the Space. - build_index.py: build_embeddings() replaces build_faiss_index(); saves embeddings ndarray instead of faiss.IndexFlatIP object - retrieval.py: pure numpy dot product, zero FAISS calls at runtime - app.py: variable renamed _rag_index -> _rag_embeddings - data/sanyu_knowledge_base.pkl: rebuilt with new format (167 chunks) Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>543fbbd -
Fix retrieval: bypass FAISS search() using numpy dot product
index.search() has incompatible SWIG bindings across faiss-cpu versions (local Windows wrapper vs HF Space Linux AVX2 C++ binding). Replace with a direct numpy dot product against vectors extracted via index.reconstruct(), which is stable across all FAISS versions. Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>c2a8c7b -
Fix FAISS search() for both old and new API versions
HF Spaces runs the raw SWIG C++ binding (search takes n, x, k, D, I). Local venv has the Python wrapper (search returns D, I directly). Try the wrapper form first; fall back to the swig_ptr form on TypeError. Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>612d3f2 -
Fix FAISS search() API compatibility for newer versions
faiss >= 1.9 requires pre-allocated output arrays passed explicitly as positional args: index.search(x, k, distances, labels). The old two-return-value form broke on the HF Space runtime. Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>41f59bc -
Add RAG pipeline: build_index.py, retrieval.py, and FAISS knowledge base
- build_index.py: extracts, cleans, chunks and embeds YAPS documents into a FAISS index (167 chunks from 2 PDFs) - retrieval.py: load_index() and retrieve() for use by app.py at runtime - data/sanyu_knowledge_base.pkl: pre-built FAISS index (422KB) - app.py: wires retrieval in as a separate context Content block per query; loads index and embedding model once at startup - requirements.txt: adds sentence-transformers, faiss-cpu, pdfplumber - .gitignore: excludes venv, docs/, build artefacts Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>0b92277 -
Update README with full project documentation
Adds tech stack, app architecture, system prompt design (12-dimension voice matrix, content domains, safety limits), known limitations, and setup instructions. Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>9f459d8
-
Longer Prompt with improved formatting
Verified signature039b21c -
Reverting to longer prompt
Verified signature50dfc0d
-
short meta-prompt version 1
Verified signaturef960241
-
Trying a really long system prompt
Verified signature5a61afe
-
Fix content extraction from Gradio message format
Verified signature3657bc9 -
Handle both dict and tuple history formats
Verified signature6289fb3 -
Remove type argument, fix history as tuples
Verified signaturee1a0990 -
Fix history format for multi-turn conversation
Verified signature8ec0d06 -
Change to gemini 2.5
Verified signature6cac943 -
Update app.py
Verified signaturee234429 -
Trying a different gemini model
Verified signature06b16df -
Update app.py
Verified signature9807933 -
Switch to smaller model
Verified signature282a536