// 商品对比
server.prompt(
"product_comparison",
"对比两个商品的优劣",
[
{ name: "product1", description: "第一个商品SKU", required: true },
{ name: "product2", description: "第二个商品SKU", required: true }
],
async ({ product1, product2 }) => {
const p1 = await db.products.findBySku(product1);
const p2 = await db.products.findBySku(product2);
return {
messages: [{
role: "user",
content: {
type: "text",
text: `请对比以下两个商品:\n\n商品1: ${JSON.stringify(p1)}\n\n商品2: ${JSON.stringify(p2)}\n\n从价格、功能、评价三个维度分析各自优劣。`
}
}]
};
}
);
// 订单摘要
server.prompt(
"order_summary",
"生成用户订单的摘要报告",
[
{ name: "userId", description: "用户ID", required: true },
{ name: "period", description: "时间范围(如 last_month)", required: false }
],
async ({ userId, period = "last_month" }) => {
const orders = await db.orders.getByUser(userId, period);
return {
messages: [{
role: "user",
content: {
type: "text",
text: `以下是用户最近的订单数据:\n\n${JSON.stringify(orders, null, 2)}\n\n请生成一份简洁的消费摘要,包括总消费、常购品类、消费趋势。`
}
}]
};
}
);