|
35 | 35 | # BUSINESS ADVANTAGE OR UNAVAILABILITY, OR LOSS OR CORRUPTION OF |
36 | 36 | # DATA. |
37 | 37 | # |
| 38 | +import logging |
38 | 39 | import re |
39 | 40 | import time |
40 | 41 | import uuid |
|
59 | 60 | from app.services.query import querier |
60 | 61 | from app.services.query.query_configuration import QueryConfiguration |
61 | 62 |
|
| 63 | +logger = logging.getLogger(__name__) |
62 | 64 |
|
63 | 65 | def chat( |
64 | 66 | session: Session, |
@@ -187,18 +189,21 @@ def extract_nodes_from_response_str( |
187 | 189 | extracted_node_ids = [ |
188 | 190 | node_id for node_id in extracted_node_ids if node_id not in node_ids_present |
189 | 191 | ] |
190 | | - if extracted_node_ids: |
191 | | - qdrant_store = VectorStoreFactory.for_chunks(data_source_id) |
192 | | - vector_store = qdrant_store.llama_vector_store() |
193 | | - extracted_source_nodes = vector_store.get_nodes(node_ids=extracted_node_ids) |
194 | | - |
195 | | - # cast them into NodeWithScore with score 0.0 |
196 | | - extracted_source_nodes_w_score = [ |
197 | | - NodeWithScore(node=node, score=0.0) for node in extracted_source_nodes |
198 | | - ] |
199 | | - # add the source nodes to the response |
200 | | - chat_response.source_nodes += extracted_source_nodes_w_score |
201 | | - |
| 192 | + if len(extracted_node_ids) > 0: |
| 193 | + try: |
| 194 | + qdrant_store = VectorStoreFactory.for_chunks(data_source_id) |
| 195 | + vector_store = qdrant_store.llama_vector_store() |
| 196 | + extracted_source_nodes = vector_store.get_nodes(node_ids=extracted_node_ids) |
| 197 | + |
| 198 | + # cast them into NodeWithScore with score 0.0 |
| 199 | + extracted_source_nodes_w_score = [ |
| 200 | + NodeWithScore(node=node, score=0.0) for node in extracted_source_nodes |
| 201 | + ] |
| 202 | + # add the source nodes to the response |
| 203 | + chat_response.source_nodes += extracted_source_nodes_w_score |
| 204 | + except Exception as e: |
| 205 | + logger.warning("Failed to extract nodes from response citations (%s): %s", extracted_node_ids, e) |
| 206 | + pass |
202 | 207 | return chat_response |
203 | 208 |
|
204 | 209 |
|
|
0 commit comments