update api context

This commit is contained in:
duanfuxiang
2025-06-06 17:20:05 +08:00
parent 8732ebf30e
commit 5bdfc91042
6 changed files with 16 additions and 6 deletions

View File

@@ -143,6 +143,7 @@ export const infioDefaultModelInfo: ModelInfo = {
let infioModelsCache: Record<string, ModelInfo> | null = null;
async function fetchInfioModels(apiKey?: string): Promise<Record<string, ModelInfo>> {
console.log("fetchInfioModels apiKey", apiKey)
if (infioModelsCache) {
return infioModelsCache;
}
@@ -1606,6 +1607,7 @@ export const GetProviderModels = async (provider: ApiProvider, settings?: InfioS
switch (provider) {
case ApiProvider.Infio: {
const apiKey = settings?.infioProvider?.apiKey
console.log("apiKey", apiKey)
return await fetchInfioModels(apiKey)
}
case ApiProvider.OpenRouter:
@@ -1640,6 +1642,8 @@ export const GetProviderModelsWithSettings = async (provider: ApiProvider, setti
switch (provider) {
case ApiProvider.Infio: {
const apiKey = settings?.infioProvider?.apiKey
console.log("apiKey", apiKey)
console.log("settings", settings)
return await fetchInfioModels(apiKey)
}
case ApiProvider.OpenRouter:

View File

@@ -1,5 +1,6 @@
import { LLMModel } from '../types/llm/model'
import { ResponseUsage } from '../types/llm/response'
import { InfioSettings } from '../types/settings'
import { GetProviderModels } from './api'
@@ -7,11 +8,13 @@ import { GetProviderModels } from './api'
export const calculateLLMCost = async ({
model,
usage,
settings,
}: {
model: LLMModel
usage: ResponseUsage
settings?: InfioSettings
}): Promise<number | null> => {
const providerModels = await GetProviderModels(model.provider)
const providerModels = await GetProviderModels(model.provider, settings)
if (!providerModels) {
return null
}