adds documentation for huggingface deployments
This commit is contained in:
parent
5bf87646eb
commit
bae6574926
35
README.md
35
README.md
|
@ -22,37 +22,8 @@ OpenAI keys have full account permissions. They can revoke themselves, generate
|
|||
If you still want to share access to your key, you can put it behind this proxy to ensure it can't be used to do anything but generate text. You can also set a separate key on the proxy to gatekeep access.
|
||||
|
||||
## How to use
|
||||
Since this is a server, you'll need to deploy it somewhere. A few options are available:
|
||||
|
||||
### 1. Get an API key
|
||||
- Go to [OpenAI](https://openai.com/) and sign up for an account.
|
||||
|
||||
### 2. Clone this Huggingface repository to your account
|
||||
- Go to [Huggingface](https://huggingface.co/) and sign up for an account.
|
||||
- Once logged in, click on the `+` button in the top right corner and select `Duplicate this Space`.
|
||||
|
||||
![Duplicate Space](https://files.catbox.moe/3n6ubn.png)
|
||||
|
||||
### 3. Set your OpenAI API key as a secret
|
||||
- Click the Settings button in the top right corner of your repository.
|
||||
- Scroll down to the `Repository Secrets` section and click `New Secret`.
|
||||
|
||||
![Secrets](https://files.catbox.moe/irrp2p.png)
|
||||
|
||||
- Enter `OPENAI_KEY` as the name and your OpenAI API key as the value.
|
||||
|
||||
![New Secret](https://files.catbox.moe/ka6s1a.png)
|
||||
|
||||
**Do not paste the key into `server.js`!** That file is public and anyone can see it. Leave it alone; it will load the key from the secret you just created.
|
||||
|
||||
### 4. Deploy the server
|
||||
- Your server should automatically deploy when you add the secret, but if not you can select `Factory Reset` from that same Settings menu.
|
||||
|
||||
### 5. Share the link
|
||||
- The Service Info section below should show the URL for your server. You can share this with anyone to safely give them access to your OpenAI API key.
|
||||
- Your friend doesn't need any OpenAI API key of their own, they just need your link.
|
||||
- However, if you want to protect access to the server, you can add another secret called `PROXY_KEY`. This key will need to be passed in the Authentication header of every request to the server, just like an OpenAI API key.
|
||||
|
||||
**Note:** The `keys` section in the serverinfo screen may not correctly identify keys as trial/paid/GPT-4 unless you use the more advanced configuration described in `.env.example`.
|
||||
|
||||
|
||||
### Deploy to Huggingface Space
|
||||
[See here for instructions on deploying to a Huggingface Space.](./docs/huggingface.md)
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 153 KiB |
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
Binary file not shown.
After Width: | Height: | Size: 36 KiB |
|
@ -0,0 +1,57 @@
|
|||
# Deploy to Huggingface Space
|
||||
|
||||
This repository can be deployed to a [Huggingface Space](https://huggingface.co/spaces). This is a free service that allows you to run a simple server in the cloud. You can use it to safely share your OpenAI API key with a friend.
|
||||
|
||||
### 1. Get an API key
|
||||
- Go to [OpenAI](https://openai.com/) and sign up for an account. You can use a free trial key for this as long as you provide SMS verification.
|
||||
|
||||
### 2. Create an empty Huggingface Space
|
||||
- Go to [Huggingface](https://huggingface.co/) and sign up for an account.
|
||||
- Once logged in, [create a new Space](https://huggingface.co/new-space).
|
||||
- Provide a name for your Space and select "Docker" as the SDK. Select "Blank" for the template.
|
||||
- Click "Create Space" and wait for the Space to be created.
|
||||
|
||||
![Create Space](huggingface-createspace.png)
|
||||
|
||||
### 3. Create an empty Dockerfile
|
||||
- Once your space is created, you'll see an option to "Create the Dockerfile in your browser". Click that link.
|
||||
|
||||
![Create Dockerfile](huggingface-dockerfile.png)
|
||||
- Paste the following into the text editor and click "Save".
|
||||
```dockerfile
|
||||
FROM node:18-bullseye-slim
|
||||
RUN apt-get update && \
|
||||
apt-get install -y git
|
||||
RUN git clone https://github.com/nai-degen/oai-reverse-proxy.git /app
|
||||
WORKDIR /app
|
||||
COPY package*.json ./
|
||||
RUN npm install
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
EXPOSE 7860
|
||||
CMD [ "npm", "start" ]
|
||||
```
|
||||
- Click "Commit new file to `main`" to save the Dockerfile.
|
||||
|
||||
![Commit](huggingface-savedockerfile.png)
|
||||
|
||||
### 4. Set your OpenAI API key as a secret
|
||||
- Click the Settings button in the top right corner of your repository.
|
||||
- Scroll down to the `Repository Secrets` section and click `New Secret`.
|
||||
|
||||
![Secrets](https://files.catbox.moe/irrp2p.png)
|
||||
|
||||
- Enter `OPENAI_KEY` as the name and your OpenAI API key as the value.
|
||||
|
||||
![New Secret](https://files.catbox.moe/ka6s1a.png)
|
||||
|
||||
### 5. Deploy the server
|
||||
- Your server should automatically deploy when you add the secret, but if not you can select `Factory Reboot` from that same Settings menu.
|
||||
|
||||
### 6. Share the link
|
||||
- The Service Info section below should show the URL for your server. You can share this with anyone to safely give them access to your OpenAI API key.
|
||||
- Your friend doesn't need any OpenAI API key of their own, they just need your link.
|
||||
- However, if you want to protect access to the server, you can add another secret called `PROXY_KEY`. This key will need to be passed in the Authentication header of every request to the server, just like an OpenAI API key.
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue