Omartificial-Intelligence-Space commited on
Commit
a027b34
·
verified ·
1 Parent(s): bc7e8e9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -4
app.py CHANGED
@@ -9,15 +9,23 @@ import uuid
9
  from datetime import datetime, timezone, timedelta
10
  from dotenv import load_dotenv
11
  import json
 
12
 
13
- # Load environment variables
14
- load_dotenv()
 
 
 
 
 
 
 
15
 
16
  app = Flask(__name__)
17
  CORS(app)
18
 
19
  # Initialize Gemini client
20
- client = genai.Client(api_key=os.getenv('GOOGLE_API_KEY'))
21
 
22
  # In-memory storage for demo (in production, use a database)
23
  document_caches = {}
@@ -384,6 +392,7 @@ HTML_TEMPLATE = """
384
  </div>
385
  </div>
386
  </div>
 
387
  <script>
388
  let currentCacheId = null;
389
 
@@ -791,4 +800,4 @@ def delete_cache(cache_id):
791
  if __name__ == '__main__':
792
  import os
793
  port = int(os.environ.get("PORT", 7860))
794
- app.run(debug=True, host='0.0.0.0', port= port)
 
9
  from datetime import datetime, timezone, timedelta
10
  from dotenv import load_dotenv
11
  import json
12
+ from huggingface_hub import HfApi
13
 
14
+ # Load Hugging Face token from the environment variable
15
+ GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
16
+ if GOOGLE_API_KEY is None:
17
+ raise ValueError("GOOGLE_API_KEY environment variable is not set. Please set it before running the script.")
18
+
19
+
20
+ hf_api = HfApi(
21
+ token= GOOGLE_API_KEY, # Token is not persisted on the machine.
22
+ )
23
 
24
  app = Flask(__name__)
25
  CORS(app)
26
 
27
  # Initialize Gemini client
28
+ client = genai.Client(api_key=hf_api)
29
 
30
  # In-memory storage for demo (in production, use a database)
31
  document_caches = {}
 
392
  </div>
393
  </div>
394
  </div>
395
+
396
  <script>
397
  let currentCacheId = null;
398
 
 
800
  if __name__ == '__main__':
801
  import os
802
  port = int(os.environ.get("PORT", 7860))
803
+ app.run(debug=True, host='0.0.0.0', port=port)