Skip to content

Commit

Permalink
V0.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
fatwang2 committed Mar 21, 2024
1 parent 2f91f9c commit 580f840
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ SERPER_KEY=your_serper_key
BING_KEY=your_bing_key
SEARCH_SERVICE=your_search_service
MAX_RESULTS=the results of search
CRAWL_RESULTS=the r
CRAWL_RESULTS=the reults of search you want to crawl
APIBASE=https://api.openai.com
16 changes: 15 additions & 1 deletion README-EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,18 @@ Special note: Vercel project does not support streaming output and has a 10s res

One-click deployment

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Ffatwang2%2Fsearch2ai&env=SEARCH_SERVICE&envDescription=%E6%9A%82%E6%97%B6%E6%94%AF%E6%8C%81google%E3%80%81bing%E3%80%81se
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Ffatwang2%2Fsearch2ai&env=SEARCH_SERVICE&envDescription=%E6%9A%82%E6%97%B6%E6%94%AF%E6%8C%81google%E3%80%81bing%E3%80%81serpapi%E3%80%81serper%E3%80%81duckduckgo%EF%BC%8C%E5%BF%85%E5%A1%AB)

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 Azure OpenAI
- Fix streaming output issues in Vercel project
- Improve the speed of streaming output
- Support more vertical searches



6 changes: 5 additions & 1 deletion gemini.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,4 +365,8 @@ async function fetchWithRetry(url, options, maxRetries = 3) {
});
}
function errorResponse(message, statusCode = 400) {
return new Response(JSON.stringi
return new Response(JSON.stringify({ error: message }), {
status: statusCode,
headers: { 'Content-Type': 'application/json' },
});
}
20 changes: 19 additions & 1 deletion units/news.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,22 @@ async function news(query) {

if (!response.ok) {
console.error(`API 请求失败, 状态码: ${response.status}`);
return `API 请求失败, 状态码: ${response.s
return `API 请求失败, 状态码: ${response.status}`;
}

const contentType = response.headers.get("content-type");
if (!contentType || !contentType.includes("application/json")) {
console.error("收到的响应不是有效的 JSON 格式");
return "收到的响应不是有效的 JSON 格式";
}

const data = await response.json();
console.log('新闻搜索服务调用完成');
return JSON.stringify(data);
} catch (error) {
console.error(`在 news 函数中捕获到错误: ${error}`);
return `在 news 函数中捕获到错误: ${error}`;
}
}

module.exports = news;
7 changes: 6 additions & 1 deletion units/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,9 @@ async function search(query) {
console.log('自定义搜索服务调用完成');
return JSON.stringify(data);
} catch (error) {
console.error(` search 函数�
console.error(`在 search 函数中捕获到错误: ${error}`);
return `在 search 函数中捕获到错误: ${error}`;
}
}

module.exports = search;

0 comments on commit 580f840

Please sign in to comment.