import * as weave from 'weave';
import OpenAI from 'openai';
async function main() {
// weave.init はクライアントインスタンスを返します
const weaveClient = await weave.init('wandb/prompt-examples');
const systemPrompt = new weave.StringPrompt({
content: 'You speak like a pirate',
name: 'your-prompt',
description: 'A helpful description of your prompt',
});
// init から返されたクライアントを使用します
await weaveClient.publish(systemPrompt, 'pirate_prompt');
// OpenAI クライアントをラップして Weave で Call をトラッキングします
const client = weave.wrapOpenAI(new OpenAI());
const response = await client.chat.completions.create({
model: "gpt-4o",
messages: [
{
role: "system",
content: systemPrompt.content
},
{
role: "user",
content: "Explain general relativity in one paragraph."
}
],
});
}
main();