Skip to content

Commit 2a36143

Browse files
author
Theodore Li
committed
Add warning comment if default calculation is used
1 parent c12e92c commit 2a36143

File tree

5 files changed

+17
-0
lines changed

5 files changed

+17
-0
lines changed

apps/sim/tools/exa/answer.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import { createLogger } from '@sim/logger'
12
import type { ExaAnswerParams, ExaAnswerResponse } from '@/tools/exa/types'
23
import type { ToolConfig } from '@/tools/types'
34

5+
const logger = createLogger('ExaAnswerTool')
6+
47
export const answerTool: ToolConfig<ExaAnswerParams, ExaAnswerResponse> = {
58
id: 'exa_answer',
69
name: 'Exa Answer',
@@ -39,6 +42,7 @@ export const answerTool: ToolConfig<ExaAnswerParams, ExaAnswerResponse> = {
3942
return { cost: response.costDollars.total, metadata: { costDollars: response.costDollars } }
4043
}
4144
// Fallback: $5/1000 requests
45+
logger.warn('Exa answer response missing costDollars, using fallback pricing')
4246
return 0.005
4347
},
4448
},

apps/sim/tools/exa/find_similar_links.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import { createLogger } from '@sim/logger'
12
import type { ExaFindSimilarLinksParams, ExaFindSimilarLinksResponse } from '@/tools/exa/types'
23
import type { ToolConfig } from '@/tools/types'
34

5+
const logger = createLogger('ExaFindSimilarLinksTool')
6+
47
export const findSimilarLinksTool: ToolConfig<
58
ExaFindSimilarLinksParams,
69
ExaFindSimilarLinksResponse
@@ -88,6 +91,7 @@ export const findSimilarLinksTool: ToolConfig<
8891
return { cost: response.costDollars.total, metadata: { costDollars: response.costDollars } }
8992
}
9093
// Fallback: $5/1000 (1-25 results) or $25/1000 (26-100 results)
94+
logger.warn('Exa find_similar_links response missing costDollars, using fallback pricing')
9195
const resultCount = response.similarLinks?.length || 0
9296
return resultCount <= 25 ? 0.005 : 0.025
9397
},

apps/sim/tools/exa/get_contents.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import { createLogger } from '@sim/logger'
12
import type { ExaGetContentsParams, ExaGetContentsResponse } from '@/tools/exa/types'
23
import type { ToolConfig } from '@/tools/types'
34

5+
const logger = createLogger('ExaGetContentsTool')
6+
47
export const getContentsTool: ToolConfig<ExaGetContentsParams, ExaGetContentsResponse> = {
58
id: 'exa_get_contents',
69
name: 'Exa Get Contents',
@@ -73,6 +76,7 @@ export const getContentsTool: ToolConfig<ExaGetContentsParams, ExaGetContentsRes
7376
return { cost: response.costDollars.total, metadata: { costDollars: response.costDollars } }
7477
}
7578
// Fallback: $1/1000 pages
79+
logger.warn('Exa get_contents response missing costDollars, using fallback pricing')
7680
return (response.results?.length || 0) * 0.001
7781
},
7882
},

apps/sim/tools/exa/research.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export const researchTool: ToolConfig<ExaResearchParams, ExaResearchResponse> =
4747
}
4848

4949
// Fallback to estimate if cost not available
50+
logger.warn('Exa research response missing costDollars, using fallback pricing')
5051
const model = params.model || 'exa-research'
5152
return model === 'exa-research-pro' ? 0.055 : 0.03
5253
},

apps/sim/tools/exa/search.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import { createLogger } from '@sim/logger'
12
import type { ExaSearchParams, ExaSearchResponse } from '@/tools/exa/types'
23
import type { ToolConfig } from '@/tools/types'
34

5+
const logger = createLogger('ExaSearchTool')
6+
47
export const searchTool: ToolConfig<ExaSearchParams, ExaSearchResponse> = {
58
id: 'exa_search',
69
name: 'Exa Search',
@@ -99,6 +102,7 @@ export const searchTool: ToolConfig<ExaSearchParams, ExaSearchResponse> = {
99102
}
100103

101104
// Fallback: estimate based on search type and result count
105+
logger.warn('Exa search response missing costDollars, using fallback pricing')
102106
const isDeepSearch = params.type === 'neural'
103107
if (isDeepSearch) {
104108
return 0.015

0 commit comments

Comments
 (0)