Skip to content

Commit 88cc81b

Browse files
committed
feat: wire Poe model fetching into webview message handler
Add Poe to the router model fetching pipeline so models are fetched when a Poe API key is configured. Supports both automatic fetch on provider selection and manual refresh with key/baseUrl overrides.
1 parent d2a7418 commit 88cc81b

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

src/api/providers/poe.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,16 @@ export class PoeHandler extends BaseProvider implements SingleCompletionHandler
5454

5555
// Only pass temperature when the user explicitly configured it.
5656
let temperature: number | undefined = this.options.modelTemperature ?? undefined
57-
// Only pass maxOutputTokens when reasoning is active and the user configured it via the UI toggles.
58-
const maxOutputTokens: number | undefined =
59-
(useBudget || useEffort) && this.options.modelMaxTokens ? this.options.modelMaxTokens : undefined
57+
let maxOutputTokens: number | undefined
6058
const providerOptions: NonNullable<Parameters<typeof streamText>[0]["providerOptions"]> & {
6159
poe?: PoeScopedProviderOptions
6260
} = {}
6361

6462
if (useBudget) {
6563
const requestedBudget = this.options.modelMaxThinkingTokens ?? DEFAULT_THINKING_BUDGET
64+
// maxOutputTokens is the text-only budget; reasoningBudgetTokens is
65+
// separate, so total output = maxOutputTokens + reasoningBudgetTokens.
66+
maxOutputTokens = this.options.modelMaxTokens ?? Math.max(0, (info.maxTokens ?? 0) - requestedBudget)
6667
providerOptions.poe = {
6768
reasoningBudgetTokens: requestedBudget,
6869
}
@@ -78,6 +79,9 @@ export class PoeHandler extends BaseProvider implements SingleCompletionHandler
7879
reasoningEffort: effort,
7980
reasoningSummary: "auto",
8081
}
82+
if (this.options.modelMaxTokens) {
83+
maxOutputTokens = this.options.modelMaxTokens
84+
}
8185
}
8286

8387
let result

src/core/webview/webviewMessageHandler.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,7 @@ export const webviewMessageHandler = async (
955955
ollama: {},
956956
lmstudio: {},
957957
roo: {},
958+
poe: {},
958959
}
959960

960961
const safeGetModels = async (options: GetModelsOptions): Promise<ModelRecord> => {
@@ -1018,6 +1019,21 @@ export const webviewMessageHandler = async (
10181019
})
10191020
}
10201021

1022+
// Poe is conditional on apiKey
1023+
const poeApiKey = apiConfiguration.poeApiKey || message?.values?.poeApiKey
1024+
const poeBaseUrl = apiConfiguration.poeBaseUrl || message?.values?.poeBaseUrl
1025+
1026+
if (poeApiKey) {
1027+
if (message?.values?.poeApiKey || message?.values?.poeBaseUrl) {
1028+
await flushModels({ provider: "poe", apiKey: poeApiKey, baseUrl: poeBaseUrl }, true)
1029+
}
1030+
1031+
candidates.push({
1032+
key: "poe",
1033+
options: { provider: "poe", apiKey: poeApiKey, baseUrl: poeBaseUrl },
1034+
})
1035+
}
1036+
10211037
// Apply single provider filter if specified
10221038
const modelFetchPromises = providerFilter
10231039
? candidates.filter(({ key }) => key === providerFilter)

0 commit comments

Comments
 (0)