Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -29,17 +29,22 @@ def create_embeddings():
|
|
29 |
return embeddings
|
30 |
|
31 |
# Function to create vector store
|
32 |
-
def create_vector_store(text_chunks, embeddings):
|
33 |
vector_store = FAISS.from_documents(text_chunks, embeddings)
|
|
|
34 |
return vector_store
|
35 |
|
|
|
|
|
|
|
|
|
36 |
# Function to create LLMS model
|
37 |
def create_llms_model():
|
38 |
llm = CTransformers(model='TheBloke/Mistral-7B-Instruct-v0.1-GGUF', config={'max_new_tokens': 128, 'temperature': 0.01})
|
39 |
return llm
|
40 |
|
41 |
# Initialize Streamlit app
|
42 |
-
st.title("Chatbot usando mistral
|
43 |
|
44 |
# loading of documents
|
45 |
documents = load_documents()
|
@@ -50,9 +55,10 @@ text_chunks = split_text_into_chunks(documents)
|
|
50 |
# Create embeddings
|
51 |
embeddings = create_embeddings()
|
52 |
|
53 |
-
|
54 |
-
vector_store =
|
55 |
-
|
|
|
56 |
# Create LLMS model
|
57 |
llm = create_llms_model()
|
58 |
|
|
|
29 |
return embeddings
|
30 |
|
31 |
# Function to create vector store
|
32 |
+
def create_vector_store(text_chunks, embeddings, nombre_vector):
|
33 |
vector_store = FAISS.from_documents(text_chunks, embeddings)
|
34 |
+
vector_store.save_local("cache") #Guardarlo en un
|
35 |
return vector_store
|
36 |
|
37 |
+
# Function to create vector store
|
38 |
+
def load_vector_store(nombre_vector, embeddings):
|
39 |
+
return FAISS.load_local(nombre_vector, embeddings)
|
40 |
+
|
41 |
# Function to create LLMS model
|
42 |
def create_llms_model():
|
43 |
llm = CTransformers(model='TheBloke/Mistral-7B-Instruct-v0.1-GGUF', config={'max_new_tokens': 128, 'temperature': 0.01})
|
44 |
return llm
|
45 |
|
46 |
# Initialize Streamlit app
|
47 |
+
st.title("Chatbot usando mistral")
|
48 |
|
49 |
# loading of documents
|
50 |
documents = load_documents()
|
|
|
55 |
# Create embeddings
|
56 |
embeddings = create_embeddings()
|
57 |
|
58 |
+
try:#load vector store from local
|
59 |
+
vector_store = load_vector_store("cache",embeddings)
|
60 |
+
except:# Create vector store
|
61 |
+
vector_store = create_vector_store(text_chunks, embeddings, "cache")
|
62 |
# Create LLMS model
|
63 |
llm = create_llms_model()
|
64 |
|