You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
📝 docs(openapi): revise tool naming and usage examples
- rename "add_add_get" to "add_get" for improved readability
- update all related code examples and descriptions in openapi.md
- ensure consistency in tool naming across synchronous and asynchronous invocation scenarios
Copy file name to clipboardExpand all lines: docs/source/openapi.md
+8-8Lines changed: 8 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -40,7 +40,7 @@ You should see a schema printed as follow. Here, we only display the first entry
40
40
{
41
41
"type": "function",
42
42
"function": {
43
-
"name": "add_add_get",
43
+
"name": "add_get",
44
44
"description": "Calculate a + b and return the result.\n\nArgs:\n a (float): The first operand.\n b (float): The second operand.\n\nReturns:\n dict: A dictionary containing the key \"result\" with the sum of a and b.",
45
45
"parameters": {
46
46
"type": "object",
@@ -92,17 +92,17 @@ Tools can be invoked directly as Python callables, or you can retrieve them usin
92
92
93
93
```python
94
94
# Direct access using subscript notation
95
-
add_func = registry["add_add_get"]
95
+
add_func = registry["add_get"]
96
96
result = add_func(1, 2)
97
97
print(result) # Expected output: 3.0
98
98
99
99
# Retrieve the callable with get_callable and call it
100
-
add_func = registry.get_callable("add_add_get")
100
+
add_func = registry.get_callable("add_get")
101
101
result = add_func(3, 4)
102
102
print(result) # Expected output: 7.0
103
103
104
104
# Retrieve the tool object with get_tool and invoke its run method
105
-
add_tool = registry.get_tool("add_add_get")
105
+
add_tool = registry.get_tool("add_get")
106
106
result = add_tool.run({"a": 5, "b": 6})
107
107
print(result) # Expected output: 11.0
108
108
```
@@ -116,20 +116,20 @@ import asyncio
116
116
117
117
asyncdefcall_async_add_func():
118
118
# Retrieve the tool callable for asynchronous invocation
119
-
add_func = registry.get_callable("add_add_get")
119
+
add_func = registry.get_callable("add_get")
120
120
result =await add_func(7, 7)
121
121
print(result) # Expected output: 14.0
122
122
123
123
# Direct subscript access for asynchronous invocation
124
-
add_func2 = registry["add_add_get"]
124
+
add_func2 = registry["add_get"]
125
125
result =await add_func2(7, 8)
126
126
print(result) # Expected output: 15.0
127
127
128
128
asyncio.run(call_async_add_func())
129
129
130
130
asyncdefcall_async_add_tool():
131
131
# Retrieve the tool object for asynchronous invocation
132
-
add_tool = registry.get_tool("add_add_get")
132
+
add_tool = registry.get_tool("add_get")
133
133
result =await add_tool.arun({"a": 9, "b": 10})
134
134
print(result) # Expected output: 19.0
135
135
@@ -221,7 +221,7 @@ if response.choices[0].message.tool_calls:
221
221
## Notes
222
222
223
223
1. OpenAPI tool registration supports both synchronous and asynchronous methods. Once tools are registered, they can be invoked as simple Python functions or as tool objects.
224
-
2. During invocation, parameters are automatically converted based on the tool definition. For example, the `add_add_get` tool expects numeric inputs and returns a numeric result.
224
+
2. During invocation, parameters are automatically converted based on the tool definition. For example, the `add_get` tool expects numeric inputs and returns a numeric result.
225
225
3. The integration with the OpenAI client allows you to seamlessly incorporate tool execution into your chat workflows.
226
226
227
227
Follow the examples above to efficiently integrate and utilize OpenAPI tools with ToolRegistry.
0 commit comments