Skip to content

How to support continue generating response #56

Description

@shekharx

I am using openai-stream library to build a chat application. We need support continue generating response feature like the one we have in ChatGPT. Looking at the code of the library I understand that OpenAIError is thrown when finish_reason is equal to length https://github.com/SpellcraftAI/openai-streams/blob/canary/src/lib/streaming/streams.ts#L80.

In my code I don't get handle to this error in the catch block. The console.error line is never called. The code looks like as shown below

try {
  const stream = await OpenAI("chat", {
    model: "gpt-3.5-turbo",
    messages: [
      {
        role: "system",
        content: DEFAULT_SYSTEM_PROMPT,
      },
      ...messagesToSend,
    ],
    max_tokens: 1000,
    temperature: DEFAULT_TEMPERATURE,
  });

  return new Response(stream);

} catch (e) {
  console.error("Error: ", e)
}

Can you guide me how to handle errors?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions