From e37e11bf573defa1fbc6b53e8b9c1a7332a17c2d Mon Sep 17 00:00:00 2001 From: Nalvick Date: Fri, 23 May 2025 23:45:03 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=9C=A8OpenAI=20chat=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E4=B8=AD=EF=BC=8C=E9=80=82=E9=85=8DgoogleSearch?= =?UTF-8?q?=E5=86=85=E7=BD=AE=E5=B7=A5=E5=85=B7=E8=B0=83=E7=94=A8=E6=94=AF?= =?UTF-8?q?=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/service/chat/openai_chat_service.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/service/chat/openai_chat_service.py b/app/service/chat/openai_chat_service.py index 2b2da4d..d2866a0 100644 --- a/app/service/chat/openai_chat_service.py +++ b/app/service/chat/openai_chat_service.py @@ -83,8 +83,13 @@ def _build_tools( names, functions = set(), [] for fc in function_declarations: if fc.get("name") not in names: - names.add(fc.get("name")) - functions.append(fc) + if fc.get("name")=="googleSearch": + # cherry开启内置搜索时,添加googleSearch工具 + tool["googleSearch"] = {} + else: + # 其他函数,添加到functionDeclarations中 + names.add(fc.get("name")) + functions.append(fc) tool["functionDeclarations"] = functions