Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,11 +11,11 @@ API_URL = "https://api.groq.com/openai/v1/chat/completions" # Updated API URL
|
|
| 11 |
|
| 12 |
def analyze_file(uploaded_file):
|
| 13 |
try:
|
| 14 |
-
# Load the file into a pandas DataFrame
|
| 15 |
if uploaded_file.name.endswith('.csv'):
|
| 16 |
-
df = pd.read_csv(uploaded_file
|
| 17 |
elif uploaded_file.name.endswith('.xlsx'):
|
| 18 |
-
df = pd.read_excel(uploaded_file
|
| 19 |
else:
|
| 20 |
return "Error: The uploaded file is neither CSV nor Excel."
|
| 21 |
|
|
@@ -68,16 +68,16 @@ def analyze_file(uploaded_file):
|
|
| 68 |
response = requests.post(API_URL, json=payload, headers=headers)
|
| 69 |
if response.status_code == 200:
|
| 70 |
groq_analysis = response.json()["choices"][0]["message"]["content"]
|
|
|
|
|
|
|
| 71 |
else:
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
return mean_gain, median_gain, std_dev_gain, fig, groq_analysis
|
| 75 |
else:
|
| 76 |
return "Error: Required columns 'Gain (dB)' or 'Frequency (GHz)' not found in the dataset."
|
| 77 |
|
| 78 |
except Exception as e:
|
| 79 |
# Return error message if something goes wrong
|
| 80 |
-
|
| 81 |
|
| 82 |
|
| 83 |
# Streamlit Interface
|
|
|
|
| 11 |
|
| 12 |
def analyze_file(uploaded_file):
|
| 13 |
try:
|
| 14 |
+
# Load the file into a pandas DataFrame from the uploaded file (in memory)
|
| 15 |
if uploaded_file.name.endswith('.csv'):
|
| 16 |
+
df = pd.read_csv(uploaded_file) # Read directly from memory
|
| 17 |
elif uploaded_file.name.endswith('.xlsx'):
|
| 18 |
+
df = pd.read_excel(uploaded_file) # Read directly from memory
|
| 19 |
else:
|
| 20 |
return "Error: The uploaded file is neither CSV nor Excel."
|
| 21 |
|
|
|
|
| 68 |
response = requests.post(API_URL, json=payload, headers=headers)
|
| 69 |
if response.status_code == 200:
|
| 70 |
groq_analysis = response.json()["choices"][0]["message"]["content"]
|
| 71 |
+
st.write("Groq's Analysis:")
|
| 72 |
+
st.write(groq_analysis)
|
| 73 |
else:
|
| 74 |
+
st.write(f"Error: {response.status_code}, {response.text}")
|
|
|
|
|
|
|
| 75 |
else:
|
| 76 |
return "Error: Required columns 'Gain (dB)' or 'Frequency (GHz)' not found in the dataset."
|
| 77 |
|
| 78 |
except Exception as e:
|
| 79 |
# Return error message if something goes wrong
|
| 80 |
+
st.write(f"An error occurred: {str(e)}")
|
| 81 |
|
| 82 |
|
| 83 |
# Streamlit Interface
|