Skip to content

Commit

Permalink
support searxng And moonshot stream
Browse files Browse the repository at this point in the history
  • Loading branch information
fatwang2 committed Apr 25, 2024
1 parent 57b84eb commit 2c1072c
Show file tree
Hide file tree
Showing 9 changed files with 881 additions and 19 deletions.
10 changes: 9 additions & 1 deletion .env.template
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
SEARCH1API_KEY=your_search1api_key
GOOGLE_CX=your_google_cx
GOOGLE_KEY=your_google_key
SERPAPI_KEY=your_serpapi_key
SERPER_KEY=your_serper_key
BING_KEY=your_bing_key
SEARXNG_BASE_URL=your_searxng_base_url
SEARCH_SERVICE=your_search_service
MAX_RESULTS=the results of search
CRAWL_RESULTS=the reults of search you want to crawl
APIBASE=https://api.openai.com
APIBASE=https://api.openai.com
OPENAI_TYPE="openai"
AUTH_KEYS="1111,2222"
RESOURCE_NAME=""
DEPLOY_NAME="gpt-35-turbo"
API_VERSION="2024-02-15-preview"
AZURE_API_KEY=""
10 changes: 5 additions & 5 deletions README-EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
<a href="https://www.buymeacoffee.com/fatwang2" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" ></a>

# Version Updates

- V0.2.6, 20240425, support the searxng search service, support the moonshot API in stream mode
- V0.2.5, 20240425, open source the code for the search api
- V0.2.4, 20240424, support for Groq in Cloudflare Worker
- V0.2.3, 20240423, support for Azure OpenAI in Cloudflare Worker. It also introduces the ability to use an authorization code and customize the user's request key.
- V0.2.2, 20240420, support Moonshot API
- V0.2.2, 20240420, support Moonshot API on unstream mode
- V0.2.1, 20240310, supports Google, Bing, Duckduckgo, Search1API for news-type searches; supports adjusting the number of search results via the MAX_RESULTS environment variable; supports adjusting the number of in-depth searches desired via the CRAWL_RESULTS environment variable.
- V0.2.0,20240310,Optimized openai.js, cloudflare worker version, really faster this time!

Expand Down Expand Up @@ -42,7 +42,7 @@ Help your LLM API support networking, search, news, web page summarization, has
| `Azure OpenAI` | search, news, crawler | stream, unstream | Cloudflare Worker |
| `Groq` | search, news, crawler | stream, unstream | Cloudflare Worker |
| `Gemini` | search | stream, unstream | Cloudflare Worker |
| `Moonshot` | search, news, crawler | unstream | Zeabur, Local deployment, Cloudflare Worker, Vercel |
| `Moonshot` | search, news, crawler | stream(only on cf), unstream | Zeabur, Local deployment, Cloudflare Worker(stream), Vercel |

# Usage

Expand Down Expand Up @@ -111,7 +111,7 @@ This project provides some additional configuration options, which can be set th

| Environment Variable | Required | Description | Example |
| -------------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
| `SEARCH_SERVICE` | Yes | Your search service. The key of the service you choose needs to be configured. Supports search1api, google, bing, serpapi, serper, duckduckgo. | `search1api, google, bing, serpapi, serper, duckduckgo` |
| `SEARCH_SERVICE` | Yes | Your search service. The key of the service you choose needs to be configured. | `search1api, google, bing, serpapi, serper, duckduckgo, searxng` |
| `APIBASE` | No | Third-party proxy address. | `https://api.openai.com, https://api.moonshot.cn, https://api.groq.com/openai` |
| `MAX_RESULTS` | No | Number of search results. | `10` |
| `CRAWL_RESULTS` | No | The number of deep searches (retrieve the main text of the webpage after searching). Currently only supports search1api, deep search will be slow. | `1` |
Expand All @@ -121,7 +121,7 @@ This project provides some additional configuration options, which can be set th
| `GOOGLE_KEY` | Conditional | Required if Google search is selected. API key. Apply at https://search2ai.online/googlekey. | `xxx` |
| `SERPAPI_KEY` | Conditional | Required if serpapi is selected. Free 100 times/month. Register at https://search2ai.online/serpapi. | `xxx` |
| `SERPER_KEY` | Conditional | Required if serper is selected. Free 2500 times for 6 months. Register at https://search2ai.online/serper. | `xxx` |
| `SEARXNG_BASE_URL` | Conditional | Required if searXNG is selected. Fill in the domain name of the self-built searXNG service, e.g. https://search.xxx.xxx. (Must contain https/http without a / at the end.) | `xxx` |
| `SEARXNG_BASE_URL` | Conditional | Required if searxng is selected. Fill in the domain name of the self-built searXNG service, refer to this repo https://github.com/searxng/searxng, plz open the json mode | `https://search.xxx.xxx` |
| `OPENAI_TYPE` | No | OpenAI provider source, default is openai | `openai, azure` |
| `RESOURCE_NAME` | Conditional | Required if azure is selected | `xxxx` |
| `DEPLOY_NAME` | Conditional | Required if azure is selected | `gpt-35-turbo` |
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
<a href="https://www.buymeacoffee.com/fatwang2" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" ></a>

