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

support basic openai, chatgpt, generative ai integration #6392

Closed
williamstein opened this issue Feb 2, 2023 · 5 comments
Closed

support basic openai, chatgpt, generative ai integration #6392

williamstein opened this issue Feb 2, 2023 · 5 comments

Comments

@williamstein
Copy link
Contributor

williamstein commented Feb 2, 2023

The goal would be to make it easy for users who explicitly add their openai key to a cocalc project to use certain functionality from openai as part of working with code or notebooks.

The api and docs are here: https://platform.openai.com/docs/libraries

The first version would work as follows.

  1. A user would create an openai account, then copy their secret key into configuration of a specific project.
  2. Code in the project itself would call the openai api (with the secret key) and get back results, which are stored in the project and surfaced to the user. E.g., you could describe an image and have the resulting image appear as a png file, or as an image embedded in a Jupyter notebook or whiteboard.
  3. If the user is out of their free credits, they have to pay openai. That's entirely between the user an openai, and has nothing to do with us.

Obviously, projects have to have the network access upgrade for this to work.

NOTE: One motivation for implementing this is to keep up with this JupyterLab extension: jupyterlab/frontends-team-compass#172
That said, in CoCalc this wouldn't just be for Jupyter.

CAVEATS: Instructors of courses should have the option to set their student projects so that the openai key can't be added, in case they want to be sure students aren't using it.

@haraldschilly
Copy link
Contributor

Regarding students, maybe the opposite is also interesting: disseminating a key to all their projects?

Well, in any case, I propose to use the column addons: {"openai": {"key": "...."} to store it per project, and similar to how datastores are propagated, a flag in the course field to use the key from the instructor project.

@williamstein
Copy link
Contributor Author

Regarding students, maybe the opposite is also interesting: disseminating a key to all their projects?

Maybe, though in practice I think this is unlikely, since each student gets a certain quite significant amount for free from openai, whereas that single key could end up costing a lot. But who knows. It's a little trickier due to the pricing model -- any one student could cost the instructor hundreds of dollars, in theory... In fact, we should probably require setting some sort of limits, since (1) a collaborator on a project could easily blow through a limit, as could students, and (2) a bug in some code could also cause 100K requests to openai and a huge bill, and that could be a liability for us.

@williamstein
Copy link
Contributor Author

It seems like there is an official api and the pricing is better: https://news.ycombinator.com/item?id=34985848

@williamstein
Copy link
Contributor Author

A first very non-intrusive way I'm thinking of adding some integration is to just create what appears to be a new Jupyter kernel, which is actually a conversation with openai. I don't quite know how to implement this, but from a user point of view, you would just select the "OpenAI" kernel in a Jupyter notebook, and use it. It thus is easy to ignore and isn't intrusive. If you generate useful things, you can copy/paste them or link them elsewhere in a project. This would just be a single step, without having to change the user interface very much, and it has the advantage that the fact you're using OpenAI is very explicit and clear, unlike some of the crazy integrations out there...

@williamstein williamstein changed the title support basic openai integration support basic openai, chatgpt, generative ai integration Mar 4, 2023
@williamstein
Copy link
Contributor Author

We do this now :-)

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

No branches or pull requests

2 participants