JavaScript bridge connection point between any page and OpenAI GPTs. It provides a way to create other extensions or use BridgeGPT library to interact with GPTs.
- Any page is a consumer of GPT, and another page contains a page with opened Chat-GPT where questions are asked.
- Using the JavaScript library (
BridgeGPT
) injected into any page by Chrome Extension, it can use the methodBridgeGPT.ask()
to communicate with another page with GPT. - For the end user provided a JavaScript accessible method
BridgeGPT.ask()
- Communication between tabs happens in one of the following ways.
- When asking GPT, optionally you can define a response schema which should be followed by GPT to form a response.
Spec of BridgeGPT
class BridgeGPT {
construct (gptUrl: string, responseSchema?: Object);
async ask<T>(question: string): Promise<T>;
}
Example of usage:
const responseSchema = {
"kpis": ["KPI 1", "KPI 2"],
};
const gpt = new BridgeGPT('https://chat.openai.com/g/g-bLDsE3HsD-goal-planner'); // or just https://chat.openai.com
const answer = gpt.ask('Grow on Twitter to 10k in 12 months');
Example of programmatical message in chat GPT:
const askGPT = (input) => {
const inputElement = document.querySelector('#prompt-textarea');
const inputEvent = new Event('input', { bubbles: true });
inputElement.value = \`${input}\`; // must be escaped backticks to support multiline
inputElement.dispatchEvent(inputEvent);
const btn = document.querySelector('button[data-testid="send-button"]');
btn.focus();
btn.disabled = false;
btn.click();
// How to wait for the response finalization and capture it?
};
- TypeScript
- Chrome extension template
- GitHub Actions for CI/CD pipelines.
- injected into the page BridgeGPT allows to interact from the page with desired GPT