feat: custom bot for poe.com (#189)

This commit is contained in:
josc146
2023-04-21 16:36:17 +08:00
parent b11e5ce6b7
commit 4cc2b91bdd
3 changed files with 37 additions and 7 deletions
+14 -6
View File
@@ -120,12 +120,20 @@ Browser.runtime.onConnect.addListener((port) => {
} else if (githubThirdPartyApiModelKeys.includes(session.modelName)) {
await generateAnswersWithWaylaidwandererApi(port, session.question, session)
} else if (poeWebModelKeys.includes(session.modelName)) {
await generateAnswersWithPoeWebApi(
port,
session.question,
session,
Models[session.modelName].value,
)
if (session.modelName === 'poeAiWebCustom')
await generateAnswersWithPoeWebApi(
port,
session.question,
session,
config.poeCustomBotName,
)
else
await generateAnswersWithPoeWebApi(
port,
session.question,
session,
Models[session.modelName].value,
)
}
} catch (err) {
console.error(err)
+8
View File
@@ -26,6 +26,7 @@ export const Models = {
customModel: { value: '', desc: 'Custom Model' },
azureOpenAi: { value: '', desc: 'ChatGPT (Azure)' },
waylaidwandererApi: { value: '', desc: 'Waylaidwanderer API (Github)' },
poeAiWebCustom: { value: '', desc: 'Poe AI (Web, Custom)' },
poeAiWebChatGpt: { value: 'chatgpt', desc: 'Poe AI (Web, ChatGPT)' },
poeAiWebDragonfly: { value: 'dragonfly', desc: 'Poe AI (Web, Dragonfly)' },
}
@@ -42,6 +43,7 @@ export const poeWebModelKeys = [
'poeAiWebGPT4',
'poeAiWebClaudePlus',
'poeAiWebClaude',
'poeAiWebCustom',
'poeAiWebChatGpt',
'poeAiWebDragonfly',
]
@@ -90,6 +92,8 @@ export const defaultConfig = {
azureEndpoint: '',
azureDeploymentName: '',
poeCustomBotName: '',
/** @type {keyof ModelMode}*/
modelMode: 'balanced',
@@ -182,6 +186,10 @@ export function isUsingCustomModel(configOrSession) {
return customApiModelKeys.includes(configOrSession.modelName)
}
export function isUsingCustomNameOnlyModel(configOrSession) {
return configOrSession.modelName === 'poeAiWebCustom'
}
export function isUsingAzureOpenAi(configOrSession) {
return azureOpenAiApiModelKeys.includes(configOrSession.modelName)
}
+15 -1
View File
@@ -7,6 +7,7 @@ import {
isUsingApiKey,
isUsingAzureOpenAi,
isUsingCustomModel,
isUsingCustomNameOnlyModel,
isUsingGithubThirdPartyApi,
isUsingMultiModeModel,
ModelMode,
@@ -90,7 +91,8 @@ function GeneralPart({ config, updateConfig }) {
isUsingApiKey(config) ||
isUsingMultiModeModel(config) ||
isUsingCustomModel(config) ||
isUsingAzureOpenAi(config)
isUsingAzureOpenAi(config) ||
isUsingCustomNameOnlyModel(config)
? 'width: 50%;'
: undefined
}
@@ -170,6 +172,18 @@ function GeneralPart({ config, updateConfig }) {
}}
/>
)}
{isUsingCustomNameOnlyModel(config) && (
<input
style="width: 50%;"
type="text"
value={config.poeCustomBotName}
placeholder={t('Bot Name')}
onChange={(e) => {
const customName = e.target.value
updateConfig({ poeCustomBotName: customName })
}}
/>
)}
{isUsingAzureOpenAi(config) && (
<input
type="password"