# 版本更新

- V0.2.6,20240425,支持 SearXNG 免费搜索服务,有损支持 Moonshot 流式模式
- V0.2.5,20240425,为了解决隐私担忧,开源搜索接口部分的代码
- V0.2.4,20240424,支持 Groq 的llama-3、mistral等模型,速度起飞
- V0.2.3,20240423,Cloudflare Worker版本支持Azure OpenAI;支持授权码,可自定义用户的请求key
- V0.2.2,20240420,支持Moonshot的非流式模式
- V0.2.2,20240420,支持 Moonshot 的非流式模式
- V0.2.1,20240310,支持Google、Bing、Duckduckgo、Search1API新闻类搜索;支持通过环境变量MAX_RESULTS调整搜索结果数量;支持通过环境变量CRAWL_RESULTS调整希望深度搜索的数量
- V0.2.0,20240310,优化openai.js,cloudflare worker版本,这次速度真的更快了!

Expand Down Expand Up @@ -42,7 +42,7 @@
| `Azure OpenAI` | 联网、新闻、内容爬取 | 流式、非流式 | Cloudflare Worker |
| `Groq` | 联网、新闻、内容爬取 | 流式、非流式 | Cloudflare Worker |
| `Gemini` | 联网 | 流式、非流式 | Cloudflare Worker |
| `Moonshot` | 联网、新闻、内容爬取 | 非流式 | Zeabur、本地部署、Cloudflare Worker、Vercel |
| `Moonshot` | 联网、新闻、内容爬取 | 部分流式、非流式 | Zeabur、本地部署、Cloudflare Worker(流式)、Vercel |

# 使用

Expand Down Expand Up @@ -111,8 +111,8 @@ http://localhost:3014/v1/chat/completions

| 环境变量 | 是否必须 | 描述 | 例子 |
| -------------------- | -------- | --------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
| `SEARCH_SERVICE` | Yes | 你的搜索服务,选择什么服务,就需要配置什么服务的key支持search1api、google、bing、serpapi、serper、duckduckgo、searXNG | `search1api, google, bing, serpapi, serper, duckduckgo, searXNG` |
| `APIBASE` | No | 三方代理地址` | `https://api.openai.com, https://api.moonshot.cn, https://api.groq.com/openai` |
| `SEARCH_SERVICE` | Yes | 你的搜索服务,选择什么服务,就需要配置什么服务的key | `search1api, google, bing, serpapi, serper, duckduckgo, searxng` |
| `APIBASE` | No | 三方代理地址 | `https://api.openai.com, https://api.moonshot.cn, https://api.groq.com/openai` |
| `MAX_RESULTS` | No | 搜索结果条数 | `10` |
| `CRAWL_RESULTS` | No | 要进行深度搜索(搜索后获取网页正文)的数量,目前仅支持 search1api,深度速度会慢 | `1` |
| `SEARCH1API_KEY` | No | 如选search1api必填,我自己搭建的搜索服务,又快又便宜,申请地址 https://search21api.com | `xxx` |
Expand All @@ -121,7 +121,7 @@ http://localhost:3014/v1/chat/completions
| `GOOGLE_KEY` | No | 如选Google搜索必填,API key,申请地址 https://search2ai.online/googlekey | `xxx` |
| `SERPAPI_KEY` | No | 如选serpapi必填,免费100次/月,注册地址 https://search2ai.online/serpapi | `xxx` |
| `SERPER_KEY` | No | 如选serper必填,6个月免费额度2500次,注册地址 https://search2ai.online/serper | `xxx` |
| `SEARXNG_BASE_URL` | No | 如选searXNG必填,填写自建searXNG服务域名,例如:https://search.xxx.xxx。(须包含https/http且末尾不含/) | `xxxx` |
| `SEARXNG_BASE_URL` | No | 如选searxng必填,填写自建searXNG服务域名,教程 https://github.com/searxng/searxng,需打开 json 模式 | `https://search.xxx.xxx` |
| `OPENAI_TYPE` | No | openai供给来源,默认为openai | `openai, azure` |
| `RESOURCE_NAME` | No | 如选azure必填 | `xxxx` |
| `DEPLOY_NAME` | No | 如选azure必填 | `gpt-35-turbo` |
Expand Down
2 changes: 1 addition & 1 deletion search2gemini.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ async function search(query) {
}));
break;

case "searXNG":
case "searxng":
const searXNGUrl = `${SEARXNG_BASE_URL}/search?q=${encodeURIComponent(
query
)}&category=general&format=json`;
Expand Down
4 changes: 2 additions & 2 deletions search2groq.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2c1072c

Please sign in to comment.