I’ve ended up doing some custom quick access, each one separated by “topic” based on original hirakujira extension, so I will paste my ideas here and maybe someone finds it useful too, thanks again Nick, definitely I will wait for the sleek choice in the near term to add some options before prompting openIA (maybe optional by conf)
Anyway, something to keep in mind always is the fact that any LLM of the GPT class will not be deterministic at all and not being a domain thing (talking about grammar improvements) make it a little hard to follow some very specific details or instructions, like the letter-case and punctuation thing and that awful workaround I’ve made on the purest spell-check action
(see below):
# PopClip custom extensions using OpenAI based on: https://github.com/hirakujira/ChatGPT-Grammar-Check-PopClip-Extension
# icons from https://icon-sets.iconify.design/
# popclip GPT Grammar
name: GPT Grammar
icon: iconify:logos:grammarly-icon
entitlements: [network]
javascript: |
const axios = require("axios");
const openai = axios.default.create({
baseURL: "https://api.openai.com/v1",
headers: { Authorization: `Bearer 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` },
});
const prompt = "Correct the grammar and polish the following sentences, do not provide any translation, comments, or notes, keep the informal or formal tone based on the sentence itself, and use the same language as input:\n\n";
const { data } = await openai.post("chat/completions", {
model: "gpt-3.5-turbo",
messages: [
{ role: "system", content: prompt },
{ role: "user", content: popclip.input.text }
],
});
const response = data.choices[0].message.content.trim();
return response;
after: paste-result
# --------------------------------------------------------------------------------------- #
# popclip GPT Spellcheck
name: GPT Spellcheck
icon: iconify:vscode-icons:file-type-word
entitlements: [network]
javascript: |
const axios = require("axios");
const openai = axios.default.create({
baseURL: "https://api.openai.com/v1",
headers: { Authorization: `Bearer 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` },
});
const prompt = "Spell check the following sentences, do not add any translation, puntuation, comments, or notes, do not change any letter to uppercase or lowercase even after a punctuation mark, and use the same language as input:\n\n";
const { data } = await openai.post("chat/completions", {
model: "gpt-3.5-turbo",
messages: [
{ role: "system", content: prompt },
{ role: "user", content: popclip.input.text }
],
});
let first_characters = [];
popclip.input.text.split('\n').forEach(line => first_characters.push(line[0]));
const response = data.choices[0].message.content.trim();
let idx = 0;
const response_fixes = response.split('\n').map(line => {
const gpt_char = line[0];
const popclip_char = first_characters[idx++];
if (gpt_char.toLowerCase() == popclip_char.toLowerCase() && gpt_char != popclip_char) {
line = popclip_char + line.slice(1);
}
return line.replace(/\.$/, '');
});
const result = response_fixes.join('\n');
return result;
after: paste-result
# --------------------------------------------------------------------------------------- #
# popclip GPT Thesaurus
name: GPT Thesaurus
icon: iconify:noto:light-bulb
entitlements: [network]
javascript: |
const axios = require("axios");
const openai = axios.default.create({
baseURL: "https://api.openai.com/v1",
headers: { Authorization: `Bearer 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` },
});
const prompt = "Rephrase the following sentences using as much synonyms as possible, and use the same language as input:\n\n";
const { data } = await openai.post("chat/completions", {
model: "gpt-3.5-turbo",
messages: [
{ role: "system", content: prompt },
{ role: "user", content: popclip.input.text }
],
});
const response = data.choices[0].message.content.trim();
return response;
after: paste-result
# --------------------------------------------------------------------------------------- #
# popclip GPT Translate English
name: GPT Translate English
icon: iconify:emojione:flag-for-united-states
entitlements: [network]
javascript: |
const axios = require("axios");
const openai = axios.default.create({
baseURL: "https://api.openai.com/v1",
headers: { Authorization: `Bearer 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` },
});
const prompt = "Translate the following sentences to English:\n\n";
const { data } = await openai.post("chat/completions", {
model: "gpt-3.5-turbo",
messages: [
{ role: "system", content: prompt },
{ role: "user", content: popclip.input.text }
],
});
const response = data.choices[0].message.content.trim();
return response;
after: paste-result
# --------------------------------------------------------------------------------------- #
# popclip GPT Translate Spanish
name: GPT Translate Spanish
icon: iconify:emojione:flag-for-spain
entitlements: [network]
javascript: |
const axios = require("axios");
const openai = axios.default.create({
baseURL: "https://api.openai.com/v1",
headers: { Authorization: `Bearer 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` },
});
const prompt = "Translate the following sentences to Spanish:\n\n";
const { data } = await openai.post("chat/completions", {
model: "gpt-3.5-turbo",
messages: [
{ role: "system", content: prompt },
{ role: "user", content: popclip.input.text }
],
});
const response = data.choices[0].message.content.trim();
return response;
after: paste-result
# --------------------------------------------------------------------------------------- #
# popclip GPT Code Bash
name: GPT Code Bash
icon: iconify:logos:bash-icon
entitlements: [network]
javascript: |
const axios = require("axios");
const openai = axios.default.create({
baseURL: "https://api.openai.com/v1",
headers: { Authorization: `Bearer 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` },
});
let prompt = "Translate the folling instructions written in natural language into Bash Script code, use english for all variables and comments created, avoid companion comments, generate only executable code:\n\n";
if (popclip.modifiers.shift) {
prompt = "Prettify the folling Bash Script code:\n\n";
}
const { data } = await openai.post("chat/completions", {
model: "gpt-3.5-turbo",
messages: [
{ role: "system", content: prompt },
{ role: "user", content: popclip.input.text }
],
});
const response = data.choices[0].message.content.trim();
return response;
after: paste-result
# --------------------------------------------------------------------------------------- #
# popclip GPT Code Javascript
name: GPT Code Javascript
icon: iconify:tabler:brand-javascript
entitlements: [network]
javascript: |
const axios = require("axios");
const openai = axios.default.create({
baseURL: "https://api.openai.com/v1",
headers: { Authorization: `Bearer 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` },
});
let prompt = "Translate the folling instructions written in natural language into Javascript code, use english for all variables and comments created, avoid companion comments, generate only executable code:\n\n";
if (popclip.modifiers.shift) {
prompt = "Prettify the folling Javascript code:\n\n";
}
const { data } = await openai.post("chat/completions", {
model: "gpt-3.5-turbo",
messages: [
{ role: "system", content: prompt },
{ role: "user", content: popclip.input.text }
],
});
const response = data.choices[0].message.content.trim();
return response;
after: paste-result
# --------------------------------------------------------------------------------------- #
# popclip extension to search for synonyms on thesaurus.com
name: Thesaurus
icon: symbol:pencil.and.outline # Apple SF Symbols
url: https://www.thesaurus.com/browse/***