aient 1.2.27__tar.gz → 1.2.28__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 (56) hide show
  1. {aient-1.2.27 → aient-1.2.28}/PKG-INFO +1 -1
  2. {aient-1.2.27 → aient-1.2.28}/aient/core/response.py +3 -2
  3. {aient-1.2.27 → aient-1.2.28}/aient/core/utils.py +38 -0
  4. {aient-1.2.27 → aient-1.2.28}/aient.egg-info/PKG-INFO +1 -1
  5. {aient-1.2.27 → aient-1.2.28}/pyproject.toml +1 -1
  6. {aient-1.2.27 → aient-1.2.28}/LICENSE +0 -0
  7. {aient-1.2.27 → aient-1.2.28}/README.md +0 -0
  8. {aient-1.2.27 → aient-1.2.28}/aient/__init__.py +0 -0
  9. {aient-1.2.27 → aient-1.2.28}/aient/architext/architext/__init__.py +0 -0
  10. {aient-1.2.27 → aient-1.2.28}/aient/architext/architext/core.py +0 -0
  11. {aient-1.2.27 → aient-1.2.28}/aient/architext/test/openai_client.py +0 -0
  12. {aient-1.2.27 → aient-1.2.28}/aient/architext/test/test.py +0 -0
  13. {aient-1.2.27 → aient-1.2.28}/aient/architext/test/test_save_load.py +0 -0
  14. {aient-1.2.27 → aient-1.2.28}/aient/core/__init__.py +0 -0
  15. {aient-1.2.27 → aient-1.2.28}/aient/core/log_config.py +0 -0
  16. {aient-1.2.27 → aient-1.2.28}/aient/core/models.py +0 -0
  17. {aient-1.2.27 → aient-1.2.28}/aient/core/request.py +0 -0
  18. {aient-1.2.27 → aient-1.2.28}/aient/core/test/test_base_api.py +0 -0
  19. {aient-1.2.27 → aient-1.2.28}/aient/core/test/test_geminimask.py +0 -0
  20. {aient-1.2.27 → aient-1.2.28}/aient/core/test/test_image.py +0 -0
  21. {aient-1.2.27 → aient-1.2.28}/aient/core/test/test_payload.py +0 -0
  22. {aient-1.2.27 → aient-1.2.28}/aient/models/__init__.py +0 -0
  23. {aient-1.2.27 → aient-1.2.28}/aient/models/audio.py +0 -0
  24. {aient-1.2.27 → aient-1.2.28}/aient/models/base.py +0 -0
  25. {aient-1.2.27 → aient-1.2.28}/aient/models/chatgpt.py +0 -0
  26. {aient-1.2.27 → aient-1.2.28}/aient/plugins/__init__.py +0 -0
  27. {aient-1.2.27 → aient-1.2.28}/aient/plugins/arXiv.py +0 -0
  28. {aient-1.2.27 → aient-1.2.28}/aient/plugins/config.py +0 -0
  29. {aient-1.2.27 → aient-1.2.28}/aient/plugins/excute_command.py +0 -0
  30. {aient-1.2.27 → aient-1.2.28}/aient/plugins/get_time.py +0 -0
  31. {aient-1.2.27 → aient-1.2.28}/aient/plugins/image.py +0 -0
  32. {aient-1.2.27 → aient-1.2.28}/aient/plugins/list_directory.py +0 -0
  33. {aient-1.2.27 → aient-1.2.28}/aient/plugins/read_file.py +0 -0
  34. {aient-1.2.27 → aient-1.2.28}/aient/plugins/read_image.py +0 -0
  35. {aient-1.2.27 → aient-1.2.28}/aient/plugins/readonly.py +0 -0
  36. {aient-1.2.27 → aient-1.2.28}/aient/plugins/registry.py +0 -0
  37. {aient-1.2.27 → aient-1.2.28}/aient/plugins/run_python.py +0 -0
  38. {aient-1.2.27 → aient-1.2.28}/aient/plugins/websearch.py +0 -0
  39. {aient-1.2.27 → aient-1.2.28}/aient/plugins/write_file.py +0 -0
  40. {aient-1.2.27 → aient-1.2.28}/aient/utils/__init__.py +0 -0
  41. {aient-1.2.27 → aient-1.2.28}/aient/utils/prompt.py +0 -0
  42. {aient-1.2.27 → aient-1.2.28}/aient/utils/scripts.py +0 -0
  43. {aient-1.2.27 → aient-1.2.28}/aient.egg-info/SOURCES.txt +0 -0
  44. {aient-1.2.27 → aient-1.2.28}/aient.egg-info/dependency_links.txt +0 -0
  45. {aient-1.2.27 → aient-1.2.28}/aient.egg-info/requires.txt +0 -0
  46. {aient-1.2.27 → aient-1.2.28}/aient.egg-info/top_level.txt +0 -0
  47. {aient-1.2.27 → aient-1.2.28}/setup.cfg +0 -0
  48. {aient-1.2.27 → aient-1.2.28}/test/test_Web_crawler.py +0 -0
  49. {aient-1.2.27 → aient-1.2.28}/test/test_ddg_search.py +0 -0
  50. {aient-1.2.27 → aient-1.2.28}/test/test_google_search.py +0 -0
  51. {aient-1.2.27 → aient-1.2.28}/test/test_ollama.py +0 -0
  52. {aient-1.2.27 → aient-1.2.28}/test/test_plugin.py +0 -0
  53. {aient-1.2.27 → aient-1.2.28}/test/test_search.py +0 -0
  54. {aient-1.2.27 → aient-1.2.28}/test/test_url.py +0 -0
  55. {aient-1.2.27 → aient-1.2.28}/test/test_whisper.py +0 -0
  56. {aient-1.2.27 → aient-1.2.28}/test/test_yjh.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aient
