Try and improve this function for function calling, not sure if it is actually making better categorization than yours.
{
"name": "categorize_movie",
"description": "Get all its possible categories for the movie",
"parameters": {
"type": "object",
"properties": {
"movie": {
"type": "string",
"description": "Movie title"
},
"categories": {
"type": "array",
"description": "All possible categories",
"items": {
"type": "object",
"properties": {
"category": {
"type": "string",
"description": "Main movie category, e.g. drama, comedy, animation"
},
"subCategories": {
"type": "array",
"description": "All possible subcategories under the specified category",
"items": {
"type": "string",
"description": "Subcategory of movie, e.g. romantic comedy, action comedy",
}
}
},
"required": ["category", "subCategories"]
}
}
},
"required": ["movie", "categories"]
}
}],
}
Sample output:
{
role: ‘assistant’,
content: null,
function_call: {
name: ‘categorize_movie’,
arguments: ‘{\n’ +
’ “movie”: “shrek”,\n’ +
’ “categories”: [\n’ +
’ {\n’ +
’ “category”: “Animation”,\n’ +
’ “subCategories”: [“Comedy”, “Adventure”]\n’ +
’ },\n’ +
’ {\n’ +
’ “category”: “Fantasy”,\n’ +
’ “subCategories”: [“Family”]\n’ +
’ }\n’ +
’ ]\n’ +
‘}’
}
}
{
role: ‘assistant’,
content: null,
function_call: {
name: ‘categorize_movie’,
arguments: ‘{\n’ +
’ “movie”: “star wars”,\n’ +
’ “categories”: [\n’ +
’ {\n’ +
’ “category”: “Science Fiction”,\n’ +
’ “subCategories”: [“Action”, “Adventure”]\n’ +
’ },\n’ +
’ {\n’ +
’ “category”: “Fantasy”,\n’ +
’ “subCategories”: [“Adventure”]\n’ +
’ }\n’ +
’ ]\n’ +
‘}’
}
}
{
role: ‘assistant’,
content: null,
function_call: {
name: ‘categorize_movie’,
arguments: ‘{\n’ +
’ “movie”: “gone with the wind”,\n’ +
’ “categories”: [\n’ +
’ {\n’ +
’ “category”: “Drama”,\n’ +
’ “subCategories”: [“Romance”, “Historical”]\n’ +
’ },\n’ +
’ {\n’ +
’ “category”: “Adventure”,\n’ +
’ “subCategories”: [“Romance”]\n’ +
’ },\n’ +
’ {\n’ +
’ “category”: “War”,\n’ +
’ “subCategories”: [“Romance”, “Historical”]\n’ +
’ }\n’ +
’ ]\n’ +
‘}’
}
}
{
role: ‘assistant’,
content: null,
function_call: {
name: ‘categorize_movie’,
arguments: ‘{\n’ +
’ “movie”: “Letters from Iwo Jima”,\n’ +
’ “categories”: [\n’ +
’ {\n’ +
’ “category”: “War”,\n’ +
’ “subCategories”: [“Drama”, “Action”]\n’ +
’ },\n’ +
’ {\n’ +
’ “category”: “History”,\n’ +
’ “subCategories”: [“Biography”]\n’ +
’ },\n’ +
’ {\n’ +
’ “category”: “Foreign”,\n’ +
’ “subCategories”: [“Japanese”]\n’ +
’ }\n’ +
’ ]\n’ +
‘}’
}
}
If you want it to only select from your own categories/subcategories, you probably need to use enum.