forked from eval-protocol/python-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtools.py
More file actions
51 lines (41 loc) · 1.42 KB
/
Copy pathtools.py
File metadata and controls
51 lines (41 loc) · 1.42 KB
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
"""
Tools for the test tasks.
"""
from eval_protocol.agent.tool_registry import ToolRegistry
# Create tool registry
R = ToolRegistry("test_task_tools")
@R.tool(
description="Add an item to the list",
parameters={"item": {"type": "string", "description": "The item to add"}},
)
def add_item(item, resource):
"""Add an item to the resource's items list."""
state = resource.get_state()
state["items"].append(item)
resource.set_state(state)
return {"status": "success", "message": f"Added item: {item}"}
@R.tool(description="Increment the counter", parameters={})
def increment_counter(resource):
"""Increment the resource's counter."""
state = resource.get_state()
state["counter"] += 1
resource.set_state(state)
return {
"status": "success",
"message": f"Counter incremented to {state['counter']}",
}
@R.tool(
description="Set the status",
parameters={"status": {"type": "string", "description": "The new status"}},
)
def set_status(status, resource):
"""Set the resource's status."""
state = resource.get_state()
state["status"] = status
resource.set_state(state)
return {"status": "success", "message": f"Status set to: {status}"}
@R.tool(description="Get the current state", parameters={})
def get_state(resource):
"""Get the current state of the resource."""
state = resource.get_state()
return {"status": "success", "state": state}