File size: 964 Bytes
94467bc
 
c98a15b
94467bc
ac57f34
 
 
 
 
 
 
 
 
 
 
 
 
916f64e
ac57f34
 
 
 
 
 
 
 
 
4ec953b
94467bc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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"])