Spaces:
Sleeping
Sleeping
anmolsahai
commited on
Commit
•
2383f67
1
Parent(s):
c1c7a1b
yup
Browse files
app.py
CHANGED
@@ -6,11 +6,20 @@ from google.cloud import aiplatform
|
|
6 |
from google.cloud.aiplatform_v1.services.model_service import ModelServiceClient
|
7 |
from google.cloud.aiplatform_v1.types import GenerateContentRequest, GenerationConfig
|
8 |
import streamlit as st
|
|
|
9 |
|
10 |
# Function to pad base64 strings
|
11 |
def pad_base64(base64_string):
|
12 |
return base64_string + '=' * (-len(base64_string) % 4)
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
# Initialize the Google AI Platform
|
15 |
aiplatform.init(project="akroda", location="us-central1")
|
16 |
|
|
|
6 |
from google.cloud.aiplatform_v1.services.model_service import ModelServiceClient
|
7 |
from google.cloud.aiplatform_v1.types import GenerateContentRequest, GenerationConfig
|
8 |
import streamlit as st
|
9 |
+
import json
|
10 |
|
11 |
# Function to pad base64 strings
|
12 |
def pad_base64(base64_string):
|
13 |
return base64_string + '=' * (-len(base64_string) % 4)
|
14 |
|
15 |
+
# Set the environment variable for Google Cloud credentials
|
16 |
+
credentials_json = os.getenv("GOOGLE_APPLICATION_CREDENTIALS_JSON")
|
17 |
+
if credentials_json:
|
18 |
+
credentials_path = "/tmp/gcp_credentials.json"
|
19 |
+
with open(credentials_path, "w") as f:
|
20 |
+
f.write(credentials_json)
|
21 |
+
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = credentials_path
|
22 |
+
|
23 |
# Initialize the Google AI Platform
|
24 |
aiplatform.init(project="akroda", location="us-central1")
|
25 |
|