Skip to content

Commit

Permalink
更新V0.1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
fatwang2 committed Mar 5, 2024
1 parent c8cb6c1 commit ffa239a
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 28 deletions.
23 changes: 13 additions & 10 deletions README-EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,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>

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

Environment variables
- SEARCH_SERVICE: Currently supports google, bing, serpapi, serper, duckduckgo (recommended), required
- APIBASE: If you are using an OpenAI third-party proxy, you can fill it in here, note that v1 is not needed, not required
- NEWS_KEY: News search, if you need plz join in [telegram](https://sum4all.one/telegram)for the Key,free now
- SEARCH_SERVICE: temporarily supports search1api, google, bing, serpapi, serper, duckduckgo, required
- 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!
- 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
- BING_KEY: Required if choosing bing search, please search for tutorials, application address https://search2ai.online/bing
- GOOGLE_CX: Required if choosing Google search, Search engine ID, please search for tutorials, application address https://search2ai.online/googlecx
- GOOGLE_KEY: Required if choosing Google search, API key, application address https://search2ai.online/googlekey
Expand All @@ -79,9 +80,9 @@ Environment variables
git clone https://github.com/fatwang2/search2ai
```
2. Copy .env.template as .env, configure environment variables
- SEARCH_SERVICE: Currently supports google, bing, serpapi, serper, duckduckgo (recommended), required
- APIBASE: If you are using an OpenAI third-party proxy, you can fill it in here, note that v1 is not needed, not required
- NEWS_KEY: News search, if you need plz join in [telegram](https://sum4all.one/telegram)for the Key,free now
- SEARCH_SERVICE: temporarily supports search1api, google, bing, serpapi, serper, duckduckgo, required
- 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!
- 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
- BING_KEY: Required if choosing bing search, please search for tutorials, application address https://search2ai.online/bing
- GOOGLE_CX: Required if choosing Google search, Search engine ID, please search for tutorials, application address https://search2ai.online/googlecx
- GOOGLE_KEY: Required if choosing Google search, API key, application address https://search2ai.online/googlekey
Expand All @@ -103,9 +104,9 @@ http://localhost:3014/v1/chat/completions

2. Configure variables in the worker(only openai)
![Effect Example](pictures/worker.png)
- SEARCH_SERVICE: Currently supports google, bing, serpapi, serper, duckduckgo (recommended), required
- APIBASE: If you are using an OpenAI third-party proxy, you can fill it in here, note that v1 is not needed, not required
- NEWS_KEY: News search, if you need plz join in [telegram](https://sum4all.one/telegram)for the Key,free now
- SEARCH_SERVICE: temporarily supports search1api, google, bing, serpapi, serper, duckduckgo, required
- 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!
- 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
- BING_KEY: Required if choosing bing search, please search for tutorials, application address https://search2ai.online/bing
- GOOGLE_CX: Required if choosing Google search, Search engine ID, please search for tutorials, application address https://search2ai.online/googlecx
- GOOGLE_KEY: Required if choosing Google search, API key, application address https://search2ai.online/googlekey
Expand All @@ -125,8 +126,10 @@ One-click deployment

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

# Risk statement
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.

# Future Iterations
- Support for Gemini stream mode
- Support for Azure OpenAI
- Fix streaming output issues in Vercel project
- Improve the speed of streaming output
Expand Down
22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@
<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.1.8,20240305,支持search1api搜索服务,更新Gemini版本搜索变量配置,开放新闻搜索能力,增加风险声明
- V0.1.7,20240224,Gemini版本支持流式输出,且兼容vision model
- V0.1.6,20240221,支持Gemini模型,暂时可通过cloudflare worker的方式配置
- V0.1.5,20240205,支持新闻搜索,快速浏览新闻更方便
- V0.1.4,20240120,支持Zeabur一键部署,非常方便,强烈推荐!
- V0.1.3,20240120,支持本地部署,可自行部署在自己的服务器上
- V0.1.2,20240115,修复cloudflare worker版本非搜索场景下的流式输出问题
- V0.1.1,20240114,支持vercel一键部署,目前只适合喜欢折腾的人

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

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

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

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

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

# 风险声明
为了确保本项目的持久运行,某些接口请求将通过[search1api](https://search.search2ai.one)进行转发。请放心,该转发服务不会保存任何隐私数据。

# 后续迭代
- 支持Azure OpenAI
- 修复Vercel项目流式输出问题
Expand Down
14 changes: 12 additions & 2 deletions gemini.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,20 @@ addEventListener('fetch', event => {

try {
const url = "https://search.search2ai.one";
const headers = {"Content-Type": "application/json"};
const headers= {
"Content-Type": "application/json",
"Authorization": typeof SEARCH1API_KEY !== 'undefined' ? `Bearer ${SEARCH1API_KEY}` : '',
"google_cx": typeof GOOGLE_CX !== 'undefined' ? GOOGLE_CX : '',
"google_key": typeof GOOGLE_KEY !== 'undefined' ? GOOGLE_KEY : '',
"serpapi_key": typeof SERPAPI_KEY !== 'undefined' ? SERPAPI_KEY : '',
"serper_key": typeof SERPER_KEY !== 'undefined' ? SERPER_KEY : '',
"bing_key": typeof BING_KEY !== 'undefined' ? BING_KEY : '',
"apibase": typeof APIBASE !== 'undefined' ? APIBASE : 'https://api.openai.com'
};
const body = {
"query": query,
"search_service": "duckduckgo"
search_service: SEARCH_SERVICE,
max_results: 5
};

const response = await fetch(url, {
Expand Down
7 changes: 4 additions & 3 deletions openai.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ async function search(query) {
method: 'POST',
headers: {
"Content-Type": "application/json",
"Authorization": typeof SEARCH1API_KEY !== 'undefined' ? `Bearer ${SEARCH1API_KEY}` : '',
"google_cx": typeof GOOGLE_CX !== 'undefined' ? GOOGLE_CX : '',
"google_key": typeof GOOGLE_KEY !== 'undefined' ? GOOGLE_KEY : '',
"serpapi_key": typeof SERPAPI_KEY !== 'undefined' ? SERPAPI_KEY : '',
Expand All @@ -88,7 +89,8 @@ async function search(query) {
},
body: JSON.stringify({
query: query,
search_service: SEARCH_SERVICE
search_service: SEARCH_SERVICE,
max_results: 5
})
});

Expand Down Expand Up @@ -118,8 +120,7 @@ async function news(query) {
const response = await fetch('https://ddg.search2ai.online/searchNews', {
method: 'POST',
headers: {
"Content-Type": "application/json",
"newskey": typeof NEWS_KEY !== 'undefined' ? NEWS_KEY : ''
"Content-Type": "application/json"
},
body: JSON.stringify({
q: query,
Expand Down
5 changes: 2 additions & 3 deletions units/news.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ config({ path: __dirname + '/../.env' });
async function news(query) {
console.log(`正在使用查询进行新闻搜索: ${JSON.stringify(query)}`);
try {
const response = await fetch('https://crawler.search2ai.one/searchNews', {
const response = await fetch('https://ddg.search2ai.online/searchNews', {
method: 'POST',
headers: {
"Content-Type": "application/json",
"newskey": process.env.NEWS_KEY || ''
"Content-Type": "application/json"
},
body: JSON.stringify({
q: query,
Expand Down
1 change: 1 addition & 0 deletions units/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ async function search(query) {
method: 'POST',
headers: {
"Content-Type": "application/json",
"Authorization": process.env.SEARCH1API_KEY ? `Bearer ${process.env.SEARCH1API_KEY}` : '',
"google_cx": process.env.GOOGLE_CX || '',
"google_key": process.env.GOOGLE_KEY || '',
"serpapi_key": process.env.SERPAPI_KEY || '',
Expand Down

0 comments on commit ffa239a

Please sign in to comment.