Skip to content

Add fromReadableStream or similar to the ResponseStream class #1376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 task done
MarkMurphy opened this issue Mar 12, 2025 · 0 comments
Open
1 task done

Add fromReadableStream or similar to the ResponseStream class #1376

MarkMurphy opened this issue Mar 12, 2025 · 0 comments

Comments

@MarkMurphy
Copy link

MarkMurphy commented Mar 12, 2025

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

Both the ChatCompletionStream and AssistantStream classes have a fromReadableStream method that the new ResponseStream class is missing.

I'm looking for something similar to allow my client side web application to request a response stream from my server and convert that to a ResponseStream instance.

For example:

const sendMessage = async (input) => {
    controller.current = new AbortController();
    const response = await fetch(`${API_URL}/responses`, {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        input,
      }),
      signal: controller.current.signal,
    })
    const stream = ResponseStream.fromReadableStream(response.body)
    handleReadableStream(stream)
  };

Also open to alternative recommendations if this is not the pattern to use moving forward. There is currently a lack of guidance in the docs on how to integrate with the new responses API when it comes to frontend applications.

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant