-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
67 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 13 additions & 3 deletions
16
apps/chrome-extension/src/pages/Content/llms/bard/bard.dom.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,16 @@ | ||
import { ChatGPTDom } from '../chatgpt/chatgpt.dom'; | ||
import { IPrompt } from '@rpidanny/llm-prompt-templates'; | ||
|
||
export class BardDom extends ChatGPTDom { | ||
import { LLMDom } from '../llm.dom'; | ||
|
||
export class BardDom extends LLMDom { | ||
protected name = 'Bard'; | ||
protected textAreaSelector = 'div > textarea'; | ||
protected textAreaSelector = 'rich-textarea > .ql-editor'; | ||
|
||
protected usePrompt(prompt: IPrompt) { | ||
const textArea = this.getTextArea(); | ||
console.log('Setting text', prompt.content); | ||
textArea.focus(); | ||
textArea.textContent = prompt.content; | ||
textArea.style.height = textArea.scrollHeight + 'px'; | ||
} | ||
} |
27 changes: 2 additions & 25 deletions
27
apps/chrome-extension/src/pages/Content/llms/chatgpt/chatgpt.dom.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { BaseDom } from '../base.dom'; | ||
|
||
export abstract class LLMDom extends BaseDom { | ||
protected abstract name: string; | ||
protected abstract textAreaSelector: string; | ||
|
||
protected getTextArea(): HTMLTextAreaElement { | ||
const textArea = document.querySelector<HTMLTextAreaElement>( | ||
this.textAreaSelector | ||
); | ||
|
||
if (!textArea) { | ||
throw new Error('Could not find text area'); | ||
} | ||
|
||
return textArea; | ||
} | ||
|
||
protected addCustomTrigger() { | ||
this.getTextArea().addEventListener('input', (event) => { | ||
const input = event.target as HTMLTextAreaElement; | ||
const text = input.value; | ||
|
||
if (text === '/templates' || text === '/lpt') { | ||
this.showPrompts(); | ||
} else if (this.isPromptsViewOpen) { | ||
this.hidePrompts(); | ||
} | ||
}); | ||
} | ||
} |