import { useState } from 'react' import { Plus, Trash2, Play, Loader2, Save } from 'lucide-react' import { useStore, useActiveProject } from '../../store/useStore' import { BUILTIN_TOOLS, executeToolCall, resolveTools } from '../../lib/tools' import { Btn, Field, Section, inputCls } from '../ui' const SAMPLE_ARGS = { web_search: { query: '大型語言模型' }, wikipedia_article: { title: 'Taipei', lang: 'en' }, fetch_url: { url: 'https://example.com' }, get_weather: { city: 'Taipei', days: 2 }, currency_convert: { amount: 100, from: 'USD', to: 'TWD' }, calculate: { expression: '(2+3)^2 * sqrt(16)' }, get_current_time: { timezone: 'Asia/Taipei' }, search_github: { query: 'llm agent', limit: 3 }, search_hackernews: { query: 'LLM', recent: true }, search_papers: { query: 'retrieval augmented generation' }, search_books: { query: '三體' }, save_note: { title: '測試筆記', content: '由工具測試寫入' }, read_notes: {}, } function Tester({ name, defaultArgs }) { const project = useActiveProject() const customTools = useStore((s) => s.customTools) const [args, setArgs] = useState(JSON.stringify(defaultArgs || {}, null, 0)) const [out, setOut] = useState('') const [busy, setBusy] = useState(false) const run = async () => { setBusy(true); setOut('') const st = useStore.getState() const tools = resolveTools([name], customTools) const res = await executeToolCall( { function: { name, arguments: args } }, tools, { settings: st.settings, project, addNote: st.addNote, signal: undefined }, ) setOut(res); setBusy(false) } return (
{out}}
{err}
}全部是真的,直接從瀏覽器呼叫公開 API。展開可測試。要給哪個 Agent 用,到「Agent」頁勾選。
{t.description}
設定 endpoint 就能真的執行:把任何允許 CORS 的 API 變成 Agent 工具。
{customTools.map((t) => ( form?.name === t.name ?{t.description} · {t.method} {t.endpoint || '(未設定 endpoint)'}