AI SDK - 图瓦卢
在终端UI中运行本地或远程AI SDK代理. @ai-sdk/tui 页:1
全屏接口有流出,工具卡,批准,下标
渲染、回转和被钉住的提示.
设置
npm i ai @ai-sdk/tui @ai-sdk/openai zod
使用量
import { openai } from '@ai-sdk/openai';
import { runAgentTUI } from '@ai-sdk/tui';
import { ToolLoopAgent, tool } from 'ai';
import { z } from 'zod';
await runAgentTUI({
title: 'Weather Agent',
agent: new ToolLoopAgent({
model: openai('gpt-6-luna'),
instructions:
'You are a concise weather assistant.' +
'Use the weather tool when the user asks about weather, ' +
'then answer in markdown.',
tools: {
weather: tool({
description: 'Get the weather in a location',
inputSchema: z.object({ city: z.string() }),
execute({ city }) {
const weatherOptions = ['sunny', 'cloudy', 'rainy', 'snowy', 'windy'];
const weather =
weatherOptions[Math.floor(Math.random() * weatherOptions.length)];
return { city, temperature: 72, weather };
},
}),
},
toolApproval: {
weather: 'user-approval',
},
}),
});
见 AI SDK TUI 文档 更多信息.