Skip to content

support a union of types on the top level #6

@uriva

Description

@uriva

A common scenario is to have multiple types that each signify an action. This could be translated to different function calls in a natural way.

Say I have action X and action y.

I'd build a type which is like this:

type action = { type: 'x', xParam: number } | { type: 'y', yParam: string }

in zod this would be a z.union.

but the zod-gpt doesn't let you use union and the user needs to resort to something like thiis:

type action = { type: 'x' | 'y', xParam: number, yParam: string } // mixing both actions parameters

this would result in much less type safety, not to mention name collisions that disagree on the property type.

maybe there is a solution I missed?

if not, maybe this is possible to implement by mapping each action to a different function_call.

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