update api context
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user