blazingbunny commited on
Commit
94cf579
·
1 Parent(s): 53bca84

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -1
app.py CHANGED
@@ -1,9 +1,23 @@
1
  import streamlit as st
2
  from google.cloud import language_v1
 
 
3
  import os
4
 
5
- # Your provided function
6
  def sample_analyze_entities(text_content):
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  client = language_v1.LanguageServiceClient()
8
 
9
  type_ = language_v1.Document.Type.PLAIN_TEXT
 
1
  import streamlit as st
2
  from google.cloud import language_v1
3
+ import json
4
+ from google.oauth2 import service_account
5
  import os
6
 
 
7
  def sample_analyze_entities(text_content):
8
+ # Read the JSON credentials from the secret
9
+ service_account_info = json.loads(os.environ.get("GOOGLE_APPLICATION_CREDENTIALS_JSON"))
10
+
11
+ # Create credentials
12
+ credentials = service_account.Credentials.from_service_account_info(
13
+ service_account_info, scopes=["https://www.googleapis.com/auth/cloud-platform"]
14
+ )
15
+
16
+ # Initialize the LanguageServiceClient with the credentials
17
+ client = language_v1.LanguageServiceClient(credentials=credentials)
18
+
19
+ # Your provided function
20
+
21
  client = language_v1.LanguageServiceClient()
22
 
23
  type_ = language_v1.Document.Type.PLAIN_TEXT