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 Inflection Pi #147

Merged
merged 8 commits into from
Aug 25, 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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Yes and no:
| Bard | Google's best. [Bard's updates are... flaky](https://twitter.com/swyx/status/1678495067663925248) |
| Llama2 via Perplexity | Can run [the latest CodeLlama 34B model](https://twitter.com/swyx/status/1694870138984747449?s=20)! try it! |
| Quora Poe | Added in #118 |
| Inflection Pi | Added in [#147](https://github.com/smol-ai/GodMode/pull/147/files) |
| You.com Chat | Added in #142 |
| HuggingChat | Offers Llama2, OpenAssistant |
| Vercel Chat | Added in #117 |
Expand Down
7 changes: 2 additions & 5 deletions release/app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Together from '../providers/together';
import Vercel from 'providers/vercel';
import OpenRouter from '../providers/openrouter';
import Poe from 'providers/poe';
import InflectionPi from 'providers/inflection';

export const allProviders = [
OpenAi,
Expand All @@ -31,5 +32,6 @@ export const allProviders = [
Smol,
Vercel,
Poe,
InflectionPi,
OpenRouter,
];
57 changes: 57 additions & 0 deletions src/providers/inflection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
const Provider = require('./provider');

class InflectionPi extends Provider {
static webviewId = 'webviewInflection';
static fullName = 'Inflection Pi';
static shortName = 'InflectionPi';

static url = 'https://pi.ai/talk/';

static handleInput(input) {
const fullName = this.fullName;
this.getWebview().executeJavaScript(`{
var inputElement = document.querySelector('.text-muted textarea');
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 does not work yet.. how to fix?
this.getWebview().executeJavaScript(`{

var inputElement = document.querySelector('.text-muted textarea');
const event = new KeyboardEvent('keydown', {
key: 'Enter',
view: window,
bubbles: true
});
inputElement.dispatchEvent(event);
}`);
}
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 = InflectionPi;
2 changes: 1 addition & 1 deletion src/providers/you.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class YouChat extends Provider {
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"
var inputElement = document.querySelector('textarea[placeholder*="Ask me anything..."]');
if (!inputElement) {
console.error('inputElement for ${fullName} doesnt exist, have you logged in or are you on the right page?')
} else {
Expand Down