Skip to content

Explicitly define the type of the output #247

@dakl

Description

@dakl

Problem Statement

I think a good addition to the toon format would be to explicitly define the type of the output. For example, when working with output from LLMm it's useful to deserialize the output into a specific type, for example having structured defined using pydantic models.

Perhaps there is already a way to do this, but I couldn't find it. Lemme know if you think this is a good idea.

Proposed Solution

If given

context:
  task: Our favorite hikes together
  location: Boulder
  season: spring_2025
friends[3]: ana,luis,sam
hikes[3]{id,name,distanceKm,elevationGain,companion,wasSunny}:
  1,Blue Lake Trail,7.5,320,ana,true
  2,Ridge Overlook,9.2,540,luis,false
  3,Wildflower Loop,5.1,180,sam,true

it's not obvious what the type of the output is. We could augment the toon format with a type field, like this:

type: HikePlan[9]
context:
  task: Our favorite hikes together
  location: Boulder
  season: spring_2025
friends[3]: ana,luis,sam
hikes[3]{id,name,distanceKm,elevationGain,companion,wasSunny}:
  1,Blue Lake Trail,7.5,320,ana,true
  2,Ridge Overlook,9.2,540,luis,false
  3,Wildflower Loop,5.1,180,sam,true

This could be returned as the first line of the toon output, so that we can immediately see the type of the output and the number of lines of data we should read to deserialize the output into a specific type.

Alternatives Considered

No response

SPEC Compliance

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions