Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,61 +1,34 @@
|
|
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 Gradio_UI import GradioUI
|
7 |
|
8 |
-
# Tool to generate the RPA automation report
|
9 |
@tool
|
10 |
def generate_automation_report(case_description: str) -> str:
|
11 |
-
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
doc = Document()
|
13 |
doc.add_heading('Automation Suitability & Requirements Report', 0)
|
14 |
-
doc.add_heading('Case Description', 1)
|
15 |
-
p = doc.add_paragraph(case_description)
|
16 |
-
p.style = 'List Bullet'
|
17 |
-
|
18 |
-
# Process Assessment Tool
|
19 |
-
doc.add_heading('Process Assessment Tool (PAT)', 1)
|
20 |
-
pat_table = doc.add_table(rows=1, cols=3)
|
21 |
-
hdr_cells = pat_table.rows[0].cells
|
22 |
-
hdr_cells[0].text = 'METRIC'
|
23 |
-
hdr_cells[1].text = 'RATING (1-5)'
|
24 |
-
hdr_cells[2].text = 'JUSTIFICATION'
|
25 |
-
row = pat_table.add_row().cells
|
26 |
-
row[0].text = 'Frequency of Execution'
|
27 |
-
row[1].text = '5'
|
28 |
-
row[2].text = 'Daily predictable patterns'
|
29 |
-
|
30 |
-
# Requirements Template
|
31 |
-
doc.add_heading('Business Requirements Template', 1)
|
32 |
-
doc.add_paragraph('I. PROJECT SCOPE\nThe goal of this automation is to...')
|
33 |
|
34 |
-
#
|
35 |
-
|
36 |
-
|
37 |
-
doc.add_paragraph('Technical Architecture\nThis section outlines the system architecture.')
|
38 |
-
|
39 |
-
# UAT Plan
|
40 |
-
doc.add_heading('User Acceptance Testing (UAT) Plan', 1)
|
41 |
-
uat_table = doc.add_table(rows=1, cols=4)
|
42 |
-
hdr_cells = uat_table.rows[0].cells
|
43 |
-
hdr_cells[0].text = 'TEST ID'
|
44 |
-
hdr_cells[1].text = 'CASE DESCRIPTION'
|
45 |
-
hdr_cells[2].text = 'EXPECTED RESULT'
|
46 |
-
hdr_cells[3].text = 'STATUS'
|
47 |
-
row = uat_table.add_row().cells
|
48 |
-
row[0].text = 'UAT-001'
|
49 |
-
row[1].text = 'Validate data extraction accuracy'
|
50 |
-
row[2].text = 'All fields correctly populated'
|
51 |
-
row[3].text = 'PASSED'
|
52 |
-
|
53 |
-
# Save report
|
54 |
report_filename = 'Automation_Suitability_Report.docx'
|
55 |
doc.save(report_filename)
|
56 |
return f"Report generated: {report_filename} (update with specific details)."
|
57 |
|
58 |
-
#
|
59 |
model = HfApiModel(
|
60 |
max_tokens=2096,
|
61 |
temperature=0.5,
|
@@ -63,17 +36,18 @@ model = HfApiModel(
|
|
63 |
custom_role_conversions=None
|
64 |
)
|
65 |
|
66 |
-
|
67 |
-
|
68 |
-
# Configure agent with tools
|
69 |
agent = CodeAgent(
|
70 |
model=model,
|
71 |
-
tools=[
|
72 |
max_steps=6,
|
73 |
verbosity_level=1,
|
74 |
-
|
|
|
|
|
|
|
75 |
)
|
76 |
|
77 |
-
# Launch Gradio UI
|
78 |
if __name__ == "__main__":
|
79 |
GradioUI(agent).launch()
|
|
|
1 |
import os
|
2 |
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, tool
|
3 |
import datetime
|
4 |
+
import requests
|
5 |
import yaml
|
6 |
from tools.final_answer import FinalAnswerTool
|
7 |
+
from docx import Document # Ensure correct import
|
8 |
from Gradio_UI import GradioUI
|
9 |
|
|
|
10 |
@tool
|
11 |
def generate_automation_report(case_description: str) -> str:
|
12 |
+
"""
|
13 |
+
Generates a structured Word report for RPA analysts based on a case description.
|
14 |
+
|
15 |
+
Parameters:
|
16 |
+
case_description (str): A detailed description of the process and workflow to be automated.
|
17 |
+
|
18 |
+
Returns:
|
19 |
+
str: Message indicating successful report generation and further instructions.
|
20 |
+
"""
|
21 |
doc = Document()
|
22 |
doc.add_heading('Automation Suitability & Requirements Report', 0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
+
# Add report sections here (as before)
|
25 |
+
# ...
|
26 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
report_filename = 'Automation_Suitability_Report.docx'
|
28 |
doc.save(report_filename)
|
29 |
return f"Report generated: {report_filename} (update with specific details)."
|
30 |
|
31 |
+
# Configure the model
|
32 |
model = HfApiModel(
|
33 |
max_tokens=2096,
|
34 |
temperature=0.5,
|
|
|
36 |
custom_role_conversions=None
|
37 |
)
|
38 |
|
39 |
+
# Set up the agent
|
|
|
|
|
40 |
agent = CodeAgent(
|
41 |
model=model,
|
42 |
+
tools=[generate_automation_report, final_answer], # Include the report tool
|
43 |
max_steps=6,
|
44 |
verbosity_level=1,
|
45 |
+
grammar=None,
|
46 |
+
planning_interval=None,
|
47 |
+
name=None,
|
48 |
+
description=None,
|
49 |
)
|
50 |
|
51 |
+
# Launch the Gradio UI
|
52 |
if __name__ == "__main__":
|
53 |
GradioUI(agent).launch()
|