Skip to content

Commit

Permalink
support groq
Browse files Browse the repository at this point in the history
  • Loading branch information
fatwang2 committed Apr 23, 2024
1 parent c2f63de commit 2b17bc0
Show file tree
Hide file tree
Showing 3 changed files with 702 additions and 4 deletions.
5 changes: 3 additions & 2 deletions README-EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Help your LLM API support networking, search, news, web page summarization, has
| -------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| `OpenAI` | search, news, crawler | stream, unstream| Zeabur, Local deployment, Cloudflare Worker, Vercel|
| `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|

Expand Down Expand Up @@ -81,7 +82,7 @@ http://localhost:3014/v1/chat/completions
```

**Cloudflare worker**
1. Copy the code of [search2openai.js](search2openai.js), or [search2gemini.js](search2gemini.js),no modifications needed! Deploy in cloudflare's worker, after going online, the worker's address can be used as your interface call's custom domain address, note the concatenation, worker address only represents the part before v1
1. Copy the code of [search2openai.js](search2openai.js), or [search2gemini.js](search2gemini.js), or [search2groq.js](search2groq.js), no modifications needed! Deploy in cloudflare's worker, after going online, the worker's address can be used as your interface call's custom domain address, note the concatenation, worker address only represents the part before v1

2. Configure variables in the worker(only openai)
![Effect Example](pictures/worker.png)
Expand All @@ -105,7 +106,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` |
| `APIBASE` | No | OpenAI third-party proxy address. If using Moonshot, fill in `https://api.moonshot.cn`. | `https://api.openai.com` |
| `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` |
| `SEARCH1API_KEY` | Conditional | Required if search1api is selected. My own fast and cheap search service. Apply at https://search21api.com. | `xxx` |
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<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.4,20240424,支持 Groq 的llama-3、mistral等模型,速度起飞
- V0.2.3,20240423,Cloudflare Worker版本支持Azure OpenAI;支持授权码,可自定义用户的请求key
- V0.2.2,20240420,支持Moonshot的非流式模式
- V0.2.1,20240310,支持Google、Bing、Duckduckgo、Search1API新闻类搜索;支持通过环境变量MAX_RESULTS调整搜索结果数量;支持通过环境变量CRAWL_RESULTS调整希望深度搜索的数量
Expand All @@ -34,6 +35,7 @@
| -------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| `OpenAI` | 联网、新闻、内容爬取 | 流式、非流式| Zeabur、本地部署、Cloudflare Worker、Vercel|
| `Azure OpenAI` | 联网、新闻、内容爬取 | 流式、非流式| Cloudflare Worker|
| `Groq` | 联网、新闻、内容爬取 | 流式、非流式| Cloudflare Worker|
| `Gemini` | 联网 | 流式、非流式| Cloudflare Worker|
| `Moonshot` | 联网、新闻、内容爬取 | 非流式| Zeabur、本地部署、Cloudflare Worker、Vercel|

Expand Down Expand Up @@ -75,7 +77,7 @@ http://localhost:3014/v1/chat/completions
```

**Cloudflare Worker部署**
1. 复制[search2openai.js](search2openai.js)或者[search2gemini.js](search2gemini.js)的代码,不需要任何修改!在cloudflare的worker里部署,上线后的worker的地址可作为你接口调用时的自定义域名地址,注意拼接,worker地址仅代表v1前的部分
1. 复制[search2openai.js](search2openai.js)或者[search2gemini.js](search2gemini.js)或者[search2groq.js](search2groq.js)的代码,不需要任何修改!在cloudflare的worker里部署,上线后的worker的地址可作为你接口调用时的自定义域名地址,注意拼接,worker地址仅代表v1前的部分

2. 在worker中配置环境变量
![效果示例](pictures/worker.png)
Expand All @@ -99,7 +101,7 @@ http://localhost:3014/v1/chat/completions
| 环境变量 | 是否必须 | 描述 | 例子 |
| -------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| `SEARCH_SERVICE` | Yes | 你的搜索服务,选择什么服务,就需要配置什么服务的key支持search1api、google、bing、serpapi、serper、duckduckgo| `search1api, google, bing, serpapi, serper, duckduckgo`|
| `APIBASE` | No | OpenAI 三方代理地址,使用Moonshot则填写`https://api.moonshot.cn`| `https://api.openai.com`|
| `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 Down
Loading

0 comments on commit 2b17bc0

Please sign in to comment.