MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / getPoeModels

Function getPoeModels

src/api/providers/fetchers/poe.ts:4–44  ·  view source on GitHub ↗
(apiKey?: string, baseURL?: string)

Source from the content-addressed store, hash-verified

2import { fetchPoeModels, getModels } from "ai-sdk-provider-poe/code"
3
4export async function getPoeModels(apiKey?: string, baseURL?: string): Promise<ModelRecord> {
5 try {
6 // fetchPoeModels populates the internal model store, then getModels()
7 // returns only code-capable models with camelCase fields.
8 await fetchPoeModels({ apiKey, baseURL })
9 const poeModels = getModels()
10 const models: ModelRecord = {}
11
12 for (const m of poeModels) {
13 // The library's applyReasoningFallbacks workaround sets
14 // supportsReasoningEffort to boolean `true` for any model that
15 // supports /v1/responses, even when the model has no actual
16 // reasoning capability (e.g. Haiku 3/3.5). Only trust the value
17 // when it is an explicit array of effort levels.
18 const effort = Array.isArray(m.supportsReasoningEffort) ? m.supportsReasoningEffort : undefined
19 const info: ModelInfo = {
20 contextWindow: m.contextWindow,
21 maxTokens: m.maxOutputTokens,
22 supportsImages: m.supportsImages,
23 supportsPromptCache: m.supportsPromptCache,
24 ...(m.supportsReasoningBudget && { supportsReasoningBudget: m.supportsReasoningBudget }),
25 ...(effort && {
26 supportsReasoningEffort: effort as ModelInfo["supportsReasoningEffort"],
27 }),
28 ...(m.pricing?.inputPerMillion != null && { inputPrice: m.pricing.inputPerMillion }),
29 ...(m.pricing?.outputPerMillion != null && { outputPrice: m.pricing.outputPerMillion }),
30 ...(m.pricing?.cacheReadPerMillion != null && { cacheReadsPrice: m.pricing.cacheReadPerMillion }),
31 ...(m.pricing?.cacheWritePerMillion != null && { cacheWritesPrice: m.pricing.cacheWritePerMillion }),
32 }
33
34 models[m.id] = info
35 }
36
37 return models
38 } catch (error) {
39 console.error(
40 `[Poe] Error fetching models: ${JSON.stringify(error, Object.getOwnPropertyNames(error as object), 2)}`,
41 )
42 return {}
43 }
44}

Callers 2

fetchModelsFromProviderFunction · 0.90
poe.spec.tsFile · 0.90

Calls 2

getModelsFunction · 0.85
errorMethod · 0.65

Tested by

no test coverage detected