From 00a04bc0160a02b7a15c5dc9ad181c89dc7b999f Mon Sep 17 00:00:00 2001 From: foryoung365 Date: Mon, 28 Apr 2025 18:38:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20README.md=E3=80=81manifest?= =?UTF-8?q?.json=E3=80=81openapi.json=20=E5=92=8C=20plugin.json=20?= =?UTF-8?q?=E6=96=87=E4=BB=B6=EF=BC=8C=E9=87=8D=E6=9E=84=E4=B8=BA=20Google?= =?UTF-8?q?=20Custom=20Search=20=E6=8F=92=E4=BB=B6=EF=BC=8C=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E8=AE=BE=E7=BD=AE=E6=AD=A5=E9=AA=A4=E3=80=81=E8=AE=A4?= =?UTF-8?q?=E8=AF=81=E6=96=B9=E5=BC=8F=E5=92=8C=E9=99=90=E5=88=B6=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=EF=BC=8C=E6=9B=B4=E6=96=B0=20API=20=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E5=92=8C=E6=8F=8F=E8=BF=B0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 43 +++++++++++++++++++++++++--- public/manifest.json | 16 +++++------ public/openapi.json | 67 ++++++++++++++++++++++++++++++++------------ public/plugin.json | 6 ++-- 4 files changed, 99 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 46b06e4..e3fd49a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,41 @@ -Formatting [Serper](https://serper.dev/) search API with OpenAPI format. +# LobeChat Google Custom Search 插件 -Designed for [LobeChat](https://github.com/lobehub/lobe-chat). -See this plugin [on their plugin store page](https://lobechat.com/discover/plugin/search-engine-serper). +使用 [Google Custom Search API](https://developers.google.com/custom-search) 的LobeChat搜索插件。 -`(Not affliated with any entities above.)` +## 设置步骤 + +1. 创建 Google Custom Search Engine + - 访问 [Google Programmable Search Engine](https://programmablesearch.google.com/create) + - 创建一个自定义搜索引擎 + - 获取您的搜索引擎ID (cx参数) + +2. 获取 Google API 密钥 + - 访问 [Google Cloud Console](https://console.cloud.google.com/) + - 创建一个项目 + - 启用 "Custom Search API" + - 创建API密钥 (key参数) + +3. 在LobeChat中配置插件 + - 将此插件添加到LobeChat + - 在配置页面中提供您的API密钥和搜索引擎ID + - 这些凭据会作为安全参数自动添加到每个请求中 + +## 认证方式 + +此插件使用以下两个安全参数: +- `key`: 您的Google API密钥 +- `cx`: 您的自定义搜索引擎ID + +这两个参数会作为查询参数添加到API请求中。 + +## 限制 + +- Google Custom Search API 免费版每天限制100次查询 +- 付费版可获得更多配额 + +## 隐私 + +- 您的搜索查询将发送到Google +- 此插件不会收集或存储您的个人数据 + +`(与上述任何实体无关联)` diff --git a/public/manifest.json b/public/manifest.json index fea66a0..020f9c8 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -1,18 +1,18 @@ { "api": { "type": "openapi", - "url": "https://raw.githubusercontent.com/GithuBarry/chat-plugin-search-engine/main/public/openapi.json", + "url": "https://raw.githubusercontent.com/foryoung365/lobechat-plugin-google/main/public/openapi.json", "is_user_authenticated": false }, "auth": { "type": "none" }, - "contact_email": "33831597+GithuBarry@users.noreply.github.com", - "description_for_human": "Google search engine via Serper.dev free API (2500x🆓/month)", - "description_for_model": "Plugin for performing web searches using the Serper.dev API to access Google search results.", - "legal_info_url": "https://serper.dev/terms", - "logo_url": "https://serper.dev/favicon.ico", - "name_for_human": "Search Google via Serper", - "name_for_model": "search-engine-serper", + "contact_email": "1758359+foryoung365@users.noreply.github.com", + "description_for_human": "Google custom search engine API (100🆓/day)", + "description_for_model": "Plugin for performing web searches using the Google custom search engine API.", + "legal_info_url": "https://developers.google.com/custom-search/v1/introduction", + "logo_url": "https://www.google.com/favicon.ico", + "name_for_human": "Search Google via Google Custom Search", + "name_for_model": "search-engine-google-custom-search", "schema_version": "v1" } diff --git a/public/openapi.json b/public/openapi.json index 6926cb6..82ccdb8 100644 --- a/public/openapi.json +++ b/public/openapi.json @@ -1,10 +1,17 @@ { "components": { "securitySchemes": { - "apiAuth": { + "googleApiKey": { "type": "apiKey", - "name": "X-API-KEY", - "in": "header" + "name": "key", + "in": "query", + "description": "API key for Google Custom Search API" + }, + "customSearchId": { + "type": "apiKey", + "name": "cx", + "in": "query", + "description": "The custom search engine ID to use for this request" } } }, @@ -14,9 +21,9 @@ }, "openapi": "3.0.0", "paths": { - "/search": { - "post": { - "summary": "Search Google and return top 10 results", + "/customsearch/v1": { + "get": { + "summary": "Search Google using Custom Search API", "operationId": "searchGoogle", "parameters": [ { @@ -28,6 +35,16 @@ "required": true, "description": "Search query string" }, + { + "in": "query", + "name": "num", + "schema": { + "type": "integer", + "default": 10 + }, + "required": false, + "description": "Number of search results to return (1-10)" + }, { "in": "query", "name": "gl", @@ -35,7 +52,7 @@ "type": "string" }, "required": false, - "description": "Google Geo location parameter" + "description": "Geolocation of end user (country code)" }, { "in": "query", @@ -44,7 +61,7 @@ "type": "string" }, "required": false, - "description": "Google Geo locale parameter" + "description": "Interface language" } ], "responses": { @@ -54,14 +71,26 @@ "application/json": { "schema": { "type": "object", - "required": [ - "result" - ], "properties": { - "result": { - "type": "string", - "description": "Top 10 search results", - "example": "\"title\": \"周末游推荐\",\n\"link\": \"https://www.example.com/destinations-for-weekends\",\n\"snippet\": \"周末去哪玩?周末旅游频道,精心推荐数百个周末游经典线路\",\n\"position\": 1" + "items": { + "type": "array", + "items": { + "type": "object", + "properties": { + "title": { + "type": "string", + "description": "The title of the search result" + }, + "link": { + "type": "string", + "description": "The URL of the search result" + }, + "snippet": { + "type": "string", + "description": "A snippet of text from the search result" + } + } + } } } } @@ -71,7 +100,8 @@ }, "security": [ { - "apiAuth": [] + "googleApiKey": [], + "customSearchId": [] } ] } @@ -79,12 +109,13 @@ }, "security": [ { - "apiAuth": [] + "googleApiKey": [], + "customSearchId": [] } ], "servers": [ { - "url": "https://google.serper.dev" + "url": "https://www.googleapis.com" } ] } \ No newline at end of file diff --git a/public/plugin.json b/public/plugin.json index 9e73e6d..0485667 100644 --- a/public/plugin.json +++ b/public/plugin.json @@ -1,13 +1,13 @@ { "author": "Barry", "homepage": "https://github.com/GithuBarry/chat-plugin-search-engine", - "identifier": "search-engine-serper", + "identifier": "search-engine-google-custom", "manifest": "https://raw.githubusercontent.com/GithuBarry/chat-plugin-search-engine/main/public/manifest.json", "meta": { "avatar": "🔍", - "description": "Google search engine via Serper.dev free API (2500x🆓/month)", + "description": "Google search engine via Google Custom Search API (100🆓/day)", "tags": ["web", "search"], - "title": "Search Google via Serper" + "title": "Search Google via Custom Search" }, "schemaVersion": 1 }