const workflow = baserun.trace(
async (question = "What is the capital of the US?") => {
const completion = await openai.chat.completions.create({
model: "gpt-4-1106-preview",
messages: [
{
role: "user",
content: question,
},
],
});
const content = completion.choices[0].message.content ?? "";
// Create the annotation
const annotation = baserun.annotate();
// Capture the user feedback as an annotation
annotation.feedback("annotate_feedback", {
score: 0.8,
metadata: { comment: "This is correct but not concise enough" },
});
annotation.checkIncludes("openai_chat.content", "Washington", content);
annotation.log("OpenAI Chat Results", {
result: content,
input: question,
});
// Make sure to submit the annotation
await annotation.submit();
},
);
await workflow();