|
| 1 | +""" |
| 2 | +## StackOneToolSet |
| 3 | +
|
| 4 | +The main class for accessing StackOne tools. |
| 5 | +
|
| 6 | +### Constructor |
| 7 | +
|
| 8 | +```python |
| 9 | +StackOneToolSet( |
| 10 | + api_key: str | None = None, |
| 11 | + account_id: str | None = None |
| 12 | +) |
| 13 | +``` |
| 14 | +
|
| 15 | +**Parameters:** |
| 16 | +- `api_key`: Optional API key. If not provided, uses `STACKONE_API_KEY` env variable |
| 17 | +- `account_id`: Optional account ID. If not provided, uses `STACKONE_ACCOUNT_ID` env variable |
| 18 | +
|
| 19 | +### Methods |
| 20 | +
|
| 21 | +#### get_tools |
| 22 | +
|
| 23 | +```python |
| 24 | +def get_tools( |
| 25 | + vertical: str, |
| 26 | + account_id: str | None = None |
| 27 | +) -> Tools |
| 28 | +``` |
| 29 | +
|
| 30 | +Get tools for a specific vertical. |
| 31 | +
|
| 32 | +**Parameters:** |
| 33 | +- `vertical`: The vertical to get tools for (e.g. "hris", "crm") |
| 34 | +- `account_id`: Optional account ID override. If not provided, uses the one from initialization |
| 35 | +
|
| 36 | +**Returns:** |
| 37 | +- `Tools` instance containing available tools |
| 38 | +
|
| 39 | +## Tools |
| 40 | +
|
| 41 | +Container for Tool instances. |
| 42 | +
|
| 43 | +### Methods |
| 44 | +
|
| 45 | +#### get_tool |
| 46 | +
|
| 47 | +```python |
| 48 | +def get_tool(name: str) -> BaseTool | None |
| 49 | +``` |
| 50 | +
|
| 51 | +Get a tool by its name. |
| 52 | +
|
| 53 | +**Parameters:** |
| 54 | +- `name`: Name of the tool to get |
| 55 | +
|
| 56 | +**Returns:** |
| 57 | +- `BaseTool` instance if found, None otherwise |
| 58 | +
|
| 59 | +#### to_openai |
| 60 | +
|
| 61 | +```python |
| 62 | +def to_openai() -> list[dict] |
| 63 | +``` |
| 64 | +
|
| 65 | +Convert all tools to OpenAI function format. |
| 66 | +
|
| 67 | +**Returns:** |
| 68 | +- List of tools in OpenAI function format |
| 69 | +
|
| 70 | +## BaseTool |
| 71 | +
|
| 72 | +Base class for individual tools. |
| 73 | +
|
| 74 | +### Methods |
| 75 | +
|
| 76 | +#### execute |
| 77 | +
|
| 78 | +```python |
| 79 | +def execute(arguments: str | dict) -> dict[str, Any] |
| 80 | +``` |
| 81 | +
|
| 82 | +Execute the tool with the given parameters. |
| 83 | +
|
| 84 | +**Parameters:** |
| 85 | +- `arguments`: Either a JSON string or dict of arguments |
| 86 | +
|
| 87 | +**Returns:** |
| 88 | +- Tool execution results |
| 89 | +
|
| 90 | +#### to_openai_function |
| 91 | +
|
| 92 | +```python |
| 93 | +def to_openai_function() -> dict |
| 94 | +``` |
| 95 | +
|
| 96 | +Convert this tool to OpenAI's function format. |
| 97 | +
|
| 98 | +**Returns:** |
| 99 | +- Tool definition in OpenAI function format |
| 100 | +""" |
| 101 | + |
| 102 | +# Example usage of the API |
| 103 | +from stackone_ai import StackOneToolSet |
| 104 | + |
| 105 | +# Initialize with environment variables |
| 106 | +toolset = StackOneToolSet() |
| 107 | + |
| 108 | +# Get tools for HRIS vertical |
| 109 | +tools = toolset.get_tools(vertical="hris") |
| 110 | + |
| 111 | +# Get a specific tool |
| 112 | +employee_tool = tools.get_tool("get_employee") |
| 113 | +if employee_tool: |
| 114 | + # Execute the tool |
| 115 | + result = employee_tool.execute({"id": "employee123"}) |
| 116 | + |
| 117 | + # Convert to OpenAI format |
| 118 | + openai_function = employee_tool.to_openai_function() |
0 commit comments