This project runs on users' browsers through the Tampermonkey script and converts the web version of ChatGPT operations into an API interface. You can use this API to do some interesting things, such as playing Auto-GPT.
- API no cost.
- If you have a chatgpt plus account, you can use gpt-4 api.
- Having unlimited context.
- Not easy to be banned and easier to handle errors.
- Make sure your system has installed Node.js and npm.
- Clone this repository and run
npm install
in the project directory to install dependencies. - Run
npm run start
to start the Node.js server. - Alternatively, you can use Docker
docker-compose up
to start the Node.js server.
- Install Tampermonkey browser extension.
- Open Tampermonkey management panel and create a new script.
- Copy the contents of
tampermonkey-script.js
file into the newly created script and save it.
Send a POST request to API address http://localhost:8766/v1/chat/completions
{
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Who are you?"
}
],
"model": "gpt-4"
}
Parameter | Description | Default | Required |
---|---|---|---|
messages | Refer to OpenAI API documentation | Yes | |
model | Refer to OpenAI API documentation | No | |
stream | Refer to OpenAI API documentation | false | No |
newChat | Whether to start a new conversation | true | No |
Modify the llm_utils.py file in Auto-GPT.
# response = openai.ChatCompletion.create(
# model=model,
# messages=messages,
# temperature=temperature,
# max_tokens=max_tokens,
# )
response = requests.post("http://localhost:8766/v1/chat/completions", json={"messages": messages, "model": model, "newChat": False, "temperature": temperature, "max_tokens": max_tokens}).json()
# return response.choices[0].message["content"]
return response["choices"][0]["message"]["content"]