-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprovider-cohere.ts
More file actions
19 lines (18 loc) · 916 Bytes
/
provider-cohere.ts
File metadata and controls
19 lines (18 loc) · 916 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { createEval2Otel, convertCohereToEval2Otel } from '../src';
import * as fs from 'fs';
import * as readline from 'readline';
// Usage: ts-node examples/provider-cohere.ts <cohere.jsonl>
async function main() {
const file = process.argv[2]; if (!file) { console.error('Usage: ts-node examples/provider-cohere.ts <cohere.jsonl>'); process.exit(1); }
const inst = createEval2Otel({ serviceName: 'cohere-replay', useSdk: false } as any);
const rl = readline.createInterface({ input: fs.createReadStream(file), crlfDelay: Infinity });
for await (const line of rl) {
const obj = JSON.parse(line);
const start = obj.startTime ?? Date.now();
const end = obj.endTime ?? (start + 1);
const evalRes = convertCohereToEval2Otel(obj.request, obj.response, start, end);
inst.processEvaluation(evalRes);
}
await inst.shutdown();
}
main().catch((e) => { console.error(e); process.exit(1); });