Skip to content

Error: FormatException: SyntaxError: Expected property name or '}' in JSON at position 1. #42

@bsubash2054

Description

@bsubash2054

I encountered this error when I set the maxTokens property as 4000, and upon investigation I managed to find and resolve the issue. The issue occurs in the file packages/dart_openai/src/core/networking/client.dart line 225 which resembles to final error = jsonDecode(data)['error'];. In my case setting maxTokens to 4000 fired an error: This model's maximum context length is 4097 tokens. However, you requested 4097 tokens (97 in the messages, 4000 in the completion). Please reduce the length of the messages or completion., and trying to decode this fired the error that's mentioned in the title instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions