Silence1412 commited on
Commit
54a5241
1 Parent(s): ec207f8

Update Chat_with_pdf_OpenAI.py

Browse files
Files changed (1) hide show
  1. Chat_with_pdf_OpenAI.py +11 -11
Chat_with_pdf_OpenAI.py CHANGED
@@ -38,10 +38,10 @@ def openai_pdf():
38
  embeddings = OpenAIEmbeddings()
39
  knowledge_base = FAISS.from_texts(chunks, embeddings)
40
 
41
- if 'generated' not in st.session_state:
42
- st.session_state['generated'] = []
43
- if 'past' not in st.session_state:
44
- st.session_state['past'] = []
45
 
46
  # show user input
47
  user_question = st.text_input("Ask a question about your PDF:")
@@ -54,11 +54,11 @@ def openai_pdf():
54
  response = chain.run(input_documents=docs, question=user_question)
55
  print(cb)
56
 
57
- #st.write(response)
58
- st.session_state.past.append(user_question)
59
- st.session_state.generated.append(response)
60
 
61
- if st.session_state['generated']:
62
- for i in range(len(st.session_state['generated'])-1, -1, -1):
63
- message(st.session_state["generated"][i], key=str(i))
64
- message(st.session_state['past'][i], is_user=True, key=str(i) + '_user')
 
38
  embeddings = OpenAIEmbeddings()
39
  knowledge_base = FAISS.from_texts(chunks, embeddings)
40
 
41
+ # if 'generated' not in st.session_state:
42
+ # st.session_state['generated'] = []
43
+ # if 'past' not in st.session_state:
44
+ # st.session_state['past'] = []
45
 
46
  # show user input
47
  user_question = st.text_input("Ask a question about your PDF:")
 
54
  response = chain.run(input_documents=docs, question=user_question)
55
  print(cb)
56
 
57
+ st.write(response)
58
+ # st.session_state.past.append(user_question)
59
+ # st.session_state.generated.append(response)
60
 
61
+ # if st.session_state['generated']:
62
+ # for i in range(len(st.session_state['generated'])-1, -1, -1):
63
+ # message(st.session_state["generated"][i], key=str(i))
64
+ # message(st.session_state['past'][i], is_user=True, key=str(i) + '_user')