Skip to content

Commit

Permalink
Streamlit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vadootvpeer committed May 29, 2023
1 parent b189cb6 commit 5472105
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions streamlitui.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ def is_openai_api_key_set() -> bool:
def main():
if len(st.session_state) == 0:
st.session_state["messages"] = []
st.session_state["url"] = ""
st.session_state["OPENAI_API_KEY"] = os.environ.get("OPENAI_API_KEY", "")
if is_openai_api_key_set():
st.session_state["webquery"] = WebQuery(st.session_state["OPENAI_API_KEY"])
else:
st.session_state["webquery"] = None

st.header("ChatPDF")
st.header("Website to Chatbot")

if st.text_input("OpenAI API Key", value=st.session_state["OPENAI_API_KEY"], key="input_OPENAI_API_KEY", type="password"):
if (
Expand All @@ -50,10 +51,10 @@ def main():
st.session_state["webquery"] = WebQuery(st.session_state["OPENAI_API_KEY"])

st.subheader("Add a url")
if st.text_input("Input url", value=st.session_state["url"], key="input_url", type="text"):
if st.text_input("Input url", value=st.session_state["url"], key="input_url", type="default"):
if (
len(st.session_state["input_url"]) > 0
and st.session_state["input_url"] != st.session_state["text"]
and st.session_state["input_url"] != st.session_state["url"]
):
st.session_state["url"] = st.session_state["input_url"]

Expand Down

0 comments on commit 5472105

Please sign in to comment.