Skip to content

Commit

Permalink
feat: support gemini (#21)
Browse files Browse the repository at this point in the history
* feat: support gemini

* fix: formatting
  • Loading branch information
rpidanny authored Jun 9, 2024
1 parent a57d818 commit 3166ed8
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 6 deletions.
10 changes: 5 additions & 5 deletions apps/chrome-extension/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

The LLM Prompt Templates Chrome Extension is a powerful tool that offers quick access to a collection of reusable prompt templates for various LLMs. With this extension installed, you can easily insert effective and relevant prompts with just a few clicks.

| LLM | Status |
| ----------------------------------- | -------- |
| [ChatGPT](https://chat.openai.com/) | 🎉 Done |
| [Bard](https://bard.google.com/) | 🎉 Done |
| Bing | 📝 To-do |
| LLM | Status |
| ------------------------------------------- | -------- |
| [ChatGPT](https://chat.openai.com/) | 🎉 Done |
| [Gemini (Bard)](https://gemini.google.com/) | 🎉 Done |
| Bing | 📝 To-do |

## Installation

Expand Down
11 changes: 11 additions & 0 deletions apps/chrome-extension/src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,18 @@
"css": ["bard.content.styles.css"],
"run_at": "document_end"
},
{
"matches": ["https://gemini.google.com/*"],
"js": ["geminiContentScript.bundle.js"],
"css": ["gemini.content.styles.css"],
"run_at": "document_end"
},
{
"matches": ["<all_urls>"],
"exclude_matches": [
"https://chat.openai.com/*",
"https://bard.google.com/*",
"https://gemini.google.com/*",
"https://chatgpt.com/*"
],
"js": ["defaultContentScript.bundle.js"]
Expand All @@ -49,6 +56,10 @@
{
"resources": ["bard.content.styles.css"],
"matches": ["https://bard.google.com/*"]
},
{
"resources": ["gemini.content.styles.css"],
"matches": ["https://gemini.google.com/*"]
}
],
"permissions": ["storage"]
Expand Down
Empty file.
Empty file.
16 changes: 16 additions & 0 deletions apps/chrome-extension/src/pages/Content/llms/gemini/gemini.dom.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { IPrompt } from '@rpidanny/llm-prompt-templates';

import { LLMDom } from '../llm.dom';

export class GeminiDom extends LLMDom {
protected name = 'Gemini';
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';
}
}
9 changes: 9 additions & 0 deletions apps/chrome-extension/src/pages/Content/llms/gemini/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { GeminiDom } from './gemini.dom';

function init() {
const geminiDom = new GeminiDom();

setTimeout(geminiDom.init, 1000);
}

init();
18 changes: 18 additions & 0 deletions apps/chrome-extension/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ module.exports = composePlugins(withNx(), withReact(), (config) => {
'bard',
'index.ts'
),
geminiContentScript: path.join(
config.context,
'src',
'pages',
'Content',
'llms',
'gemini',
'index.ts'
),
defaultContentScript: path.join(
config.context,
'src',
Expand Down Expand Up @@ -198,6 +207,15 @@ module.exports = composePlugins(withNx(), withReact(), (config) => {
},
],
}),
new CopyWebpackPlugin({
patterns: [
{
from: 'src/pages/Content/llms/gemini/gemini.content.styles.css',
to: path.join(config.output.path),
force: true,
},
],
}),
new HtmlWebpackPlugin({
template: path.join(
config.context,
Expand Down
2 changes: 1 addition & 1 deletion libs/llm-prompt-templates/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
"url": "https://github.com/rpidanny/llm-prompt-templates.git",
"directory": "libs/llm-prompt-templates"
}
}
}

0 comments on commit 3166ed8

Please sign in to comment.