Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed connection closing prematurely in index.py #140

Merged
merged 3 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/unstract/sdk/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.54.0rc10"
__version__ = "0.54.0rc11"


def get_sdk_version():
Expand Down
20 changes: 10 additions & 10 deletions src/unstract/sdk/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,8 @@ def query_index(
filters=filters,
similarity_top_k=Constants.TOP_K,
)
except Exception as e:
self.tool.stream_log(
f"Error building query {vector_db}: {e}", level=LogLevel.ERROR
)
raise VectorDBError(
f"Error building query for {vector_db}: {e}", actual_err=e
)
finally:
vector_db.close()

try:
# Execute query with the open connection
n: VectorStoreQueryResult = vector_db.query(query=q)
if len(n.nodes) > 0:
self.tool.stream_log(f"Found {len(n.nodes)} nodes for {doc_id}")
Expand All @@ -110,7 +101,16 @@ def query_index(
else:
self.tool.stream_log(f"No nodes found for {doc_id}")
return None

except Exception as e:
self.tool.stream_log(
pk-zipstack marked this conversation as resolved.
Show resolved Hide resolved
f"Error building query {vector_db}: {e}", level=LogLevel.ERROR
)
raise VectorDBError(
f"Error building query for {vector_db}: {e}", actual_err=e
)
finally:
# Close connection only once at the end
vector_db.close()

@log_elapsed(operation="EXTRACTION")
Expand Down