Skip to content

Commit ffa239a

Browse files
committed
更新V0.1.8
1 parent c8cb6c1 commit ffa239a

File tree

6 files changed

+44
-28
lines changed

6 files changed

+44
-28
lines changed

README-EN.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<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>
88

99
# Version Updates
10+
- V0.1.8, 20240305, support search1api search service, update Gemini version search variable configuration, open news search capability, add risk statement
1011
- V0.1.7, 20240224, Gemini version supports streaming output and is compatible with vision model
1112
- V0.1.6, 20240221, Supports Gemini model, can be temporarily configured through Cloudflare worker method
1213
- V0.1.5, 20240205, supports news search, making it more convenient to quickly browse news
@@ -64,9 +65,9 @@ To keep the project updated, it is recommended to fork this repository first, th
6465
[![Deployed on Zeabur](https://zeabur.com/deployed-on-zeabur-dark.svg)](https://zeabur.com?referralCode=fatwang2&utm_source=fatwang2&utm_campaign=oss)
6566

6667
Environment variables
67-
- SEARCH_SERVICE: Currently supports google, bing, serpapi, serper, duckduckgo (recommended), required
68-
- APIBASE: If you are using an OpenAI third-party proxy, you can fill it in here, note that v1 is not needed, not required
69-
- NEWS_KEY: News search, if you need plz join in [telegram](https://sum4all.one/telegram)for the Key,free now
68+
- SEARCH_SERVICE: temporarily supports search1api, google, bing, serpapi, serper, duckduckgo, required
69+
- APIBASE: if you are using OpenAI three-way proxy, you can fill in here, note that you do not need to add v1, non-required!
70+
- SEARCH1API_KEY: such as the selection of search1api required, I build their own search services, 0.99 U.S. dollars / 1000 times per month, the application address https://search2ai.online/docs
7071
- BING_KEY: Required if choosing bing search, please search for tutorials, application address https://search2ai.online/bing
7172
- GOOGLE_CX: Required if choosing Google search, Search engine ID, please search for tutorials, application address https://search2ai.online/googlecx
7273
- GOOGLE_KEY: Required if choosing Google search, API key, application address https://search2ai.online/googlekey
@@ -79,9 +80,9 @@ Environment variables
7980
git clone https://github.com/fatwang2/search2ai
8081
```
8182
2. Copy .env.template as .env, configure environment variables
82-
- SEARCH_SERVICE: Currently supports google, bing, serpapi, serper, duckduckgo (recommended), required
83-
- APIBASE: If you are using an OpenAI third-party proxy, you can fill it in here, note that v1 is not needed, not required
84-
- NEWS_KEY: News search, if you need plz join in [telegram](https://sum4all.one/telegram)for the Key,free now
83+
- SEARCH_SERVICE: temporarily supports search1api, google, bing, serpapi, serper, duckduckgo, required
84+
- APIBASE: if you are using OpenAI three-way proxy, you can fill in here, note that you do not need to add v1, non-required!
85+
- SEARCH1API_KEY: such as the selection of search1api required, I build their own search services, 0.99 U.S. dollars / 1000 times per month, the application address https://search2ai.online/docs
8586
- BING_KEY: Required if choosing bing search, please search for tutorials, application address https://search2ai.online/bing
8687
- GOOGLE_CX: Required if choosing Google search, Search engine ID, please search for tutorials, application address https://search2ai.online/googlecx
8788
- GOOGLE_KEY: Required if choosing Google search, API key, application address https://search2ai.online/googlekey
@@ -103,9 +104,9 @@ http://localhost:3014/v1/chat/completions
103104

104105
2. Configure variables in the worker(only openai)
105106
![Effect Example](pictures/worker.png)
106-
- SEARCH_SERVICE: Currently supports google, bing, serpapi, serper, duckduckgo (recommended), required
107-
- APIBASE: If you are using an OpenAI third-party proxy, you can fill it in here, note that v1 is not needed, not required
108-
- NEWS_KEY: News search, if you need plz join in [telegram](https://sum4all.one/telegram)for the Key,free now
107+
- SEARCH_SERVICE: temporarily supports search1api, google, bing, serpapi, serper, duckduckgo, required
108+
- APIBASE: if you are using OpenAI three-way proxy, you can fill in here, note that you do not need to add v1, non-required!
109+
- SEARCH1API_KEY: such as the selection of search1api required, I build their own search services, 0.99 U.S. dollars / 1000 times per month, the application address https://search2ai.online/docs
109110
- BING_KEY: Required if choosing bing search, please search for tutorials, application address https://search2ai.online/bing
110111
- GOOGLE_CX: Required if choosing Google search, Search engine ID, please search for tutorials, application address https://search2ai.online/googlecx
111112
- GOOGLE_KEY: Required if choosing Google search, API key, application address https://search2ai.online/googlekey
@@ -125,8 +126,10 @@ One-click deployment
125126

126127
To ensure updates, you can also first fork this project and then deploy it on Vercel yourself
127128

129+
# Risk statement
130+
To ensure the persistence of this project, certain interface requests will be forwarded via [search1api](https://search.search2ai.one). Please be assured that this forwarding service does not save any private data.
131+
128132
# Future Iterations
129-
- Support for Gemini stream mode
130133
- Support for Azure OpenAI
131134
- Fix streaming output issues in Vercel project
132135
- Improve the speed of streaming output

README.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@
88
<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>
99

1010
# 版本更新
11+
- V0.1.8,20240305,支持search1api搜索服务,更新Gemini版本搜索变量配置,开放新闻搜索能力,增加风险声明
1112
- V0.1.7,20240224,Gemini版本支持流式输出,且兼容vision model
1213
- V0.1.6,20240221,支持Gemini模型,暂时可通过cloudflare worker的方式配置
1314
- V0.1.5,20240205,支持新闻搜索,快速浏览新闻更方便
1415
- V0.1.4,20240120,支持Zeabur一键部署,非常方便,强烈推荐!
1516
- V0.1.3,20240120,支持本地部署,可自行部署在自己的服务器上
16-
- V0.1.2,20240115,修复cloudflare worker版本非搜索场景下的流式输出问题
17-
- V0.1.1,20240114,支持vercel一键部署,目前只适合喜欢折腾的人
1817

1918
更多历史更新,请参见 [版本记录](https://github.com/fatwang2/search2ai/releases)
2019

@@ -65,9 +64,9 @@ demo站体验地址:[OpenAI](https://search2ai.online/demo),根据提示使
6564
[![Deployed on Zeabur](https://zeabur.com/deployed-on-zeabur-dark.svg)](https://zeabur.com?referralCode=fatwang2&utm_source=fatwang2&utm_campaign=oss)
6665

6766
环境变量
68-
- SEARCH_SERVICE:暂时支持google、bing、serpapi、serper、duckduckgo(推荐),必填
69-
- APIBASE:如果你在用 OpenAI 三方代理,可在这里填入,注意不需要加v1,非必填
70-
- NEWS_KEY: 单独的新闻搜索服务,如需体验可加入 [telegram频道 ](https://sum4all.one/telegram)申请Key,暂时免费
67+
- SEARCH_SERVICE:暂时支持search1api、google、bing、serpapi、serper、duckduckgo,必填
68+
- APIBASE:如果你在用 OpenAI 三方代理,在这里填入,注意不需要加v1,非必填
69+
- SEARCH1API_KEY:如选search1api必填,我自己搭建的搜索服务,0.99美金/1000次每个月,申请地址 https://search2ai.online/docs
7170
- BING_KEY:如选bing搜索必填,请自行搜索教程,申请地址 https://search2ai.online/bing
7271
- GOOGLE_CX:如选Google搜索必填,Search engine ID,请自行搜索教程,申请地址 https://search2ai.online/googlecx
7372
- GOOGLE_KEY:如选Google搜索必填,API key,申请地址 https://search2ai.online/googlekey
@@ -80,9 +79,9 @@ demo站体验地址:[OpenAI](https://search2ai.online/demo),根据提示使
8079
git clone https://github.com/fatwang2/search2ai
8180
```
8281
2. 复制.env.template为.env,配置环境变量
83-
- SEARCH_SERVICE:暂时支持google、bing、serpapi、serper、duckduckgo(推荐),必填
82+
- SEARCH_SERVICE:暂时支持search1api、google、bing、serpapi、serper、duckduckgo,必填
8483
- APIBASE:如果你在用 OpenAI 三方代理,可在这里填入,注意不需要加v1,非必填
85-
- NEWS_KEY: 单独的新闻搜索服务,如需体验可加入 [telegram频道 ](https://sum4all.one/telegram)申请Key,暂时免费
84+
- SEARCH1API_KEY:如选search1api必填,我自己搭建的搜索服务,0.99美金/1000次每个月,申请地址 https://search2ai.online/docs
8685
- BING_KEY:如选bing搜索必填,请自行搜索教程,申请地址 https://search2ai.online/bing
8786
- GOOGLE_CX:如选Google搜索必填,Search engine ID,请自行搜索教程,申请地址 https://search2ai.online/googlecx
8887
- GOOGLE_KEY:如选Google搜索必填,API key,申请地址 https://search2ai.online/googlekey
@@ -102,11 +101,11 @@ http://localhost:3014/v1/chat/completions
102101
**cloudflare worker部署**
103102
1. 复制[openai.js](https://search2ai.online/cloudflare)或者[gemini.js](https://search2ai.online/geminicf)的代码,不需要任何修改!在cloudflare的worker里部署,上线后的worker的地址可作为你接口调用时的自定义域名地址,注意拼接,worker地址仅代表v1前的部分
104103

105-
2. 在worker中配置变量(部署openai时需要配置,gemini暂不支持)
104+
2. 在worker中配置变量
106105
![效果示例](pictures/worker.png)
107-
- SEARCH_SERVICE:暂时支持google、bing、serpapi、serper、duckduckgo(推荐),必填
106+
- SEARCH_SERVICE:暂时支持search1api、google、bing、serpapi、serper、duckduckgo,必填
108107
- APIBASE:如果你在用 OpenAI 三方代理,可在这里填入,注意不需要加v1,非必填
109-
- NEWS_KEY: 单独的新闻搜索服务,如需体验可加入 [telegram频道 ](https://sum4all.one/telegram)申请Key,暂时免费
108+
- SEARCH1API_KEY:如选search1api必填,我自己搭建的搜索服务,0.99美金/1000次每个月,申请地址 https://search2ai.online/docs
110109
- BING_KEY:如选bing搜索必填,请自行搜索教程,申请地址 https://search2ai.online/bing
111110
- GOOGLE_CX:如选Google搜索必填,Search engine ID,请自行搜索教程,申请地址 https://search2ai.online/googlecx
112111
- GOOGLE_KEY:如选Google搜索必填,API key,申请地址 https://search2ai.online/googlekey
@@ -126,6 +125,9 @@ http://localhost:3014/v1/chat/completions
126125

127126
为保证更新,也可以先fork本项目后自己在vercel上部署
128127

128+
# 风险声明
129+
为了确保本项目的持久运行,某些接口请求将通过[search1api](https://search.search2ai.one)进行转发。请放心,该转发服务不会保存任何隐私数据。
130+
129131
# 后续迭代
130132
- 支持Azure OpenAI
131133
- 修复Vercel项目流式输出问题

gemini.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,20 @@ addEventListener('fetch', event => {
1313

1414
try {
1515
const url = "https://search.search2ai.one";
16-
const headers = {"Content-Type": "application/json"};
16+
const headers= {
17+
"Content-Type": "application/json",
18+
"Authorization": typeof SEARCH1API_KEY !== 'undefined' ? `Bearer ${SEARCH1API_KEY}` : '',
19+
"google_cx": typeof GOOGLE_CX !== 'undefined' ? GOOGLE_CX : '',
20+
"google_key": typeof GOOGLE_KEY !== 'undefined' ? GOOGLE_KEY : '',
21+
"serpapi_key": typeof SERPAPI_KEY !== 'undefined' ? SERPAPI_KEY : '',
22+
"serper_key": typeof SERPER_KEY !== 'undefined' ? SERPER_KEY : '',
23+
"bing_key": typeof BING_KEY !== 'undefined' ? BING_KEY : '',
24+
"apibase": typeof APIBASE !== 'undefined' ? APIBASE : 'https://api.openai.com'
25+
};
1726
const body = {
1827
"query": query,
19-
"search_service": "duckduckgo"
28+
search_service: SEARCH_SERVICE,
29+
max_results: 5
2030
};
2131

2232
const response = await fetch(url, {

openai.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ async function search(query) {
7979
method: 'POST',
8080
headers: {
8181
"Content-Type": "application/json",
82+
"Authorization": typeof SEARCH1API_KEY !== 'undefined' ? `Bearer ${SEARCH1API_KEY}` : '',
8283
"google_cx": typeof GOOGLE_CX !== 'undefined' ? GOOGLE_CX : '',
8384
"google_key": typeof GOOGLE_KEY !== 'undefined' ? GOOGLE_KEY : '',
8485
"serpapi_key": typeof SERPAPI_KEY !== 'undefined' ? SERPAPI_KEY : '',
@@ -88,7 +89,8 @@ async function search(query) {
8889
},
8990
body: JSON.stringify({
9091
query: query,
91-
search_service: SEARCH_SERVICE
92+
search_service: SEARCH_SERVICE,
93+
max_results: 5
9294
})
9395
});
9496

@@ -118,8 +120,7 @@ async function news(query) {
118120
const response = await fetch('https://ddg.search2ai.online/searchNews', {
119121
method: 'POST',
120122
headers: {
121-
"Content-Type": "application/json",
122-
"newskey": typeof NEWS_KEY !== 'undefined' ? NEWS_KEY : ''
123+
"Content-Type": "application/json"
123124
},
124125
body: JSON.stringify({
125126
q: query,

units/news.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ config({ path: __dirname + '/../.env' });
66
async function news(query) {
77
console.log(`正在使用查询进行新闻搜索: ${JSON.stringify(query)}`);
88
try {
9-
const response = await fetch('https://crawler.search2ai.one/searchNews', {
9+
const response = await fetch('https://ddg.search2ai.online/searchNews', {
1010
method: 'POST',
1111
headers: {
12-
"Content-Type": "application/json",
13-
"newskey": process.env.NEWS_KEY || ''
12+
"Content-Type": "application/json"
1413
},
1514
body: JSON.stringify({
1615
q: query,

units/search.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ async function search(query) {
99
method: 'POST',
1010
headers: {
1111
"Content-Type": "application/json",
12+
"Authorization": process.env.SEARCH1API_KEY ? `Bearer ${process.env.SEARCH1API_KEY}` : '',
1213
"google_cx": process.env.GOOGLE_CX || '',
1314
"google_key": process.env.GOOGLE_KEY || '',
1415
"serpapi_key": process.env.SERPAPI_KEY || '',

0 commit comments

Comments
 (0)