MechanicCoder commited on
Commit
a99b38f
·
verified ·
1 Parent(s): 4c8f1bb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -7
app.py CHANGED
@@ -9,15 +9,38 @@ from Gradio_UI import GradioUI
9
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
12
- def get_error_tickets(arg1:str, arg2:int)-> str: #it's import to specify the return type
13
- #Keep this format for the description / args / args description but feel free to modify the tool
14
- """A tool that makes searches the databank reagarding existing problems
 
15
  Args:
16
- arg1: a machine name like MachineXY
17
- arg2: a error code of the machine
 
 
 
18
  """
 
 
 
 
 
 
 
19
 
20
-
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  return f"if have found existing tickets for {arg1} with error code {arg2}, please check the ticketsystem"
23
 
@@ -58,7 +81,7 @@ with open("prompts.yaml", 'r') as stream:
58
 
59
  agent = CodeAgent(
60
  model=model,
61
- tools=[final_answer, get_error_tickets], ## add your tools here (don't remove final answer)
62
  max_steps=6,
63
  verbosity_level=1,
64
  grammar=None,
 
9
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
12
+ def search_error_tickets(machine_name: str, error_code: int) -> str:
13
+ """
14
+ Simulates a search for error tickets in a system for a given machine and error code.
15
+
16
  Args:
17
+ machine_name: The name or identifier of the machine (e.g., "MachineXY").
18
+ error_code: The error code to search for.
19
+
20
+ Returns:
21
+ A string summarizing the simulated search results.
22
  """
23
+ # Simulated database of error tickets
24
+ simulated_tickets = [
25
+ {"ticket_id": 2032, "machine": "MachineXY", "error_code": 404, "description": "Not Found"},
26
+ {"ticket_id": 2033, "machine": "MachineXY", "error_code": 500, "description": "Internal Server Error"},
27
+ {"ticket_id": 2034, "machine": "MachineAB", "error_code": 404, "description": "Not Found"},
28
+ {"ticket_id": 2035, "machine": "MachineXY", "error_code": 404, "description": "Resource missing"},
29
+ ]
30
 
31
+ # Filter the simulated tickets based on the provided machine name and error code.
32
+ matching_tickets = [
33
+ ticket for ticket in simulated_tickets
34
+ if ticket["machine"].lower() == machine_name.lower() and ticket["error_code"] == error_code
35
+ ]
36
+
37
+ if matching_tickets:
38
+ results = "\n".join(
39
+ [f"Ticket {ticket['ticket_id']}: {ticket['description']}" for ticket in matching_tickets]
40
+ )
41
+ return f"Found the following tickets for machine '{machine_name}' with error code {error_code}:\n{results}"
42
+ else:
43
+ return f"No tickets found for machine '{machine_name}' with error code {error_code}."
44
 
45
  return f"if have found existing tickets for {arg1} with error code {arg2}, please check the ticketsystem"
46
 
 
81
 
82
  agent = CodeAgent(
83
  model=model,
84
+ tools=[final_answer, search_error_tickets], ## add your tools here (don't remove final answer)
85
  max_steps=6,
86
  verbosity_level=1,
87
  grammar=None,