Skip to content

How to create chat endpoint with express? #492

Closed Answered by spy16
spy16 asked this question in Help
Discussion options

You must be logged in to vote

I just figured this out. Just leaving the idea here for anyone else stumbling on this discussion looking for answers:

  1. Copy-paste the file from this comment: #199 (comment)

  2. Take the response from openai.createChatCompletion() and re-create it as:

     new Response(
       StreamCompat.toReadable(resp.body),
       {
           status: resp.status,
           headers: resp.headers,
           statusText: resp.statusText,
       }
     )
  3. Then use the new StreamingTextResponse(OpenAiStream(resp)) to create the stream that can be returned from remix-run action.

Replies: 2 comments 11 replies

Comment options

You must be logged in to vote
11 replies
@spy16
Comment options

@MaxLeiter
Comment options

@spy16
Comment options

@spy16
Comment options

Answer selected by spy16
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
3 participants