5
5
from google .cloud import translate_v3 as translate
6
6
from google .cloud import videointelligence , vision
7
7
from google .cloud .language import LanguageServiceClient
8
+ from google .oauth2 import service_account
8
9
9
10
from edenai_apis .apis .google .google_audio_api import GoogleAudioApi
10
11
from edenai_apis .apis .google .google_image_api import GoogleImageApi
@@ -43,14 +44,24 @@ def __init__(self, api_keys: Dict = {}):
43
44
self .webhook_settings = load_provider (ProviderDataEnum .KEY , "webhooksite" )
44
45
self .webhook_token = self .webhook_settings ["webhook_token" ]
45
46
self .project_id = self .api_settings ["project_id" ]
46
- os .environ ["GOOGLE_APPLICATION_CREDENTIALS" ] = self .location
47
+
48
+ clients_init_payload = {}
49
+ if self .location :
50
+ os .environ ["GOOGLE_APPLICATION_CREDENTIALS" ] = self .location
51
+ else :
52
+ credentials = service_account .Credentials .from_service_account_info (
53
+ self .api_settings
54
+ )
55
+ clients_init_payload ["credentials" ] = credentials
47
56
48
57
self .clients = {
49
- "image" : vision .ImageAnnotatorClient (),
50
- "text" : LanguageServiceClient (),
51
- "storage" : storage .Client (),
52
- "video" : videointelligence .VideoIntelligenceServiceClient (),
53
- "translate" : translate .TranslationServiceClient (),
58
+ "image" : vision .ImageAnnotatorClient (** clients_init_payload ),
59
+ "text" : LanguageServiceClient (** clients_init_payload ),
60
+ "storage" : storage .Client (** clients_init_payload ),
61
+ "video" : videointelligence .VideoIntelligenceServiceClient (
62
+ ** clients_init_payload
63
+ ),
64
+ "translate" : translate .TranslationServiceClient (** clients_init_payload ),
54
65
"llm_client" : LLMEngine (
55
66
provider_name = "gemini" ,
56
67
provider_config = {
@@ -59,6 +70,4 @@ def __init__(self, api_keys: Dict = {}):
59
70
),
60
71
}
61
72
62
- aiplatform .init (
63
- project = self .project_id ,
64
- )
73
+ aiplatform .init (project = self .project_id , ** clients_init_payload )
0 commit comments