aient 1.1.64__tar.gz → 1.1.66__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.64 → aient-1.1.66}/PKG-INFO +1 -1
- {aient-1.1.64 → aient-1.1.66}/aient/core/request.py +21 -18
- {aient-1.1.64 → aient-1.1.66}/aient/core/response.py +26 -38
- {aient-1.1.64 → aient-1.1.66}/aient/core/utils.py +8 -2
- {aient-1.1.64 → aient-1.1.66}/aient.egg-info/PKG-INFO +1 -1
- {aient-1.1.64 → aient-1.1.66}/pyproject.toml +1 -1
- {aient-1.1.64 → aient-1.1.66}/LICENSE +0 -0
- {aient-1.1.64 → aient-1.1.66}/README.md +0 -0
- {aient-1.1.64 → aient-1.1.66}/aient/__init__.py +0 -0
- {aient-1.1.64 → aient-1.1.66}/aient/core/__init__.py +0 -0
- {aient-1.1.64 → aient-1.1.66}/aient/core/log_config.py +0 -0
- {aient-1.1.64 → aient-1.1.66}/aient/core/models.py +0 -0
- {aient-1.1.64 → aient-1.1.66}/aient/core/test/test_base_api.py +0 -0
- {aient-1.1.64 → aient-1.1.66}/aient/core/test/test_geminimask.py +0 -0
- {aient-1.1.64 → aient-1.1.66}/aient/core/test/test_image.py +0 -0
- {aient-1.1.64 → aient-1.1.66}/aient/core/test/test_payload.py +0 -0
- {aient-1.1.64 → aient-1.1.66}/aient/models/__init__.py +0 -0
- {aient-1.1.64 → aient-1.1.66}/aient/models/audio.py +0 -0
- {aient-1.1.64 → aient-1.1.66}/aient/models/base.py +0 -0
- {aient-1.1.64 → aient-1.1.66}/aient/models/chatgpt.py +0 -0
- {aient-1.1.64 → aient-1.1.66}/aient/plugins/__init__.py +0 -0
- {aient-1.1.64 → aient-1.1.66}/aient/plugins/arXiv.py +0 -0
- {aient-1.1.64 → aient-1.1.66}/aient/plugins/config.py +0 -0
- {aient-1.1.64 → aient-1.1.66}/aient/plugins/excute_command.py +0 -0
- {aient-1.1.64 → aient-1.1.66}/aient/plugins/get_time.py +0 -0
- {aient-1.1.64 → aient-1.1.66}/aient/plugins/image.py +0 -0
- {aient-1.1.64 → aient-1.1.66}/aient/plugins/list_directory.py +0 -0
- {aient-1.1.64 → aient-1.1.66}/aient/plugins/read_file.py +0 -0
- {aient-1.1.64 → aient-1.1.66}/aient/plugins/read_image.py +0 -0
- {aient-1.1.64 → aient-1.1.66}/aient/plugins/readonly.py +0 -0
- {aient-1.1.64 → aient-1.1.66}/aient/plugins/registry.py +0 -0
- {aient-1.1.64 → aient-1.1.66}/aient/plugins/run_python.py +0 -0
- {aient-1.1.64 → aient-1.1.66}/aient/plugins/websearch.py +0 -0
- {aient-1.1.64 → aient-1.1.66}/aient/plugins/write_file.py +0 -0
- {aient-1.1.64 → aient-1.1.66}/aient/utils/__init__.py +0 -0
- {aient-1.1.64 → aient-1.1.66}/aient/utils/prompt.py +0 -0
- {aient-1.1.64 → aient-1.1.66}/aient/utils/scripts.py +0 -0
- {aient-1.1.64 → aient-1.1.66}/aient.egg-info/SOURCES.txt +0 -0
- {aient-1.1.64 → aient-1.1.66}/aient.egg-info/dependency_links.txt +0 -0
- {aient-1.1.64 → aient-1.1.66}/aient.egg-info/requires.txt +0 -0
- {aient-1.1.64 → aient-1.1.66}/aient.egg-info/top_level.txt +0 -0
- {aient-1.1.64 → aient-1.1.66}/setup.cfg +0 -0
- {aient-1.1.64 → aient-1.1.66}/test/test_Web_crawler.py +0 -0
- {aient-1.1.64 → aient-1.1.66}/test/test_ddg_search.py +0 -0
- {aient-1.1.64 → aient-1.1.66}/test/test_google_search.py +0 -0
- {aient-1.1.64 → aient-1.1.66}/test/test_ollama.py +0 -0
- {aient-1.1.64 → aient-1.1.66}/test/test_plugin.py +0 -0
- {aient-1.1.64 → aient-1.1.66}/test/test_search.py +0 -0
- {aient-1.1.64 → aient-1.1.66}/test/test_url.py +0 -0
- {aient-1.1.64 → aient-1.1.66}/test/test_whisper.py +0 -0
- {aient-1.1.64 → aient-1.1.66}/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
|
|
@@ -426,53 +426,41 @@ async def fetch_claude_response_stream(client, url, headers, payload, model):
|
|
426
426
|
line, buffer = buffer.split("\n", 1)
|
427
427
|
# logger.info(line)
|
428
428
|
|
429
|
-
if line.startswith("data:"):
|
430
|
-
line = line.lstrip("data: ")
|
429
|
+
if line.startswith("data:") and (line := line.lstrip("data: ")):
|
431
430
|
resp: dict = json.loads(line)
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
tokens_use = message.get("usage")
|
439
|
-
if tokens_use:
|
440
|
-
input_tokens = tokens_use.get("input_tokens", 0)
|
441
|
-
usage = resp.get("usage")
|
442
|
-
if usage:
|
443
|
-
output_tokens = usage.get("output_tokens", 0)
|
431
|
+
|
432
|
+
input_tokens = input_tokens or safe_get(resp, "message", "usage", "input_tokens", default=0)
|
433
|
+
# cache_creation_input_tokens = safe_get(resp, "message", "usage", "cache_creation_input_tokens", default=0)
|
434
|
+
# cache_read_input_tokens = safe_get(resp, "message", "usage", "cache_read_input_tokens", default=0)
|
435
|
+
output_tokens = safe_get(resp, "usage", "output_tokens", default=0)
|
436
|
+
if output_tokens:
|
444
437
|
total_tokens = input_tokens + output_tokens
|
445
438
|
sse_string = await generate_sse_response(timestamp, model, None, None, None, None, None, total_tokens, input_tokens, output_tokens)
|
446
439
|
yield sse_string
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
# print("tool_use", tool_use)
|
454
|
-
tools_id = tool_use["id"]
|
455
|
-
if "name" in tool_use:
|
456
|
-
function_call_name = tool_use["name"]
|
457
|
-
sse_string = await generate_sse_response(timestamp, model, None, tools_id, function_call_name, None)
|
458
|
-
yield sse_string
|
459
|
-
delta = resp.get("delta")
|
460
|
-
# print("delta", delta)
|
461
|
-
if not delta:
|
440
|
+
break
|
441
|
+
|
442
|
+
text = safe_get(resp, "delta", "text", default="")
|
443
|
+
if text:
|
444
|
+
sse_string = await generate_sse_response(timestamp, model, text)
|
445
|
+
yield sse_string
|
462
446
|
continue
|
463
|
-
|
464
|
-
|
465
|
-
|
447
|
+
|
448
|
+
function_call_name = safe_get(resp, "content_block", "name", default=None)
|
449
|
+
tools_id = safe_get(resp, "content_block", "id", default=None)
|
450
|
+
if tools_id and function_call_name:
|
451
|
+
sse_string = await generate_sse_response(timestamp, model, None, tools_id, function_call_name, None)
|
466
452
|
yield sse_string
|
467
|
-
|
468
|
-
|
469
|
-
|
453
|
+
|
454
|
+
thinking_content = safe_get(resp, "delta", "thinking", default="")
|
455
|
+
if thinking_content:
|
456
|
+
sse_string = await generate_sse_response(timestamp, model, reasoning_content=thinking_content)
|
470
457
|
yield sse_string
|
471
|
-
|
472
|
-
|
473
|
-
|
458
|
+
|
459
|
+
function_call_content = safe_get(resp, "delta", "partial_json", default="")
|
460
|
+
if function_call_content:
|
474
461
|
sse_string = await generate_sse_response(timestamp, model, None, None, None, function_call_content)
|
475
462
|
yield sse_string
|
463
|
+
|
476
464
|
yield "data: [DONE]" + end_of_line
|
477
465
|
|
478
466
|
async def fetch_aws_response_stream(client, url, headers, payload, model):
|
@@ -46,7 +46,10 @@ class BaseAPI:
|
|
46
46
|
before_v1 = ""
|
47
47
|
self.base_url: str = urlunparse(parsed_url[:2] + ("",) + ("",) * 3)
|
48
48
|
self.v1_url: str = urlunparse(parsed_url[:2]+ (before_v1,) + ("",) * 3)
|
49
|
-
|
49
|
+
if "v1/messages" in parsed_url.path:
|
50
|
+
self.v1_models: str = urlunparse(parsed_url[:2] + ("v1/models",) + ("",) * 3)
|
51
|
+
else:
|
52
|
+
self.v1_models: str = urlunparse(parsed_url[:2] + (before_v1 + "models",) + ("",) * 3)
|
50
53
|
self.chat_url: str = urlunparse(parsed_url[:2] + (before_v1 + "chat/completions",) + ("",) * 3)
|
51
54
|
self.image_url: str = urlunparse(parsed_url[:2] + (before_v1 + "images/generations",) + ("",) * 3)
|
52
55
|
if parsed_url.hostname == "dashscope.aliyuncs.com":
|
@@ -192,7 +195,10 @@ def update_initial_model(provider):
|
|
192
195
|
endpoint_models_url = endpoint.v1_models
|
193
196
|
if isinstance(api, list):
|
194
197
|
api = api[0]
|
195
|
-
|
198
|
+
if "v1/messages" in api_url:
|
199
|
+
headers = {"x-api-key": api, "anthropic-version": "2023-06-01"}
|
200
|
+
else:
|
201
|
+
headers = {"Authorization": f"Bearer {api}"}
|
196
202
|
response = httpx.get(
|
197
203
|
endpoint_models_url,
|
198
204
|
headers=headers,
|
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
|