aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md19
-rw-r--r--index.ts140
-rw-r--r--readme.md18
3 files changed, 2 insertions, 175 deletions
diff --git a/README.md b/README.md
index 67ca89a..f263a08 100644
--- a/README.md
+++ b/README.md
@@ -1,18 +1,3 @@
-# Logseq Plugin Template React 🚀
+# 🦙 ollama-logseq plugin
-## Features
-
-- Plug-and-play boilerplate with properly defined GitHub action defaults
-- Develop with HMR, empowered by lightning-fast Vite ⚡ with [vite-logseq-plugin](https://github.com/pengx17/vite-plugin-logseq)
-- TailwindCSS for styling
-- Pnpm
-
-## How to get started
-1. Clone the repository or use the button "Use this template" on GitHub to create your own version of the repository 🔨
-2. Make sure you have pnpm installed, [install](https://pnpm.io/installation) if necessary 🛠
-3. Execute `pnpm install` 📦
-4. Change the plugin-name in `package.json` to your liking. Adapt both the package-name and the plugin-id at the bottom of the `package.json`. Make sure that they are not conflicting with plugins you already installed. 📝
-5. Execute `pnpm build` to build the plugin 🚧
-6. Enable developer-mode in Logseq, go to plugins, select "Load unpacked plugin" 🔌
-7. Select the directory of your plugin (not the `/dist`-directory, but the directory which includes your package.json) 📂
-8. Enjoy! 🎉
+A plugin to integrate ollama with logseq
diff --git a/index.ts b/index.ts
deleted file mode 100644
index dd3748d..0000000
--- a/index.ts
+++ /dev/null
@@ -1,140 +0,0 @@
-import '@logseq/libs'
-import { LSPluginBaseInfo } from '@logseq/libs/dist/LSPlugin'
-import { SettingSchemaDesc } from '@logseq/libs/dist/LSPlugin';
-
-const delay = (t = 100) => new Promise(r => setTimeout(r, t))
-
-let settings: SettingSchemaDesc[] = [
- {
- key: "host",
- type: "string",
- title: "Host",
- description: "Set the host of your ollama model",
- default: "localhost:11434"
- },
- {
- key: "model",
- type: "string",
- title: "LLM Model",
- description: "Set your desired model to use ollama",
- default: "mistral:instruct"
- },
-]
-
-async function promptLLM(url: string, prompt: string, model: string) {
- const response = await fetch('http://localhost:11434/api/generate', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify({
- model: model,
- prompt: prompt,
- stream: false,
- }),
- })
- if (!response.ok) {
- throw new Error('Network response was not ok');
- }
-
- const data = await response.json();
-
- return data.response;
-
-}
-
-/**
- * main entry
- * @param baseInfo
- */
-function main(baseInfo: LSPluginBaseInfo) {
- logseq.useSettingsSchema(settings)
- let loading = false
-
- logseq.provideModel({
- async summarize() {
-
- const info = await logseq.App.getUserConfigs()
- if (loading) return
-
-
- await delay(300)
-
- loading = true
-
-
- logseq.App.showMsg(`
- [:div.p-2
- [:h1 "response"]
- [:h2.text-xl "Hello"]]
- `)
-
- try {
- const currentSelectedBlocks = await logseq.Editor.getCurrentPageBlocksTree()
- let blocksContent = ""
- if (currentSelectedBlocks) {
- let lastBlock: any = currentSelectedBlocks[currentSelectedBlocks.length - 1]
- for (const block of currentSelectedBlocks) {
- blocksContent += block.content + "/n"
- }
- if (lastBlock) {
- lastBlock = await logseq.Editor.insertBlock(lastBlock.uuid, '🚀 Summarizing....', { before: false })
- }
-
- const summary = await promptLLM(logseq.settings.host, `Summarize the following ${blocksContent}`, logseq.settings.model)
-
- await logseq.Editor.updateBlock(lastBlock.uuid, `Summary: ${summary}`)
- }
-
- } catch (e) {
- logseq.App.showMsg(e.toString(), 'warning')
- console.error(e)
- } finally {
- loading = false
- }
- }
- })
-
-
- logseq.Editor.registerBlockContextMenuItem('Summarize with AI',
- async () => {
- logseq.App.showMsg(
- 'Summarizing....'
- );
- const currentSelectedBlocks = await logseq.Editor.getCurrentPageBlocksTree()
- let blocksContent = ""
- if (currentSelectedBlocks != undefined) {
- let lastBlock: any = currentSelectedBlocks[currentSelectedBlocks.length - 1]
- for (const block in currentSelectedBlocks) {
- blocksContent += currentSelectedBlocks[block].content + "/n"
- }
- if (lastBlock) {
- lastBlock = await logseq.Editor.insertBlock(lastBlock.uuid, '🚀 Summarizing....', { before: false })
- }
-
- const summary = await promptLLM(logseq.settings.host, `Summarize the following ${blocksContent}`, logseq.settings.model)
-
- await logseq.Editor.updateBlock(lastBlock.uuid, `Summary: ${summary}`)
- }
- })
-
- logseq.App.registerUIItem('toolbar', {
- key: 'logseq-reddit',
- template: `
- <a data-on-click="summarize"
- class="button">
- <i class="ti ti-brand-reddit"></i>
- </a>
- `
- })
-
- logseq.provideStyle(`
- [data-injected-ui=logseq-reddit-${baseInfo.id}] {
- display: flex;
- align-items: center;
- }
- `)
-}
-
-// bootstrap
-logseq.ready(main).catch(console.error)
diff --git a/readme.md b/readme.md
deleted file mode 100644
index 67ca89a..0000000
--- a/readme.md
+++ /dev/null
@@ -1,18 +0,0 @@
-# Logseq Plugin Template React 🚀
-
-## Features
-
-- Plug-and-play boilerplate with properly defined GitHub action defaults
-- Develop with HMR, empowered by lightning-fast Vite ⚡ with [vite-logseq-plugin](https://github.com/pengx17/vite-plugin-logseq)
-- TailwindCSS for styling
-- Pnpm
-
-## How to get started
-1. Clone the repository or use the button "Use this template" on GitHub to create your own version of the repository 🔨
-2. Make sure you have pnpm installed, [install](https://pnpm.io/installation) if necessary 🛠
-3. Execute `pnpm install` 📦
-4. Change the plugin-name in `package.json` to your liking. Adapt both the package-name and the plugin-id at the bottom of the `package.json`. Make sure that they are not conflicting with plugins you already installed. 📝
-5. Execute `pnpm build` to build the plugin 🚧
-6. Enable developer-mode in Logseq, go to plugins, select "Load unpacked plugin" 🔌
-7. Select the directory of your plugin (not the `/dist`-directory, but the directory which includes your package.json) 📂
-8. Enjoy! 🎉