classToolLabelEnum(Enum): SEARCH ='search' IMAGE ='image' VIDEOS ='videos' WEATHER ='weather' FINANCE ='finance' DESIGN ='design' TRAVEL ='travel' SOCIAL ='social' NEWS ='news' MEDICAL ='medical' PRODUCTIVITY ='productivity' EDUCATION ='education' BUSINESS ='business' ENTERTAINMENT ='entertainment' UTILITIES ='utilities' OTHER ='other'
确保该文件路径位于 /tools 目录,完整的路径如下:
plugins:tools: - "google.yaml"
其中 google.yaml 文件需要使用其在插件项目的绝对路径。
补全第三方服务凭据
为了便于开发,选择采用第三方服务 SerpApi 所提供的 Google Search API 。 SerpApi 要求填写一个 API Key 才能使用,因此需要在 yaml 文件内添加 credentials_for_provider 字段。
完整代码如下:
identity:author:Difyname:googlelabel:en_US:Googlezh_Hans:Googlept_BR:Googledescription:en_US:Googlezh_Hans:GoogleSearchpt_BR:Googleicon:icon.svgtags: - searchcredentials_for_provider:#添加 credentials_for_provider 字段serpapi_api_key:type:secret-inputrequired:truelabel:en_US:SerpApi API keyzh_Hans:SerpApi API keyplaceholder:en_US:Please input your SerpApi API keyzh_Hans:请输入你的 SerpApi API keyhelp:en_US:Get your SerpApi API key from SerpApizh_Hans:从 SerpApi 获取您的 SerpApi API keyurl:https://serpapi.com/manage-api-keytools: - tools/google_search.yamlextra:python:source:google.py
identity:name:google_searchauthor:Difylabel:en_US:GoogleSearchzh_Hans:谷歌搜索pt_BR:GoogleSearchdescription:human:en_US:A tool for performing a Google SERP search and extracting snippets and webpages.Input should be a search query.zh_Hans:一个用于执行 Google SERP 搜索并提取片段和网页的工具。输入应该是一个搜索查询。pt_BR:A tool for performing a Google SERP search and extracting snippets and webpages.Input should be a search query.llm:A tool for performing a Google SERP search and extracting snippets and webpages.Input should be a search query.parameters: - name:querytype:stringrequired:truelabel:en_US:Query stringzh_Hans:查询语句pt_BR:Query stringhuman_description:en_US:used for searchingzh_Hans:用于搜索网页内容pt_BR:used for searchingllm_description:key words for searchingform:llmextra:python:source:tools/google_search.py
identity 包含了工具的基本信息,包括名称、作者、标签、描述等
parameters 参数列表
name (必填)参数名称,唯一,不允许和其他参数重名
type (必填)参数类型,目前支持string、number、boolean、select、secret-input 五种类型,分别对应字符串、数字、布尔值、下拉框、加密输入框,对于敏感信息,请使用secret-input类型