Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -67,11 +67,14 @@ API_ENDPOINT = "https://api2.woorank.com/reviews"
|
|
67 |
API_KEY = os.environ.get("woorank_api_key")
|
68 |
openai_api_key = os.environ.get("openai_api_key")
|
69 |
|
|
|
70 |
if not API_KEY:
|
71 |
st.error("The API keys are not properly configured. Check your environment variables!")
|
|
|
|
|
72 |
else:
|
73 |
# Generate the report by calling the ChatGPT Turbo API and the WooRank API
|
74 |
-
def analyze_data(_advice, _items, _topics, _issues, _technologies):
|
75 |
"""
|
76 |
:param _advice: A list of strings, each string is a piece of advice
|
77 |
:param _items: a list of items that are being analyzed
|
@@ -86,10 +89,6 @@ else:
|
|
86 |
YOU ARE WRITING THE REPORT IN HTML USING A TEMPLATE.'''}]
|
87 |
|
88 |
|
89 |
-
if not openai_api_key:
|
90 |
-
st.error("OPENAI_API_KEY not found in environment variables.")
|
91 |
-
return None
|
92 |
-
|
93 |
llm = OpenAIChat(model_name="gpt-4o-mini", temperature=0, prefix_messages=prefix_messages, openai_api_key=openai_api_key)
|
94 |
|
95 |
# Create the prompt template and the run statement when there are NOT issues
|
@@ -255,7 +254,7 @@ else:
|
|
255 |
if not advice:
|
256 |
st.warning("Whoops, sorry, our bot didn't find any data. It might be that the URL is not accessible (a firewall is in place, for example), or the website does not have structured data.", icon="⚠️")
|
257 |
else:
|
258 |
-
msg = analyze_data(advice, items, topics, issues, technologies)
|
259 |
# Display the results when the button is clicked and the data is available
|
260 |
if schema_org and msg:
|
261 |
st.write("##### Your Findings 📈")
|
|
|
67 |
API_KEY = os.environ.get("woorank_api_key")
|
68 |
openai_api_key = os.environ.get("openai_api_key")
|
69 |
|
70 |
+
|
71 |
if not API_KEY:
|
72 |
st.error("The API keys are not properly configured. Check your environment variables!")
|
73 |
+
elif not openai_api_key:
|
74 |
+
st.error("The OpenAI API key is not properly configured. Check your environment variables!")
|
75 |
else:
|
76 |
# Generate the report by calling the ChatGPT Turbo API and the WooRank API
|
77 |
+
def analyze_data(_advice, _items, _topics, _issues, _technologies, openai_api_key):
|
78 |
"""
|
79 |
:param _advice: A list of strings, each string is a piece of advice
|
80 |
:param _items: a list of items that are being analyzed
|
|
|
89 |
YOU ARE WRITING THE REPORT IN HTML USING A TEMPLATE.'''}]
|
90 |
|
91 |
|
|
|
|
|
|
|
|
|
92 |
llm = OpenAIChat(model_name="gpt-4o-mini", temperature=0, prefix_messages=prefix_messages, openai_api_key=openai_api_key)
|
93 |
|
94 |
# Create the prompt template and the run statement when there are NOT issues
|
|
|
254 |
if not advice:
|
255 |
st.warning("Whoops, sorry, our bot didn't find any data. It might be that the URL is not accessible (a firewall is in place, for example), or the website does not have structured data.", icon="⚠️")
|
256 |
else:
|
257 |
+
msg = analyze_data(advice, items, topics, issues, technologies, openai_api_key)
|
258 |
# Display the results when the button is clicked and the data is available
|
259 |
if schema_org and msg:
|
260 |
st.write("##### Your Findings 📈")
|