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).
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
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?
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
Edit: Made a better solution for deepl I think 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.
Edit 2: Just digged into log files and can confirm that the action continues using GPT-3.5-Turbo despite changing the action to the custom model & providing the respective API key