USER-GNEXUSES commited on
Commit
d3785cd
·
verified ·
1 Parent(s): 9e8930b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +62 -105
app.py CHANGED
@@ -1,123 +1,80 @@
1
  import os
2
- from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel,load_tool, tool
3
  import datetime
4
- import requests
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
7
- import Document
8
-
9
  from Gradio_UI import GradioUI
10
 
11
-
12
  @tool
13
- #from docx import Document
14
-
15
- class UiPathReportTool:
16
- def __init__(self):
17
- pass
18
-
19
- def generate_automation_report(self, case_description: str) -> str:
20
- """A tool that generates a structured Word report for RPA analysts based on a case description."""
21
- # Create a new Word document
22
- doc = Document()
23
-
24
- # Report title
25
- doc.add_heading('Automation Suitability & Requirements Report', 0)
26
-
27
- # Case Description
28
- doc.add_heading('Case Description', 1)
29
- p = doc.add_paragraph(case_description)
30
- p.style = 'List Bullet' # Example formatting
31
-
32
- # Process Assessment Tool
33
- doc.add_heading('Process Assessment Tool (PAT) for Automation', 1)
34
- pat_table = doc.add_table(rows=1, cols=3)
35
- hdr_cells = pat_table.rows[0].cells
36
- hdr_cells[0].text = 'METRIC'
37
- hdr_cells[1].text = 'RATING (1-5)'
38
- hdr_cells[2].text = 'JUSTIFICATION'
39
- # Example assessment
40
- row = pat_table.add_row().cells
41
- row[0].text = 'Frequency of Execution'
42
- row[1].text = '5'
43
- row[2].text = 'Process is executed daily with predictable patterns'
44
-
45
- # Requirements Template
46
- doc.add_heading('Business Requirements Template', 1)
47
- doc.add_heading('I. PROJECT SCOPE', 2)
48
- doc.add_paragraph('The goal of this automation is to... ')
49
- # Add requirement sections here (Objectives, Constraints, Compliance, etc.)
50
-
51
- # PDD (Process Definition Document)
52
- doc.add_heading('Process Definition Document (PDD)', 1)
53
- doc.add_heading('A. Process Overview', 2)
54
- doc.add_paragraph('This section describes the current manual process.')
55
- # Add PDD sections like Input/Output Data, Process Step Diagram, Stakeholders
56
-
57
- # SDD (System Design Document)
58
- doc.add_heading('System Design Document (SDD)', 1)
59
- doc.add_heading('1. Technical Architecture', 2)
60
- doc.add_paragraph('This section outlines the system architecture.')
61
- # Add SDD sections (Integration Points, Error Handling, Validation Rules)
62
-
63
- # UAT (User Acceptance Testing)
64
- doc.add_heading('User Acceptance Testing (UAT) Plan', 1)
65
- doc.add_heading('A. Test Cases', 2)
66
- uat_table = doc.add_table(rows=1, cols=4)
67
- hdr_cells = uat_table.rows[0].cells
68
- hdr_cells[0].text = 'TEST ID'
69
- hdr_cells[1].text = 'CASE DESCRIPTION'
70
- hdr_cells[2].text = 'EXPECTED RESULT'
71
- hdr_cells[3].text = 'STATUS'
72
- # Example test case
73
- row = uat_table.add_row().cells
74
- row[0].text = 'UAT-001'
75
- row[1].text = 'Validate data extraction accuracy'
76
- row[2].text = 'All fields correctly populated'
77
- row[3].text = 'PASSED' # Default placeholder
78
-
79
- # Analysis Charts
80
- doc.add_heading('Analysis Charts & Key Metrics', 1)
81
- doc.add_paragraph('Include charts like Process Complexity vs. Frequency, ROI Projection.')
82
- doc.add_paragraph('These visualizations can be inserted as Excel graphs or Visio diagrams.')
83
-
84
- # Save the document
85
- report_filename = 'Automation_Suitability_Report.docx'
86
- doc.save(report_filename)
87
-
88
- return (f"Automation suitability report successfully generated: {report_filename}. "
89
- f"Replace placeholders with project-specific details and add supporting images as needed.")
90
-
91
- # Example usage
92
- if __name__ == "__main__":
93
- report_tool = UiPathReportTool()
94
- case_desc = "A manual process where sales orders are entered into ERP from emails, currently taking 30 minutes per order."
95
- result = report_tool.generate_automation_report(case_desc)
96
- print(result)
97
-
98
- # If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
99
- # model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
100
 
 
101
  model = HfApiModel(
102
- max_tokens=2096,
103
- temperature=0.5,
104
- model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
105
- custom_role_conversions=None,
106
  )
107
 
 
108
 
109
-
110
  agent = CodeAgent(
111
  model=model,
112
- tools=[final_answer], ## add your tools here (don't remove final answer)
113
  max_steps=6,
114
  verbosity_level=1,
115
- grammar=None,
116
- planning_interval=None,
117
- name=None,
118
- description=None,
119
- prompt_templates=prompt_templates
120
  )
121
 
122
-
123
- GradioUI(agent).launch()
 
 
1
  import os
2
+ from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, tool
3
  import datetime
 
4
  import yaml
5
  from tools.final_answer import FinalAnswerTool
6
+ from docx import Document # Corrected import
 
7
  from Gradio_UI import GradioUI
8
 
9
+ # Tool to generate the RPA automation report
10
  @tool
11
+ def generate_automation_report(case_description: str) -> str:
12
+ """Generates a structured Word report for RPA suitability analysis."""
13
+ doc = Document()
14
+ doc.add_heading('Automation Suitability & Requirements Report', 0)
15
+ doc.add_heading('Case Description', 1)
16
+ p = doc.add_paragraph(case_description)
17
+ p.style = 'List Bullet'
18
+
19
+ # Process Assessment Tool
20
+ doc.add_heading('Process Assessment Tool (PAT)', 1)
21
+ pat_table = doc.add_table(rows=1, cols=3)
22
+ hdr_cells = pat_table.rows[0].cells
23
+ hdr_cells[0].text = 'METRIC'
24
+ hdr_cells[1].text = 'RATING (1-5)'
25
+ hdr_cells[2].text = 'JUSTIFICATION'
26
+ row = pat_table.add_row().cells
27
+ row[0].text = 'Frequency of Execution'
28
+ row[1].text = '5'
29
+ row[2].text = 'Daily predictable patterns'
30
+
31
+ # Requirements Template
32
+ doc.add_heading('Business Requirements Template', 1)
33
+ doc.add_paragraph('I. PROJECT SCOPE\nThe goal of this automation is to...')
34
+
35
+ # PDD & SDD
36
+ doc.add_heading('Process Definition Document (PDD)', 1)
37
+ doc.add_heading('System Design Document (SDD)', 1)
38
+ doc.add_paragraph('Technical Architecture\nThis section outlines the system architecture.')
39
+
40
+ # UAT Plan
41
+ doc.add_heading('User Acceptance Testing (UAT) Plan', 1)
42
+ uat_table = doc.add_table(rows=1, cols=4)
43
+ hdr_cells = uat_table.rows[0].cells
44
+ hdr_cells[0].text = 'TEST ID'
45
+ hdr_cells[1].text = 'CASE DESCRIPTION'
46
+ hdr_cells[2].text = 'EXPECTED RESULT'
47
+ hdr_cells[3].text = 'STATUS'
48
+ row = uat_table.add_row().cells
49
+ row[0].text = 'UAT-001'
50
+ row[1].text = 'Validate data extraction accuracy'
51
+ row[2].text = 'All fields correctly populated'
52
+ row[3].text = 'PASSED'
53
+
54
+ # Save report
55
+ report_filename = 'Automation_Suitability_Report.docx'
56
+ doc.save(report_filename)
57
+ return f"Report generated: {report_filename} (update with specific details)."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
 
59
+ # Model and tool setup
60
  model = HfApiModel(
61
+ max_tokens=2096,
62
+ temperature=0.5,
63
+ model_id='Qwen/Qwen2.5-Coder-32B-Instruct',
64
+ custom_role_conversions=None
65
  )
66
 
67
+ final_answer = FinalAnswerTool()
68
 
69
+ # Configure agent with tools
70
  agent = CodeAgent(
71
  model=model,
72
+ tools=[final_answer, generate_automation_report], # Include report tool
73
  max_steps=6,
74
  verbosity_level=1,
75
+ prompt_templates=None # Handle templates appropriately
 
 
 
 
76
  )
77
 
78
+ # Launch Gradio UI
79
+ if __name__ == "__main__":
80
+ GradioUI(agent).launch()