hkoppen's picture
Updates after sync
eeee47d verified
from document_qa_engine import DocumentQAEngine
import streamlit as st
import logging
from yaml import load, SafeLoader, YAMLError
def load_authenticator_config(file_path='authenticator_config.yaml'):
try:
with open(file_path, 'r') as file:
authenticator_config = load(file, Loader=SafeLoader)
return authenticator_config
except FileNotFoundError:
logging.error(f"File {file_path} not found.")
except YAMLError as error:
logging.error(f"Error parsing YAML file: {error}")
def new_file():
st.session_state['loaded_embeddings'] = None
st.session_state['doc_id'] = None
st.session_state['uploaded'] = True
clear_memory()
def clear_memory():
if st.session_state['memory']:
st.session_state['memory'].clear()
def init_qa(model, api_key=None):
print(f"Initializing QA with model: {model} and API key: {api_key}")
return DocumentQAEngine(model, api_key=api_key)
def append_header():
st.header('πŸ“„ Document Insights :rainbow[AI] Assistant πŸ“š', divider='rainbow')
st.text("πŸ“₯ Upload documents in PDF format. Get insights.. ask questions..")
def append_documentation_to_sidebar():
with st.expander("Disclaimer"):
st.markdown(
"""
:warning: Do not upload sensitive data. We **temporarily** store text from the uploaded PDF documents solely
for the purpose of processing your request, and we **do not assume responsibility** for any subsequent use
or handling of the data submitted to third parties LLMs.
""")
with st.expander("Documentation"):
st.markdown(
"""
Upload a document as a PDF document. Once the spinner stops, you can proceed to ask your questions. The answers will
be displayed in the right column. The system will answer your questions using the content of the document
and mark refrences over the PDF viewer.
""")