refactor session state and add todo list

main
Gustav von Zitzewitz 1 year ago
parent 3dfff5a41d
commit a1910d075d

@ -21,4 +21,10 @@ This is an app that let's you ask questions about any data source by leveraging
## How does it look like?
<img src="./datachad.png" width="100%"/>
<img src="./datachad.png" width="100%"/>
## TODO LIST
If you like to contribute, feel free to grab any task
- [ ] Add option to choose model and embeddings
- [ ] Enable fully local / private mode
- [ ] Refactor utils, especially the loaders

@ -37,40 +37,28 @@ st.markdown(
unsafe_allow_html=True,
)
SESSION_DEFAULTS = {
"past": [],
"usage": {},
"chat_history": [],
"generated": [],
"data_source": DEFAULT_DATA_SOURCE,
"uploaded_file": None,
"auth_ok": False,
"openai_api_key": None,
"activeloop_token": None,
"activeloop_org_name": None,
"k": K,
"fetch_k": FETCH_K,
"chunk_size": CHUNK_SIZE,
"temperature": TEMPERATURE,
"max_tokens": MAX_TOKENS,
}
# Initialise session state variables
# Chat and Data Source
if "past" not in st.session_state:
st.session_state["past"] = []
if "usage" not in st.session_state:
st.session_state["usage"] = {}
if "chat_history" not in st.session_state:
st.session_state["chat_history"] = []
if "generated" not in st.session_state:
st.session_state["generated"] = []
if "data_source" not in st.session_state:
st.session_state["data_source"] = DEFAULT_DATA_SOURCE
if "uploaded_file" not in st.session_state:
st.session_state["uploaded_file"] = None
# Authentication and Credentials
if "auth_ok" not in st.session_state:
st.session_state["auth_ok"] = False
if "openai_api_key" not in st.session_state:
st.session_state["openai_api_key"] = None
if "activeloop_token" not in st.session_state:
st.session_state["activeloop_token"] = None
if "activeloop_org_name" not in st.session_state:
st.session_state["activeloop_org_name"] = None
# Advanced Options
if "k" not in st.session_state:
st.session_state["k"] = K
if "fetch_k" not in st.session_state:
st.session_state["fetch_k"] = FETCH_K
if "chunk_size" not in st.session_state:
st.session_state["chunk_size"] = CHUNK_SIZE
if "temperature" not in st.session_state:
st.session_state["temperature"] = TEMPERATURE
if "max_tokens" not in st.session_state:
st.session_state["max_tokens"] = MAX_TOKENS
for k, v in SESSION_DEFAULTS.items():
if k not in st.session_state:
st.session_state[k] = v
# Sidebar with Authentication

@ -263,7 +263,7 @@ def load_any_data_source(
loader = WebBaseLoader(data_source)
elif is_file:
if is_text:
loader = TextLoader(data_source)
loader = TextLoader(data_source, encoding="utf-8")
elif is_notebook:
loader = NotebookLoader(data_source)
elif is_pdf:

Loading…
Cancel
Save