A simple gpt-3 integration with Logseq

Overview

Readme

Using GPT-3 in [[logseq]] is actually remarkably easy. The folks over at OpenAI have built a really powerful model with pretty good documentation All that you really need to do is send a post request to their site with the propper api key in the header of the message. This is all the code the plugin uses:

	  let gpt3Options = {
	    // "engine": "text-davinci-001",
	    "prompt": "this is the text that gets sent",
	    "temperature": 0.7,
	    "max_tokens": 64,
	    "top_p": 1,
	    "frequency_penalty": 0,
	    "presence_penalty": 0
	  }
	  
	  function main () {
	    logseq.Editor.registerSlashCommand(
	      'GPT-3',
	      async () => {
		const { content, uuid } = await logseq.Editor.getCurrentBlock({includeChildren: true})
		console.log(content)
		gpt3Options.prompt = content
	  
		postData('https://api.openai.com/v1/engines/text-davinci-001/completions', gpt3Options)
		.then(data => {
		  logseq.Editor.insertBlock(uuid, data.choices[0].text, { before: false, sibling: true })
		 console.log(data);
		});
	  
	      }
	    )
	  
	    
	  }
	  
	  async function postData(url = '', data = {}) {
	    // Default options are marked with *
	    const response = await fetch(url, {
	      method: 'POST', // *GET, POST, PUT, DELETE, etc.
	      mode: 'cors', // no-cors, *cors, same-origin
	      cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached
	      credentials: 'same-origin', // include, *same-origin, omit
	      headers: {
		'Content-Type': 'application/json',
		'Authorization': 'Bearer PASTE-YOUR-APIKEY-HERE'
		// 'Content-Type': 'application/x-www-form-urlencoded',
	      },
	      redirect: 'follow', // manual, *follow, error
	      
	      referrerPolicy: 'no-referrer', // no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url
	      body: JSON.stringify(data) // body data type must match "Content-Type" header
	    });
	    return response.json(); // parses JSON response into native JavaScript objects
	  }
	  
	  // bootstrap
	  logseq.ready(main).catch(console.error)

All you need to do to use it is:

  • Sign Up for OpenAI
  • Copy your API KEY
  • Paste it into line 40. Make sure to leave the word 'Bearer' in the string- the line should look like 'Authorization': 'Bearer sk-salkfjasdpfijasfkjavvkblahblahsecretsecretkey'
  • Load the unpacked plugin
  • Type some stuff you want to send to gpt-3
  • Use the slash command 'GPT-3'

Things to note are that it only grabs the text of the current block, and the options at the top are somewhat arbitrary. Editing them suit your needs. There's a lot more that can be done with this model and plugin- feel free to improve on this

You might also like...

yet another 2048, but this time it's controlled by GPT

2048 About a few years ago, I built 2048.wasm This is yet another 2048 from me, but this time it's controlled by GPT. Demo 2048-short.mov How GPT crus

Jul 17, 2023

A simple to-do list plugin for logseq

A simple to-do list plugin for logseq

