XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 1
返回提交历史

XFEstudio/gpt4free

Add missing webview requirements Fix web_search in Web UI

ae978ad5
hlohaus <983577+hlohaus@users.noreply.github.com>
提交于

代码差异

4 个文件 +14 -12
Modified g4f/gui/server/api.py +3 -8
@@ -99,14 +99,9 @@ class Api:
99 99 },
100 100 "type": "function"
101 101 }]
102 do_web_search = json_data.get('web_search')
103 if do_web_search and provider:
104 kwargs["tool_calls"].append({
105 "function": {
106 "name": "safe_search_tool"
107 },
108 "type": "function"
109 })
102 web_search = json_data.get('web_search')
103 if web_search:
104 kwargs["web_search"] = web_search
110 105 action = json_data.get('action')
111 106 if action == "continue":
112 107 kwargs["tool_calls"].append({
Modified g4f/tools/run_tools.py +6 -4
@@ -29,10 +29,11 @@ def validate_arguments(data: dict) -> dict:
29 29
30 30 async def async_iter_run_tools(async_iter_callback, model, messages, tool_calls: Optional[list] = None, **kwargs):
31 31 # Handle web_search from kwargs
32 if kwargs.get('web_search'):
32 web_search = kwargs.get('web_search')
33 if web_search:
33 34 try:
34 35 messages = messages.copy()
35 messages[-1]["content"] = await do_search(messages[-1]["content"])
36 messages[-1]["content"] = await do_search(messages[-1]["content"], web_search if web_search != "true" else None)
36 37 except Exception as e:
37 38 debug.log(f"Couldn't do web search: {e.__class__.__name__}: {e}")
38 39 # Keep web_search in kwargs for provider native support
@@ -78,10 +79,11 @@ def iter_run_tools(
78 79 **kwargs
79 80 ) -> AsyncIterator:
80 81 # Handle web_search from kwargs
81 if kwargs.get('web_search'):
82 web_search = kwargs.get('web_search')
83 if web_search:
82 84 try:
83 85 messages = messages.copy()
84 messages[-1]["content"] = asyncio.run(do_search(messages[-1]["content"]))
86 messages[-1]["content"] = asyncio.run(do_search(messages[-1]["content"], web_search if web_search != "true" else None))
85 87 except Exception as e:
86 88 debug.log(f"Couldn't do web search: {e.__class__.__name__}: {e}")
87 89 # Keep web_search in kwargs for provider native support
Modified requirements.txt +2 -0
@@ -16,6 +16,8 @@ brotli
16 16 beautifulsoup4
17 17 aiohttp_socks
18 18 pywebview
19 plyer
20 setuptools
19 21 cryptography
20 22 nodriver
21 23 python-multipart
Modified setup.py +3 -0
@@ -36,6 +36,9 @@ EXTRA_REQUIRE = {
36 36 "uvicorn", # api
37 37 "nodriver",
38 38 "python-multipart",
39 "pywebview",
40 "plyer",
41 "setuptools",
39 42 "pypdf2", # files
40 43 "docx",
41 44 "odfpy",