Update app.py
Browse files
app.py
CHANGED
|
@@ -7,9 +7,9 @@ import requests
|
|
| 7 |
|
| 8 |
# Groq API Setup
|
| 9 |
API_KEY = "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"
|
| 10 |
-
API_URL = "https://api.groq.com/openai/v1/chat/completions"
|
| 11 |
|
| 12 |
-
|
| 13 |
try:
|
| 14 |
# Load the file into a pandas DataFrame
|
| 15 |
if uploaded_file.name.endswith('.csv'):
|
|
@@ -77,3 +77,22 @@ API_URL = "https://api.groq.com/openai/v1/chat/completions"
|
|
| 77 |
except Exception as e:
|
| 78 |
# Return error message if something goes wrong
|
| 79 |
return f"An error occurred: {str(e)}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
# Groq API Setup
|
| 9 |
API_KEY = "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"
|
| 10 |
+
API_URL = "https://api.groq.com/openai/v1/chat/completions"
|
| 11 |
|
| 12 |
+
def analyze_file(uploaded_file):
|
| 13 |
try:
|
| 14 |
# Load the file into a pandas DataFrame
|
| 15 |
if uploaded_file.name.endswith('.csv'):
|
|
|
|
| 77 |
except Exception as e:
|
| 78 |
# Return error message if something goes wrong
|
| 79 |
return f"An error occurred: {str(e)}"
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
# Create the Gradio interface using the new Gradio 3.x syntax
|
| 83 |
+
iface = gr.Interface(
|
| 84 |
+
fn=analyze_file,
|
| 85 |
+
inputs=gr.File(label="Upload CSV or Excel File"), # Corrected to use `gr.File`
|
| 86 |
+
outputs=[
|
| 87 |
+
gr.Textbox(label="Mean Gain"),
|
| 88 |
+
gr.Textbox(label="Median Gain"),
|
| 89 |
+
gr.Textbox(label="Standard Deviation of Gain"),
|
| 90 |
+
gr.Image(label="Plot"),
|
| 91 |
+
gr.Textbox(label="Groq's Analysis")
|
| 92 |
+
],
|
| 93 |
+
title="Data Analysis and Visualization with Groq API",
|
| 94 |
+
description="Upload a CSV or Excel file to analyze the antenna data and get insights."
|
| 95 |
+
)
|
| 96 |
+
|
| 97 |
+
# Launch the interface
|
| 98 |
+
iface.launch()
|