Logseq Todo Plugin A simple to-do list plugin for logseq Feature quick add new to-do items to today's journal page show all today's to-do items (inclu

Jan 1, 2023

tools and plugins for logseq

logtools tools and plugins for logseq logtools-css-productivitypack my css mods for Kanban/columns view (#.v-kanban), Einsihower Matrix (#.v-einsenhow

Jan 2, 2023

Weekly, Monthly and Yearly notes in Logseq!

Periodic Notes for Logseq Currently is very early stages. My roadmap for releasing on the Logseq marketplace can view viewed here Functionality Curren

Dec 29, 2022

A logseq plugin to extract tweets. Optionally tag the tweet's author as well.

A logseq plugin to extract tweets. Optionally tag the tweet's author as well.

Logseq Twitter Extractor Plugin If this plugin helps you, I'd really appreciate your support. You can buy me a coffee here. A quick utility to parse a

Nov 17, 2022

Migrate unfinished tasks to today, Logseq plugin

Migrate unfinished tasks to today, Logseq plugin

Unfinished-business Unfinished Business Because the day may be over, but your business isn't View Demo · Report Bug · Request Feature This plugin migr

Nov 16, 2022

logseq custom.js and custom.css utilities : resize query table columns, hide namespaces...

logseq custom.js and custom.css utilities : resize query table columns, hide namespaces...

logseq-custom-files custom.js and custom.css utilities for Logseq. current version v20220331 query table view : add handles on the query table headers

Dec 7, 2022

Embed Luckysheet (spreadsheet) into Logseq.

Embed Luckysheet (spreadsheet) into Logseq.

logseq-plugin-luckysheet 在 Logseq 中嵌入电子表格 Luckysheet。你也可以用它来维护一张 markdown 表格。 Embed Luckysheet (spreadsheet) into Logseq. You can also use it to maint

Jan 1, 2023

Plugin that lets you create diagrams from textual representation (aka 'Diagrams as Code') within Logseq

Plugin that lets you create diagrams from textual representation (aka 'Diagrams as Code') within Logseq

Logseq - Diagrams as Code Plugin that lets you create diagrams (and other visualizations) from textual representation (aka 'Diagrams as Code') within

Dec 21, 2022
Owner
null
Logseq-craft-theme - Craft Theme for Logseq

Craft for Logseq Almost all creativity requires purposeful play. A Craft insprir

Alexander Rink 33 Oct 26, 2022
Connect Web Integration illustrates the integration of Connect-Web in various JS frameworks and tooling

Connect Web Integration Connect Web Integration is a repository of example projects using Connect-Web with various JS frameworks and tooling. It provi

Buf 43 Dec 29, 2022
A simple CLI experiment that writes recommendation of GitHub repository/project in form of tweet. Powered by OpenAI GPT-3.

GitHub Repo Recommendation Writer A simple CLI experiment that writes recommendation of GitHub repository/project in form of tweet. Powered by OpenAI

Viktor Bezdek 5 Jul 18, 2022
Obsidian text generator Plugin Text generator using GPT-3 (OpenAI)

is a handy plugin for Obsidian that helps you generate text content using the powerful language model GP

null 356 Dec 29, 2022
Labels issues using OpenAI's Classification API powered by GPT-3 models!

OpenAI Issue Labeler ?? This GitHub action labels issues using OpenAI's Classification API powered by GPT-3 models! We are using curie as our completi

Austen Stone 11 Dec 21, 2022
App that leverages GPT-3 to facilitate new language listening and speaking practice.

Talk w/GPT-3 app: Getting started The Talk w/GPT-3 application was developed by James L. Weaver (the author of this document) to get more new language

James Weaver 47 Jan 1, 2023
GPT-3 powered cli tool to help with bash commands you can't remember

qwery GPT-3 powered cli tool to help with bash commands you can't remember eg $ qw ffmpeg command to transcode mp4 to mov QWERY RESULT: ffmpeg -i inpu

Aaron Peddle 4 Oct 31, 2022
This repository contains a fullstack chatbot project based on the ChatGPT `gpt-3.5-turbo` model.

This is a fullstack chatbot created with React, Nodejs, OpenAi, and ChatGPT while developing the following tutorial: How To Build A Chat Bot Applicati

NJOKU SAMSON EBERE 6 May 10, 2023
An example implementation of the slack-gpt starter which ingests confluence pages to create a helpful slack bot

Slack-GPT (HR bot example implementation) Table of Contents Introduction Prerequisites Creating and installing the application Configuration Starting

Martin Hunt 17 Jul 31, 2023
Chat with GPT from the terminal, with the ability to execute shell scripts.

ChatSH Chat with GPT from the terminal, and let it execute shell scripts and perform tasks for you. What could go wrong? Example Why? The reason I'm p

Victor Taelin 47 Jun 11, 2023