Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -147,8 +147,26 @@ def run_chain(user_query):
|
|
147 |
print("****************")
|
148 |
return final_ai_response
|
149 |
else:
|
150 |
-
print("Invalid inputs.")
|
151 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
def delete_index_namespace():
|
153 |
pinecone.init(api_key=PINECONE_API_KEY, environment=PINECONE_ENVIRONMENT)
|
154 |
index_namespace_to_delete = pinecone.Index(index_name=index_name)
|
|
|
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)
|
154 |
+
if user_query !="" and not user_query.strip().isspace() and not user_query.isspace():
|
155 |
+
print("Your query:\n"+user_query)
|
156 |
+
vector_db_from_index = Pinecone.from_existing_index(index_name, hf_embeddings, namespace=namespace)
|
157 |
+
ss_results = vector_db_from_index.similarity_search(query=user_query, namespace=namespace, k=5)
|
158 |
+
initial_ai_response = chain.run(input_documents=ss_results, question=user_query, return_only_outputs=True)
|
159 |
+
temp_ai_response = initial_ai_response.partition('<|end|>')[0]
|
160 |
+
final_ai_response = temp_ai_response.replace('\n', '')
|
161 |
+
print(final_ai_response)
|
162 |
+
print(index_status)
|
163 |
+
print(index_name_extracted)
|
164 |
+
print(namespace)
|
165 |
+
print("****************")
|
166 |
+
return final_ai_response
|
167 |
+
else:
|
168 |
+
print("Invalid inputs.")
|
169 |
+
|
170 |
def delete_index_namespace():
|
171 |
pinecone.init(api_key=PINECONE_API_KEY, environment=PINECONE_ENVIRONMENT)
|
172 |
index_namespace_to_delete = pinecone.Index(index_name=index_name)
|