DrishtiSharma commited on
Commit
d2c82ee
Β·
verified Β·
1 Parent(s): e827c90

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -6
app.py CHANGED
@@ -4,16 +4,15 @@ from bs4 import BeautifulSoup
4
  import requests
5
  import os
6
 
7
- # Function to fetch OpenAI API key from Hugging Face secrets
8
  def fetch_openai_api_key():
 
9
  try:
10
- # Fetch the OpenAI API key using Streamlit's secrets
11
  secret_key = st.secrets.get("OPENAI_API_KEY", "")
12
  if secret_key:
13
  os.environ['OPENAI_API_KEY'] = secret_key
14
- st.success("OpenAI API Key retrieved and set successfully!")
15
  else:
16
- st.error("Could not retrieve the OpenAI API Key. Please check your Hugging Face secrets configuration.")
17
  except Exception as e:
18
  st.error(f"Error retrieving OpenAI API Key: {str(e)}")
19
 
@@ -107,8 +106,6 @@ This app leverages a **multi-agent system** built on OpenAI's Swarm framework to
107
  Simply provide a URL, and let the agents do the rest!
108
  """)
109
 
110
- # Fetch OpenAI API Key from Hugging Face secrets
111
- st.subheader("πŸ”‘ OpenAI API Key Setup")
112
  fetch_openai_api_key()
113
 
114
  # Initialize Swarm client only after API key is set
 
4
  import requests
5
  import os
6
 
7
+ # Function to fetch OpenAI API key
8
  def fetch_openai_api_key():
9
+ """Fetch the OpenAI API key from Hugging Face secrets."""
10
  try:
 
11
  secret_key = st.secrets.get("OPENAI_API_KEY", "")
12
  if secret_key:
13
  os.environ['OPENAI_API_KEY'] = secret_key
 
14
  else:
15
+ st.warning("⚠️ OpenAI API Key is missing! Please check your Hugging Face secrets configuration.")
16
  except Exception as e:
17
  st.error(f"Error retrieving OpenAI API Key: {str(e)}")
18
 
 
106
  Simply provide a URL, and let the agents do the rest!
107
  """)
108
 
 
 
109
  fetch_openai_api_key()
110
 
111
  # Initialize Swarm client only after API key is set