How to add additional large language model websites that can be displayed as a web apps. There are already existing websites that are displayed as web apps.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
To add additional large language model (LLM) websites as web apps in the GodMode application, follow these steps. The existing implementation for providers like Bard and Bing can serve as templates.
1. Create a New Provider Class
Providers for different LLMs are implemented as JavaScript/TypeScript classes and extend the base Provider class defined in ./repos/GodMode/src/providers/provider.js.
Steps to Add a New Provider:
Create a New File for the Provider:
Add the new provider file in the src/providers directory.
Use an existing provider file (e.g., bard.js or bing.js) as a template.
Extend the Provider Class:
Your new provider must extend the Provider class and override its necessary static methods.
Define Properties and Methods:
webviewId: The unique ID for the webview element.
url: The LLM's website URL.
handleInput(input): Code to set the user input into the LLM's input field.
handleSubmit(): Code to simulate the submission of the input.
handleCss(): (Optional) Inject custom CSS to modify the web app's UI.
getUserAgent(): (Optional) Set a custom user agent string for compatibility.
Example Provider Template:
Here’s a minimal example for a hypothetical LLM named ExampleAI:
javascript
const Provider = require('./provider');
class ExampleAI extends Provider {
static webviewId = 'webviewEXAMPLEAI';
static fullName = 'Example AI';
static shortName = 'ExampleAI';
static url = 'https://exampleai.com';
static handleInput(input) {
this.getWebview().executeJavaScript(`{
const inputElement = document.querySelector('#input-field'); // Replace with actual input field selector
if (inputElement) {
const inputEvent = new Event('input', { bubbles: true });
inputElement.value = \`${input}\`; // Escape backticks for multiline inputs
inputElement.dispatchEvent(inputEvent);
}
}`);
}
static handleSubmit() {
this.getWebview().executeJavaScript(`{
const submitButton = document.querySelector('#submit-button'); // Replace with actual submit button selector
if (submitButton) {
submitButton.click();
}
}`);
}
static handleCss() {
this.getWebview().addEventListener('dom-ready', () => {
this.getWebview().insertCSS(`
/* Add custom CSS here */
body { font-family: Arial, sans-serif; }
`);
});
}
static getUserAgent() {
// Return a custom user agent if needed
return 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/[Redacted IPAddress] Safari/537.36';
}
static isEnabled() {
return window.electron.electronStore.get(`${this.webviewId}Enabled`, true);
}
}
module.exports = ExampleAI;
2. Register the New Provider
To make the new provider available in the app, it must be imported and registered.
Update the Main Application:
Locate the part of the code where existing providers are registered (e.g., renderer or main files).
Import the new provider and add it to the list of available providers.
Example:
In src/renderer/components/settings.tsx or a related file, add the new provider to the list:
javascript
import ExampleAI from '../providers/exampleai';
// Add ExampleAI to the list of providers
const providers = [
[Redacted Person],
Bing,
ExampleAI, // Add here
// Other providers...
];
3. Enable the Provider in the UI
The new provider needs to be toggleable in the UI. This is usually managed via settings or a context menu.
Update the UI Components:
Add an option to enable/disable the new provider in the settings menu or provider list.
Example:
In src/renderer/components/settings.tsx, add a toggle for the new provider:
Ensure the input and submission features are functional.
Test the custom CSS and user agent, if applicable.
Check enabling/disabling functionality.
5. Build and Package
Once the new provider is functional, build and package the app:
bash
npm run build
npm run package
Additional Notes:
Authentication: Make sure the new website handles authentication correctly. You may need to log in manually or handle session persistence.
Shadow DOM Handling: If the target website uses Shadow DOM (like Bing), selectors may require accessing shadow roots. See the Bing provider implementation for reference.
By following these steps, you can add support for additional LLM websites and display them as web apps in GodMode.