ikraamkb commited on
Commit
6daac1d
Β·
verified Β·
1 Parent(s): e8c3695

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -8
app.py CHANGED
@@ -1,4 +1,4 @@
1
- """from fastapi import FastAPI, File, UploadFile
2
  import fitz # PyMuPDF for PDF parsing
3
  from tika import parser # Apache Tika for document parsing
4
  import openpyxl
@@ -130,10 +130,10 @@ app = gr.mount_gradio_app(app, demo, path="/")
130
  @app.get("/")
131
  def home():
132
  return RedirectResponse(url="/")
133
- """
134
 
135
 
136
- import gradio as gr
 
137
  import pandas as pd
138
  import matplotlib.pyplot as plt
139
  import seaborn as sns
@@ -155,7 +155,7 @@ print("βœ… AI models loaded successfully!")
155
  app = FastAPI()
156
 
157
  def generate_visualization(excel_file, viz_type, user_request):
158
- """Generates Python visualization code and insights based on user requests and Excel data."""
159
  try:
160
  print("πŸ“‚ Loading Excel file...")
161
  df = pd.read_excel(excel_file)
@@ -182,13 +182,13 @@ def generate_visualization(excel_file, viz_type, user_request):
182
  print("βœ… Table analysis completed!")
183
 
184
  # βœ… AI-generated code
185
- prompt = f"""Generate clean and executable Python code to visualize the following dataset:
186
  Columns: {list(df.columns)}
187
  Visualization type: {viz_type}
188
  User request: {user_request}
189
  Use the provided DataFrame 'df' without reloading it.
190
  Ensure 'plt.show()' is at the end.
191
- """
192
 
193
  print("πŸ€– Sending request to AI code generator...")
194
  generated_code = code_generator(prompt, max_length=200)[0]['generated_text']
@@ -257,5 +257,4 @@ print("βœ… Gradio interface mounted successfully!")
257
  @app.get("/")
258
  def home():
259
  print("🏠 Redirecting to UI...")
260
- return RedirectResponse(url="/")
261
-
 
1
+ from fastapi import FastAPI, File, UploadFile
2
  import fitz # PyMuPDF for PDF parsing
3
  from tika import parser # Apache Tika for document parsing
4
  import openpyxl
 
130
  @app.get("/")
131
  def home():
132
  return RedirectResponse(url="/")
 
133
 
134
 
135
+
136
+ """import gradio as gr
137
  import pandas as pd
138
  import matplotlib.pyplot as plt
139
  import seaborn as sns
 
155
  app = FastAPI()
156
 
157
  def generate_visualization(excel_file, viz_type, user_request):
158
+ Generates Python visualization code and insights based on user requests and Excel data.
159
  try:
160
  print("πŸ“‚ Loading Excel file...")
161
  df = pd.read_excel(excel_file)
 
182
  print("βœ… Table analysis completed!")
183
 
184
  # βœ… AI-generated code
185
+ prompt = f Generate clean and executable Python code to visualize the following dataset:
186
  Columns: {list(df.columns)}
187
  Visualization type: {viz_type}
188
  User request: {user_request}
189
  Use the provided DataFrame 'df' without reloading it.
190
  Ensure 'plt.show()' is at the end.
191
+
192
 
193
  print("πŸ€– Sending request to AI code generator...")
194
  generated_code = code_generator(prompt, max_length=200)[0]['generated_text']
 
257
  @app.get("/")
258
  def home():
259
  print("🏠 Redirecting to UI...")
260
+ return RedirectResponse(url="/")"""