From 6d2389de1c84e97f4891efd950472513cc9b8764 Mon Sep 17 00:00:00 2001 From: Sidharth Mohanty Date: Fri, 22 Dec 2023 12:03:45 +0530 Subject: [PATCH] [fix] streamlit app init by caching it (#1047) --- examples/mistral-streamlit/app.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/mistral-streamlit/app.py b/examples/mistral-streamlit/app.py index 8c5ebd43..a5a68c06 100644 --- a/examples/mistral-streamlit/app.py +++ b/examples/mistral-streamlit/app.py @@ -4,6 +4,12 @@ import streamlit as st from embedchain import Pipeline as App + +@st.cache_resource +def ec_app(): + return App.from_config(config_path="config.yaml") + + with st.sidebar: 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)" @@ -34,7 +40,7 @@ if prompt := st.chat_input("Ask me anything!"): st.stop() 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"): with st.chat_message("user"):