( stats: Stats, uniquePools: UniquePools )
| 58 | }; |
| 59 | |
| 60 | function generateRandomRecord( |
| 61 | stats: Stats, |
| 62 | uniquePools: UniquePools |
| 63 | ): { core: MicrodollarUsage; metadata: UsageMetaData } { |
| 64 | const id = randomUUID(); |
| 65 | const created_at = new Date().toISOString(); |
| 66 | const usageStats = stats.microdollar_usage; |
| 67 | const metaStats = stats.microdollar_usage_metadata; |
| 68 | |
| 69 | const core: MicrodollarUsage = { |
| 70 | id, |
| 71 | kilo_user_id: pickRandom(uniquePools.userIds, Math.random()), |
| 72 | organization_id: maybeNull(randomUUID(), usageStats.organization_id_null_pct), |
| 73 | provider: maybeNull( |
| 74 | randomString( |
| 75 | usageStats.provider_avg_len, |
| 76 | usageStats.provider_min_len, |
| 77 | usageStats.provider_max_len |
| 78 | ), |
| 79 | usageStats.provider_null_pct |
| 80 | ), |
| 81 | cost: randomInt(usageStats.cost_avg, usageStats.cost_min, usageStats.cost_max), |
| 82 | input_tokens: randomInt(usageStats.input_tokens_avg), |
| 83 | output_tokens: randomInt(usageStats.output_tokens_avg), |
| 84 | cache_write_tokens: randomInt(usageStats.cache_write_tokens_avg), |
| 85 | cache_hit_tokens: randomInt(usageStats.cache_hit_tokens_avg), |
| 86 | created_at, |
| 87 | model: maybeNull( |
| 88 | randomString(usageStats.model_avg_len, usageStats.model_min_len, usageStats.model_max_len), |
| 89 | usageStats.model_null_pct |
| 90 | ), |
| 91 | requested_model: maybeNull( |
| 92 | randomString( |
| 93 | usageStats.requested_model_avg_len, |
| 94 | usageStats.requested_model_min_len, |
| 95 | usageStats.requested_model_max_len |
| 96 | ), |
| 97 | usageStats.requested_model_null_pct |
| 98 | ), |
| 99 | cache_discount: maybeNull(randomInt(1000), usageStats.cache_discount_null_pct), |
| 100 | has_error: Math.random() < 0.01, |
| 101 | abuse_classification: 0, |
| 102 | inference_provider: maybeNull( |
| 103 | randomString( |
| 104 | usageStats.inference_provider_avg_len, |
| 105 | usageStats.inference_provider_min_len, |
| 106 | usageStats.inference_provider_max_len |
| 107 | ), |
| 108 | usageStats.inference_provider_null_pct |
| 109 | ), |
| 110 | project_id: maybeNull( |
| 111 | randomString( |
| 112 | usageStats.project_id_avg_len, |
| 113 | usageStats.project_id_min_len, |
| 114 | usageStats.project_id_max_len |
| 115 | ), |
| 116 | usageStats.project_id_null_pct |
| 117 | ), |
no test coverage detected