Function calling give not expected output

Hello,
I have this function:

{
				"name": "return_files",
				"description": "Generates preview of code from a given files with code",
				"parameters": {
					"type": "object",
					"properties": {
						"name": {
							"type": "string",
							"description": "Name of project"
						},
						"files": {
							"type": "array",
							"items": {
								"type": "object",
								"properties": {
									"name": {
										"type": "string",
										"description": "Name of file"
									},
									"content": {
										"type": "string",
										"description": "Content of file"
									}
								}
							}
						}
					},
					"required": ["files", "name"]
				}
			}

Which should return files as array with name and content of file, but i got this:

"{\n  \"name\": \"Testcase\",\n  \"files\": \"main.js,index.js\"\n}"

I got files as string seperated with commas. I’m using gpt-3.5-turbo-16k-0613 model.
Anybody know how to solve this issue?
Thanks!

Your “content” and content description “content of file” makes no sense. That would seem to be the return value of your function, not the input to an API that retrieves the content. Or does AI know the contents of “files” and is supposed to save them as a file name? It is unclear.

Maybe explain to the AI as clear as I need, where the files are stored and where data is coming from, what the AI is supposed to write for each property.

As _i has said, where is the file contents being read from? How would the AI know the contents, and is this not a function best performed by traditional software?

In most cases, if you treat the AI like a compiler, it will not function as you expect, functions do not add a new special mode to the AI, it is a fine tune of an existing behaviour with some support functionality built into the API. It is still the model being told to reply in json format, which it will try to do, but trying to take advantage of json syntax nuance will usually fail. Think of it as a way to get structured output in a consistent format, and not a json handling library.