diff --git a/README.md b/README.md index 3978c2c..b3022c2 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/index.js b/index.js index a40d1a1..4a05fed 100644 --- a/index.js +++ b/index.js @@ -33,6 +33,7 @@ const providers = { Bing: require('./providers/bing'), Claude: require('./providers/claude'), Claude2: require('./providers/claude2'), + Together: require('./providers/together'), Perplexity: require('./providers/perplexity'), Phind: require('./providers/phind'), HuggingChat: require('./providers/huggingchat'), diff --git a/interface.js b/interface.js index 03ffce4..fe8b2e8 100644 --- a/interface.js +++ b/interface.js @@ -11,6 +11,7 @@ const providers = { Bing: require('./providers/bing'), Claude: require('./providers/claude'), Claude2: require('./providers/claude2'), + Together: require('./providers/together'), Perplexity: require('./providers/perplexity'), Phind: require('./providers/phind'), HuggingChat: require('./providers/huggingchat'), 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 c3c6477..254cb89 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}"); @@ -30,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', { @@ -38,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]; @@ -56,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 new file mode 100644 index 0000000..40634a9 --- /dev/null +++ b/providers/together.js @@ -0,0 +1,78 @@ +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"]'); + 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!!!! + 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, 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() { + return store.get(`${this.webviewId}Enabled`, false); + } +} + +module.exports = Together;