Существует ли какая-либо четкая документация по формату объекта инструментов/функций API завершения чата OpenAI? Я понимаю, что это JSON, но, похоже, существуют основные требования к тому, какие имена/типы свойств разрешены внутри объектов.
Я пытался выяснить, какие типы свойств OpenAI разрешены в определении своих инструментов/функций, но их документация не очень хороша (у них просто есть ссылки на простой пример и объяснение схемы JSON 💩). Они определяют description
и name
, но оставляют parameters
открытым для интерпретации.
После часа или двух поисков, экспериментов и сборки чего-то вместе, я думаю, что наконец создал шаблон, на который я мог бы ссылаться в будущем. Надеюсь, это сэкономит кому-то время в будущем.
{
"description": "This is a template that you can start from to build your tool",
"name": "new_tool",
"parameters": {
"properties": {
"array_property_name": {
"description": "A property that returns an array of items (can be any type mentioned below, including an object)",
"items": {
"type": "string"
},
"type": "array"
},
"boolean_property_name": {
"description": "A property that returns a boolean",
"type": "boolean"
},
"enum_property_name": {
"description": "A property that returns a value from a list of enums (can be any type)",
"enum": [
"option 1",
"option 2",
"option 3"
],
"type": "string"
},
"number_property_name": {
"description": "A property that returns a number",
"type": "number"
},
"object_property_name": {
"description": "A property that returns an object",
"properties": {
"foo": {
"description": "A property on the object called 'foo' that returns a string",
"type": "string"
},
"bar": {
"description": "A property on the object called 'bar' that returns a number",
"type": "number"
}
}
},
"string_property_name": {
"description": "A property that returns a string",
"type": "string"
}
},
"required": [
"array_property_name",
"number_property_name"
],
"type": "object"
}
}