aient 1.1.65__tar.gz → 1.1.67__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {aient-1.1.65 → aient-1.1.67}/PKG-INFO +1 -1
- {aient-1.1.65 → aient-1.1.67}/aient/core/request.py +21 -18
- {aient-1.1.65 → aient-1.1.67}/aient/models/chatgpt.py +13 -2
- {aient-1.1.65 → aient-1.1.67}/aient.egg-info/PKG-INFO +1 -1
- {aient-1.1.65 → aient-1.1.67}/pyproject.toml +1 -1
- {aient-1.1.65 → aient-1.1.67}/LICENSE +0 -0
- {aient-1.1.65 → aient-1.1.67}/README.md +0 -0
- {aient-1.1.65 → aient-1.1.67}/aient/__init__.py +0 -0
- {aient-1.1.65 → aient-1.1.67}/aient/core/__init__.py +0 -0
- {aient-1.1.65 → aient-1.1.67}/aient/core/log_config.py +0 -0
- {aient-1.1.65 → aient-1.1.67}/aient/core/models.py +0 -0
- {aient-1.1.65 → aient-1.1.67}/aient/core/response.py +0 -0
- {aient-1.1.65 → aient-1.1.67}/aient/core/test/test_base_api.py +0 -0
- {aient-1.1.65 → aient-1.1.67}/aient/core/test/test_geminimask.py +0 -0
- {aient-1.1.65 → aient-1.1.67}/aient/core/test/test_image.py +0 -0
- {aient-1.1.65 → aient-1.1.67}/aient/core/test/test_payload.py +0 -0
- {aient-1.1.65 → aient-1.1.67}/aient/core/utils.py +0 -0
- {aient-1.1.65 → aient-1.1.67}/aient/models/__init__.py +0 -0
- {aient-1.1.65 → aient-1.1.67}/aient/models/audio.py +0 -0
- {aient-1.1.65 → aient-1.1.67}/aient/models/base.py +0 -0
- {aient-1.1.65 → aient-1.1.67}/aient/plugins/__init__.py +0 -0
- {aient-1.1.65 → aient-1.1.67}/aient/plugins/arXiv.py +0 -0
- {aient-1.1.65 → aient-1.1.67}/aient/plugins/config.py +0 -0
- {aient-1.1.65 → aient-1.1.67}/aient/plugins/excute_command.py +0 -0
- {aient-1.1.65 → aient-1.1.67}/aient/plugins/get_time.py +0 -0
- {aient-1.1.65 → aient-1.1.67}/aient/plugins/image.py +0 -0
- {aient-1.1.65 → aient-1.1.67}/aient/plugins/list_directory.py +0 -0
- {aient-1.1.65 → aient-1.1.67}/aient/plugins/read_file.py +0 -0
- {aient-1.1.65 → aient-1.1.67}/aient/plugins/read_image.py +0 -0
- {aient-1.1.65 → aient-1.1.67}/aient/plugins/readonly.py +0 -0
- {aient-1.1.65 → aient-1.1.67}/aient/plugins/registry.py +0 -0
- {aient-1.1.65 → aient-1.1.67}/aient/plugins/run_python.py +0 -0
- {aient-1.1.65 → aient-1.1.67}/aient/plugins/websearch.py +0 -0
- {aient-1.1.65 → aient-1.1.67}/aient/plugins/write_file.py +0 -0
- {aient-1.1.65 → aient-1.1.67}/aient/utils/__init__.py +0 -0
- {aient-1.1.65 → aient-1.1.67}/aient/utils/prompt.py +0 -0
- {aient-1.1.65 → aient-1.1.67}/aient/utils/scripts.py +0 -0
- {aient-1.1.65 → aient-1.1.67}/aient.egg-info/SOURCES.txt +0 -0
- {aient-1.1.65 → aient-1.1.67}/aient.egg-info/dependency_links.txt +0 -0
- {aient-1.1.65 → aient-1.1.67}/aient.egg-info/requires.txt +0 -0
- {aient-1.1.65 → aient-1.1.67}/aient.egg-info/top_level.txt +0 -0
- {aient-1.1.65 → aient-1.1.67}/setup.cfg +0 -0
- {aient-1.1.65 → aient-1.1.67}/test/test_Web_crawler.py +0 -0
- {aient-1.1.65 → aient-1.1.67}/test/test_ddg_search.py +0 -0
- {aient-1.1.65 → aient-1.1.67}/test/test_google_search.py +0 -0
- {aient-1.1.65 → aient-1.1.67}/test/test_ollama.py +0 -0
- {aient-1.1.65 → aient-1.1.67}/test/test_plugin.py +0 -0
- {aient-1.1.65 → aient-1.1.67}/test/test_search.py +0 -0
- {aient-1.1.65 → aient-1.1.67}/test/test_url.py +0 -0
- {aient-1.1.65 → aient-1.1.67}/test/test_whisper.py +0 -0
- {aient-1.1.65 → aient-1.1.67}/test/test_yjh.py +0 -0
@@ -27,8 +27,6 @@ from .utils import (
|
|
27
27
|
gemini_max_token_65k_models = ["gemini-2.5-pro", "gemini-2.0-pro", "gemini-2.0-flash-thinking", "gemini-2.5-flash"]
|
28
28
|
|
29
29
|
async def get_gemini_payload(request, engine, provider, api_key=None):
|
30
|
-
import re
|
31
|
-
|
32
30
|
headers = {
|
33
31
|
'Content-Type': 'application/json'
|
34
32
|
}
|
@@ -176,6 +174,24 @@ async def get_gemini_payload(request, engine, provider, api_key=None):
|
|
176
174
|
]
|
177
175
|
generation_config = {}
|
178
176
|
|
177
|
+
def process_tool_parameters(data):
|
178
|
+
if isinstance(data, dict):
|
179
|
+
# 移除 Gemini 不支持的 'additionalProperties'
|
180
|
+
data.pop("additionalProperties", None)
|
181
|
+
|
182
|
+
# 将 'default' 值移入 'description'
|
183
|
+
if "default" in data:
|
184
|
+
default_value = data.pop("default")
|
185
|
+
description = data.get("description", "")
|
186
|
+
data["description"] = f"{description}\nDefault: {default_value}"
|
187
|
+
|
188
|
+
# 递归处理
|
189
|
+
for value in data.values():
|
190
|
+
process_tool_parameters(value)
|
191
|
+
elif isinstance(data, list):
|
192
|
+
for item in data:
|
193
|
+
process_tool_parameters(item)
|
194
|
+
|
179
195
|
for field, value in request.model_dump(exclude_unset=True).items():
|
180
196
|
if field not in miss_fields and value is not None:
|
181
197
|
if field == "tools" and "gemini-2.0-flash-thinking" in original_model:
|
@@ -185,22 +201,9 @@ async def get_gemini_payload(request, engine, provider, api_key=None):
|
|
185
201
|
processed_tools = []
|
186
202
|
for tool in value:
|
187
203
|
function_def = tool["function"]
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
# 处理 parameters.properties 中的 default 字段
|
193
|
-
if safe_get(function_def, "parameters", "properties", default=None):
|
194
|
-
for prop_value in function_def["parameters"]["properties"].values():
|
195
|
-
if "additionalProperties" in prop_value:
|
196
|
-
del prop_value["additionalProperties"]
|
197
|
-
if "default" in prop_value:
|
198
|
-
# 将 default 值添加到 description 中
|
199
|
-
default_value = prop_value["default"]
|
200
|
-
description = prop_value.get("description", "")
|
201
|
-
prop_value["description"] = f"{description}\nDefault: {default_value}"
|
202
|
-
# 删除 default 字段
|
203
|
-
del prop_value["default"]
|
204
|
+
if "parameters" in function_def:
|
205
|
+
process_tool_parameters(function_def["parameters"])
|
206
|
+
|
204
207
|
if function_def["name"] != "googleSearch" and function_def["name"] != "googleSearch":
|
205
208
|
processed_tools.append({"function": function_def})
|
206
209
|
|
@@ -67,6 +67,7 @@ class chatgpt(BaseLLM):
|
|
67
67
|
cut_history_by_function_name: str = "",
|
68
68
|
cache_messages: list = None,
|
69
69
|
logger: logging.Logger = None,
|
70
|
+
check_done: bool = False,
|
70
71
|
) -> None:
|
71
72
|
"""
|
72
73
|
Initialize Chatbot with API key (from https://platform.openai.com/account/api-keys)
|
@@ -86,6 +87,7 @@ class chatgpt(BaseLLM):
|
|
86
87
|
self.function_call_max_loop = function_call_max_loop
|
87
88
|
self.cut_history_by_function_name = cut_history_by_function_name
|
88
89
|
self.latest_file_content = {}
|
90
|
+
self.check_done = check_done
|
89
91
|
|
90
92
|
if logger:
|
91
93
|
self.logger = logger
|
@@ -465,6 +467,12 @@ class chatgpt(BaseLLM):
|
|
465
467
|
missing_required_params = []
|
466
468
|
|
467
469
|
if self.use_plugins == True:
|
470
|
+
if self.check_done:
|
471
|
+
# self.logger.info(f"worker Response: {full_response}")
|
472
|
+
if not full_response.strip().endswith('[done]'):
|
473
|
+
raise Exception(f"Response is not ended with [done]: {full_response}")
|
474
|
+
else:
|
475
|
+
full_response = full_response.strip().rstrip('[done]')
|
468
476
|
full_response = full_response.replace("<tool_code>", "").replace("</tool_code>", "")
|
469
477
|
function_parameter = parse_function_xml(full_response)
|
470
478
|
if function_parameter:
|
@@ -711,7 +719,7 @@ class chatgpt(BaseLLM):
|
|
711
719
|
self.logger.info(f"api_key: {kwargs.get('api_key', self.api_key)}")
|
712
720
|
|
713
721
|
# 发送请求并处理响应
|
714
|
-
for i in range(
|
722
|
+
for i in range(10):
|
715
723
|
if self.print_log:
|
716
724
|
replaced_text = json.loads(re.sub(r';base64,([A-Za-z0-9+/=]+)', ';base64,***', json.dumps(json_post)))
|
717
725
|
replaced_text_str = json.dumps(replaced_text, indent=4, ensure_ascii=False)
|
@@ -763,6 +771,9 @@ class chatgpt(BaseLLM):
|
|
763
771
|
except httpx.RemoteProtocolError:
|
764
772
|
continue
|
765
773
|
except Exception as e:
|
774
|
+
if "Response is not ended with [done]:" in str(e):
|
775
|
+
self.logger.error(f"Response is not ended with [done]: {e}")
|
776
|
+
continue
|
766
777
|
self.logger.error(f"发生了未预料的错误:{e}")
|
767
778
|
import traceback
|
768
779
|
self.logger.error(traceback.format_exc())
|
@@ -770,7 +781,7 @@ class chatgpt(BaseLLM):
|
|
770
781
|
e = "您输入了无效的API URL,请使用正确的URL并使用`/start`命令重新设置API URL。具体错误如下:\n\n" + str(e)
|
771
782
|
raise Exception(f"{e}")
|
772
783
|
# 最后一次重试失败,向上抛出异常
|
773
|
-
if i ==
|
784
|
+
if i == 11:
|
774
785
|
raise Exception(f"{e}")
|
775
786
|
|
776
787
|
def ask_stream(
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|