Download src/utils/tools.js from shutajb/agent: direct link, hf CLI and curl.
- Browser
- Download file 1.11 kB
-
https://huggingface.co/spaces/shutajb/agent/resolve/main/src/utils/tools.js
- Command line
-
hf download hf://spaces/shutajb/agent/src/utils/tools.js
-
curl -L -o tools.js https://huggingface.co/spaces/shutajb/agent/resolve/main/src/utils/tools.js
1.11 kB
| // OpenAI 相容 tools 格式:{ type: 'function', function: { name, description, parameters } } | |
| // 少了 type/function 外層包裝,OpenRouter 等端點會直接回 400。 | |
| export const tools = [ | |
| { | |
| name: 'search_web', | |
| description: '即時搜尋網路資訊,回傳相關結果摘要', | |
| parameters: { | |
| type: 'object', | |
| properties: { | |
| query: { type: 'string', description: '要搜尋的關鍵字或問題' }, | |
| }, | |
| required: ['query'], | |
| }, | |
| }, | |
| { | |
| name: 'calculate', | |
| description: '計算四則運算表達式,只支援數字與 + - * / ( ) . %', | |
| parameters: { | |
| type: 'object', | |
| properties: { | |
| expression: { type: 'string', description: '運算式,例如 (2+3)*4' }, | |
| }, | |
| required: ['expression'], | |
| }, | |
| }, | |
| ] | |
| /** 把內部工具定義轉成 OpenAI 相容格式 */ | |
| export function toOpenAITools(list) { | |
| return (list || []).map((t) => ({ | |
| type: 'function', | |
| function: { | |
| name: t.name, | |
| description: t.description || '', | |
| parameters: t.parameters || { type: 'object', properties: {} }, | |
| }, | |
| })) | |
| } | |