Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -47,32 +47,27 @@ def initialize_vector_store_index(data_path, service_context):
|
|
47 |
loader = PyPDFLoader("./Cloudflare.pdf")
|
48 |
pages = loader.load_and_split()
|
49 |
# Load the index from a file
|
50 |
-
|
51 |
#index = VectorStoreIndex.from_documents(documents, service_context=service_context)
|
52 |
embeddings_2 = SentenceTransformerEmbeddings(model_name="all-MiniLM-L6-v2")
|
53 |
documents = SimpleDirectoryReader("./").load_data()
|
54 |
index = VectorStoreIndex.from_documents(documents, service_context=service_context)
|
55 |
return index
|
56 |
|
57 |
-
def main():
|
58 |
-
st.title("Cloudflare RAG")
|
59 |
-
# User input
|
60 |
-
user_input = st.text_input("Enter your message:")
|
61 |
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
|
|
|
|
|
|
|
|
67 |
|
68 |
|
|
|
|
|
|
|
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()
|
|
|
47 |
loader = PyPDFLoader("./Cloudflare.pdf")
|
48 |
pages = loader.load_and_split()
|
49 |
# Load the index from a file
|
50 |
+
|
51 |
#index = VectorStoreIndex.from_documents(documents, service_context=service_context)
|
52 |
embeddings_2 = SentenceTransformerEmbeddings(model_name="all-MiniLM-L6-v2")
|
53 |
documents = SimpleDirectoryReader("./").load_data()
|
54 |
index = VectorStoreIndex.from_documents(documents, service_context=service_context)
|
55 |
return index
|
56 |
|
|
|
|
|
|
|
|
|
57 |
|
58 |
+
|
59 |
+
# Configure and initialize components
|
60 |
+
llm = configure_llama_model()
|
61 |
+
embed_model = configure_embeddings()
|
62 |
+
service_context = configure_service_context(llm, embed_model)
|
63 |
+
index = initialize_vector_store_index("./", service_context)
|
64 |
+
|
65 |
+
# User input
|
66 |
+
user_input = input()
|
67 |
|
68 |
|
69 |
+
query_engine = index.as_query_engine()
|
70 |
+
response = query_engine.query(user_input)
|
71 |
+
print(response)
|
72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
|
|
|
|