Skip to content

Conversation

@longwei66
Copy link
Contributor

@longwei66 longwei66 commented Oct 4, 2024

Your checklist for this pull request

Description

  • Generative API

  • Update examples for Using structured outputs with JSON schema (manual definition or with (Pydantic)

  • The API requires the response_format when using a json_schema to have a name attribute like this one

response_format={
        "type": "json_schema",
        "json_schema": {
            "name": "VoiceNote",
            "schema": VoiceNote.model_json_schema(),
        }
    },

To avoid errors like this one

BadRequestError: Error code: 400 - {'object': 'error', 'message': "[{'type': 'missing', 'loc': ('body', 'response_format', 'json_schema', 'name'), 'msg': 'Field required', 'input': {'schema': {'properties': {'title': {'description': 'A title for the voice note', 'title': 'Title', 'type': 'string'}, 'summary': {'description': 'A short one-sentence summary of the voice note.', 'title': 'Summary', 'type': 'string'}, 'actionItems': {'description': 'A list of action items from the voice note.', 'items': {'type': 'string'}, 'title': 'Actionitems', 'type': 'array'}}, 'required': ['title', 'summary', 'actionItems'], 'title': 'VoiceNote', 'type': 'object'}}}]", 'type': 'BadRequestError', 'param': None, 'code': 400}

Update examples for Using structured outputs with JSON schema (manual definition or with (Pydantic)

The API requires the response_format when using a json_schema to have a name attribute.
@longwei66 longwei66 requested a review from bene2k1 as a code owner October 4, 2024 12:38
@bene2k1 bene2k1 merged commit 618fb6f into scaleway:main Oct 7, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants