From d615c18cc245f09bebf83c9ec080f6415312954f Mon Sep 17 00:00:00 2001 From: swyx Date: Sat, 15 Jul 2023 17:46:19 -0700 Subject: [PATCH 1/6] add together.xyz --- index.js | 1 + interface.js | 1 + providers/together.js | 69 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 providers/together.js diff --git a/index.js b/index.js index 70240d7..33d73d1 100644 --- a/index.js +++ b/index.js @@ -31,6 +31,7 @@ const providers = { Bing: require('./providers/bing'), Claude: require('./providers/claude'), Claude2: require('./providers/claude2'), + Together: require('./providers/together'), OobaBooga: require('./providers/oobabooga'), Smol: require('./providers/smol'), }; diff --git a/interface.js b/interface.js index b2ece35..86abc5b 100644 --- a/interface.js +++ b/interface.js @@ -10,6 +10,7 @@ const providers = { Bing: require('./providers/bing'), Claude: require('./providers/claude'), Claude2: require('./providers/claude2'), + Together: require('./providers/together'), OobaBooga: require('./providers/oobabooga'), Smol: require('./providers/smol'), }; diff --git a/providers/together.js b/providers/together.js new file mode 100644 index 0000000..f1acab3 --- /dev/null +++ b/providers/together.js @@ -0,0 +1,69 @@ +const Store = require('electron-store'); +const store = new Store(); + +const Provider = require('./provider'); + +class Together extends Provider { + static webviewId = 'webviewTOGETHER'; + static fullName = 'Together (RedPajama, StarCoder, Falcon, etc)'; + + + static url = 'https://api.together.xyz/playground/chat'; + + static handleInput(input) { + this.getWebview().executeJavaScript(` + var inputElement = document.querySelector('form textarea[placeholder*="Enter text here"]'); + inputElement.focus(); + inputElement.value = "${input}"; + // try to send keyboard event to trigger the re-enable of the disabled button + // thanks chatgpt! + var event = new Event('input', { bubbles: true }); + event.simulated = true; + var tracker = inputElement._valueTracker; + if (tracker) { + tracker.setValue("${input}"); + } + // Dispatch the event after a short delay to fix the button state + setTimeout(function() { + inputElement.dispatchEvent(event); + }, 100); + `); + } + + static handleSubmit() { + this.getWebview().executeJavaScript(` + var btn = document.querySelector('form button:has(svg)'); // YES we are using the has selector!!!! + btn.focus(); + btn.disabled = false; + btn.click()`); + } + + static handleCss() { + // this.getWebview().addEventListener('dom-ready', () => { + // // hide message below text input, sidebar, suggestions on new chat + // setTimeout(() => { + // this.getWebview().insertCSS(` + // header, .container { + // background-color: white; + // /* single line dark mode ftw */ + // filter: invert(100%) hue-rotate(180deg); + // } + // /* hide the claude avatar in response */ + // .p-1.w-9.h-9.shrink-0 { + // display: none; + // } + // /* reduce claude prompt margins */ + // .mx-4.md\:mx-12.mb-2.md\:mb-4.mt-2.w-auto { + // margin: 0 !important; + // } + // `); + // }, 1000); + // }); + } + + static isEnabled() { + return store.get(`${this.webviewId}Enabled`, false); + } +} + +module.exports = Together; \ No newline at end of file From 4c1e3d477f8ee25348bb3ad7f85f2511c99aab90 Mon Sep 17 00:00:00 2001 From: "swyx.io" Date: Wed, 19 Jul 2023 00:08:18 +0800 Subject: [PATCH 2/6] Update providers/together.js --- providers/together.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/providers/together.js b/providers/together.js index f1acab3..8689b60 100644 --- a/providers/together.js +++ b/providers/together.js @@ -5,7 +5,7 @@ const Provider = require('./provider'); class Together extends Provider { static webviewId = 'webviewTOGETHER'; - static fullName = 'Together (RedPajama, StarCoder, Falcon, etc)'; + static fullName = 'Together (WIP - RedPajama, StarCoder, Falcon, etc)'; static url = 'https://api.together.xyz/playground/chat'; From d3b5562a91c4f2695ec50e834ebf20483a55ec4e Mon Sep 17 00:00:00 2001 From: swyxio Date: Mon, 31 Jul 2023 05:46:43 +0000 Subject: [PATCH 3/6] Apply prettier changes --- providers/together.js | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/providers/together.js b/providers/together.js index 8689b60..6878fa3 100644 --- a/providers/together.js +++ b/providers/together.js @@ -5,8 +5,7 @@ const Provider = require('./provider'); class Together extends Provider { static webviewId = 'webviewTOGETHER'; - static fullName = 'Together (WIP - RedPajama, StarCoder, Falcon, etc)'; - + static fullName = 'Together (WIP - RedPajama, StarCoder, Falcon, etc)'; static url = 'https://api.together.xyz/playground/chat'; @@ -43,20 +42,20 @@ class Together extends Provider { // // hide message below text input, sidebar, suggestions on new chat // setTimeout(() => { // this.getWebview().insertCSS(` - // header, .container { - // background-color: white; - // /* single line dark mode ftw */ - // filter: invert(100%) hue-rotate(180deg); - // } - // /* hide the claude avatar in response */ - // .p-1.w-9.h-9.shrink-0 { - // display: none; - // } - // /* reduce claude prompt margins */ - // .mx-4.md\:mx-12.mb-2.md\:mb-4.mt-2.w-auto { - // margin: 0 !important; - // } - // `); + // header, .container { + // background-color: white; + // /* single line dark mode ftw */ + // filter: invert(100%) hue-rotate(180deg); + // } + // /* hide the claude avatar in response */ + // .p-1.w-9.h-9.shrink-0 { + // display: none; + // } + // /* reduce claude prompt margins */ + // .mx-4.md\:mx-12.mb-2.md\:mb-4.mt-2.w-auto { + // margin: 0 !important; + // } + // `); // }, 1000); // }); } @@ -66,4 +65,4 @@ class Together extends Provider { } } -module.exports = Together; \ No newline at end of file +module.exports = Together; From 57825a1c314e3ff41c9cdd10bc855f8bb122b012 Mon Sep 17 00:00:00 2001 From: swyxio Date: Sun, 30 Jul 2023 23:00:46 -0700 Subject: [PATCH 4/6] add together --- index.js | 2 +- providers/perplexity.js | 8 -------- providers/together.js | 34 ++++++++++++++++++++-------------- 3 files changed, 21 insertions(+), 23 deletions(-) diff --git a/index.js b/index.js index 2674d23..1e89171 100644 --- a/index.js +++ b/index.js @@ -91,7 +91,7 @@ app.on('ready', () => { }, width: store.get('isFullscreen', false) ? width : 1200, height: 750, - focusable: process.env.NODE_ENV !== 'development', + // focusable: process.env.NODE_ENV !== 'development', }, tray, showOnAllWorkspaces: false, diff --git a/providers/perplexity.js b/providers/perplexity.js index c3c6477..942668d 100644 --- a/providers/perplexity.js +++ b/providers/perplexity.js @@ -11,15 +11,7 @@ class Perplexity extends Provider { static handleInput(input) { this.getWebview().executeJavaScript(` - // function simulateUserInput(element, text) { - // const inputEvent = new Event('input', { bubbles: true }); - // element.focus(); - // element.value = text; - // element.dispatchEvent(inputEvent); - // } var inputElement = document.querySelector('textarea[placeholder*="Ask"]'); // can be "Ask anything" or "Ask follow-up" - // inputElement.focus(); inputElement.click(); - // simulateUserInput(inputElement, "${input}"); var nativeTextAreaValueSetter = Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype, "value").set; nativeTextAreaValueSetter.call(inputElement, "${input}"); diff --git a/providers/together.js b/providers/together.js index 6878fa3..891ba94 100644 --- a/providers/together.js +++ b/providers/together.js @@ -12,23 +12,29 @@ class Together extends Provider { static handleInput(input) { this.getWebview().executeJavaScript(` var inputElement = document.querySelector('form textarea[placeholder*="Enter text here"]'); - inputElement.focus(); - inputElement.value = "${input}"; - // try to send keyboard event to trigger the re-enable of the disabled button - // thanks chatgpt! - var event = new Event('input', { bubbles: true }); - event.simulated = true; - var tracker = inputElement._valueTracker; - if (tracker) { - tracker.setValue("${input}"); - } - // Dispatch the event after a short delay to fix the button state - setTimeout(function() { - inputElement.dispatchEvent(event); - }, 100); + var nativeTextAreaValueSetter = Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype, "value").set; + nativeTextAreaValueSetter.call(inputElement, "${input}"); + var event = new Event('input', { bubbles: true}); + inputElement.dispatchEvent(event); `); } + // inputElement.focus(); + // inputElement.value = "${input}"; + // // try to send keyboard event to trigger the re-enable of the disabled button + // // thanks chatgpt! + // var event = new Event('input', { bubbles: true }); + // event.simulated = true; + // var tracker = inputElement._valueTracker; + // if (tracker) { + // tracker.setValue("${input}"); + // } + // // Dispatch the event after a short delay to fix the button state + // setTimeout(function() { + // inputElement.dispatchEvent(event); + // }, 100); + + static handleSubmit() { this.getWebview().executeJavaScript(` var btn = document.querySelector('form button:has(svg)'); // YES we are using the has selector!!!! From 0897ac2880dd7fce1320058710919c271fdf3a34 Mon Sep 17 00:00:00 2001 From: swyxio Date: Sun, 30 Jul 2023 23:24:08 -0700 Subject: [PATCH 5/6] add together, promote phind --- README.md | 14 ++++---- providers/claude.js | 2 +- providers/huggingchat.js | 2 +- providers/perplexity.js | 13 +++++-- providers/phind.js | 2 +- providers/together.js | 76 +++++++++++++++++++++------------------- 6 files changed, 61 insertions(+), 48 deletions(-) diff --git a/README.md b/README.md index 3978c2c..7cf04fa 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # 👼 smol menubar -This is a smol menubar app that helps you quickly access **the full webapps** of ChatGPT (defaults to "[GPT4.5](https://www.latent.space/p/code-interpreter#details)"!!), Perplexity.ai, Claude 2, and more (see below) with a single keyboard shortcut (Cmd+Shift+G). +This is a smol menubar app that helps you quickly access **the full webapps** of ChatGPT (defaults to "[GPT4.5](https://www.latent.space/p/code-interpreter#details)"!!), Claude 2, Perplexity.ai, Phind and more (see below) with a single keyboard shortcut (Cmd+Shift+G). -> we also support Bard, Bing, Claude 1, and local models like LLaMA and Vicuna (via [OobaBooga](https://github.com/oobabooga/text-generation-webui)) but hide by default bc they aren't as good! +> we also support Bard, Bing, Claude 1, Together.ai, and local models like LLaMA and Vicuna (via [OobaBooga](https://github.com/oobabooga/text-generation-webui)) but hide by default bc they aren't as good! ![image](https://github.com/smol-ai/menubar/assets/6764957/0cc8f90a-b7eb-447c-808a-6883654dcad4) @@ -24,16 +24,16 @@ Yes and no: | Provider (default in **bold**) | Status | Notes | | ---------------------------------------------------------------------------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------- | | **ChatGPT** | ☑️ | Defaults to GPT 4 Code Interpreter | -| Bard | ☑️ | | -| Bing | ☑️ | [It's not the same as GPT-4!](https://twitter.com/jeremyphoward/status/1666593682676662272?s=20) | -| Claude | ☑️ | Requires Beta Access | +| Bard | ☑️ | Google's best. | +| Bing | ☑️ | Microsoft's best. [It's not the same as GPT-4!](https://twitter.com/jeremyphoward/status/1666593682676662272?s=20) | | **Claude 2** | ☑️ | **Login Tip**: Use manual email login and remember to type (not paste) the login code! ([#56](https://github.com/smol-ai/menubar/issues/56)) | | Local Models (via [OobaBooga](https://github.com/oobabooga/text-generation-webui)) | ☑️ | Requires Local Setup | | **HuggingChat** | ☑️ | Offers Llama2, OpenAssistant | -| **Perplexity** | ☑️ | | -| Phind | ☑️ | | +| **Perplexity** | ☑️ | Search + Chat | +| **Phind** | ☑️ | Developer focused chat | | OpenAssistant | ☐ | Coming Soon — [Submit a PR](https://github.com/smol-ai/menubar/issues/37)! | | Quora Poe | ☐ | Coming Soon — [Submit a PR](https://github.com/smol-ai/menubar/issues/38)! | +| Claude | ☑️ | Requires Beta Access | | ... What's Else? | ☐ | [Submit a New Issue](https://github.com/smol-ai/menubar/issues)! | ## Features and Usage diff --git a/providers/claude.js b/providers/claude.js index d60666a..7b6ad5a 100644 --- a/providers/claude.js +++ b/providers/claude.js @@ -42,7 +42,7 @@ class Claude extends Provider { margin: 0 !important; } `); - }, 1000); + }, 100); }); } diff --git a/providers/huggingchat.js b/providers/huggingchat.js index d559b5d..b8db8ef 100644 --- a/providers/huggingchat.js +++ b/providers/huggingchat.js @@ -78,7 +78,7 @@ class HuggingChat extends Provider { } static isEnabled() { - return store.get(`${this.webviewId}Enabled`, false); + return store.get(`${this.webviewId}Enabled`, true); } } diff --git a/providers/perplexity.js b/providers/perplexity.js index 942668d..254cb89 100644 --- a/providers/perplexity.js +++ b/providers/perplexity.js @@ -22,7 +22,7 @@ class Perplexity extends Provider { static handleSubmit() { this.getWebview().executeJavaScript(` - var inputElement = document.querySelector('textarea[placeholder*="Ask anything"]'); + // var inputElement = document.querySelector('textarea[placeholder*="Ask anything"]'); // var btn = document.querySelector('button.bg-super.aspect-square'); // btn.click(); // const event = new KeyboardEvent('keyup', { @@ -30,7 +30,7 @@ class Perplexity extends Provider { // metaKey: true // }); // inputElement.dispatchEvent(event); - var buttons = Array.from(document.querySelectorAll('button')); + var buttons = Array.from(document.querySelectorAll('button.bg-super')); var buttonsWithSvgPath = buttons.filter(button => button.querySelector('svg path')); var button = buttonsWithSvgPath[buttonsWithSvgPath.length - 1]; @@ -48,8 +48,17 @@ class Perplexity extends Provider { // Add Dark Mode document.documentElement.classList.add('dark'); + `); }, 100); + // Hide the "Try asking" segment + setTimeout(() => { + this.getWebview().insertCSS(` + .mt-lg { + display: none; + } + `); + }, 100); }); } diff --git a/providers/phind.js b/providers/phind.js index d1c384b..56837dc 100644 --- a/providers/phind.js +++ b/providers/phind.js @@ -84,7 +84,7 @@ class Phind extends Provider { } static isEnabled() { - return store.get(`${this.webviewId}Enabled`, false); + return store.get(`${this.webviewId}Enabled`, true); } } diff --git a/providers/together.js b/providers/together.js index 891ba94..40634a9 100644 --- a/providers/together.js +++ b/providers/together.js @@ -5,7 +5,7 @@ const Provider = require('./provider'); class Together extends Provider { static webviewId = 'webviewTOGETHER'; - static fullName = 'Together (WIP - RedPajama, StarCoder, Falcon, etc)'; + static fullName = 'Together (RedPajama, StarCoder, Falcon, etc)'; static url = 'https://api.together.xyz/playground/chat'; @@ -19,21 +19,20 @@ class Together extends Provider { `); } - // inputElement.focus(); - // inputElement.value = "${input}"; - // // try to send keyboard event to trigger the re-enable of the disabled button - // // thanks chatgpt! - // var event = new Event('input', { bubbles: true }); - // event.simulated = true; - // var tracker = inputElement._valueTracker; - // if (tracker) { - // tracker.setValue("${input}"); - // } - // // Dispatch the event after a short delay to fix the button state - // setTimeout(function() { - // inputElement.dispatchEvent(event); - // }, 100); - + // inputElement.focus(); + // inputElement.value = "${input}"; + // // try to send keyboard event to trigger the re-enable of the disabled button + // // thanks chatgpt! + // var event = new Event('input', { bubbles: true }); + // event.simulated = true; + // var tracker = inputElement._valueTracker; + // if (tracker) { + // tracker.setValue("${input}"); + // } + // // Dispatch the event after a short delay to fix the button state + // setTimeout(function() { + // inputElement.dispatchEvent(event); + // }, 100); static handleSubmit() { this.getWebview().executeJavaScript(` @@ -44,26 +43,31 @@ class Together extends Provider { } static handleCss() { - // this.getWebview().addEventListener('dom-ready', () => { - // // hide message below text input, sidebar, suggestions on new chat - // setTimeout(() => { - // this.getWebview().insertCSS(` - // header, .container { - // background-color: white; - // /* single line dark mode ftw */ - // filter: invert(100%) hue-rotate(180deg); - // } - // /* hide the claude avatar in response */ - // .p-1.w-9.h-9.shrink-0 { - // display: none; - // } - // /* reduce claude prompt margins */ - // .mx-4.md\:mx-12.mb-2.md\:mb-4.mt-2.w-auto { - // margin: 0 !important; - // } - // `); - // }, 1000); - // }); + this.getWebview().addEventListener('dom-ready', () => { + // hide message below text input, sidebar, suggestions on new chat + setTimeout(() => { + this.getWebview().insertCSS(` + header, header + div { + background-color: white; + /* single line dark mode ftw */ + filter: invert(100%) hue-rotate(180deg); + } + header { + height: 10px; + margin-top: -5px; + padding-top: 0px; + padding-bottom: 0px; + } + /* the "chat" header is pretty big */ + .mui-style-qe6v0i { + padding-top: 0px; + } + div + h1, h1, h1 + div { + display: none; + } + `); + }, 100); + }); } static isEnabled() { From 0b1ddbdda2a3bcd08c6c8e28a09cfde7b76af04a Mon Sep 17 00:00:00 2001 From: swyxio Date: Mon, 31 Jul 2023 06:25:16 +0000 Subject: [PATCH 6/6] Apply prettier changes --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7cf04fa..b3022c2 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,8 @@ Yes and no: | Provider (default in **bold**) | Status | Notes | | ---------------------------------------------------------------------------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------- | | **ChatGPT** | ☑️ | Defaults to GPT 4 Code Interpreter | -| Bard | ☑️ | Google's best. | -| Bing | ☑️ | Microsoft's best. [It's not the same as GPT-4!](https://twitter.com/jeremyphoward/status/1666593682676662272?s=20) | +| Bard | ☑️ | Google's best. | +| Bing | ☑️ | Microsoft's best. [It's not the same as GPT-4!](https://twitter.com/jeremyphoward/status/1666593682676662272?s=20) | | **Claude 2** | ☑️ | **Login Tip**: Use manual email login and remember to type (not paste) the login code! ([#56](https://github.com/smol-ai/menubar/issues/56)) | | Local Models (via [OobaBooga](https://github.com/oobabooga/text-generation-webui)) | ☑️ | Requires Local Setup | | **HuggingChat** | ☑️ | Offers Llama2, OpenAssistant |