lorentz commited on
Commit
6ed3644
·
verified ·
1 Parent(s): c4d0806

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -7
app.py CHANGED
@@ -7,16 +7,28 @@ from langchain.chains import RetrievalQA
7
  from langchain.chains import ConversationalRetrievalChain
8
 
9
  from langchain_openai import ChatOpenAI
10
- import os
11
  from langchain_community.vectorstores import Chroma
12
 
13
- import tempfile
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
- user_api_key = st.sidebar.text_input(
17
- label="#### Your OpenAI API key 👇",
18
- placeholder="user_historye your openAI API key, sk-",
19
- type="password")
20
 
21
  # uploaded_file = st.sidebar.file_uploader("upload", type="csv")
22
 
@@ -32,7 +44,7 @@ if KaggleX_courses_db :
32
  retriever = KaggleX_courses_db.as_retriever() # search_kwargs={"k": 4}
33
 
34
  chain = ConversationalRetrievalChain.from_llm(llm = ChatOpenAI(temperature=0.0,model_name='gpt-3.5-turbo',
35
- openai_api_key=user_api_key),
36
  retriever = retriever)
37
 
38
  def conversational_chat(query):
 
7
  from langchain.chains import ConversationalRetrievalChain
8
 
9
  from langchain_openai import ChatOpenAI
 
10
  from langchain_community.vectorstores import Chroma
11
 
 
12
 
13
+ st.sidebar.title("Introduction")
14
+ st.sidebar.markdown("""
15
+ ChatMate is an advanced conversational AI interface, expertly crafted to demonstrate the fusion of Streamlit's user-friendly design and OpenAI's powerful GPT-3.5 model. Here are its highlights:
16
+
17
+ <ul style='text-align: left;'>
18
+ <li><strong>Intuitive Interface</strong>: Built with Streamlit, ChatMate offers a clean, responsive user experience, allowing for natural dialogue with the AI.</li>
19
+ <li><strong>Advanced NLP</strong>: Incorporating OpenAI's most advanced GPT model, the app provides nuanced understanding and generation of human-like text, showcasing the model's impressive capabilities.</li>
20
+ <li><strong>State Management</strong>: Utilizes <code>ConversationChain</code> and <code>ConversationMemory</code> from <code>langchain</code> to preserve the context and flow, ensuring coherent and engaging interactions.</li>
21
+ <li><strong>Python Proficiency</strong>: The app's robust backend, written in Python, reflects the data scientist’s adeptness in programming and system design.</li>
22
+ <li><strong>Secure Interaction</strong>: Streamlit's session state management is used for secure API key handling and user input retention across sessions.</li>
23
+ </ul>
24
+
25
+ ChatMate is developed by Lorentz Yeung
26
+ """, unsafe_allow_html=True)
27
+
28
+ if 'API_Key' not in st.session_state:
29
+ st.session_state['API_Key'] =''
30
+ st.session_state['API_Key']= st.text_input("First, to get it work, put your OpenAI API Key here please, the system will enter for you automatically.",type="password")
31
 
 
 
 
 
32
 
33
  # uploaded_file = st.sidebar.file_uploader("upload", type="csv")
34
 
 
44
  retriever = KaggleX_courses_db.as_retriever() # search_kwargs={"k": 4}
45
 
46
  chain = ConversationalRetrievalChain.from_llm(llm = ChatOpenAI(temperature=0.0,model_name='gpt-3.5-turbo',
47
+ openai_api_key=st.session_state['API_Key']),
48
  retriever = retriever)
49
 
50
  def conversational_chat(query):