aient 1.1.64__tar.gz → 1.1.65__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.
Files changed (51) hide show
  1. {aient-1.1.64 → aient-1.1.65}/PKG-INFO +1 -1
  2. {aient-1.1.64 → aient-1.1.65}/aient/core/response.py +26 -38
  3. {aient-1.1.64 → aient-1.1.65}/aient/core/utils.py +8 -2
  4. {aient-1.1.64 → aient-1.1.65}/aient.egg-info/PKG-INFO +1 -1
  5. {aient-1.1.64 → aient-1.1.65}/pyproject.toml +1 -1
  6. {aient-1.1.64 → aient-1.1.65}/LICENSE +0 -0
  7. {aient-1.1.64 → aient-1.1.65}/README.md +0 -0
  8. {aient-1.1.64 → aient-1.1.65}/aient/__init__.py +0 -0
  9. {aient-1.1.64 → aient-1.1.65}/aient/core/__init__.py +0 -0
  10. {aient-1.1.64 → aient-1.1.65}/aient/core/log_config.py +0 -0
  11. {aient-1.1.64 → aient-1.1.65}/aient/core/models.py +0 -0
  12. {aient-1.1.64 → aient-1.1.65}/aient/core/request.py +0 -0
  13. {aient-1.1.64 → aient-1.1.65}/aient/core/test/test_base_api.py +0 -0
  14. {aient-1.1.64 → aient-1.1.65}/aient/core/test/test_geminimask.py +0 -0
  15. {aient-1.1.64 → aient-1.1.65}/aient/core/test/test_image.py +0 -0
  16. {aient-1.1.64 → aient-1.1.65}/aient/core/test/test_payload.py +0 -0
  17. {aient-1.1.64 → aient-1.1.65}/aient/models/__init__.py +0 -0
  18. {aient-1.1.64 → aient-1.1.65}/aient/models/audio.py +0 -0
  19. {aient-1.1.64 → aient-1.1.65}/aient/models/base.py +0 -0
  20. {aient-1.1.64 → aient-1.1.65}/aient/models/chatgpt.py +0 -0
  21. {aient-1.1.64 → aient-1.1.65}/aient/plugins/__init__.py +0 -0
  22. {aient-1.1.64 → aient-1.1.65}/aient/plugins/arXiv.py +0 -0
  23. {aient-1.1.64 → aient-1.1.65}/aient/plugins/config.py +0 -0
  24. {aient-1.1.64 → aient-1.1.65}/aient/plugins/excute_command.py +0 -0
  25. {aient-1.1.64 → aient-1.1.65}/aient/plugins/get_time.py +0 -0
  26. {aient-1.1.64 → aient-1.1.65}/aient/plugins/image.py +0 -0
  27. {aient-1.1.64 → aient-1.1.65}/aient/plugins/list_directory.py +0 -0
  28. {aient-1.1.64 → aient-1.1.65}/aient/plugins/read_file.py +0 -0
  29. {aient-1.1.64 → aient-1.1.65}/aient/plugins/read_image.py +0 -0
  30. {aient-1.1.64 → aient-1.1.65}/aient/plugins/readonly.py +0 -0
  31. {aient-1.1.64 → aient-1.1.65}/aient/plugins/registry.py +0 -0
  32. {aient-1.1.64 → aient-1.1.65}/aient/plugins/run_python.py +0 -0
  33. {aient-1.1.64 → aient-1.1.65}/aient/plugins/websearch.py +0 -0
  34. {aient-1.1.64 → aient-1.1.65}/aient/plugins/write_file.py +0 -0
  35. {aient-1.1.64 → aient-1.1.65}/aient/utils/__init__.py +0 -0
  36. {aient-1.1.64 → aient-1.1.65}/aient/utils/prompt.py +0 -0
  37. {aient-1.1.64 → aient-1.1.65}/aient/utils/scripts.py +0 -0
  38. {aient-1.1.64 → aient-1.1.65}/aient.egg-info/SOURCES.txt +0 -0
  39. {aient-1.1.64 → aient-1.1.65}/aient.egg-info/dependency_links.txt +0 -0
  40. {aient-1.1.64 → aient-1.1.65}/aient.egg-info/requires.txt +0 -0
  41. {aient-1.1.64 → aient-1.1.65}/aient.egg-info/top_level.txt +0 -0
  42. {aient-1.1.64 → aient-1.1.65}/setup.cfg +0 -0
  43. {aient-1.1.64 → aient-1.1.65}/test/test_Web_crawler.py +0 -0
  44. {aient-1.1.64 → aient-1.1.65}/test/test_ddg_search.py +0 -0
  45. {aient-1.1.64 → aient-1.1.65}/test/test_google_search.py +0 -0
  46. {aient-1.1.64 → aient-1.1.65}/test/test_ollama.py +0 -0
  47. {aient-1.1.64 → aient-1.1.65}/test/test_plugin.py +0 -0
  48. {aient-1.1.64 → aient-1.1.65}/test/test_search.py +0 -0
  49. {aient-1.1.64 → aient-1.1.65}/test/test_url.py +0 -0
  50. {aient-1.1.64 → aient-1.1.65}/test/test_whisper.py +0 -0
  51. {aient-1.1.64 → aient-1.1.65}/test/test_yjh.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aient
3
- Version: 1.1.64
3
+ Version: 1.1.65
4
4
  Summary: Aient: The Awakening of Agent.
5
5
  Requires-Python: >=3.11
6
6
  Description-Content-Type: text/markdown
@@ -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
- message = resp.get("message")
433
- if message:
434
- role = message.get("role")
435
- if role:
436
- sse_string = await generate_sse_response(timestamp, model, None, None, None, None, role)
437
- yield sse_string
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
- # print("\n\rtotal_tokens", total_tokens)
448
-
449
- tool_use = resp.get("content_block")
450
- tools_id = None
451
- function_call_name = None
452
- if tool_use and "tool_use" == tool_use['type']:
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
- if "text" in delta:
464
- content = delta["text"]
465
- sse_string = await generate_sse_response(timestamp, model, content, None, None)
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
- if "thinking" in delta and delta["thinking"]:
468
- content = delta["thinking"]
469
- sse_string = await generate_sse_response(timestamp, model, reasoning_content=content)
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
- if "partial_json" in delta:
472
- # {"type":"input_json_delta","partial_json":""}
473
- function_call_content = delta["partial_json"]
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
- self.v1_models: str = urlunparse(parsed_url[:2] + (before_v1 + "models",) + ("",) * 3)
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
- headers = {"Authorization": f"Bearer {api}"}
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,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aient
3
- Version: 1.1.64
3
+ Version: 1.1.65
4
4
  Summary: Aient: The Awakening of Agent.
5
5
  Requires-Python: >=3.11
6
6
  Description-Content-Type: text/markdown
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "aient"
3
- version = "1.1.64"
3
+ version = "1.1.65"
4
4
  description = "Aient: The Awakening of Agent."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
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