-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapp.py
44 lines (33 loc) · 1.02 KB
/
app.py
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
import streamlit as st
from icecream import ic
from langchain.embeddings import OpenAIEmbeddings
# from langchain.vectorstores import FAISS
from langchain.vectorstores import Pinecone
import public
from config import open_ai, pinecone
from config.constants import INDEX_NAME, MODE, PRODUCTION
from config.log import setup_log
from utils.ai.open_ai import create_or_get_conversation_chain
from views.home import home
st.set_page_config(
page_title='OpenSource Chat',
page_icon=':books:',
) # TODO: release
st.write(public.css_index, unsafe_allow_html=True)
def main():
if MODE == PRODUCTION:
ic.disable()
setup_log()
open_ai.setup()
pinecone.setup()
embeddings = OpenAIEmbeddings()
vectorstore = Pinecone.from_existing_index(
index_name=INDEX_NAME, embedding=embeddings,
)
st.session_state.conversation = create_or_get_conversation_chain(
vectorstore,
)
home()
# to run this application, you need to run "streamlit run app.py"
if __name__ == '__main__':
main()