Spaces:
Runtime error
Runtime error
Commit
·
923089a
1
Parent(s):
cf018dc
Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,18 @@
|
|
|
|
|
|
1 |
import vertexai
|
2 |
from vertexai.generative_models import GenerativeModel
|
3 |
import vertexai.preview.generative_models as generative_models
|
4 |
import gradio as gr
|
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
def generate(text):
|
7 |
try:
|
8 |
vertexai.init(project="idyllic-now-424815-h2", location="us-central1")
|
|
|
1 |
+
import os
|
2 |
+
import json
|
3 |
import vertexai
|
4 |
from vertexai.generative_models import GenerativeModel
|
5 |
import vertexai.preview.generative_models as generative_models
|
6 |
import gradio as gr
|
7 |
|
8 |
+
# Set the path to the service account key JSON file
|
9 |
+
SERVICE_ACCOUNT_KEY_PATH = "path/to/your/service-account-file.json"
|
10 |
+
|
11 |
+
# Read the service account key JSON file and set the environment variable
|
12 |
+
with open(SERVICE_ACCOUNT_KEY_PATH) as f:
|
13 |
+
service_account_info = json.load(f)
|
14 |
+
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = SERVICE_ACCOUNT_KEY_PATH
|
15 |
+
|
16 |
def generate(text):
|
17 |
try:
|
18 |
vertexai.init(project="idyllic-now-424815-h2", location="us-central1")
|