Skip to content

Create an util to convert a ResponseOutputItem[] into a ResponseInputItem[] #1737

@Pitouli

Description

@Pitouli

Confirm this is a feature request for the Node library and not the underlying OpenAI API.

  • This is a feature request for the Node library

Describe the feature or improvement you're requesting

ResponseOutputItem returned by the Response API are supposed to be reusable as input ResponseInputItem[] for the next question.

But the types do not completely overlap.

It would be great to have a utility function that take an array of (ResponseInputItem | ResponseOutputItem)[] -- all the user inputs and all the assistant answers -- and convert it to a clean ResponseInputItem[], by removing all the ResponseOutputItem that are not allowed as ResponseInputItem (for example ResponseApplyPatchToolCall, ResponseApplyPatchToolCallOutput, ResponseCompactionItem) and converting those that should be converted (for example ResponseOutputItem.ImageGenerationCall, ResponseOutputItem.LocalShellCall to respectively ResponseInputItem.ImageGenerationCall, ResponseInputItem.LocalShellCall )

Additional context

In my project, we must manage our own database of messages (store = false), so we store the ResponseInputItem made by the user and the ResponseOutputItem returned by the assistant, and we provide them back for the next question.

But perhaps it is a very bad way to do that?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions