JBHF commited on
Commit
8080d41
1 Parent(s): 705a5b8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -2
app.py CHANGED
@@ -43,6 +43,8 @@ load_dotenv() #
43
  groq_api_key = "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" # os.environ['GROQ_API_KEY']
44
  print("groq_api_key: ", groq_api_key)
45
 
 
 
46
 
47
  if "vector" not in st.session_state:
48
 
@@ -104,9 +106,20 @@ if "vector" not in st.session_state:
104
 
105
  st.session_state.text_splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=200)
106
  st.session_state.documents = st.session_state.text_splitter.split_documents(st.session_state.docs)
107
- #
 
 
 
 
 
 
 
 
 
 
108
  # st.session_state.vector = FAISS.from_documents(st.session_state.documents, st.session_state.embeddings) # ORIGINAL
109
  st.session_state.vector = FAISS.from_documents(st.session_state.documents, st.session_state.embeddings) # ORIGINAL
 
110
  # ZIE:
111
  # ZIE VOOR EEN APP MET CHROMADB:
112
  # https://github.com/vndee/local-rag-example/blob/main/rag.py
@@ -117,7 +130,7 @@ if "vector" not in st.session_state:
117
 
118
 
119
  # st.title("Chat with Docs - Groq Edition :) ")
120
- st.title("Literature Based Research (LBR) - A. Unzicker and J. Bours - Chat with Docs - Groq Edition (Very Fast!) - VERSION 3 - March 8 2024")
121
 
122
  llm = ChatGroq(
123
  temperature=0.2,
 
43
  groq_api_key = "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" # os.environ['GROQ_API_KEY']
44
  print("groq_api_key: ", groq_api_key)
45
 
46
+ # st.title("Chat with Docs - Groq Edition :) ")
47
+ st.title("Literature Based Research (LBR) - A. Unzicker and J. Bours - Chat with Docs - Groq Edition (Very Fast!) - VERSION 3 - March 8 2024")
48
 
49
  if "vector" not in st.session_state:
50
 
 
106
 
107
  st.session_state.text_splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=200)
108
  st.session_state.documents = st.session_state.text_splitter.split_documents(st.session_state.docs)
109
+ # https://python.langchain.com/docs/integrations/vectorstores/faiss
110
+ # docs_and_scores = db.similarity_search_with_score(query)
111
+ # Saving and loading
112
+ # You can also save and load a FAISS index.
113
+ # This is useful so you don’t have to recreate it everytime you use it.
114
+ # db.save_local("faiss_index")
115
+ # new_db = FAISS.load_local("faiss_index", embeddings)
116
+ # docs = new_db.similarity_search(query)
117
+ # docs[0]
118
+ # Document(page_content='Tonight. I call on the Senate to: Pass the Freedom to Vote Act. Pass the John Lewis Voting Rights Act. And while you’re at it, pass the Disclose Act so Americans can know who is funding our elections. \n\nTonight, I’d like to honor someone who has dedicated his life to serve this country: Justice Stephen Breyer—an Army veteran, Constitutional scholar, and retiring Justice of the United States Supreme Court. Justice Breyer, thank you for your service. \n\nOne of the most serious constitutional responsibilities a President has is nominating someone to serve on the United States Supreme Court. \n\nAnd I did that 4 days ago, when I nominated Circuit Court of Appeals Judge Ketanji Brown Jackson. One of our nation’s top legal minds, who will continue Justice Breyer’s legacy of excellence.', metadata={'source': '../../../state_of_the_union.txt'})
119
+ #
120
  # st.session_state.vector = FAISS.from_documents(st.session_state.documents, st.session_state.embeddings) # ORIGINAL
121
  st.session_state.vector = FAISS.from_documents(st.session_state.documents, st.session_state.embeddings) # ORIGINAL
122
+ st.session_state.vector.save_local("faiss_index")
123
  # ZIE:
124
  # ZIE VOOR EEN APP MET CHROMADB:
125
  # https://github.com/vndee/local-rag-example/blob/main/rag.py
 
130
 
131
 
132
  # st.title("Chat with Docs - Groq Edition :) ")
133
+ # st.title("Literature Based Research (LBR) - A. Unzicker and J. Bours - Chat with Docs - Groq Edition (Very Fast!) - VERSION 3 - March 8 2024")
134
 
135
  llm = ChatGroq(
136
  temperature=0.2,