3
- Version: 1.2.27
3
+ Version: 1.2.28
4
4
  Summary: Aient: The Awakening of Agent.
5
5
  Requires-Python: >=3.11
6
6
  Description-Content-Type: text/markdown
@@ -8,7 +8,7 @@ from datetime import datetime
8
8
 
9
9
  from .log_config import logger
10
10
 
11
- from .utils import safe_get, generate_sse_response, generate_no_stream_response, end_of_line, parse_json_safely
11
+ from .utils import safe_get, generate_sse_response, generate_no_stream_response, end_of_line, parse_json_safely, upload_image_to_0x0st
12
12
 
13
13
  async def check_response(response, error_log):
14
14
  if response and not (200 <= response.status_code < 300):
@@ -277,7 +277,8 @@ async def fetch_gpt_response_stream(client, url, headers, payload, timeout):
277
277
  openrouter_reasoning = safe_get(line, "choices", 0, "delta", "reasoning", default="")
278
278
  openrouter_base64_image = safe_get(line, "choices", 0, "delta", "images", 0, "image_url", "url", default="")
279
279
  if openrouter_base64_image:
280
- sse_string = await generate_sse_response(timestamp, payload["model"], content=f"\n\n![image]({openrouter_base64_image})")
280
+ image_url = await upload_image_to_0x0st(openrouter_base64_image)
281
+ sse_string = await generate_sse_response(timestamp, payload["model"], content=f"\n\n![image]({image_url})")
281
282
  yield sse_string
282
283
  continue
283
284
  azure_databricks_claude_summary_content = safe_get(line, "choices", 0, "delta", "content", 0, "summary", 0, "text", default="")
@@ -797,6 +797,44 @@ def parse_json_safely(json_str):
797
797
  # 两种方法都失败,抛出异常
798
798
  raise Exception(f"无法解析JSON字符串: {e}, {json_str}")
799
799
 
800
+ async def upload_image_to_0x0st(base64_image: str):
801
+ """
802
+ Uploads a base64 encoded image to 0x0.st.
803
+
804
+ Args:
805
+ base64_image: The base64 encoded image string.
806
+
807
+ Returns:
808
+ The URL of the uploaded image.
809
+ """
810
+ if "," in base64_image:
811
+ base64_image_split = base64_image.split(",")[1]
812
+
813
+ image_data = base64.b64decode(base64_image_split)
814
+
815
+ img_format = get_image_format(image_data)
816
+ if not img_format:
817
+ img_format = 'png' # 如果无法检测到格式,则默认为 png
818
+
819
+ content_type = f'image/{img_format}'
820
+ file_name = f'image.{img_format}'
821
+
822
+ files = {'file': (file_name, image_data, content_type)}
823
+ data = {'expires': '24', 'secret': '123456'}
824
+
825
+ async with httpx.AsyncClient() as client:
826
+ try:
827
+ response = await client.post("https://0x0.st", files=files, data=data)
828
+ response.raise_for_status()
829
+ return response.text.strip()
830
+ except httpx.RequestError as e:
831
+ logger.error(f"请求 0x0.st 时出错: {e}")
832
+ # raise HTTPException(status_code=500, detail="上传图片到 0x0.st 失败")
833
+ except httpx.HTTPStatusError as e:
834
+ logger.error(f"上传图片到 0x0.st 时发生 HTTP 错误: {e.response.status_code}")
835
+ # raise HTTPException(status_code=e.response.status_code, detail=f"上传图片到 0x0.st 失败: {e.response.text}")
836
+ return base64_image
837
+
800
838
  if __name__ == "__main__":
801
839
  provider = {
802
840
  "base_url": "https://gateway.ai.cloudflare.com/v1/%7Baccount_id%7D/%7Bgateway_id%7D/google-vertex-ai",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aient
3
- Version: 1.2.27
3
+ Version: 1.2.28
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.2.27"
3
+ version = "1.2.28"
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