Skip to content

Commit

Permalink
add you.com chat (#142)
Browse files Browse the repository at this point in the history
Co-authored-by: swyxio <swyxio@users.noreply.github.com>
  • Loading branch information
swyxio and swyxio committed Aug 18, 2023
1 parent 137ba0c commit f67cfec
Show file tree
Hide file tree
Showing 24 changed files with 141 additions and 83 deletions.
35 changes: 18 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# GodMode - the smol AI Chat Browser
# 🐣 GodMode - the smol AI Chat Browser

This is a dedicated chat browser that only does one thing: help you quickly access **the full webapps** of ChatGPT, Claude 2, Perplexity, Bing and more **with a single keyboard shortcut (Cmd+Shift+G)**.

Expand Down Expand Up @@ -27,21 +27,22 @@ Yes and no:

## Supported LLM Providers

| Provider (default in **bold**) | Notes |
| --------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| **ChatGPT** | Defaults to "[GPT4.5](https://www.latent.space/p/code-interpreter#details)"! |
| **Claude 2** | Excellent, long context, multi document, fast model. |
| **Perplexity** | The login is finnicky - login to Google on any of the other chats, and then reload (cmd+R) - it'll auto login. Hopefully they make it more intuitive/reliable in future. |
| **Bing** | Microsoft's best. [It's not the same as GPT-4!](https://twitter.com/jeremyphoward/status/1666593682676662272?s=20). We could use help normalizing its styling. |
| Bard | Google's best. [Bard's updates are... flaky](https://twitter.com/swyx/status/1678495067663925248) |
| Quora Poe | Added in #118 |
| HuggingChat | Offers Llama2, OpenAssistant |
| Vercel Chat | Added in #117 |
| Local/GGML Models (via [OobaBooga](https://github.com/oobabooga/text-generation-webui)) | Requires Local Setup, see oobabooga docs |
| Phind | Developer focused chat (temporarily disabled) |
| OpenAssistant | Coming Soon — [Submit a PR](https://github.com/smol-ai/menubar/issues/37)! |
| Claude 1 | Requires Beta Access |
| ... What Else? | [Submit a New Issue](https://github.com/smol-ai/menubar/issues)! |
| Provider (default in **bold**) | Notes |
| --------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **ChatGPT** | Defaults to "[GPT4.5](https://www.latent.space/p/code-interpreter#details)"! |
| **Claude 2** | Excellent, long context, multi document, fast model. |
| **Perplexity** | The login is finnicky - login to Google on any of the other chats, and then reload (cmd+R) - it'll auto login. Hopefully they make it more intuitive/reliable in future. |
| **Bing** | Microsoft's best. [It's not the same as GPT-4!](https://twitter.com/jeremyphoward/status/1666593682676662272?s=20). We could use help normalizing its styling. |
| Bard | Google's best. [Bard's updates are... flaky](https://twitter.com/swyx/status/1678495067663925248) |
| Quora Poe | Added in #118 |
| You.com Chat | Added in #142 |
| HuggingChat | Offers Llama2, OpenAssistant |
| Vercel Chat | Added in #117 |
| Local/GGML Models (via [OobaBooga](https://github.com/oobabooga/text-generation-webui)) | Requires Local Setup, see oobabooga docs |
| Phind | Developer focused chat (temporarily disabled) |
| OpenAssistant | Coming Soon — [Submit a PR](https://github.com/smol-ai/menubar/issues/37)! |
| Claude 1 | Requires Beta Access |
| ... What Else? | [Submit a New Issue](https://github.com/smol-ai/menubar/issues)! |

## Features and Usage

Expand Down Expand Up @@ -126,7 +127,7 @@ If you want to build from source, you will need to clone the repo and open the p
```bash
npm run package # https://electron-react-boilerplate.js.org/docs/packaging
# ts-node scripts/clean.js dist clears the webpackPaths.distPath, webpackPaths.buildPath, webpackPaths.dllPath
# npm run build outputs to /release/app/dist/main
# npm run build outputs to /release/app/dist/main
# electron-builder build --publish never builds and code signs the app.

# this is mostly for swyx to publish the official codesigned and notarized releases
Expand Down
6 changes: 3 additions & 3 deletions scripts/configs/webpack.config.renderer.dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ if (
) {
console.log(
chalk.black.bgYellow.bold(
'The DLL files are missing. Sit back while we build them for you with "npm run build-dll"'
)
'The DLL files are missing. Sit back while we build them for you with "npm run build-dll"',
),
);
execSync('npm run postinstall');
}
Expand Down Expand Up @@ -205,7 +205,7 @@ const configuration: webpack.Configuration = {
let args = ['run', 'start:main'];
if (process.env.MAIN_ARGS) {
args = args.concat(
['--', ...process.env.MAIN_ARGS.matchAll(/"[^"]+"|[^\s"]+/g)].flat()
['--', ...process.env.MAIN_ARGS.matchAll(/"[^"]+"|[^\s"]+/g)].flat(),
);
}
spawn('npm', args, {
Expand Down
8 changes: 4 additions & 4 deletions scripts/scripts/check-build-exists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ const rendererPath = path.join(webpackPaths.distRendererPath, 'renderer.js');
if (!fs.existsSync(mainPath)) {
throw new Error(
chalk.whiteBright.bgRed.bold(
'The main process is not built yet. Build it by running "npm run build:main"'
)
'The main process is not built yet. Build it by running "npm run build:main"',
),
);
}

if (!fs.existsSync(rendererPath)) {
throw new Error(
chalk.whiteBright.bgRed.bold(
'The renderer process is not built yet. Build it by running "npm run build:renderer"'
)
'The renderer process is not built yet. Build it by running "npm run build:renderer"',
),
);
}
12 changes: 6 additions & 6 deletions scripts/scripts/check-native-dep.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,34 @@ if (dependencies) {
// because of a devDependency then that is okay. Warn when it is installed
// because of a dependency
const { dependencies: dependenciesObject } = JSON.parse(
execSync(`npm ls ${nativeDeps.join(' ')} --json`).toString()
execSync(`npm ls ${nativeDeps.join(' ')} --json`).toString(),
);
const rootDependencies = Object.keys(dependenciesObject);
const filteredRootDependencies = rootDependencies.filter((rootDependency) =>
dependenciesKeys.includes(rootDependency)
dependenciesKeys.includes(rootDependency),
);
if (filteredRootDependencies.length > 0) {
const plural = filteredRootDependencies.length > 1;
console.log(`
${chalk.whiteBright.bgYellow.bold(
'Webpack does not work with native dependencies.'
'Webpack does not work with native dependencies.',
)}
${chalk.bold(filteredRootDependencies.join(', '))} ${
plural ? 'are native dependencies' : 'is a native dependency'
} and should be installed inside of the "./release/app" folder.
First, uninstall the packages from "./package.json":
${chalk.whiteBright.bgGreen.bold('npm uninstall your-package')}
${chalk.bold(
'Then, instead of installing the package to the root "./package.json":'
'Then, instead of installing the package to the root "./package.json":',
)}
${chalk.whiteBright.bgRed.bold('npm install your-package')}
${chalk.bold('Install the package to "./release/app/package.json"')}
${chalk.whiteBright.bgGreen.bold(
'cd ./release/app && npm install your-package'
'cd ./release/app && npm install your-package',
)}
Read more about native dependencies at:
${chalk.bold(
'https://electron-react-boilerplate.js.org/docs/adding-dependencies/#module-structure'
'https://electron-react-boilerplate.js.org/docs/adding-dependencies/#module-structure',
)}
`);
process.exit(1);
Expand Down
4 changes: 2 additions & 2 deletions scripts/scripts/check-node-env.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export default function checkNodeEnv(expectedEnv) {
if (process.env.NODE_ENV !== expectedEnv) {
console.log(
chalk.whiteBright.bgRed.bold(
`"process.env.NODE_ENV" must be "${expectedEnv}" to use this webpack config`
)
`"process.env.NODE_ENV" must be "${expectedEnv}" to use this webpack config`,
),
);
process.exit(2);
}
Expand Down
4 changes: 2 additions & 2 deletions scripts/scripts/check-port-in-use.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ detectPort(port, (err, availablePort) => {
if (port !== String(availablePort)) {
throw new Error(
chalk.whiteBright.bgRed.bold(
`Port "${port}" on "localhost" is already in use. Please use another port. ex: PORT=4343 npm start`
)
`Port "${port}" on "localhost" is already in use. Please use another port. ex: PORT=4343 npm start`,
),
);
} else {
process.exit(0);
Expand Down
4 changes: 2 additions & 2 deletions scripts/scripts/copy-version-number.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const appPackageJsonPath = path.join(
__dirname,
'../../release',
'app',
'package.json'
'package.json',
);
const appPackageJson = require(appPackageJsonPath);

Expand All @@ -21,5 +21,5 @@ appPackageJson.version = rootPackageJson.version;
fs.writeFileSync(appPackageJsonPath, JSON.stringify(appPackageJson, null, 2));

console.log(
`Copied version ${appPackageJson.version} from root package.json to release/app/package.json`
`Copied version ${appPackageJson.version} from root package.json to release/app/package.json`,
);
2 changes: 1 addition & 1 deletion scripts/scripts/notarize.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ exports.default = async function notarizeMacos(context) {

if (!('APPLE_ID' in process.env && 'APPLE_ID_PASS' in process.env)) {
console.warn(
'Skipping notarizing step. APPLE_ID and APPLE_ID_PASS env variables must be set'
'Skipping notarizing step. APPLE_ID and APPLE_ID_PASS env variables must be set',
);
return;
}
Expand Down
2 changes: 2 additions & 0 deletions src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import HuggingChat from '../providers/huggingchat';
import OobaBooga from '../providers/oobabooga';
import OpenAi from '../providers/openai';
import Perplexity from '../providers/perplexity';
import YouChat from '../providers/you';
import PerplexityLlama from '../providers/perplexity-llama.js';
import Phind from '../providers/phind';
import Smol from '../providers/smol';
Expand All @@ -20,6 +21,7 @@ export const allProviders = [
// Claude, // Can't Verify
Claude2,
Together,
YouChat,
Perplexity,
// Phind, // Broken
PerplexityLlama,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export function isValidShortcut(...keys: (string | string[])[]): boolean {
let shiftCount = 0; // Track the count of shift keys

const shortcut = keys.flatMap((value) =>
typeof value === 'string' ? value.split('+') : value.flat()
typeof value === 'string' ? value.split('+') : value.flat(),
);

shortcut.forEach((key) => {
Expand Down
10 changes: 5 additions & 5 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const installExtensions = async () => {
return installer
.default(
extensions.map((name) => installer[name]),
forceDownload
forceDownload,
)
.catch(console.log);
};
Expand Down Expand Up @@ -261,11 +261,11 @@ app
*/
const quickOpenDefaultShortcut = store.get(
'quickOpenShortcut',
'CommandOrControl+Shift+G'
'CommandOrControl+Shift+G',
) as string;

console.log(quickOpenDefaultShortcut);
console.log(isValidShortcut(quickOpenDefaultShortcut))
console.log(isValidShortcut(quickOpenDefaultShortcut));
/*
* Update the global shortcut to one provided
*/
Expand All @@ -288,7 +288,7 @@ function quickOpen() {
mainWindow.focus();
// put focus on the #prompt textarea if it is at all present on the document inside mainWindow
mainWindow.webContents.executeJavaScript(
`{document.querySelector('#prompt')?.focus()}`
`{document.querySelector('#prompt')?.focus()}`,
);
}
}
Expand Down Expand Up @@ -327,7 +327,7 @@ app.on('ready', () => {
(newValue: unknown, oldValue: unknown) => {
if (newValue === oldValue) return;
changeGlobalShortcut(newValue as string);
}
},
);
});

Expand Down
8 changes: 4 additions & 4 deletions src/main/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export default class MenuBuilder {
label: 'Documentation',
click() {
shell.openExternal(
'https://github.com/electron/electron/tree/main/docs#readme'
'https://github.com/electron/electron/tree/main/docs#readme',
);
},
},
Expand Down Expand Up @@ -233,7 +233,7 @@ export default class MenuBuilder {
accelerator: 'F11',
click: () => {
this.mainWindow.setFullScreen(
!this.mainWindow.isFullScreen()
!this.mainWindow.isFullScreen(),
);
},
},
Expand All @@ -251,7 +251,7 @@ export default class MenuBuilder {
accelerator: 'F11',
click: () => {
this.mainWindow.setFullScreen(
!this.mainWindow.isFullScreen()
!this.mainWindow.isFullScreen(),
);
},
},
Expand All @@ -270,7 +270,7 @@ export default class MenuBuilder {
label: 'Documentation',
click() {
shell.openExternal(
'https://github.com/electron/electron/tree/main/docs#readme'
'https://github.com/electron/electron/tree/main/docs#readme',
);
},
},
Expand Down
2 changes: 1 addition & 1 deletion src/providers/oobabooga.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class OobaBooga extends Provider {
} else {
const inputEvent = new Event('input', { bubbles: true });
inputElement.value = \`${this.templateFn(
input
input,
)}\`; // must be escaped backticks to support multiline
inputElement.dispatchEvent(inputEvent);
}
Expand Down
50 changes: 50 additions & 0 deletions src/providers/you.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const Provider = require('./provider');

class YouChat extends Provider {
static webviewId = 'webviewYoudotcom';
static fullName = 'You.com Chat';
static shortName = 'You.com';

static url = 'https://you.com/chat/';

static handleInput(input) {
const fullName = this.fullName;
this.getWebview().executeJavaScript(`{
var inputElement = document.querySelector('textarea[placeholder*="Ask me anything..."]'); // can be "Ask anything" or "Ask follow-up"
if (!inputElement) {
console.error('inputElement for ${fullName} doesnt exist, have you logged in or are you on the right page?')
} else {
var nativeTextAreaValueSetter = Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype, "value").set;
nativeTextAreaValueSetter.call(inputElement, \`${input}\`);
var event = new Event('input', { bubbles: true});
inputElement.dispatchEvent(event);
}
}`);
}

static handleSubmit() {
this.getWebview().executeJavaScript(`{
var buttons = Array.from(document.querySelectorAll('button[type="submit"]'));
buttons[0].click();
}`);
}
static handleCss() {
// this.getWebview().addEventListener('dom-ready', () => {
// // Hide the "Try asking" segment
// setTimeout(() => {
// this.getWebview().insertCSS(`
// .mt-lg {
// display: none;
// }
// `);
// }, 100);
// });
}

static isEnabled() {
return window.electron.electronStore.get(`${this.webviewId}Enabled`, false);
}
}

module.exports = YouChat;
Loading

0 comments on commit f67cfec

Please sign in to comment.