Prevent chat model from streaming after first full _valid_ response object
Some models do not stop responding after the json response is finished. They continue with plaintext or try to continue the conversation and output more response objects. This PR prevents reading response past the first FULL VALID json response.
@ehlowr0ld shouldn't we do this by tracking closing brackets instead? When the dirtyjson class traverses the text, it reaches points of "self.stack.pop()" where branches of the object are being closed. Once the stack is 0 length, the json is complete. I don't really like the idea if specifying required properties, as they are prompt based and thoughts for example can be optional.
@frdel This was the only robust way I could make it work - without the required properties sometimes the message was cutting off for example tool_args. There is the method parse_string_checked which needs the required properties - and the normal parse string which works like before but with a little more checks under the hood which still can be used in other places.