AshAI json schema usage
Any examples passing in json_schema to:
I keep getting
I tested the same schema in openai playground and it has worked fine
action :parse_raw, :map do
argument :raw_content, :string, allow_nil?: false
run prompt(
fn _input, _context ->
LangChain.ChatModels.ChatOpenAI.new!(%{
model: "gpt-4o-mini",
api_key: System.get_env("OPENAI_API_KEY"),
temperature: 0.1,
json_schema: JobListingSchema.schema()
})
end,
prompt: """
Parse this job listing into structured data following the exact schema.
Extract all available information and return as JSON:
<%= @input.arguments.raw_content %>
""",
tools: false
)
end action :parse_raw, :map do
argument :raw_content, :string, allow_nil?: false
run prompt(
fn _input, _context ->
LangChain.ChatModels.ChatOpenAI.new!(%{
model: "gpt-4o-mini",
api_key: System.get_env("OPENAI_API_KEY"),
temperature: 0.1,
json_schema: JobListingSchema.schema()
})
end,
prompt: """
Parse this job listing into structured data following the exact schema.
Extract all available information and return as JSON:
<%= @input.arguments.raw_content %>
""",
tools: false
)
endI keep getting
[error] Received error from API: "Invalid schema for response_format 'result': In context=('properties', 'result'), 'additionalProperties' is required to be supplied and to be false."
[error] Error during chat call. Reason: %LangChain.LangChainError{type: nil, message: "Invalid schema for response_format 'result': In context=('properties', 'result'), 'additionalProperties' is required to be supplied and to be false.", original: nil}[error] Received error from API: "Invalid schema for response_format 'result': In context=('properties', 'result'), 'additionalProperties' is required to be supplied and to be false."
[error] Error during chat call. Reason: %LangChain.LangChainError{type: nil, message: "Invalid schema for response_format 'result': In context=('properties', 'result'), 'additionalProperties' is required to be supplied and to be false.", original: nil}I tested the same schema in openai playground and it has worked fine
