Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add together.xyz, promote Phind to default, minor dark mode tweaks #69

Merged
merged 8 commits into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)

Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
1 change: 1 addition & 0 deletions interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
2 changes: 1 addition & 1 deletion providers/claude.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Claude extends Provider {
margin: 0 !important;
}
`);
}, 1000);
}, 100);
});
}

Expand Down
2 changes: 1 addition & 1 deletion providers/huggingchat.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class HuggingChat extends Provider {
}

static isEnabled() {
return store.get(`${this.webviewId}Enabled`, false);
return store.get(`${this.webviewId}Enabled`, true);
}
}

Expand Down
21 changes: 11 additions & 10 deletions providers/perplexity.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}");

Expand All @@ -30,15 +22,15 @@ 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', {
// key: 'Enter',
// metaKey: true
// });
// inputElement.dispatchEvent(event);
var buttons = Array.from(document.querySelectorAll('button'));
var buttons = Array.from(document.querySelectorAll('button.bg-super'));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initial implementation was broken without this

var buttonsWithSvgPath = buttons.filter(button => button.querySelector('svg path'));

var button = buttonsWithSvgPath[buttonsWithSvgPath.length - 1];
Expand All @@ -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);
});
}

Expand Down
2 changes: 1 addition & 1 deletion providers/phind.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class Phind extends Provider {
}

static isEnabled() {
return store.get(`${this.webviewId}Enabled`, false);
return store.get(`${this.webviewId}Enabled`, true);
}
}

Expand Down
78 changes: 78 additions & 0 deletions providers/together.js
Original file line number Diff line number Diff line change
@@ -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;