为了便于开发,选择采用第三方服务 SerpApi 所提供的 Google Search API 。 SerpApi 要求填写 API Key 进行使用,因此需要在 yaml 文件内添加 credentials_for_provider 字段。
完整代码如下:
Copy
Ask AI
identity: author: Dify name: google label: en_US: Google zh_Hans: Google pt_BR: Google description: en_US: Google zh_Hans: GoogleSearch pt_BR: Google icon: icon.svg tags: - searchcredentials_for_provider: #添加 credentials_for_provider 字段 serpapi_api_key: type: secret-input required: true label: en_US: SerpApi API key zh_Hans: SerpApi API key placeholder: en_US: Please input your SerpApi API key zh_Hans: 请输入你的 SerpApi API key help: en_US: Get your SerpApi API key from SerpApi zh_Hans: 从 SerpApi 获取您的 SerpApi API key url: https://serpapi.com/manage-api-keytools: - tools/google_search.yamlextra: python: source: google.py
identity: name: google_search author: Dify label: en_US: GoogleSearch zh_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: query type: string required: true label: en_US: Query string zh_Hans: 查询语句 pt_BR: Query string human_description: en_US: used for searching zh_Hans: 用于搜索网页内容 pt_BR: used for searching llm_description: key words for searching form: llmextra: python: source: tools/google_search.py
identity 包含了工具的基本信息,包括名称、作者、标签、描述等。
parameters 参数列表
name (必填)参数名称,唯一,不允许和其他参数重名。
type (必填)参数类型,目前支持string、number、boolean、select、secret-input、file、files、model-selector、app-selector 九种类型,分别对应字符串、数字、布尔值、下拉框、加密输入框、文件、文件集、模型选择、应用选择,对于敏感信息,请使用 secret-input 类型。