tools.md 9.1 KB


更新时间: "2026-11-19"

版本: "2026.11.19.1"

平台工具(function calling)

这些函数名是被创建智能体的配置数据,不是 CocoBuddy 可直接调用的工具。只选老师明确要求的子集,不改写必需参数结构。

工具清单

界面中文名 → 函数名。序号用于老师点名时对齐,写进请求的是函数名。

中文名 函数名 必需参数 能干什么
图片生成 get_dalle_image prompt 按描述出图
语音生成 get_tts_voice prompt 把文字读成语音
口语评分 get_azure_speech prompt 按语音地址给朗读/口语评分
Bing搜索 get_bing_search prompt 联网检索资料
Google搜索 get_google_search prompt 联网检索(境外站点)
youtube视频搜索 get_youtube_video prompt 找 YouTube 视频
B站视频搜索 get_bilibili_video prompt 找 B 站视频
出题 set_problems prompt 按知识点/要求出题
解题 solve_problems prompt 讲解答题过程
网页爬取 scrape_with_playwright url 读取指定网页正文
图片搜索 get_image_search prompt 找图,每次只触发一次
获取时间 get_current_time 无 当前日期时间
天气查询 get_weather city 指定城市天气

当前不可见的工具:语音生成与天气查询对受限机构隐藏,Bing 搜索与 B 站视频搜索对港区隐藏(平台按机构/站点过滤)。老师点名了却不可见时,说“这个工具在当前机构/站点没有开通”,其余配置照常保存并列出待配项,不写进 functionNames 后声称已配置。

三个字段怎么算

functionNames、functionContents、tools 必须由同一份选择一次算出,不能分头手写:

// chosen 是老师选中的函数名数组,例如 ["get_bing_search","get_weather"]
const F = TOOLS.filter(t => chosen.includes(t.function.name));   // TOOLS 见下方完整定义

const functionNames = F.length ? F.map(x => x.function.name).join(",") + "," : "";
const functionContents = JSON.stringify(F);

// tools 基座按模型族决定,不一律 file_search
const base = /gpt/i.test(modelType)                 ? [{ type: "file_search" }, { type: "code_interpreter" }]
           : modelType.includes("own")              ? [{ type: "pdf_extracter" }, { type: "code_interpreter" }]
           :                                          [{ type: "file_search" }];
const tools = [...base, ...F];
  • functionNames 每项后带逗号("get_bing_search,get_weather,"),没有工具时为空字符串 ""。
  • functionContents 是被选工具的完整定义数组序列化后的字符串,没有工具时为 "[]",不含基座。
  • tools 是数组:基座在前,被选工具定义在后。模型标识含 gpt(如 open-gpt-5.4-mini)时基座是 file_search + code_interpreter;含 own 时是 pdf_extracter + code_interpreter;其余(豆包、DeepSeek、Gemini、千问、GLM 等)是单个 file_search。

教学场景怎么选

从老师说的话反推,只取需要的:

老师要的效果 选
查最新资料、时事、教材外的内容 Bing 搜索(港区用 Google 搜索)
让学生读某篇网页/新闻 网页爬取
课堂练习、随堂测、分层作业 出题;要讲解再加解题
英语/语文朗读打分 口语评分 + 语音生成
让助手“说”出来 语音生成(配合使用体验里的语音交互模式)
课文配图、板书插图 图片生成;要找现成图用图片搜索
视频资源推荐 B 站视频搜索(境外用 YouTube)
今天几号、这周进度、天气提醒 获取时间、天气查询

不要为了“功能全”全勾:工具越多,模型要多判断要不要调用,容易答非所问。老师没说就一个都不加。

服务器会改写定义,核对别逐字比

实测(2026-11-19,PUT 后回读):服务器会给每个工具描述追加“Singleton操作:每个API调用严格执行1次调用。”,并把 get_current_time 描述改写为“获取当前时间,支持不同时区……”,同时补一个可选 timezone 参数。

所以核对时只比:函数名集合与 functionNames 一致、原必需参数及其类型仍在、没有多出没选的工具。描述文字与新增可选参数属于平台规范化,不要因此循环 PUT。

完整定义

[
  {
    "type": "function",
    "function": {
      "name": "get_dalle_image",
      "description": "根据传入的prompt生成图片.",
      "parameters": {
        "type": "object",
        "properties": { "prompt": { "type": "string", "description": "Prompt of DALL-E 3." } },
        "required": ["prompt"]
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "get_tts_voice",
      "description": "根据传入的prompt生成语音.",
      "parameters": {
        "type": "object",
        "properties": { "prompt": { "type": "string", "description": "Prompt of Text-to-speech 1 HD." } },
        "required": ["prompt"]
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "get_azure_speech",
      "description": "根据语音url,生成语音的评分",
      "parameters": {
        "type": "object",
        "properties": { "prompt": { "type": "string", "description": "Prompt of speech." } },
        "required": ["prompt"]
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "get_bing_search",
      "description": "这是一个Bing搜索搜索工具,当我需要查询或者搜索时可以用到它",
      "parameters": {
        "type": "object",
        "properties": { "prompt": { "type": "string", "description": "这是搜索的参数" } },
        "required": ["prompt"]
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "get_google_search",
      "description": "这是一个Google搜索搜索工具,当我需要查询或者搜索时可以用到它",
      "parameters": {
        "type": "object",
        "properties": { "prompt": { "type": "string", "description": "这是搜索的参数" } },
        "required": ["prompt"]
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "get_youtube_video",
      "description": "这是一个Youtube视频搜索工具,当我需要查询或者搜索时可以用到它",
      "parameters": {
        "type": "object",
        "properties": { "prompt": { "type": "string", "description": "这是搜索的参数" } },
        "required": ["prompt"]
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "get_bilibili_video",
      "description": "这是一个bilibili视频搜索工具,当我需要查询或者搜索时可以用到它",
      "parameters": {
        "type": "object",
        "properties": { "prompt": { "type": "string", "description": "这是搜索的参数" } },
        "required": ["prompt"]
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "set_problems",
      "description": "这是一个出题工具,当我需要出题时可以用到它",
      "parameters": {
        "type": "object",
        "properties": { "prompt": { "type": "string", "description": "Prompt of qwen-math-plus." } },
        "required": ["prompt"]
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "solve_problems",
      "description": "这是一个解题工具,当我需要解题时可以用到它",
      "parameters": {
        "type": "object",
        "properties": { "prompt": { "type": "string", "description": "Prompt of qwen-math-plus." } },
        "required": ["prompt"]
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "scrape_with_playwright",
      "description": "这是一个网页爬取工具,当我需要网页爬取时可以用到它",
      "parameters": {
        "type": "object",
        "properties": { "url": { "type": "string", "description": "url of Crawl web page." } },
        "required": ["url"]
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "get_image_search",
      "description": "这是一个图片搜索工具,当我需要查询或者搜索时可以用到它,每次调用,只允许触发一次",
      "parameters": {
        "type": "object",
        "properties": { "prompt": { "type": "string", "description": "这是搜索的参数" } },
        "required": ["prompt"]
      }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "get_current_time",
      "description": "这是一个获取当前时间的工具,可以获取当前的日期和时间",
      "parameters": { "type": "object", "properties": {}, "required": [] }
    }
  },
  {
    "type": "function",
    "function": {
      "name": "get_weather",
      "description": "这是一个天气查询工具,可以查询指定城市的天气情况",
      "parameters": {
        "type": "object",
        "properties": { "city": { "type": "string", "description": "要查询天气的城市名称" } },
        "required": ["city"]
      }
    }
  }
]