ai-puppy commited on
Commit
c7ebfd3
Β·
1 Parent(s): 4b905c5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -17
app.py CHANGED
@@ -23,16 +23,12 @@ uploaded_file_path = None
23
 
24
  # Chat functionality removed - focusing on file analysis
25
 
26
- def test_function():
27
- """Simple test function to verify Gradio API binding works"""
28
- return "βœ… API binding test successful!"
29
-
30
  def handle_file_upload(file):
31
  """Handle file upload and store the path globally"""
32
  global uploaded_file_path
33
  try:
34
  if file is not None:
35
- # Gradio File component returns the file path directly
36
  uploaded_file_path = file
37
  filename = os.path.basename(file)
38
  return f"βœ… File uploaded successfully: {filename}"
@@ -89,7 +85,8 @@ with gr.Blocks(title="DataForge - AI-Powered File Analysis") as demo:
89
  # File Upload Section
90
  gr.Markdown("### πŸ“€ File Upload")
91
  file_upload = gr.File(
92
- label="Upload File for Analysis"
 
93
  )
94
  upload_status = gr.Textbox(
95
  label="Upload Status",
@@ -129,16 +126,16 @@ with gr.Blocks(title="DataForge - AI-Powered File Analysis") as demo:
129
  )
130
 
131
  # Event handlers
132
- file_upload.upload(
133
  fn=handle_file_upload,
134
- inputs=file_upload,
135
- outputs=upload_status
136
  )
137
 
138
  analyze_btn.click(
139
  fn=analyze_file_with_question,
140
- inputs=user_question,
141
- outputs=analysis_output
142
  )
143
 
144
  gr.Markdown("---")
@@ -188,9 +185,4 @@ with gr.Blocks(title="DataForge - AI-Powered File Analysis") as demo:
188
 
189
  if __name__ == "__main__":
190
  print("Starting DataForge application...")
191
- try:
192
- demo.launch(server_name="127.0.0.1", server_port=7860)
193
- except Exception as e:
194
- print(f"Error launching app: {e}")
195
- # Fallback launch
196
- demo.launch()
 
23
 
24
  # Chat functionality removed - focusing on file analysis
25
 
 
 
 
 
26
  def handle_file_upload(file):
27
  """Handle file upload and store the path globally"""
28
  global uploaded_file_path
29
  try:
30
  if file is not None:
31
+ # With type="filepath", Gradio returns the file path as a string
32
  uploaded_file_path = file
33
  filename = os.path.basename(file)
34
  return f"βœ… File uploaded successfully: {filename}"
 
85
  # File Upload Section
86
  gr.Markdown("### πŸ“€ File Upload")
87
  file_upload = gr.File(
88
+ label="Upload File for Analysis",
89
+ type="filepath"
90
  )
91
  upload_status = gr.Textbox(
92
  label="Upload Status",
 
126
  )
127
 
128
  # Event handlers
129
+ file_upload.change(
130
  fn=handle_file_upload,
131
+ inputs=[file_upload],
132
+ outputs=[upload_status]
133
  )
134
 
135
  analyze_btn.click(
136
  fn=analyze_file_with_question,
137
+ inputs=[user_question],
138
+ outputs=[analysis_output]
139
  )
140
 
141
  gr.Markdown("---")
 
185
 
186
  if __name__ == "__main__":
187
  print("Starting DataForge application...")
188
+ demo.launch()