Spaces:
Sleeping
appy.py
Browse filesKey Features of This Tool:
Structured Document: Generates a professional Word report template
Sections Included:
Case Description
Process Assessment Metrics
Requirements Template
Process & System Design Documentation
UAT Test Cases
Chart/Graph Integration Preparation
Automation Suitability Evaluation: Provides a framework to rate process factors (e.g., frequency, complexity)
Placeholders for Customization: Includes editable sections and tables for analysts to fill in case-specific data
Adaptable Workflow: Built to align with UiPath RPA project lifecycle stages
Integration with Your Workflow:
AI Agent Integration: Wrap this function as a custom tool within your existing agent framework (e.g., decorate with
@tool
for LangChain compatibility)
Document Enrichment: Use your LLM model (e.g., Qwen/Qwen2.5-Coder-32B-Instruct) to generate initial content for sections like the Process Overview or UAT test cases
Image Integration: Modify the tool to accept workflow screenshots and embed them using doc.add_picture()
Report Automation: Extend the tool to auto-populate tables with data extracted from stakeholders via UI forms or OCR
|
@@ -3,6 +3,7 @@ import datetime
|
|
| 3 |
import requests
|
| 4 |
import pytz
|
| 5 |
import yaml
|
|
|
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
|
@@ -19,22 +20,90 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
|
|
| 19 |
return "What magic will you build ?"
|
| 20 |
|
| 21 |
@tool
|
| 22 |
-
|
| 23 |
-
"""A tool that fetches the current local time in a specified timezone.
|
| 24 |
-
Args:
|
| 25 |
-
timezone: A string representing a valid timezone (e.g., 'America/New_York').
|
| 26 |
-
"""
|
| 27 |
-
try:
|
| 28 |
-
# Create timezone object
|
| 29 |
-
tz = pytz.timezone(timezone)
|
| 30 |
-
# Get current time in that timezone
|
| 31 |
-
local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
|
| 32 |
-
return f"The current local time in {timezone} is: {local_time}"
|
| 33 |
-
except Exception as e:
|
| 34 |
-
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 35 |
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
# 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:
|
| 40 |
# model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
|
|
@@ -47,11 +116,6 @@ custom_role_conversions=None,
|
|
| 47 |
)
|
| 48 |
|
| 49 |
|
| 50 |
-
# Import tool from Hub
|
| 51 |
-
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 52 |
-
|
| 53 |
-
with open("prompts.yaml", 'r') as stream:
|
| 54 |
-
prompt_templates = yaml.safe_load(stream)
|
| 55 |
|
| 56 |
agent = CodeAgent(
|
| 57 |
model=model,
|
|
|
|
| 3 |
import requests
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
+
from docx import Document
|
| 7 |
from tools.final_answer import FinalAnswerTool
|
| 8 |
|
| 9 |
from Gradio_UI import GradioUI
|
|
|
|
| 20 |
return "What magic will you build ?"
|
| 21 |
|
| 22 |
@tool
|
| 23 |
+
from docx import Document
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
+
class UiPathReportTool:
|
| 26 |
+
def __init__(self):
|
| 27 |
+
pass
|
| 28 |
|
| 29 |
+
def generate_automation_report(self, case_description: str) -> str:
|
| 30 |
+
"""A tool that generates a structured Word report for RPA analysts based on a case description."""
|
| 31 |
+
# Create a new Word document
|
| 32 |
+
doc = Document()
|
| 33 |
+
|
| 34 |
+
# Report title
|
| 35 |
+
doc.add_heading('Automation Suitability & Requirements Report', 0)
|
| 36 |
+
|
| 37 |
+
# Case Description
|
| 38 |
+
doc.add_heading('Case Description', 1)
|
| 39 |
+
p = doc.add_paragraph(case_description)
|
| 40 |
+
p.style = 'List Bullet' # Example formatting
|
| 41 |
+
|
| 42 |
+
# Process Assessment Tool
|
| 43 |
+
doc.add_heading('Process Assessment Tool (PAT) for Automation', 1)
|
| 44 |
+
pat_table = doc.add_table(rows=1, cols=3)
|
| 45 |
+
hdr_cells = pat_table.rows[0].cells
|
| 46 |
+
hdr_cells[0].text = 'METRIC'
|
| 47 |
+
hdr_cells[1].text = 'RATING (1-5)'
|
| 48 |
+
hdr_cells[2].text = 'JUSTIFICATION'
|
| 49 |
+
# Example assessment
|
| 50 |
+
row = pat_table.add_row().cells
|
| 51 |
+
row[0].text = 'Frequency of Execution'
|
| 52 |
+
row[1].text = '5'
|
| 53 |
+
row[2].text = 'Process is executed daily with predictable patterns'
|
| 54 |
+
|
| 55 |
+
# Requirements Template
|
| 56 |
+
doc.add_heading('Business Requirements Template', 1)
|
| 57 |
+
doc.add_heading('I. PROJECT SCOPE', 2)
|
| 58 |
+
doc.add_paragraph('The goal of this automation is to... ')
|
| 59 |
+
# Add requirement sections here (Objectives, Constraints, Compliance, etc.)
|
| 60 |
+
|
| 61 |
+
# PDD (Process Definition Document)
|
| 62 |
+
doc.add_heading('Process Definition Document (PDD)', 1)
|
| 63 |
+
doc.add_heading('A. Process Overview', 2)
|
| 64 |
+
doc.add_paragraph('This section describes the current manual process.')
|
| 65 |
+
# Add PDD sections like Input/Output Data, Process Step Diagram, Stakeholders
|
| 66 |
+
|
| 67 |
+
# SDD (System Design Document)
|
| 68 |
+
doc.add_heading('System Design Document (SDD)', 1)
|
| 69 |
+
doc.add_heading('1. Technical Architecture', 2)
|
| 70 |
+
doc.add_paragraph('This section outlines the system architecture.')
|
| 71 |
+
# Add SDD sections (Integration Points, Error Handling, Validation Rules)
|
| 72 |
+
|
| 73 |
+
# UAT (User Acceptance Testing)
|
| 74 |
+
doc.add_heading('User Acceptance Testing (UAT) Plan', 1)
|
| 75 |
+
doc.add_heading('A. Test Cases', 2)
|
| 76 |
+
uat_table = doc.add_table(rows=1, cols=4)
|
| 77 |
+
hdr_cells = uat_table.rows[0].cells
|
| 78 |
+
hdr_cells[0].text = 'TEST ID'
|
| 79 |
+
hdr_cells[1].text = 'CASE DESCRIPTION'
|
| 80 |
+
hdr_cells[2].text = 'EXPECTED RESULT'
|
| 81 |
+
hdr_cells[3].text = 'STATUS'
|
| 82 |
+
# Example test case
|
| 83 |
+
row = uat_table.add_row().cells
|
| 84 |
+
row[0].text = 'UAT-001'
|
| 85 |
+
row[1].text = 'Validate data extraction accuracy'
|
| 86 |
+
row[2].text = 'All fields correctly populated'
|
| 87 |
+
row[3].text = 'PASSED' # Default placeholder
|
| 88 |
+
|
| 89 |
+
# Analysis Charts
|
| 90 |
+
doc.add_heading('Analysis Charts & Key Metrics', 1)
|
| 91 |
+
doc.add_paragraph('Include charts like Process Complexity vs. Frequency, ROI Projection.')
|
| 92 |
+
doc.add_paragraph('These visualizations can be inserted as Excel graphs or Visio diagrams.')
|
| 93 |
+
|
| 94 |
+
# Save the document
|
| 95 |
+
report_filename = 'Automation_Suitability_Report.docx'
|
| 96 |
+
doc.save(report_filename)
|
| 97 |
+
|
| 98 |
+
return (f"Automation suitability report successfully generated: {report_filename}. "
|
| 99 |
+
f"Replace placeholders with project-specific details and add supporting images as needed.")
|
| 100 |
+
|
| 101 |
+
# Example usage
|
| 102 |
+
if __name__ == "__main__":
|
| 103 |
+
report_tool = UiPathReportTool()
|
| 104 |
+
case_desc = "A manual process where sales orders are entered into ERP from emails, currently taking 30 minutes per order."
|
| 105 |
+
result = report_tool.generate_automation_report(case_desc)
|
| 106 |
+
print(result)
|
| 107 |
|
| 108 |
# 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:
|
| 109 |
# model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
|
|
|
|
| 116 |
)
|
| 117 |
|
| 118 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
|
| 120 |
agent = CodeAgent(
|
| 121 |
model=model,
|