mirror of
https://github.com/hwchase17/langchain.git
synced 2026-01-25 22:49:59 +00:00
```python
from langchain_core.tools import Tool
from langchain_core.utils.function_calling import convert_to_openai_tool
def my_function(x: int) -> int:
return x + 2
tool = Tool(
name="tool_name",
func=my_function,
description="test description",
)
convert_to_openai_tool(tool)
```
Current:
```
{'type': 'function',
'function': {'name': 'tool_name',
'description': 'test description',
'parameters': {'type': 'object',
'properties': {'args': {'type': 'array', 'items': {}},
'config': {'type': 'object',
'properties': {'tags': {'type': 'array', 'items': {'type': 'string'}},
'metadata': {'type': 'object'},
'callbacks': {'anyOf': [{'type': 'array', 'items': {}}, {}]},
'run_name': {'type': 'string'},
'max_concurrency': {'type': 'integer'},
'recursion_limit': {'type': 'integer'},
'configurable': {'type': 'object'},
'run_id': {'type': 'string', 'format': 'uuid'}}},
'kwargs': {'type': 'object'}},
'required': ['config']}}}
```
Here:
```
{'type': 'function',
'function': {'name': 'tool_name',
'description': 'test description',
'parameters': {'properties': {'__arg1': {'title': '__arg1',
'type': 'string'}},
'required': ['__arg1'],
'type': 'object'}}}
```