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 falcon 180b #236

Merged
merged 1 commit into from
Sep 6, 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
2 changes: 2 additions & 0 deletions src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import OpenRouter from '../providers/openrouter';
import Poe from 'providers/poe';
import InflectionPi from 'providers/inflection';
import StableChat from 'providers/stablechat';
import Falcon180BSpace from 'providers/falcon180bspace';

export const allProviders = [
OpenAi,
Expand All @@ -31,6 +32,7 @@ export const allProviders = [
InflectionPi,
HuggingChat,
StableChat,
Falcon180BSpace,
OobaBooga,
Together,
OpenRouter,
Expand Down
71 changes: 71 additions & 0 deletions src/providers/falcon180bspace.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
const Provider = require('./provider');

class Falcon180BSpace extends Provider {
static webviewId = 'webviewFalcon180BSpace';
static fullName = 'Falcon 180B (HF Space, temporary)';
static shortName = 'Falcon180BSpace';

static url = 'https://tiiuae-falcon-180b-demo.hf.space/?__theme=dark';

static handleInput(input) {
this.getWebview().executeJavaScript(`{
var inputElement = document.querySelector('textarea[data-testid="textbox"]');
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('button.primary');
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(`
div[data-testid="markdown"] {
display: none;
}
#banner-image {
height: 30px;
}
`);
}, 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 = Falcon180BSpace;
Loading