Kevin Kipp

Kevin Kipp

// Name: Fix Spelling and Grammar
// Author: Kevin Kipp
// Email: kevin.kipp@gmail.com
// Twitter: https://twitter.com/kevin_kipp
// Github: https://github.com/third774
import '@johnlindquist/kit';
import OpenAI from 'openai';
const openai = new OpenAI({
apiKey: await env('OPENAI_API_KEY', {
secret: true,
}),
});
const text = await getSelectedText();
const completion = await openai.chat.completions.create({
messages: [
{
role: 'user',
content: `You are an editor and you are tasked with fixing the spelling and grammar of the following text:
---
Text to fix:
${text}
---
The corrected text is:`,
},
],
model: 'gpt-3.5-turbo',
temperature: 0,
});
const insertText = await editor(completion.choices[0].message.content);
await setSelectedText(insertText);
// Name: Feedbin Unread
// Author: Kevin Kipp
// Email: kevin.kipp@gmail.com
// Twitter: https://twitter.com/kevin_kipp
// Github: https://github.com/third774
import '@johnlindquist/kit';
const feedbinUsername = await env('FEEDBIN_USERNAME');
const feedbinPassword = await env('FEEDBIN_PASSWORD', () =>
arg({
placeholder: 'Feedbin Password',
secret: true,
}),
);
const headers = {
Authorization: `Basic ${btoa(`${feedbinUsername}:${feedbinPassword}`)}`,
};
type Entries = EntriesItem[];
interface EntriesItem {
author: null;
content: string;
created_at: string;
extracted_content_url: string;
feed_id: number;
id: number;
published: string;
summary: string;
title: string;
url: string;
}
const { data } = await get<Entries>(
`https://api.feedbin.com/v2/entries.json?read=false`,
{ headers },
);
const selection = await arg<EntriesItem>(
{
name: data.length > 0 ? 'Article Title' : 'No unread articles',
actions: [
{
name: 'Open',
onAction: async (_, state) => {
open(state.focused.value.url);
finishScript();
},
shortcut: 'o',
},
{
name: 'Mark as read',
onAction: async (_, state) => {
await post(
`https://api.feedbin.com/v2/unread_entries/delete.json`,
{ unread_entries: [state.focused.value.id] },
{ headers },
);
},
shortcut: 'm',
},
],
},
data.map((item: any) => ({
name: item.title,
description: item.url,
value: item,
})),
);
await open(selection.url);
await post(
`https://api.feedbin.com/v2/unread_entries/delete.json`,
{ unread_entries: [selection.id] },
{ headers },
);