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

DatabricksVectorSearch doesn't allow access with service principal client ID/secret #33

Open
daisuke834 opened this issue Dec 13, 2024 · 1 comment

Comments

@daisuke834
Copy link

VectorSearchClient of databricks.vector_search.client can optionally receive the optional arguments service_principal_client_id=None and service_principal_client_secret=None for allowing access with service principal client ID/secret.

However, DatabricksVectorSearch for langchain integration isn't capable for doing it because it calls VectorSearchClient() without any arguments.

        try:
            self.index = VectorSearchClient().get_index(
                endpoint_name=endpoint, index_name=index_name
            )

at

self.index = VectorSearchClient().get_index(
endpoint_name=endpoint, index_name=index_name

Could you fix the code like this?

--- a/vectorstores.py
+++ b/vectorstores.py
@@ -216,6 +216,11 @@ class DatabricksVectorSearch(VectorStore):
         embedding: Optional[Embeddings] = None,
         text_column: Optional[str] = None,
         columns: Optional[List[str]] = None,
+        workspace_url=None,
+        personal_access_token=None,
+        service_principal_client_id=None,
+        service_principal_client_secret=None,
+        disable_notice=False,
     ):
         if not (isinstance(index_name, str) and _INDEX_NAME_PATTERN.match(index_name)):
             raise ValueError(
@@ -234,7 +239,13 @@ class DatabricksVectorSearch(VectorStore):
             ) from e
 
         try:
-            self.index = VectorSearchClient().get_index(
+            self.index = VectorSearchClient(
+                    workspace_url=workspace_url,
+                    personal_access_token=personal_access_token,
+                    service_principal_client_id=service_principal_client_id,
+                    service_principal_client_secret=service_principal_client_secret,
+                    disable_notice=disable_notice
+                ).get_index(
                 endpoint_name=endpoint, index_name=index_name
             )
         except Exception as e:

Other alternative solution like #27 is also fine with me.

@chutch1122
Copy link
Contributor

#27 was just merged!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants