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 openai stores my custom session window and can get a list of it. #559

Closed
1 task done
J-django opened this issue Dec 11, 2023 · 3 comments
Closed
1 task done
Assignees

Comments

@J-django
Copy link

J-django commented Dec 11, 2023

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

I want the message to create a new session window and store it in openai so I can view it the next time I log in.

Additional context

No response

@J-django
Copy link
Author

J-django commented Dec 11, 2023

To implement the function:

  • chat

Need to achieve:

  • Pause generation
  • Create a new chat window.
  • Get all chat Windows.
  • Get the chat records in the selected chat window.
  • Edit and delete chat window names
  • The chat window name is generated

I looked for a long time in the openai library, but did not find these features to be implemented, perhaps I did not observe carefully enough.🤔

import OpenAI from "openai";

export const openai = new OpenAI({
    apiKey: "xxxxxxx-xxxxxxx-xxxxxxx-xxxxxxx-xxxxxxx-xxxxxxx,
    dangerouslyAllowBrowser: true,
    maxRetries: 0
});

export const useOpenaiChat = () => {
    const completions = async () => {
        return await openai.chat.completions.create({
            model: "gpt-3.5-turbo-1106",
            messages: [{ "role": "user", "content": "Say this is a test" }],
            stream: true,
            frequency_penalty: 1
        });
    }

    return {
        completions
    }
}
import { useOpenaiChat } from "@renderer/hooks";
import { APIError } from "openai";

const openai_chat = useOpenaiChat();

const stream = await openai_chat
    .completions()
    .catch(({ error: { message } }: APIError) => {
      console.log(message);
    });

  if (stream) {
    for await (const chunk of stream) {
      console.log(chunk.choices[0]?.delta?.content || "");
    }
  }

OS

Windows10 x86

Node version

v16.20.2

Library version

openai ^4.20.1

@rattrayalex
Copy link
Collaborator

cc @logankilpatrick

@logankilpatrick
Copy link
Contributor

Hey, not sure what you are asking for exactly here, please post questions like this on https://community.openai.com!

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

3 participants