Spaces:
Configuration error
Configuration error
Download src/rag_chatbot/shared/datacard_values.py from nhabibi/HF-RAGChatbot-Streamlit: direct link, hf CLI and curl.
- Browser
- Download file 1.11 kB
-
https://huggingface.co/spaces/nhabibi/HF-RAGChatbot-Streamlit/resolve/main/src/rag_chatbot/shared/datacard_values.py
- Command line
-
hf download hf://spaces/nhabibi/HF-RAGChatbot-Streamlit/src/rag_chatbot/shared/datacard_values.py
-
curl -L -o datacard_values.py https://huggingface.co/spaces/nhabibi/HF-RAGChatbot-Streamlit/resolve/main/src/rag_chatbot/shared/datacard_values.py
1.11 kB
| """Markers for Data Card fields that have no value.""" | |
| from typing import Any | |
| # The sources were read, but none of them states this value. | |
| NOT_REPORTED = "not_reported" | |
| # The field does not apply to this model, e.g. tokenization for an image model. | |
| NOT_APPLICABLE = "not_applicable" | |
| # No value was extracted: the source or the LLM call failed, or the field was | |
| # never filled. | |
| NOT_RETRIEVED = "not_retrieved" | |
| MISSING_MARKERS = (NOT_REPORTED, NOT_APPLICABLE, NOT_RETRIEVED) | |
| # Older Data Cards use "N/A" and similar strings for every missing value. | |
| LEGACY_MISSING = {"", "n/a", "na", "none", "null", "unknown", "not available"} | |
| MISSING_VALUES = LEGACY_MISSING | set(MISSING_MARKERS) | |
| def is_missing(value: Any) -> bool: | |
| """True for None, empty containers, legacy empty strings, and the markers.""" | |
| if value is None: | |
| return True | |
| if isinstance(value, (list, dict)): | |
| return not value | |
| return isinstance(value, str) and value.strip().lower() in MISSING_VALUES | |
| def is_legacy_missing(value: Any) -> bool: | |
| return isinstance(value, str) and value.strip().lower() in LEGACY_MISSING | |