Spaces:
Runtime error
Runtime error
Merge pull request #45 from barun-saha/maintenance
Browse filesFix #44: show helpful error message when the token count exceeds
Files changed (2)
- app.py+17
- global_config.py+1-1
8 unmodified lines91011121314202 unmodified lines2172182192202212228 unmodified linesimport tempfilefrom typing import List, Unionimport json5import requestsimport streamlit as st202 unmodified lineslogger.error(msg)st.error(msg)returnhistory.add_user_message(prompt)history.add_ai_message(response)8 unmodified lines9101112131415202 unmodified lines2182192202212222232242252262272282292302312322332342352362372382398 unmodified linesimport tempfilefrom typing import List, Unionimport huggingface_hubimport json5import requestsimport streamlit as st202 unmodified lineslogger.error(msg)st.error(msg)returnexcept huggingface_hub.errors.ValidationError as ve:msg = (f'An error occurred while trying to generate the content: {ve}''\nPlease try again with a significantly shorter input text.')logger.error(msg)st.error(msg)returnexcept Exception as ex:msg = (f'An unexpected error occurred while generating the content: {ex}''\nPlease try again later, possibly with different inputs.')logger.error(msg)st.error(msg)returnhistory.add_user_message(prompt)history.add_ai_message(response)
20 unmodified lines2122232425262720 unmodified linesLLM_MODEL_TEMPERATURE = 0.2LLM_MODEL_MIN_OUTPUT_LENGTH = 100LLM_MODEL_MAX_OUTPUT_LENGTH = 4 * 4096 # tokensLLM_MODEL_MAX_INPUT_LENGTH = 750 # charactersHUGGINGFACEHUB_API_TOKEN = os.environ.get('HUGGINGFACEHUB_API_TOKEN', '')20 unmodified lines2122232425262720 unmodified linesLLM_MODEL_TEMPERATURE = 0.2LLM_MODEL_MIN_OUTPUT_LENGTH = 100LLM_MODEL_MAX_OUTPUT_LENGTH = 4 * 4096 # tokensLLM_MODEL_MAX_INPUT_LENGTH = 400 # charactersHUGGINGFACEHUB_API_TOKEN = os.environ.get('HUGGINGFACEHUB_API_TOKEN', '')
app.py+17
global_config.py+1-1