|
2 | 2 | import json |
3 | 3 | import os |
4 | 4 | from dataclasses import dataclass |
| 5 | +from pathlib import Path |
5 | 6 | from typing import TYPE_CHECKING, Annotated, Any, List, Optional |
6 | 7 |
|
7 | 8 | import numpy as np |
8 | 9 | from pydantic import Field, Secret, ValidationError |
9 | 10 | from pydantic.functional_validators import BeforeValidator |
10 | | -from unstructured.utils import FileHandler |
11 | 11 |
|
12 | 12 | from unstructured_ingest.embed.interfaces import BaseEmbeddingEncoder, EmbeddingConfig |
13 | 13 | from unstructured_ingest.utils.dep_check import requires_dependencies |
@@ -35,10 +35,10 @@ class VertexAIEmbeddingConfig(EmbeddingConfig): |
35 | 35 |
|
36 | 36 | def register_application_credentials(self): |
37 | 37 | # TODO look into passing credentials in directly, rather than via env var and tmp file |
38 | | - application_credentials_path = os.path.join("/tmp", "google-vertex-app-credentials.json") |
39 | | - credentials_file = FileHandler(application_credentials_path) |
40 | | - credentials_file.write_file(json.dumps(self.api_key.get_secret_value())) |
41 | | - os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = application_credentials_path |
| 38 | + application_credentials_path = Path("/tmp") / "google-vertex-app-credentials.json" |
| 39 | + with application_credentials_path.open("w+") as credentials_file: |
| 40 | + json.dump(self.api_key.get_secret_value(), credentials_file) |
| 41 | + os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = str(application_credentials_path) |
42 | 42 |
|
43 | 43 | @requires_dependencies( |
44 | 44 | ["langchain", "langchain_google_vertexai"], |
|
0 commit comments