Quazim0t0 commited on
Commit
97d5125
·
verified ·
1 Parent(s): db33f59

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -34
app.py CHANGED
@@ -8,10 +8,9 @@ agent = CodeAgent(
8
  )
9
 
10
  def analyze_content(file_paths, progress=gr.Progress()):
11
- """Process files and generate comprehensive report with progress tracking"""
12
  full_content = []
13
 
14
- # Track file reading progress
15
  progress(0, desc="Starting analysis...")
16
  for i, path in enumerate(file_paths):
17
  progress(i/len(file_paths), desc=f"Reading {path.split('/')[-1]}...")
@@ -20,59 +19,49 @@ def analyze_content(file_paths, progress=gr.Progress()):
20
  content = f.read()
21
  full_content.append(f"## {path.split('/')[-1]}\n{content}\n")
22
  except Exception as e:
23
- return f"Error processing {path}: {str(e)}"
24
 
25
- # Track analysis progress
26
- progress(0.8, desc="Analyzing content with AI...")
27
  report = agent.run(f"""
28
- Analyze these documents and create a detailed report:
29
-
30
  {"".join(full_content)[:10000]}
31
 
32
- Report structure:
33
- 1. Executive Summary
34
- 2. Key Findings
35
- 3. Important Patterns
36
- 4. Recommendations
37
 
38
- Use professional markdown formatting with headings and bullet points.
39
  """)
40
 
41
  progress(1.0, desc="Analysis complete!")
42
- return report
43
 
44
  with gr.Blocks() as demo:
45
- gr.Markdown("# Professional Document Analyzer")
46
 
47
  with gr.Row():
48
- with gr.Column(scale=1):
49
- file_input = gr.File(
50
- file_count="multiple",
51
- file_types=[".txt"],
52
- label="Upload Documents"
53
- )
54
- process_btn = gr.Button("Generate Report", variant="primary")
55
-
56
- with gr.Column(scale=2, variant="panel"):
57
- gr.Markdown("## Analysis Report")
58
- report_output = gr.Markdown(
59
- elem_classes="report-box",
60
- label="",
61
- show_label=False
62
- )
63
- status = gr.Textbox(label="Processing Status", visible=False)
64
 
65
  process_btn.click(
66
  fn=analyze_content,
67
  inputs=file_input,
68
  outputs=[report_output, status],
69
- show_progress="minimal"
70
  )
71
 
72
  if __name__ == "__main__":
73
  demo.launch(
74
  server_name="0.0.0.0",
75
  server_port=7860,
76
- share=True,
77
- ssr=False # Disable experimental server-side rendering
78
  )
 
8
  )
9
 
10
  def analyze_content(file_paths, progress=gr.Progress()):
11
+ """Process files and generate report with progress tracking"""
12
  full_content = []
13
 
 
14
  progress(0, desc="Starting analysis...")
15
  for i, path in enumerate(file_paths):
16
  progress(i/len(file_paths), desc=f"Reading {path.split('/')[-1]}...")
 
19
  content = f.read()
20
  full_content.append(f"## {path.split('/')[-1]}\n{content}\n")
21
  except Exception as e:
22
+ return f"Error processing {path}: {str(e)}", ""
23
 
24
+ progress(0.8, desc="Analyzing content...")
 
25
  report = agent.run(f"""
26
+ Analyze these documents:
 
27
  {"".join(full_content)[:10000]}
28
 
29
+ Create report with:
30
+ 1. Key insights
31
+ 2. Important patterns
32
+ 3. Actionable recommendations
33
+ 4. Supporting evidence
34
 
35
+ Use markdown formatting with headers.
36
  """)
37
 
38
  progress(1.0, desc="Analysis complete!")
39
+ return report, "Process completed successfully"
40
 
41
  with gr.Blocks() as demo:
42
+ gr.Markdown("# Document Analysis System")
43
 
44
  with gr.Row():
45
+ file_input = gr.File(
46
+ file_count="multiple",
47
+ file_types=[".txt"],
48
+ label="Upload Documents"
49
+ )
50
+ process_btn = gr.Button("Generate Report", variant="primary")
51
+
52
+ report_output = gr.Markdown(label="Analysis Report")
53
+ status = gr.Textbox(label="Status", visible=False)
 
 
 
 
 
 
 
54
 
55
  process_btn.click(
56
  fn=analyze_content,
57
  inputs=file_input,
58
  outputs=[report_output, status],
59
+ show_progress="full"
60
  )
61
 
62
  if __name__ == "__main__":
63
  demo.launch(
64
  server_name="0.0.0.0",
65
  server_port=7860,
66
+ share=True # Public link enabled
 
67
  )