File tree 3 files changed +20
-2
lines changed
3 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -244,7 +244,8 @@ onMessage(Messages.fetch_html, async ({ data }) => {
244
244
245
245
onMessage ( Messages . ai_explain , async ( { data } ) => {
246
246
const { word, text } = data
247
- const explain = await explainWord ( word , text , settings ( ) . openai . model )
247
+ const model = settings ( ) . openai . model === "custom" ? settings ( ) . openai . customModel : settings ( ) . openai . model
248
+ const explain = await explainWord ( word , text , model )
248
249
return explain
249
250
} )
250
251
Original file line number Diff line number Diff line change @@ -45,7 +45,8 @@ export const DEFAULT_SETTINGS = {
45
45
apiKey : '' ,
46
46
apiProxy : 'https://api.openai.com/v1/chat/completions' ,
47
47
model : 'gpt-3.5-turbo' ,
48
- prompt : 'explain the word ${word} in the sentence "${context}" with grade 2 English words'
48
+ prompt : 'explain the word ${word} in the sentence "${context}" with grade 2 English words' ,
49
+ customModel : ''
49
50
} ,
50
51
githubToken : '' ,
51
52
githubGistId : ''
Original file line number Diff line number Diff line change @@ -26,6 +26,12 @@ export const OpenAISetting = () => {
26
26
setSetting ( 'openai' , { ...openai , model : target . value } )
27
27
}
28
28
29
+ const onCustomModelChange = ( e : Event ) => {
30
+ const target = e . target as HTMLInputElement
31
+ const openai = settings ( ) . openai
32
+ setSetting ( 'openai' , { ...openai , customModel : target . value } )
33
+ }
34
+
29
35
return (
30
36
< Show when = { settings ( ) . dictTabs . openai } >
31
37
< section class = "section" >
@@ -43,8 +49,18 @@ export const OpenAISetting = () => {
43
49
< option value = "gpt-4" > gpt-4</ option >
44
50
< option value = "gpt-4o" > gpt-4o</ option >
45
51
< option value = "gpt-4o-mini" > gpt-4o-mini</ option >
52
+ < option value = "custom" > custom model</ option >
46
53
</ select >
47
54
</ div >
55
+ { settings ( ) . openai . model === 'custom' && (
56
+ < input
57
+ type = "text"
58
+ placeholder = "input custom model"
59
+ class = "input input-bordered input-sm w-full max-w-xs text-xs"
60
+ value = { settings ( ) . openai . customModel }
61
+ oninput = { onCustomModelChange }
62
+ />
63
+ ) }
48
64
< textarea
49
65
placeholder = "input your openai apikey"
50
66
class = "textarea textarea-bordered textarea-lg w-full h-24 max-w-xs text-xs leading-5"
You can’t perform that action at this time.
0 commit comments