Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -7,7 +7,7 @@ from llama_index.llms.llama_utils import messages_to_prompt, completion_to_promp
|
|
7 |
from langchain.embeddings.huggingface import HuggingFaceEmbeddings
|
8 |
from langchain.embeddings.huggingface import HuggingFaceEmbeddings
|
9 |
from llama_index.embeddings import LangchainEmbedding
|
10 |
-
|
11 |
|
12 |
|
13 |
# Set up logging
|
@@ -32,6 +32,9 @@ def configure_embeddings():
|
|
32 |
embed_model = HuggingFaceEmbeddings(model_name="ggrn/e5-small-v2")
|
33 |
return embed_model
|
34 |
|
|
|
|
|
|
|
35 |
def configure_service_context(llm, embed_model):
|
36 |
return ServiceContext.from_defaults(chunk_size=256, llm=llm, embed_model=embed_model)
|
37 |
|
@@ -42,9 +45,10 @@ def initialize_vector_store_index(data_path, service_context):
|
|
42 |
# Load the index from a file
|
43 |
with open('./index_file.pkl', 'rb') as f:
|
44 |
index = pickle.load(f)
|
45 |
-
index = VectorStoreIndex.from_documents(documents, service_context=service_context)
|
46 |
-
|
47 |
-
|
|
|
48 |
|
49 |
def main():
|
50 |
st.title("Cloudflare RAG")
|
@@ -60,8 +64,7 @@ def main():
|
|
60 |
|
61 |
if user_input:
|
62 |
# Generate response
|
63 |
-
|
64 |
-
response = query_engine.query(user_input)
|
65 |
|
66 |
# Display response
|
67 |
st.text_area("ChatGPT Response:", response, height=100)
|
|
|
7 |
from langchain.embeddings.huggingface import HuggingFaceEmbeddings
|
8 |
from langchain.embeddings.huggingface import HuggingFaceEmbeddings
|
9 |
from llama_index.embeddings import LangchainEmbedding
|
10 |
+
from langchain.embeddings import SentenceTransformerEmbeddings
|
11 |
|
12 |
|
13 |
# Set up logging
|
|
|
32 |
embed_model = HuggingFaceEmbeddings(model_name="ggrn/e5-small-v2")
|
33 |
return embed_model
|
34 |
|
35 |
+
|
36 |
+
|
37 |
+
|
38 |
def configure_service_context(llm, embed_model):
|
39 |
return ServiceContext.from_defaults(chunk_size=256, llm=llm, embed_model=embed_model)
|
40 |
|
|
|
45 |
# Load the index from a file
|
46 |
with open('./index_file.pkl', 'rb') as f:
|
47 |
index = pickle.load(f)
|
48 |
+
#index = VectorStoreIndex.from_documents(documents, service_context=service_context)
|
49 |
+
embeddings_2 = SentenceTransformerEmbeddings(model_name="all-MiniLM-L6-v2")
|
50 |
+
index2 = FAISS.from_documents(pages, embeddings_2)
|
51 |
+
return index2
|
52 |
|
53 |
def main():
|
54 |
st.title("Cloudflare RAG")
|
|
|
64 |
|
65 |
if user_input:
|
66 |
# Generate response
|
67 |
+
docs = index2.similarity_search(user_input)
|
|
|
68 |
|
69 |
# Display response
|
70 |
st.text_area("ChatGPT Response:", response, height=100)
|