diff --git a/README.md b/README.md index c4fb769..2f67297 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,7 @@ Yes and no: | Vercel Chat | Simple open source chat wrapper for GPT3 API | | Local/GGML Models (via [OobaBooga](https://github.com/oobabooga/text-generation-webui)) | Requires Local Setup, see oobabooga docs | | Phind | Developer focused chat with [finetuned CodeLlama](https://www.phind.com/blog/code-llama-beats-gpt4) | +| Stable Chat | Chat interface for [Stable Beluga](https://stability.ai/blog/stable-beluga-large-instruction-fine-tuned-models), an open LLM by Stability AI. | | [OpenRouter](https://openrouter.ai) | Access GPT4, Claude, PaLM, and open source models | | OpenAssistant | Coming Soon — [Submit a PR](https://github.com/smol-ai/GodMode/issues/37)! | | Claude 1 | Requires Beta Access | diff --git a/package-lock.json b/package-lock.json index cafe3c3..38807ee 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "godmode", - "version": "1.0.0-beta.5", + "version": "1.0.0-beta.6", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "godmode", - "version": "1.0.0-beta.5", + "version": "1.0.0-beta.6", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/src/lib/constants.ts b/src/lib/constants.ts index d8bee82..247868a 100644 --- a/src/lib/constants.ts +++ b/src/lib/constants.ts @@ -16,6 +16,7 @@ import Vercel from 'providers/vercel'; import OpenRouter from '../providers/openrouter'; import Poe from 'providers/poe'; import InflectionPi from 'providers/inflection'; +import StableChat from 'providers/stablechat'; export const allProviders = [ OpenAi, @@ -29,6 +30,7 @@ export const allProviders = [ Poe, InflectionPi, HuggingChat, + StableChat, OobaBooga, Together, OpenRouter, diff --git a/src/providers/stablechat.js b/src/providers/stablechat.js new file mode 100644 index 0000000..17886eb --- /dev/null +++ b/src/providers/stablechat.js @@ -0,0 +1,68 @@ +const Provider = require('./provider'); + +class StableChat extends Provider { + static webviewId = 'webviewStableChat'; + static fullName = 'Stable Chat (Stability AI)'; + static shortName = 'StableChat'; + + static url = 'https://chat.stability.ai'; + + static handleInput(input) { + this.getWebview().executeJavaScript(`{ + var inputElement = document.querySelector('textarea[placeholder="Type something here..."]'); + if (inputElement) { + 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 btn = document.querySelector('textarea[placeholder="Type something here..."] + button'); + if (btn) { + btn.focus(); + btn.disabled = false; + btn.click(); + } + }`); + } + static handleCss() { + // this.getWebview().addEventListener('dom-ready', () => { + // // Hide the "Try asking" segment + // setTimeout(() => { + // this.getWebview().insertCSS(` + // .mt-lg { + // display: none; + // } + // `); + // }, 100); + // }); + } + static handleDarkMode(isDarkMode) { + if (isDarkMode) { + this.getWebview().executeJavaScript(`{ + if(document.querySelector('html').dataset.theme === 'light'){ + document.querySelector('.menu > ul > div:nth-child(2) > button').click() + } + } + `); + } else { + this.getWebview().executeJavaScript(`{ + if(document.querySelector('html').dataset.theme === 'business'){ + document.querySelector('.menu > ul > div:nth-child(2) > button').click() + } + } + `); + } + } + + static isEnabled() { + return window.electron.electronStore.get(`${this.webviewId}Enabled`, false); + } +} + +module.exports = StableChat;