import {
IGenerationMessage,
LiteralClient,
} from "@literalai/client";
import OpenAI from "openai";
const client = new LiteralClient();
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
async function main(file: ArrayBuffer) {
const thread = await client.thread({ name: 'Test Thread' }).upsert();
const run = await thread
.run({
threadId: thread.id,
name: "Tool Run",
})
.send();
const start = new Date();
const { text: transcribedText } = await openai.audio.transcriptions.create({
file: audioFile,
model: "whisper-1",
language: "en",
});
const end = new Date();
await run
.step({
type: "llm",
name: "whisper-1",
input,
output,
startTime: start.toISOString(),
endTime: end.toISOString(),
})
.send();
run.endTime = end.toISOString();
await run.send();
}