Vageesh1 commited on
Commit
a1d1228
·
1 Parent(s): dbce2c4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -16
app.py CHANGED
@@ -16,22 +16,23 @@ user_api_key = st.sidebar.text_input(
16
  placeholder="Paste your openAI API key, sk-",
17
  type="password")
18
 
19
- os.environ["OPENAI_API_KEY"] =user_api_key
20
-
21
- file_path='./personality_less.csv'
22
-
23
-
24
- loader = CSVLoader(file_path=file_path, encoding="utf-8", csv_args={
25
- 'delimiter': ','})
26
-
27
- data = loader.load()
28
-
29
- embeddings = OpenAIEmbeddings()
30
- vectorstore = FAISS.from_documents(data, embeddings)
31
-
32
- chain = ConversationalRetrievalChain.from_llm(
33
- llm = ChatOpenAI(temperature=0.0,model_name='gpt-3.5-turbo'),
34
- retriever=vectorstore.as_retriever())
 
35
 
36
  def conversational_chat(query):
37
  result = chain({"question": query,
 
16
  placeholder="Paste your openAI API key, sk-",
17
  type="password")
18
 
19
+ if user_api_key is not None:
20
+ os.environ["OPENAI_API_KEY"] =user_api_key
21
+
22
+ file_path='./personality_less.csv'
23
+
24
+
25
+ loader = CSVLoader(file_path=file_path, encoding="utf-8", csv_args={
26
+ 'delimiter': ','})
27
+
28
+ data = loader.load()
29
+
30
+ embeddings = OpenAIEmbeddings()
31
+ vectorstore = FAISS.from_documents(data, embeddings)
32
+
33
+ chain = ConversationalRetrievalChain.from_llm(
34
+ llm = ChatOpenAI(temperature=0.0,model_name='gpt-3.5-turbo'),
35
+ retriever=vectorstore.as_retriever())
36
 
37
  def conversational_chat(query):
38
  result = chain({"question": query,