Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/cron/monitor-chutes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { runMonitor, round6 } from '../../models-monitor/lib.ts'
import { runMonitor, round6 } from '@models.dev/monitor'

export const config = { maxDuration: 60 }

Expand Down
2 changes: 1 addition & 1 deletion api/cron/monitor-openrouter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { runMonitor, round6 } from '../../models-monitor/lib.ts'
import { runMonitor, round6 } from '@models.dev/monitor'

export const config = { maxDuration: 60 }

Expand Down
9 changes: 9 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

239 changes: 0 additions & 239 deletions models-monitor/lib.ts

This file was deleted.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"helicone:generate": "bun ./packages/core/script/generate-helicone.ts",
"venice:generate": "bun ./packages/core/script/generate-venice.ts",
"vercel:generate": "bun ./packages/core/script/generate-vercel.ts",
"monitor:openrouter": "bun ./models-monitor/openrouter.ts",
"monitor:chutes": "bun ./models-monitor/chutes.ts"
"monitor:openrouter": "bun ./packages/monitor/providers/openrouter.ts",
"monitor:chutes": "bun ./packages/monitor/providers/chutes.ts"
},
"type": "module",
"workspaces": {
Expand Down
3 changes: 3 additions & 0 deletions packages/monitor/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { runMonitor } from './src/runner.ts'
export { round6 } from './src/helpers.ts'
export type { ModelEntry, MonitorOptions } from './src/types.ts'
11 changes: 11 additions & 0 deletions packages/monitor/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "@models.dev/monitor",
"version": "0.0.0",
"type": "module",
"main": "./index.ts",
"exports": { ".": "./index.ts" },
"private": true,
"dependencies": {
"@aws-sdk/client-s3": "*"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Usage: bun run monitor:chutes
*/

import { runMonitor, round6 } from './lib.ts'
import { runMonitor, round6 } from '@models.dev/monitor'

runMonitor({
name: 'Chutes',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Usage: bun run monitor:openrouter
*/

import { runMonitor, round6 } from './lib.ts'
import { runMonitor, round6 } from '@models.dev/monitor'

runMonitor({
name: 'OpenRouter',
Expand Down
26 changes: 26 additions & 0 deletions packages/monitor/src/helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
export function round6(n: number): number {
return Math.round(n * 1_000_000) / 1_000_000
}

export function formatPrice(p: number): string {
if (p === 0) return '$0'
return `$${p.toFixed(2)}`
}

export function priceArrow(oldVal: number, newVal: number): string {
if (newVal > oldVal) return '↑'
if (newVal < oldVal) return '↓'
return '→'
}

export function pctChange(oldVal: number, newVal: number): string {
if (oldVal === 0) return ''
const pct = ((newVal - oldVal) / oldVal) * 100
const sign = pct > 0 ? '+' : ''
return ` _(${sign}${Math.round(pct)}%)_`
}

export function truncateList(lines: string[], maxItems = 20, sep = '\n'): string {
if (lines.length <= maxItems) return lines.join(sep)
return lines.slice(0, maxItems).join(sep) + `${sep}_…and ${lines.length - maxItems} more_`
}
Loading