Skip to content

[BUG] Importing a schema object in script() lead to a 400 error #922

Open
@waltoss

Description

@waltoss

The following GenAIScript configuration leads to a 400 Error when making a request to OpenAI:

import { dialog } from "./schema-magnolia.mts";

script({
  model: "openai:gpt-4o",
  system: ["system.schema"],
  responseSchema: dialog,
  responseType: "json_schema",
});

defSchema("DIALOG_SCHEMA", dialog);

$`
Generate a dialog for Magnolia CMS respecting DIALOG_SCHEMA
`;

The OpenAI API returns the following error:

- Invalid schema for response_format 'result': In context=('properties', '0'), 'default' is not permitted.

The reason is that responseSchema is equal to the string value "dialog" instead of the imported js object

Image

This is due to parsePromptScriptMeta turning the code inside script({...}) into JSON

Image

Do you have a lead to fix that ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions