Skip to content

Commit 2997131

Browse files
committed
📝 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
1 parent 7f76c1c commit 2997131

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

docs/source/openapi.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ You should see a schema printed as follow. Here, we only display the first entry
4040
{
4141
"type": "function",
4242
"function": {
43-
"name": "add_add_get",
43+
"name": "add_get",
4444
"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.",
4545
"parameters": {
4646
"type": "object",
@@ -92,17 +92,17 @@ Tools can be invoked directly as Python callables, or you can retrieve them usin
9292

9393
```python
9494
# Direct access using subscript notation
95-
add_func = registry["add_add_get"]
95+
add_func = registry["add_get"]
9696
result = add_func(1, 2)
9797
print(result) # Expected output: 3.0
9898

9999
# 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")
101101
result = add_func(3, 4)
102102
print(result) # Expected output: 7.0
103103

104104
# 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")
106106
result = add_tool.run({"a": 5, "b": 6})
107107
print(result) # Expected output: 11.0
108108
```
@@ -116,20 +116,20 @@ import asyncio
116116

117117
async def call_async_add_func():
118118
# Retrieve the tool callable for asynchronous invocation
119-
add_func = registry.get_callable("add_add_get")
119+
add_func = registry.get_callable("add_get")
120120
result = await add_func(7, 7)
121121
print(result) # Expected output: 14.0
122122

123123
# Direct subscript access for asynchronous invocation
124-
add_func2 = registry["add_add_get"]
124+
add_func2 = registry["add_get"]
125125
result = await add_func2(7, 8)
126126
print(result) # Expected output: 15.0
127127

128128
asyncio.run(call_async_add_func())
129129

130130
async def call_async_add_tool():
131131
# Retrieve the tool object for asynchronous invocation
132-
add_tool = registry.get_tool("add_add_get")
132+
add_tool = registry.get_tool("add_get")
133133
result = await add_tool.arun({"a": 9, "b": 10})
134134
print(result) # Expected output: 19.0
135135

@@ -221,7 +221,7 @@ if response.choices[0].message.tool_calls:
221221
## Notes
222222

223223
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.
225225
3. The integration with the OpenAI client allows you to seamlessly incorporate tool execution into your chat workflows.
226226

227227
Follow the examples above to efficiently integrate and utilize OpenAPI tools with ToolRegistry.

0 commit comments

Comments
 (0)