Skip to content
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

How to support continue generating response #56

Open
shekharx opened this issue Aug 2, 2023 · 0 comments
Open

How to support continue generating response #56

shekharx opened this issue Aug 2, 2023 · 0 comments

Comments

@shekharx
Copy link

shekharx commented Aug 2, 2023

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?

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