Spaces:
Paused
Paused
Rahul Bhoyar
commited on
Commit
·
4ddfb35
1
Parent(s):
8225db2
Updated file
Browse files
app.py
CHANGED
@@ -15,14 +15,12 @@ def read_pdf(uploaded_file):
|
|
15 |
return text
|
16 |
|
17 |
def querying(query_engine):
|
18 |
-
progress_container = st.empty()
|
19 |
query = st.text_input("Enter the Query for PDF:")
|
20 |
submit = st.button("Generate The response for the query")
|
21 |
-
|
22 |
if submit:
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
|
27 |
|
28 |
# docs = document_search.similarity_search(query_text)
|
@@ -40,20 +38,20 @@ def main():
|
|
40 |
documents = Document(text=file_contents)
|
41 |
documents = [documents]
|
42 |
st.success("Documents loaded successfully!")
|
43 |
-
|
44 |
-
embed_model_uae = HuggingFaceEmbedding(model_name="WhereIsAI/UAE-Large-V1")
|
45 |
-
service_context = ServiceContext.from_defaults(llm=llm, chunk_size=800, chunk_overlap=20, embed_model=embed_model_uae)
|
46 |
-
|
47 |
-
# Indexing the documents
|
48 |
-
progress_container = st.empty()
|
49 |
-
progress_container.text("Creating VectorStoreIndex...")
|
50 |
-
# Download embeddings from OpenAI
|
51 |
|
52 |
-
index = VectorStoreIndex.from_documents(documents, service_context=service_context, show_progress=True)
|
53 |
-
index.storage_context.persist()
|
54 |
-
query_engine = index.as_query_engine()
|
55 |
-
st.success("VectorStoreIndex created successfully!")
|
56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
querying(query_engine)
|
58 |
|
59 |
|
|
|
15 |
return text
|
16 |
|
17 |
def querying(query_engine):
|
|
|
18 |
query = st.text_input("Enter the Query for PDF:")
|
19 |
submit = st.button("Generate The response for the query")
|
|
|
20 |
if submit:
|
21 |
+
with st.spinner("Fetching the response..."):
|
22 |
+
response = query_engine.query(query)
|
23 |
+
st.write(f"**Response:** {response}")
|
24 |
|
25 |
|
26 |
# docs = document_search.similarity_search(query_text)
|
|
|
38 |
documents = Document(text=file_contents)
|
39 |
documents = [documents]
|
40 |
st.success("Documents loaded successfully!")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
|
|
|
|
|
|
|
|
42 |
|
43 |
+
with st.spinner("Created Embedding model..."):
|
44 |
+
embed_model_uae = HuggingFaceEmbedding(model_name="WhereIsAI/UAE-Large-V1")
|
45 |
+
service_context = ServiceContext.from_defaults(llm=llm, chunk_size=800, chunk_overlap=20, embed_model=embed_model_uae)
|
46 |
+
st.success("Embedding model created successfully!")
|
47 |
+
|
48 |
+
# Download embeddings from OpenAI
|
49 |
+
with st.spinner("Created VectorStoreIndex..."):
|
50 |
+
index = VectorStoreIndex.from_documents(documents, service_context=service_context, show_progress=True)
|
51 |
+
index.storage_context.persist()
|
52 |
+
query_engine = index.as_query_engine()
|
53 |
+
st.success("VectorStoreIndex created successfully!")
|
54 |
+
|
55 |
querying(query_engine)
|
56 |
|
57 |
|