|
import streamlit as st |
|
from PIL import Image |
|
|
|
def set_state_if_absent(key, value): |
|
if key not in st.session_state: |
|
st.session_state[key] = value |
|
|
|
def set_initial_state(): |
|
set_state_if_absent("username", "Provide a Mastodon username (e.g. [email protected])") |
|
set_state_if_absent("result", None) |
|
set_state_if_absent("haystack_started", False) |
|
|
|
def reset_results(*args): |
|
st.session_state.result = None |
|
|
|
def set_openai_api_key(api_key: str): |
|
st.session_state["OPENAI_API_KEY"] = api_key |
|
|
|
def sidebar(): |
|
with st.sidebar: |
|
st.markdown( |
|
"## Thanks for checking this demo! 🎈\n" |
|
"The AI has access to the following Knowledge base: https://help.etsy.com/hc/en-us.\n\n" |
|
"Enter a short question about Etsy and click ASK. That's it!\n\n" |
|
"The app currently runs on Cohere AI but can be changed to any other LLM provider." |
|
) |
|
|