bearking58 commited on
Commit
562e1f8
·
1 Parent(s): bcd9850

feat: move credentials to json file

Browse files
public-prediction/predict_custom_model.py CHANGED
@@ -2,6 +2,7 @@ from typing import Dict, List, Union
2
  from google.cloud import aiplatform
3
  from google.protobuf import json_format
4
  from google.protobuf.struct_pb2 import Value
 
5
 
6
 
7
  def predict_custom_trained_model(
@@ -17,9 +18,13 @@ def predict_custom_trained_model(
17
  """
18
  # The AI Platform services require regional API endpoints.
19
  client_options = {"api_endpoint": api_endpoint}
 
 
 
20
  # Initialize client that will be used to create and send requests.
21
  # This client only needs to be created once, and can be reused for multiple requests.
22
  client = aiplatform.gapic.PredictionServiceClient(
 
23
  client_options=client_options)
24
  # The format of each instance should conform to the deployed model's prediction input schema.
25
  instances = instances if isinstance(instances, list) else [instances]
 
2
  from google.cloud import aiplatform
3
  from google.protobuf import json_format
4
  from google.protobuf.struct_pb2 import Value
5
+ from google.oauth2 import service_account
6
 
7
 
8
  def predict_custom_trained_model(
 
18
  """
19
  # The AI Platform services require regional API endpoints.
20
  client_options = {"api_endpoint": api_endpoint}
21
+
22
+ credentials = service_account.Credentials.from_service_account_file(
23
+ "steady-climate-416810-ea1536e1868c.json")
24
  # Initialize client that will be used to create and send requests.
25
  # This client only needs to be created once, and can be reused for multiple requests.
26
  client = aiplatform.gapic.PredictionServiceClient(
27
+ credentials=credentials
28
  client_options=client_options)
29
  # The format of each instance should conform to the deployed model's prediction input schema.
30
  instances = instances if isinstance(instances, list) else [instances]
public-prediction/requirements.txt CHANGED
@@ -2,4 +2,5 @@ kafka-python
2
  langchain
3
  openai
4
  langchain-openai
5
- python-dotenv
 
 
2
  langchain
3
  openai
4
  langchain-openai
5
+ python-dotenv
6
+ google-cloud-aiplatform