Spaces:
Runtime error
Runtime error
Merge pull request #42 from barun-saha/maintenance
Browse filesFiles changed (2)
- app.py+38-8
- requirements.txt+1-1
9 unmodified lines10111213141516182 unmodified lines19920020120220120220320420520620720820320420520620720820921021121221321421521621721821922022122259 unmodified lines2822832842852862872882892902912922932942952962972982993003013023033043053063079 unmodified linesfrom typing import List, Union
import json5import requestsimport streamlit as stfrom langchain_community.chat_message_histories import StreamlitChatMessageHistoryfrom langchain_core.messages import HumanMessage182 unmodified lines progress_bar = st.progress(0, 'Preparing to call LLM...') response = ''
try: for chunk in _get_llm().stream(formatted_template): response += chunk
# Update the progress bar progress_percentage = min(len(response) / APPROX_TARGET_LENGTH, 0.95) progress_bar.progress( progress_percentage, text='Streaming content...this might take a while...' for chunk in _get_llm().stream(formatted_template): response += chunk
# Update the progress bar progress_percentage = min(len(response) / APPROX_TARGET_LENGTH, 0.95) progress_bar.progress( progress_percentage, text='Streaming content...this might take a while...' ) except requests.exceptions.ConnectionError: msg = ( 'A connection error occurred while streaming content from the LLM endpoint.' ' Unfortunately, the slide deck cannot be generated. Please try again later.' ) logger.error(msg) st.error(msg) return
history.add_user_message(prompt) history.add_ai_message(response)59 unmodified lines )
return None except RecursionError: st.error( 'Encountered an error while parsing JSON...' 'the slide deck cannot be created, unfortunately ☹' '\nPlease try again later.' ) logger.error('Caught RecursionError while parsing JSON. Cannot generate the slide deck!')
return None except Exception: st.error( 'Encountered an error while parsing JSON...' 'the slide deck cannot be created, unfortunately ☹' '\nPlease try again later.' ) logger.error( 'Caught ValueError: failed to parse JSON!' )
return None
if DOWNLOAD_FILE_KEY in st.session_state: path = pathlib.Path(st.session_state[DOWNLOAD_FILE_KEY])12344567aiohttp==3.10.5python-dotenv[cli]~=1.0.0gitpython==3.1.43json_repair==0.15.3json-repair==0.29.2idna==3.7jinja2==3.1.4Pillow==10.3.0app.py+38-8
requirements.txt+1-1