anasfik / openai

Dart/Flutter SDK for ChatGPT and all OpenAI APIs (GPT, Dall-e..)
https://pub.dev/packages/dart_openai
MIT License
582 stars 183 forks source link

'responseFormat' should be 'Map<String, dynamic>' #188

Closed joaopegoraro closed 2 months ago

joaopegoraro commented 2 months ago

Currently the responseFormat on createStream is just a Map<String, String>, but if we want to pass the json_schema like the example from here, we can't, since json_schema must be an object, like so:

{
        "type": "json_schema",
        "json_schema": {
            "name": "math_response",
            "schema": {
                "type": "object",
                "properties": {
                    "steps": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "explanation": {"type": "string"},
                                "output": {"type": "string"}
                            },
                            "required": ["explanation", "output"],
                            "additionalProperties": false
                        }
                    },
                    "final_answer": {"type": "string"}
                },
                "required": ["steps", "final_answer"],
                "additionalProperties": false
            },
            "strict": true
        }
    }

It should be of type Map<String, dynamic> to allow usage of this feature

guilhermezdev commented 2 months ago

Any updates on this? seems reasonable for me

franboladoruiz commented 2 months ago

openai_dart just added support for Structured Outputs: https://pub.dev/packages/openai_dart/changelog#041