Add warning comment if default calculation is used

This commit is contained in:
Theodore Li
2026-02-13 11:16:17 -08:00
parent c12e92c807
commit 2a36143f46
5 changed files with 17 additions and 0 deletions

View File

@@ -1,6 +1,9 @@
import { createLogger } from '@sim/logger'
import type { ExaAnswerParams, ExaAnswerResponse } from '@/tools/exa/types'
import type { ToolConfig } from '@/tools/types'
const logger = createLogger('ExaAnswerTool')
export const answerTool: ToolConfig<ExaAnswerParams, ExaAnswerResponse> = {
id: 'exa_answer',
name: 'Exa Answer',
@@ -39,6 +42,7 @@ export const answerTool: ToolConfig<ExaAnswerParams, ExaAnswerResponse> = {
return { cost: response.costDollars.total, metadata: { costDollars: response.costDollars } }
}
// Fallback: $5/1000 requests
logger.warn('Exa answer response missing costDollars, using fallback pricing')
return 0.005
},
},

View File

@@ -1,6 +1,9 @@
import { createLogger } from '@sim/logger'
import type { ExaFindSimilarLinksParams, ExaFindSimilarLinksResponse } from '@/tools/exa/types'
import type { ToolConfig } from '@/tools/types'
const logger = createLogger('ExaFindSimilarLinksTool')
export const findSimilarLinksTool: ToolConfig<
ExaFindSimilarLinksParams,
ExaFindSimilarLinksResponse
@@ -88,6 +91,7 @@ export const findSimilarLinksTool: ToolConfig<
return { cost: response.costDollars.total, metadata: { costDollars: response.costDollars } }
}
// Fallback: $5/1000 (1-25 results) or $25/1000 (26-100 results)
logger.warn('Exa find_similar_links response missing costDollars, using fallback pricing')
const resultCount = response.similarLinks?.length || 0
return resultCount <= 25 ? 0.005 : 0.025
},

View File

@@ -1,6 +1,9 @@
import { createLogger } from '@sim/logger'
import type { ExaGetContentsParams, ExaGetContentsResponse } from '@/tools/exa/types'
import type { ToolConfig } from '@/tools/types'
const logger = createLogger('ExaGetContentsTool')
export const getContentsTool: ToolConfig<ExaGetContentsParams, ExaGetContentsResponse> = {
id: 'exa_get_contents',
name: 'Exa Get Contents',
@@ -73,6 +76,7 @@ export const getContentsTool: ToolConfig<ExaGetContentsParams, ExaGetContentsRes
return { cost: response.costDollars.total, metadata: { costDollars: response.costDollars } }
}
// Fallback: $1/1000 pages
logger.warn('Exa get_contents response missing costDollars, using fallback pricing')
return (response.results?.length || 0) * 0.001
},
},

View File

@@ -47,6 +47,7 @@ export const researchTool: ToolConfig<ExaResearchParams, ExaResearchResponse> =
}
// Fallback to estimate if cost not available
logger.warn('Exa research response missing costDollars, using fallback pricing')
const model = params.model || 'exa-research'
return model === 'exa-research-pro' ? 0.055 : 0.03
},

View File

@@ -1,6 +1,9 @@
import { createLogger } from '@sim/logger'
import type { ExaSearchParams, ExaSearchResponse } from '@/tools/exa/types'
import type { ToolConfig } from '@/tools/types'
const logger = createLogger('ExaSearchTool')
export const searchTool: ToolConfig<ExaSearchParams, ExaSearchResponse> = {
id: 'exa_search',
name: 'Exa Search',
@@ -99,6 +102,7 @@ export const searchTool: ToolConfig<ExaSearchParams, ExaSearchResponse> = {
}
// Fallback: estimate based on search type and result count
logger.warn('Exa search response missing costDollars, using fallback pricing')
const isDeepSearch = params.type === 'neural'
if (isDeepSearch) {
return 0.015