Spaces:
Build error
Build error
| import streamlit as st | |
| from langchain_helper import get_qa_chain, create_vector_db | |
| import base64 | |
| titleimg = "bg.jpeg" | |
| #impliment background formating | |
| def set_bg_hack(main_bg): | |
| # set bg name | |
| main_bg_ext = "jpeg" | |
| st.markdown( | |
| f""" | |
| <style> | |
| .stApp {{ | |
| background: url(data:image/{main_bg_ext};base64,{base64.b64encode(open(main_bg, "rb").read()).decode()}); | |
| background-repeat: no-repeat; | |
| background-position: right 50% bottom 95% ; | |
| background-size: cover; | |
| background-attachment: scroll; | |
| }} | |
| </style> | |
| """, | |
| unsafe_allow_html=True, | |
| ) | |
| set_bg_hack(titleimg) | |
| st.title("Ask Q&A🌱") | |
| btn = st.button("Create Knowledgebase") | |
| if btn: | |
| create_vector_db() | |
| question = st.text_input("Question: ") | |
| if question: | |
| chain = get_qa_chain() | |
| response = chain(question) | |
| st.header("Answer") | |
| st.write(response["result"]) | |