Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -128,26 +128,7 @@ PROMPT = PromptTemplate(template=prompt_template, input_variables=["context", "q
|
|
128 |
|
129 |
chain = load_qa_chain(llm=llm, chain_type="stuff", prompt=PROMPT)
|
130 |
|
131 |
-
#chain = load_qa_chain(llm=llm, chain_type="stuff")
|
132 |
-
|
133 |
-
def run_chain(user_query):
|
134 |
-
pinecone.init(api_key=PINECONE_API_KEY, environment=PINECONE_ENVIRONMENT)
|
135 |
-
if user_query !="" and not user_query.strip().isspace() and not user_query.isspace():
|
136 |
-
print("Your query:\n"+user_query)
|
137 |
-
vector_db_from_index = Pinecone.from_existing_index(index_name, hf_embeddings, namespace=namespace)
|
138 |
-
ss_results = vector_db_from_index.similarity_search(query=user_query, namespace=namespace, k=5)
|
139 |
-
initial_ai_response = chain.run(input_documents=ss_results, question=user_query, return_only_outputs=True)
|
140 |
-
#initial_ai_response=chain({"input_documents": ss_results, "question": user_query}, return_only_outputs=True)
|
141 |
-
temp_ai_response = initial_ai_response.partition('<|end|>')[0]
|
142 |
-
final_ai_response = temp_ai_response.replace('\n', '')
|
143 |
-
print(final_ai_response)
|
144 |
-
print(index_status)
|
145 |
-
print(index_name_extracted)
|
146 |
-
print(namespace)
|
147 |
-
print("****************")
|
148 |
-
return final_ai_response
|
149 |
-
else:
|
150 |
-
print("Invalid inputs.")
|
151 |
|
152 |
def run_chain(delete_button, user_query):
|
153 |
pinecone.init(api_key=PINECONE_API_KEY, environment=PINECONE_ENVIRONMENT)
|
@@ -167,8 +148,6 @@ def run_chain(delete_button, user_query):
|
|
167 |
else:
|
168 |
print("Invalid inputs.")
|
169 |
|
170 |
-
|
171 |
-
|
172 |
def delete_index_namespace():
|
173 |
pinecone.init(api_key=PINECONE_API_KEY, environment=PINECONE_ENVIRONMENT)
|
174 |
index_namespace_to_delete = pinecone.Index(index_name=index_name)
|
|
|
128 |
|
129 |
chain = load_qa_chain(llm=llm, chain_type="stuff", prompt=PROMPT)
|
130 |
|
131 |
+
#chain = load_qa_chain(llm=llm, chain_type="stuff")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
|
133 |
def run_chain(delete_button, user_query):
|
134 |
pinecone.init(api_key=PINECONE_API_KEY, environment=PINECONE_ENVIRONMENT)
|
|
|
148 |
else:
|
149 |
print("Invalid inputs.")
|
150 |
|
|
|
|
|
151 |
def delete_index_namespace():
|
152 |
pinecone.init(api_key=PINECONE_API_KEY, environment=PINECONE_ENVIRONMENT)
|
153 |
index_namespace_to_delete = pinecone.Index(index_name=index_name)
|