A PopClip extension for ChatGPT

@rdouma is correct, and it is the most likely explanation. Have you checked the paid credit status of your OpenAI account @jberrebi? Failing that, there are debug instructions in this post.

I added my credit card to my OpenAI account and it works indeed :slight_smile:

This extension is really a killer app.

Thanks @nick and @rdouma

I need a proxy to access OpenAI. Is it possible to use axios proxy?

The proxy config is not working properly:

const openai = require("axios").create({
    baseURL: "https://api.openai.com/v1",
    headers: { Authorization: `Bearer ${options.apikey}` },
    proxy: {
        protocol: 'http',
        host: 'localhost',
        port: 7890,
    }
  });


I see that some people have found a workaround using HttpsProxyAgent, but this package seems not applicable in Popclip extensions.

It’s a little in-depth for me to dive into right now, but if Axios supports proxy config like that, I would expect it to work. However, the log shows that the underlying XMLHttpRequest is going directly to the API, so it isn’t using the proxy.

Modules loaded within popclip extensions are bundled inside PopClip’s executable. The current bundle axios version is 0.26.1. There are only a small number of other modules bundled, but none for networking.

However, I notice your proxy uses HTTP, and unfortunately, PopClip will refuse to make an outgoing connection that isn’t https anyway, even to localhost. So even if you get the proxy set-up working, it won’t connect :frowning:

A post was split to a new topic: Bing chat extension

I got an access to ChatGPT4 API.

I updated the code and installed the new extension.

I tried to use it but I’m getting axios errors

Error: Request failed with status code 429
axios.js.lzfse:667:24
axios.js.lzfse:923:23
axios.js.lzfse:67:13

Result: error: Error: Request failed with status code 429 (axios.js.lzfse:667:24)

‘paste-result’ was specified but there is no result text

according to OpenAI, they sent back an answer but I never got it…

Any idea?

1 Like

HTTP error code 429 is “too many requests”; perhaps you are encountering some sort of rate limiting?

It looks like OpenAI is an article about it: https://help.openai.com/en/articles/5955604-how-can-i-solve-429-too-many-requests-errors

I got the same error with my very first requestion…Bizarre

Do you have an access to ChatGPT4 API yourself? Is it working?

I don’t have it. Are you accessing it from your company network? It could be other usage from your organisation.

I’m the owner of the company and managing the main account.
Now it works. I don’t know why!
All good!

1 Like

I have followed this and am a paid ChatGPT user, but it doesn’t do anything. A little X pops up and shakes and then nothing. Any suggestions?

You’ll also need to add credit to your API account. It is not included in your ChatGPT subscription. (See posts above.)

Can you give me a code to use gpt-4? I tried to change the above code, but it didn’t help(

I haven’t looked at the GPT-4 modifications because I don’t have API access myself yet. If you do have access, my guess is that you just need to change the constant gpt-3.5-turbo to gpt-4 (based on https://platform.openai.com/docs/guides/chat)

Indeed this is what I’ve done and it works perfectly well

// #popclip extension for ChatGPT
// name: ChatGPT4
// icon: iconify:simple-icons:openai
// language: javascript
// module: true
// entitlements: [network]
// options: [{
//   identifier: apikey, label: API Key, type: string,
//   description: 'Obtain API key from https://platform.openai.com/account/api-keys'
// }]
const messages = []; // history of previous messages
async function chat (input, options) {
  const openai = require("axios").create({
    baseURL: "https://api.openai.com/v1",
    headers: { Authorization: `Bearer ${options.apikey}` },
  });
  messages.push({ "role": "user", "content": input.text });
  const { data } = await openai.post("/chat/completions", {
    model: "gpt-4", messages
  });
  messages.push(data.choices[0].message);
  return input.text.trimEnd() + "\n\n" + messages.at(-1).content.trim();
};
exports.actions = [{
  title: "ChatGPT: Chat",
  after: "paste-result",
  code: chat,
}, {
  title: "ChatGPT: Reset",
  icon: "iconify:game-icons:broom",
  requirements: [],
  after: "show-status",
  code: () => messages.length = 0 // clear the message history
}];
1 Like

3 posts were split to a new topic: Problem with ChatGPT extension

2 posts were split to a new topic: Request: Start new chat on ChatGPT website

This is my version of ClipboardGPT:

try it please.

Hello,

Do you think it would be possible to add conditions?
I often use ChatGPT to correct or improve my messages.
However, today I have to add the conditions, correct, improve, etc…
So, it forces me to go back to the top of the message and add this condition.
But also to remove it afterwards.
It would be very convenient if we could add our conditions in the extension.

Thank you for your feedback.

Bonjour,

Pensez-vous qu’il serait possible d’ajouter des conditions ?
J’utilise fréquemment chatgpt pour corriger ou améliorer mes messages.
Cependant, aujourd’hui, je dois ajouter les conditions, corriger, améliorer, etc …
Par conséquent, ça m’oblige à revenir en haut du message et ajouter cette condition.
Mais aussi à la supprimer par la suite.
Alors que si on pouvait ajouter nos conditions dans l’extension, ça serait très pratique.

Merci de votre retour.

1 Like

Adding the ability to wrap selected text inside a predefined prompt, with multiple prompts available and easy UX to select them, would be a powerful feature for this extension.