BroBro87 commited on
Commit
9455595
β€’
1 Parent(s): 368b977

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -32,7 +32,7 @@ def configure_llama_model():
32
  return llm
33
 
34
  def configure_embeddings():
35
- embed_model = HuggingFaceEmbeddings(model_name="ggrn/e5-small-v2")
36
  return embed_model
37
 
38
 
@@ -51,8 +51,9 @@ def initialize_vector_store_index(data_path, service_context):
51
  index = pickle.load(f)
52
  #index = VectorStoreIndex.from_documents(documents, service_context=service_context)
53
  embeddings_2 = SentenceTransformerEmbeddings(model_name="all-MiniLM-L6-v2")
54
- index2 = FAISS.from_documents(pages, embeddings_2)
55
- return index2
 
56
 
57
  def main():
58
  st.title("Cloudflare RAG")
@@ -68,10 +69,10 @@ def main():
68
 
69
  if user_input:
70
  # Generate response
71
- docs = index.similarity_search(user_input)
72
-
73
  # Display response
74
- st.text_area("ChatGPT Response:", docs[0], height=100)
75
 
76
  if __name__ == "__main__":
77
  main()
 
32
  return llm
33
 
34
  def configure_embeddings():
35
+ embed_model = HuggingFaceEmbeddings(model_name="all-MiniLM-L6-v2")
36
  return embed_model
37
 
38
 
 
51
  index = pickle.load(f)
52
  #index = VectorStoreIndex.from_documents(documents, service_context=service_context)
53
  embeddings_2 = SentenceTransformerEmbeddings(model_name="all-MiniLM-L6-v2")
54
+ documents = SimpleDirectoryReader("/content/Data/").load_data()
55
+ index = VectorStoreIndex.from_documents(documents, service_context=service_context)
56
+ return index
57
 
58
  def main():
59
  st.title("Cloudflare RAG")
 
69
 
70
  if user_input:
71
  # Generate response
72
+ query_engine = index.as_query_engine()
73
+ response = query_engine.query(user_input)
74
  # Display response
75
+ st.text_area("ChatGPT Response:", response, height=400)
76
 
77
  if __name__ == "__main__":
78
  main()