-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi_reference.py
More file actions
118 lines (79 loc) · 2.11 KB
/
api_reference.py
File metadata and controls
118 lines (79 loc) · 2.11 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
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
"""
## StackOneToolSet
The main class for accessing StackOne tools.
### Constructor
```python
StackOneToolSet(
api_key: str | None = None,
account_id: str | None = None
)
```
**Parameters:**
- `api_key`: Optional API key. If not provided, uses `STACKONE_API_KEY` env variable
- `account_id`: Optional account ID. If not provided, uses `STACKONE_ACCOUNT_ID` env variable
### Methods
#### get_tools
```python
def get_tools(
vertical: str,
account_id: str | None = None
) -> Tools
```
Get tools for a specific vertical.
**Parameters:**
- `vertical`: The vertical to get tools for (e.g. "hris", "crm")
- `account_id`: Optional account ID override. If not provided, uses the one from initialization
**Returns:**
- `Tools` instance containing available tools
## Tools
Container for Tool instances.
### Methods
#### get_tool
```python
def get_tool(name: str) -> BaseTool | None
```
Get a tool by its name.
**Parameters:**
- `name`: Name of the tool to get
**Returns:**
- `BaseTool` instance if found, None otherwise
#### to_openai
```python
def to_openai() -> list[dict]
```
Convert all tools to OpenAI function format.
**Returns:**
- List of tools in OpenAI function format
## BaseTool
Base class for individual tools.
### Methods
#### execute
```python
def execute(arguments: str | dict) -> dict[str, Any]
```
Execute the tool with the given parameters.
**Parameters:**
- `arguments`: Either a JSON string or dict of arguments
**Returns:**
- Tool execution results
#### to_openai_function
```python
def to_openai_function() -> dict
```
Convert this tool to OpenAI's function format.
**Returns:**
- Tool definition in OpenAI function format
"""
# Example usage of the API
from stackone_ai import StackOneToolSet
# Initialize with environment variables
toolset = StackOneToolSet()
# Get tools for HRIS vertical
tools = toolset.get_tools(vertical="hris")
# Get a specific tool
employee_tool = tools.get_tool("get_employee")
if employee_tool:
# Execute the tool
result = employee_tool.execute({"id": "employee123"})
# Convert to OpenAI format
openai_function = employee_tool.to_openai_function()