Skip to content

Commit

Permalink
支持search1api
Browse files Browse the repository at this point in the history
  • Loading branch information
fatwang2 committed Mar 16, 2024
1 parent 288f98f commit d47b434
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions config.json.template
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"search_sum": {
"enabled": false,
"service": "sum4all",
"search_service": "duckduckgo",
"group": true,
"search_prefix":"搜",
"prompt": "你是一个信息检索专家,我会把我的问题和搜索结果发给你,请你根据问题,从搜索结果里找出能回答问题的相关内容,用简单明了的语言为我做回复,尽量使用emoji让你的表达更生动"
Expand All @@ -35,6 +36,7 @@
},
"keys": {
"sum4all_key": "",
"search1api_key": "",
"gemini_key": "",
"perplexity_key": "",
"open_ai_api_key": "",
Expand Down
Binary file added picture/search1api.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

## 微信插件
### 更新日志
- V0.7.4,20240316,支持search1api搜索聚合服务,google、bing、duckduckgo自由切换
- V0.7.3,20240217,修改Gemini代理,修改为更稳定的cf代理
- V0.7.2,20240206,增加图片压缩逻辑,修复图片过大时无法总结的bug
- V0.7.1,20240130,修复关闭笔记功能时私聊无法总结网页的bug
Expand Down Expand Up @@ -82,6 +83,7 @@
|------|----------|------|----------|-----------|
| OpenAI | 搜索、文件、图片、绝大部分网页文章 | 无需额外申请服务,舍得花钱的话,效果最可控 | [OpenAI](https://platform.openai.com/account/api-keys) \| [LinkAI代理](https://sum4all.site/linkai) | ![OpenAI](picture/openai.png) |
| sum4all | 搜索、文件、绝大部分网页文章 | 注册免费送1万token,邀请好友注册再各得5k| [sum4all](https://sum4all.site/key) | ![Sum4all](picture/sum4all.png) |
| search1api | Google、Bing、Duckduckgo搜索 | 搜索聚合服务,无需注册,$0.99/1000次每个月| [search1api](https://search2ai.online/api)| ![search1api](picture/search1api.png) |
| Gemini | 搜索、文件、图片、绝大部分网页文章 | Google最新大模型,免费 | [gemini](https://sum4all.site/google) | ![Gemini](picture/gemini.png) |
| Perplexity | 搜索 | 国外的搜索总结服务,速度快,价格贵,自带大模型,需自行注册和付费 | [Perplexity](https://sum4all.site/perplexity) | ![Perplexity](picture/p.png) | ![Alt text](picture/[email protected]) |
| 讯飞 | 图片 | 讯飞星火大模型的图片理解功能,免费200万token,随便用 | [xunfei](https://sum4all.site/xunfei) | ![Perplexity](picture/讯飞.png) |
Expand All @@ -108,6 +110,7 @@
"search_sum": {
"enabled": false, #搜索总结服务开关
"service": "sum4all", #搜索总结服务,目前支持openai、sum4all、gemini、perplexity
"search_service": "duckduckgo", #搜索服务,duckduckgo免费,google、bing 需配置 search1api 的key
"group": true, #搜索总结群聊开关
"search_prefix":"搜", #搜索总结前缀词
"prompt": "" #搜索总结prompt
Expand All @@ -133,6 +136,7 @@
},
"keys": {
"sum4all_key": "", #如选sum4all,则必填
"search1api_key": "", #如search_service选google或bing,则必填,购买方式见上
"gemini_key": "", #如选gemini,则必填
"perplexity_key": "", #如选perplexity,则必填
"open_ai_api_key": "", #如选openai,则必填
Expand Down
7 changes: 5 additions & 2 deletions sum4all.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def __init__(self):
self.note = self.config.get("note", {})

self.sum4all_key = self.keys.get("sum4all_key", "")
self.search1api_key = self.keys.get("search1api_key", "")
self.gemini_key = self.keys.get("gemini_key", "")
self.bibigpt_key = self.keys.get("bibigpt_key", "")
self.outputLanguage = self.keys.get("outputLanguage", "zh-CN")
Expand All @@ -93,6 +94,7 @@ def __init__(self):

self.search_sum_enabled = self.search_sum.get("enabled", False)
self.search_sum_service = self.search_sum.get("service", "")
self.search_service = self.search_sum.get("search_service", "")
self.search_sum_group = self.search_sum.get("group", True)
self.search_sum_search_prefix = self.search_sum.get("search_prefix", "搜")
self.search_sum_prompt = self.search_sum.get("prompt", "")
Expand Down Expand Up @@ -185,7 +187,6 @@ def on_handle_context(self, e_context: EventContext):
file_path = context.content
logger.info(f"on_handle_context: 获取到文件路径 {file_path}")


# 检查是否应该进行文件总结
if self.file_sum_enabled:
# 更新params_cache中的last_file_content
Expand Down Expand Up @@ -503,7 +504,9 @@ def handle_search(self, content, e_context):
"ur": content,
"prompt": self.search_sum_prompt,
"model": model,
"base": api_base
"base": api_base,
"search1api_key": self.search1api_key,
"search_service": self.search_service
})
try:
api_url = "https://ai.sum4all.site"
Expand Down

0 comments on commit d47b434

Please sign in to comment.