File size: 2,657 Bytes
f1592f3
d3785cd
9b5b26a
c19d193
6aae614
9b5b26a
 
d3785cd
9b5b26a
d3785cd
7f6d9fa
d3785cd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ae7a494
d3785cd
e121372
d3785cd
 
 
 
13d500a
8c01ffb
d3785cd
8c01ffb
d3785cd
8c01ffb
8fe992b
d3785cd
8c01ffb
 
d3785cd
8fe992b
 
d3785cd
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import os
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, tool
import datetime
import yaml
from tools.final_answer import FinalAnswerTool
from Gradio_UI import GradioUI

# Tool to generate the RPA automation report
@tool
def generate_automation_report(case_description: str) -> str:
    """ Generates a structured Word report for RPA suitability analysis."""
    doc = Document()
    doc.add_heading('Automation Suitability & Requirements Report', 0)
    doc.add_heading('Case Description', 1)
    p = doc.add_paragraph(case_description)
    p.style = 'List Bullet'
    
    # Process Assessment Tool
    doc.add_heading('Process Assessment Tool (PAT)', 1)
    pat_table = doc.add_table(rows=1, cols=3)
    hdr_cells = pat_table.rows[0].cells
    hdr_cells[0].text = 'METRIC'
    hdr_cells[1].text = 'RATING (1-5)'
    hdr_cells[2].text = 'JUSTIFICATION'
    row = pat_table.add_row().cells
    row[0].text = 'Frequency of Execution'
    row[1].text = '5'
    row[2].text = 'Daily predictable patterns'
    
    # Requirements Template
    doc.add_heading('Business Requirements Template', 1)
    doc.add_paragraph('I. PROJECT SCOPE\nThe goal of this automation is to...')
    
    # PDD & SDD
    doc.add_heading('Process Definition Document (PDD)', 1)
    doc.add_heading('System Design Document (SDD)', 1)
    doc.add_paragraph('Technical Architecture\nThis section outlines the system architecture.')
    
    # UAT Plan
    doc.add_heading('User Acceptance Testing (UAT) Plan', 1)
    uat_table = doc.add_table(rows=1, cols=4)
    hdr_cells = uat_table.rows[0].cells
    hdr_cells[0].text = 'TEST ID'
    hdr_cells[1].text = 'CASE DESCRIPTION'
    hdr_cells[2].text = 'EXPECTED RESULT'
    hdr_cells[3].text = 'STATUS'
    row = uat_table.add_row().cells
    row[0].text = 'UAT-001'
    row[1].text = 'Validate data extraction accuracy'
    row[2].text = 'All fields correctly populated'
    row[3].text = 'PASSED'
    
    # Save report
    report_filename = 'Automation_Suitability_Report.docx'
    doc.save(report_filename)
    return f"Report generated: {report_filename} (update with specific details)."

# Model and tool setup
model = HfApiModel(
    max_tokens=2096,
    temperature=0.5,
    model_id='Qwen/Qwen2.5-Coder-32B-Instruct',
    custom_role_conversions=None
)

final_answer = FinalAnswerTool()

# Configure agent with tools
agent = CodeAgent(
    model=model,
    tools=[final_answer, generate_automation_report],  # Include report tool
    max_steps=6,
    verbosity_level=1,
    prompt_templates=None  # Handle templates appropriately
)

# Launch Gradio UI
if __name__ == "__main__":
    GradioUI(agent).launch()