Assistant API consistency issues

Hi All,

I am integrating the assistant api to see what we can do with it. I have a relatively straight forward use case where I want users to be able to upload sheets where employees keep there work hour registrations. So it states who they worked for and then the date, from / to time and possibly a break from / to time. Once it transformed that info to a json (usually coming from an xls or csv) it should call a function with that json, so the function can create the time registrations in the database.

I created an asssitant like this one:

    assistant = self.client.beta.assistants.create(
            name="Hour registration helper",
            instructions="""You receive a file with rows of registrations that an employer worked. It contains the from and to times, date and possibly the time the employee had a break. The file is in dutch. It needs to be transformed into a normalized json file. This is the format of the json. This is not the actual json we want from you! We want you to create a json that has this structure with the provided information from the provide file! Never make a json just with the contents of this schema!
{'type': 'object', 'properties': {'employer': {'type': 'string'}, 'employee': {'type': 'string'}, 'registration': {'type': 'array', 'items': {'type': 'object', 'properties': {'id': {'type': 'integer' }, 'date': {'type': 'string' }, 'location': {'type': 'string' }, 'department': {'type': 'string' }, 'work_time': {'type': 'object', 'properties': {'start': { 'type': 'string' }, 'end': { 'type': 'string' } }, 'required': [ 'start', 'end' ] }, 'break_time': {'type': 'object', 'properties': {'start': { 'type': 'string' }, 'end': { 'type': 'string' } }, 'required': [ 'start', 'end' ] }, }, 'required': ['date', 'location', 'department', 'work_time', 'break_time'] } } }, 'required': ['employer', 'employee'] } Look at the provided file very carefully, since it potentially contains a lot of blank rows when it's a csv file. The blank rows do not automatically mean that the file is empty. You always have to read the provided file and transform it into a json in the structure stated above. The json file most likely is separated with semicolons and newlines are with newline characters
            """,
            model="gpt-3.5-turbo-1106",
            tools=[
                {
                    "type": "code_interpreter"
                },
                {
                    "type": "function",
                    "function": {
                        "name": "register_hours",
                        "description": "Registers the hours in the database",
                        "parameters": {
                            "type": "object",
                            "properties": {
                                "json": {"type": "string", "description": "The json file resulting from the assistants transformation"}
                            },
                            "required": ["content"]
                        }
                    }
                }
            ]
        )

This asssitant sometimes comes back with the correct information:

RequiredActionSubmitToolOutputs(tool_calls=[RequiredActionFunctionToolCall(id='call_niyP87aIi9NbXMSlsfDx5Ndg', function=Function(arguments='{"json":"{\\"type\\": \\"object\\", \\"properties\\": {\\"employer\\": {\\"type\\": \\"string\\"}, \\"employee\\": {\\"type\\": \\"string\\"}, \\"registration\\": {\\"type\\": \\"array\\", \\"items\\": {\\"type\\": \\"object\\", \\"properties\\": {\\"id\\": {\\"type\\": \\"integer\\" }, \\"date\\": {\\"type\\": \\"string\\" }, \\"location\\": {\\"type\\": \\"string\\" }, \\"department\\": {\\"type\\": \\"string\\" }, \\"work_time\\": {\\"type\\": \\"object\\", \\"properties\\": {\\"start\\": { \\"type\\": \\"string\\" }, \\"end\\": { \\"type\\": \\"string\\" } }, \\"required\\": [ \\"start\\", \\"end\\" ] }, \\"break_time\\": {\\"type\\": \\"object\\", \\"properties\\": {\\"start\\": { \\"type\\": \\"string\\" }, \\"end\\": { \\"type\\": \\"string\\" } }, \\"required\\": [ \\"start\\", \\"end\\" ] }, \\"required\\": [\\"date\\", \\"location\\", \\"department\\", \\"work_time\\", \\"break_time\\"] } } }, \\"required\\": [\\"employer\\", \\"employee\\"] }","employee":"John Doe","employer":"ABC Inc.","registration":[{"id":1,"date":"2022-01-05","location":"Head Office","department":"Finance","work_time":{"start":"08:00","end":"17:00"},"break_time":{"start":"12:00","end":"13:00"}},{"id":2,"date":"2022-01-06","location":"Branch Office","department":"Marketing","work_time":{"start":"09:00","end":"18:00"},"break_time":{"start":"13:00","end":"14:00"}}]}', name='register_hours'), type='function')])

But other times, comes back with something completely different like this:

RequiredActionSubmitToolOutputs(tool_calls=[RequiredActionFunctionToolCall(id='call_PwoPI68w467mgXqLLfoOr7MX', function=Function(arguments='{"json":"/mnt/data/file-IaCWsZtAG1Lb28HkF1SjntUC"}', name='register_hours'), type='function')])

I am new to this. Is there something I am missing? Should I be more consise with my assistants instructions or is unpredictability something that’s expected right now?

Would love to get some insights on this. Thanks!