Jave Script inline Text Replacement with OpenAI API does not work with gpt-4 but works with get-3.5-turbo

I have installed the inline replacement named-trigger using Java Script to access the OpenAI API. I have an API Key approved for gpt-4 and I have been using it for a while. I have used the Java Script as given on the folivora site and works fine if I leave the gpt model version to be gpt-3.5-turbo. However, if I replace that with gpt-4 I get an error. Since I do not get to see the system response I am not sure what the error is, but I have tested my API key independently and works fine with gpt-4. I am wondering if I need to modify something else in Java Script? In other interfaces (e.g. iOS Shortcuts, I use the two version of the gpt models interchangeably without having to modify anything else in the code).

Many thanks for any insight!!

I'd recommend to use the dedicated chatgpt action in the latest version. It allows to specify the model to use

Thank you Andreas. That's true but I like the inline replacement option because it can be quicker when doing code development in an editor of Jupyter notebook.

the "transform selected text with ChatGPT" action does also do inline replacement!
I'm currently not on my computer but can post a. example on how to configure it later

Thank you so much Andreas that would be super helpful!

oh and I forgot: this might require the latest alpha version

Here is an example with BTT 4.070:

Everything works fine now, thank you!

Hi Andreas, now that with your help I got the basic ChatGPT text replacement functionality to work, I would like to experiment with combining this functionality with DeepL to translate ChatGPT inputs/outputs form/to other languages. I much prefer DeepL for translations over ChatGPT's translation capabilities, at least for certain languages. I tried using raw Apple Script with Apple Shortcuts but I could not properly figure out the UI elements of DeepL to interact with. I am wondering if BTT can make it easier to implement this idea?

P.S. I was experimenting with the MacOS App of DeepL, but they also provide a Web API: DeepL Translate: The world's most accurate translator

OK, I figured it out, I am using a Python Script to call the DeepL API and I am invoking the script through the Shortcuts app and then created a trigger in BTT to invoke it and replace text. Works great.

It would be nice if you could share the python and shortcut (or share the link to the shortcut) code :slight_smile:

Edit: Made a better solution for deepl I think :wink: Use the Action: Transform and Replace selection with Java Script and then use this Transformer - YOU HAVE TO ADD THE API KEY!!!! and also change the target language for your needs.

async (clipboardContentString) => {
    var response = await fetch('https://api-free.deepl.com/v2/translate', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded'
      body: `auth_key=DEEPL_API_KEY&text=${clipboardContentString}&target_lang=DE`
	var data = await response.json();
	var translatedText = data.translations[0].text;
   return translatedText;

Thanks, this looks good. I will clean-up a little my python and shortcut because I left them in a messy debugging state while I turned my attention to other things and I will post and update everyone on this topic.