[fix] streamlit app init by caching it (#1047)
This commit is contained in:
@@ -4,6 +4,12 @@ import streamlit as st
|
|||||||
|
|
||||||
from embedchain import Pipeline as App
|
from embedchain import Pipeline as App
|
||||||
|
|
||||||
|
|
||||||
|
@st.cache_resource
|
||||||
|
def ec_app():
|
||||||
|
return App.from_config(config_path="config.yaml")
|
||||||
|
|
||||||
|
|
||||||
with st.sidebar:
|
with st.sidebar:
|
||||||
huggingface_access_token = st.text_input("Hugging face Token", key="chatbot_api_key", type="password")
|
huggingface_access_token = st.text_input("Hugging face Token", key="chatbot_api_key", type="password")
|
||||||
"[Get Hugging Face Access Token](https://huggingface.co/settings/tokens)"
|
"[Get Hugging Face Access Token](https://huggingface.co/settings/tokens)"
|
||||||
@@ -34,7 +40,7 @@ if prompt := st.chat_input("Ask me anything!"):
|
|||||||
st.stop()
|
st.stop()
|
||||||
|
|
||||||
os.environ["HUGGINGFACE_ACCESS_TOKEN"] = st.session_state.chatbot_api_key
|
os.environ["HUGGINGFACE_ACCESS_TOKEN"] = st.session_state.chatbot_api_key
|
||||||
app = App.from_config(config_path="config.yaml")
|
app = ec_app()
|
||||||
|
|
||||||
if prompt.startswith("/add"):
|
if prompt.startswith("/add"):
|
||||||
with st.chat_message("user"):
|
with st.chat_message("user"):
|
||||||
|
|||||||
Reference in New Issue
Block a user