Skip to content

Commit

Permalink
Selection tool explain (#491)
Browse files Browse the repository at this point in the history
* hover selection tool Explain

* prompt
  • Loading branch information
zeddyemmy authored Aug 1, 2023
1 parent 1d10ea8 commit 9aa2adc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/config/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ export const defaultConfig = {
userLanguage: getNavigatorLanguage(),
apiModes: Object.keys(Models),
selectionTools: [
'explain',
'translate',
'translateToEn',
'translateToZh',
Expand All @@ -227,6 +228,7 @@ export const defaultConfig = {
'ask',
],
selectionToolsDesc: [
'Explain',
'Translate',
'Translate (To English)',
'Translate (Bidirectional)',
Expand Down
9 changes: 9 additions & 0 deletions src/content-script/selection-tools/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,19 @@ import {
Translate,
Braces,
Globe,
ChatTextFill,
} from 'react-bootstrap-icons'
import { getPreferredLanguage } from '../../config/language.mjs'

export const config = {
explain: {
icon: <ChatTextFill />,
label: 'Explain',
genPrompt: async (selection) => {
const preferredLanguage = await getPreferredLanguage()
return `Reply in ${preferredLanguage}.Explain the following:\n"${selection}"`
},
},
translate: {
icon: <Translate />,
label: 'Translate',
Expand Down

0 comments on commit 9aa2adc

Please sign in to comment.