Spaces:
Runtime error
Runtime error
File size: 1,117 Bytes
53dc0ac 5117e0a 53dc0ac a565e7e 53dc0ac 2db4636 54b3256 5117e0a a565e7e 5117e0a a565e7e 5117e0a a565e7e cd5bd85 a565e7e cd5bd85 a565e7e aff284c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
import os
import streamlit as st
from typing import List
data_dir = os.path.join(os.path.dirname(__file__), '..', 'data')
img_dir = os.path.join(os.path.dirname(__file__), '..', 'img')
config_dir = os.path.join(os.path.dirname(__file__), '..', 'config')
def hf_api_token() -> str:
"""
Utility single access point to look up the hugging face access token.
"""
token = st.secrets['hf_token']
if token is None:
raise ValueError('No HF access token found in streamlit secrets')
return token
def join_items_comma_and(items: List[str]) -> str:
"""
Utility to convert a list of items to lowercase strings, comma separated and ending with and
"""
items = [str(i).strip() for i in items]
string_count = len(items)
if string_count == 0:
return ""
if string_count == 1:
return items[0]
return f"{', '.join(items[:-1])} and {items[-1]}"
def escape_dollars(text: str) -> str:
"""
Convenience function to escape dollar signs for prices in markdown
"""
if text is None:
return text
return text.replace("$", "\\$")
|