saherPervaiz commited on
Commit
5733740
·
verified ·
1 Parent(s): ae25535

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -2,9 +2,10 @@ import streamlit as st
2
  import pandas as pd
3
  import requests
4
  from groq import Groq
5
- import os
6
- from google.colab import userdata
7
- api=userdata.get('demo')
 
8
  # Initialize the Groq client with the API key
9
  client = Groq(api_key=api_key)
10
 
@@ -55,10 +56,11 @@ def get_health_articles(query):
55
  articles = []
56
  return articles
57
  except requests.exceptions.HTTPError as http_err:
58
- st.error(f"HTTP error occurred: {http_err}")
 
59
  return []
60
  except requests.exceptions.RequestException as err:
61
- st.error(f"Error fetching articles: {err}")
62
  return []
63
 
64
  # Streamlit app layout
 
2
  import pandas as pd
3
  import requests
4
  from groq import Groq
5
+
6
+ # Set the API key directly or from environment variable
7
+ api_key = "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" # Replace with your actual demo API key
8
+
9
  # Initialize the Groq client with the API key
10
  client = Groq(api_key=api_key)
11
 
 
56
  articles = []
57
  return articles
58
  except requests.exceptions.HTTPError as http_err:
59
+ st.error(f"HTTP error occurred: {http_err}. Please check your API key and the endpoint.")
60
+ st.error(f"Response content: {response.text}")
61
  return []
62
  except requests.exceptions.RequestException as err:
63
+ st.error(f"Error fetching articles: {err}. Please check your internet connection.")
64
  return []
65
 
66
  # Streamlit app layout