Skip to content

Commit

Permalink
update web search functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
binary-husky committed Dec 1, 2024
1 parent e62deca commit bd7b219
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
4 changes: 2 additions & 2 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@


# Searxng互联网检索服务
SEARXNG_URL = "https://cloud-1.agent-matrix.com/"
SEARXNG_URLS = [ f"https://hamercity-ai-search-{x}.hf.space/" for x in range(1, 9) ]


# 是否允许通过自然语言描述修改本页的配置,该功能具有一定的危险性,默认关闭
Expand Down Expand Up @@ -403,7 +403,7 @@
插件在线服务配置依赖关系示意图
├── 互联网检索
│ └── SEARXNG_URL
│ └── SEARXNG_URLS
├── 语音功能
│ ├── ENABLE_AUDIO
Expand Down
3 changes: 2 additions & 1 deletion crazy_functions/Internet_GPT.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ def get_auth_ip():

def searxng_request(query, proxies, categories='general', searxng_url=None, engines=None):
if searxng_url is None:
url = get_conf("SEARXNG_URL")
urls = get_conf("SEARXNG_URLS")
url = random.choice(urls)
else:
url = searxng_url

Expand Down
7 changes: 5 additions & 2 deletions crazy_functions/Internet_GPT_Wrap.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

import random
from toolbox import get_conf
from crazy_functions.Internet_GPT import 连接网络回答问题
from crazy_functions.plugin_template.plugin_class_template import GptAcademicPluginTemplate, ArgProperty
Expand All @@ -20,6 +20,9 @@ def define_arg_selection_menu(self):
第三个参数,名称`allow_cache`,参数`type`声明这是一个下拉菜单,下拉菜单上方显示`title`+`description`,下拉菜单的选项为`options`,`default_value`为下拉菜单默认值;
"""
urls = get_conf("SEARXNG_URLS")
url = random.choice(urls)

gui_definition = {
"main_input":
ArgProperty(title="输入问题", description="待通过互联网检索的问题,会自动读取输入框内容", default_value="", type="string").model_dump_json(), # 主输入,自动从输入框同步
Expand All @@ -30,7 +33,7 @@ def define_arg_selection_menu(self):
"optimizer":
ArgProperty(title="搜索优化", options=["关闭", "开启", "开启(增强)"], default_value="关闭", description="是否使用搜索增强。注意这可能会消耗较多token", type="dropdown").model_dump_json(),
"searxng_url":
ArgProperty(title="Searxng服务地址", description="输入Searxng的地址", default_value=get_conf("SEARXNG_URL"), type="string").model_dump_json(), # 主输入,自动从输入框同步
ArgProperty(title="Searxng服务地址", description="输入Searxng的地址", default_value=url, type="string").model_dump_json(), # 主输入,自动从输入框同步

}
return gui_definition
Expand Down
14 changes: 12 additions & 2 deletions tests/test_markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,18 @@
E --> B
D --> F[Save Image and Code]
F --> B
```
<details>
<summary><b>My section header in bold</b></summary>
Any folded content here. It requires an empty line just above it.
</details>
"""
def validate_path():
import os, sys
Expand All @@ -44,8 +54,8 @@ def validate_path():
validate_path() # validate path so you can run from base directory
from toolbox import markdown_convertion
from shared_utils.advanced_markdown_format import markdown_convertion_for_file
with open("gpt_log/default_user/shared/2024-04-22-01-27-43.zip.extract/translated_markdown.md", "r", encoding="utf-8") as f:
md = f.read()
# with open("gpt_log/default_user/shared/2024-04-22-01-27-43.zip.extract/translated_markdown.md", "r", encoding="utf-8") as f:
# md = f.read()
html = markdown_convertion_for_file(md)
# print(html)
with open("test.html", "w", encoding="utf-8") as f:
Expand Down

0 comments on commit bd7b219

Please sign in to comment.