Skip to content

Commit f734b5e

Browse files
committed
feat: custom bot for poe.com (#189)
1 parent 6437746 commit f734b5e

File tree

3 files changed

+37
-7
lines changed

3 files changed

+37
-7
lines changed

src/background/index.mjs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,20 @@ Browser.runtime.onConnect.addListener((port) => {
120120
} else if (githubThirdPartyApiModelKeys.includes(session.modelName)) {
121121
await generateAnswersWithWaylaidwandererApi(port, session.question, session)
122122
} else if (poeWebModelKeys.includes(session.modelName)) {
123-
await generateAnswersWithPoeWebApi(
124-
port,
125-
session.question,
126-
session,
127-
Models[session.modelName].value,
128-
)
123+
if (session.modelName === 'poeAiWebCustom')
124+
await generateAnswersWithPoeWebApi(
125+
port,
126+
session.question,
127+
session,
128+
config.poeCustomBotName,
129+
)
130+
else
131+
await generateAnswersWithPoeWebApi(
132+
port,
133+
session.question,
134+
session,
135+
Models[session.modelName].value,
136+
)
129137
}
130138
} catch (err) {
131139
console.error(err)

src/config/index.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export const Models = {
2626
customModel: { value: '', desc: 'Custom Model' },
2727
azureOpenAi: { value: '', desc: 'ChatGPT (Azure)' },
2828
waylaidwandererApi: { value: '', desc: 'Waylaidwanderer API (Github)' },
29+
poeAiWebCustom: { value: '', desc: 'Poe AI (Web, Custom)' },
2930
poeAiWebChatGpt: { value: 'chatgpt', desc: 'Poe AI (Web, ChatGPT)' },
3031
poeAiWebDragonfly: { value: 'dragonfly', desc: 'Poe AI (Web, Dragonfly)' },
3132
}
@@ -42,6 +43,7 @@ export const poeWebModelKeys = [
4243
'poeAiWebGPT4',
4344
'poeAiWebClaudePlus',
4445
'poeAiWebClaude',
46+
'poeAiWebCustom',
4547
'poeAiWebChatGpt',
4648
'poeAiWebDragonfly',
4749
]
@@ -90,6 +92,8 @@ export const defaultConfig = {
9092
azureEndpoint: '',
9193
azureDeploymentName: '',
9294

95+
poeCustomBotName: '',
96+
9397
/** @type {keyof ModelMode}*/
9498
modelMode: 'balanced',
9599

@@ -182,6 +186,10 @@ export function isUsingCustomModel(configOrSession) {
182186
return customApiModelKeys.includes(configOrSession.modelName)
183187
}
184188

189+
export function isUsingCustomNameOnlyModel(configOrSession) {
190+
return configOrSession.modelName === 'poeAiWebCustom'
191+
}
192+
185193
export function isUsingAzureOpenAi(configOrSession) {
186194
return azureOpenAiApiModelKeys.includes(configOrSession.modelName)
187195
}

src/popup/Popup.jsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
isUsingApiKey,
88
isUsingAzureOpenAi,
99
isUsingCustomModel,
10+
isUsingCustomNameOnlyModel,
1011
isUsingGithubThirdPartyApi,
1112
isUsingMultiModeModel,
1213
ModelMode,
@@ -90,7 +91,8 @@ function GeneralPart({ config, updateConfig }) {
9091
isUsingApiKey(config) ||
9192
isUsingMultiModeModel(config) ||
9293
isUsingCustomModel(config) ||
93-
isUsingAzureOpenAi(config)
94+
isUsingAzureOpenAi(config) ||
95+
isUsingCustomNameOnlyModel(config)
9496
? 'width: 50%;'
9597
: undefined
9698
}
@@ -170,6 +172,18 @@ function GeneralPart({ config, updateConfig }) {
170172
}}
171173
/>
172174
)}
175+
{isUsingCustomNameOnlyModel(config) && (
176+
<input
177+
style="width: 50%;"
178+
type="text"
179+
value={config.poeCustomBotName}
180+
placeholder={t('Bot Name')}
181+
onChange={(e) => {
182+
const customName = e.target.value
183+
updateConfig({ poeCustomBotName: customName })
184+
}}
185+
/>
186+
)}
173187
{isUsingAzureOpenAi(config) && (
174188
<input
175189
type="password"

0 commit comments

Comments
 (0)