beswarm 0.1.12__py3-none-any.whl → 0.1.13__py3-none-any.whl

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 (75) hide show
  1. beswarm/aient/main.py +50 -0
  2. beswarm/aient/setup.py +15 -0
  3. beswarm/aient/src/aient/__init__.py +1 -0
  4. beswarm/aient/src/aient/core/__init__.py +1 -0
  5. beswarm/aient/src/aient/core/log_config.py +6 -0
  6. beswarm/aient/src/aient/core/models.py +232 -0
  7. beswarm/aient/src/aient/core/request.py +1665 -0
  8. beswarm/aient/src/aient/core/response.py +617 -0
  9. beswarm/aient/src/aient/core/test/test_base_api.py +18 -0
  10. beswarm/aient/src/aient/core/test/test_image.py +15 -0
  11. beswarm/aient/src/aient/core/test/test_payload.py +92 -0
  12. beswarm/aient/src/aient/core/utils.py +715 -0
  13. beswarm/aient/src/aient/models/__init__.py +9 -0
  14. beswarm/aient/src/aient/models/audio.py +63 -0
  15. beswarm/aient/src/aient/models/base.py +251 -0
  16. beswarm/aient/src/aient/models/chatgpt.py +938 -0
  17. beswarm/aient/src/aient/models/claude.py +640 -0
  18. beswarm/aient/src/aient/models/duckduckgo.py +241 -0
  19. beswarm/aient/src/aient/models/gemini.py +357 -0
  20. beswarm/aient/src/aient/models/groq.py +268 -0
  21. beswarm/aient/src/aient/models/vertex.py +420 -0
  22. beswarm/aient/src/aient/plugins/__init__.py +33 -0
  23. beswarm/aient/src/aient/plugins/arXiv.py +48 -0
  24. beswarm/aient/src/aient/plugins/config.py +172 -0
  25. beswarm/aient/src/aient/plugins/excute_command.py +35 -0
  26. beswarm/aient/src/aient/plugins/get_time.py +19 -0
  27. beswarm/aient/src/aient/plugins/image.py +72 -0
  28. beswarm/aient/src/aient/plugins/list_directory.py +50 -0
  29. beswarm/aient/src/aient/plugins/read_file.py +79 -0
  30. beswarm/aient/src/aient/plugins/registry.py +116 -0
  31. beswarm/aient/src/aient/plugins/run_python.py +156 -0
  32. beswarm/aient/src/aient/plugins/websearch.py +394 -0
  33. beswarm/aient/src/aient/plugins/write_file.py +51 -0
  34. beswarm/aient/src/aient/prompt/__init__.py +1 -0
  35. beswarm/aient/src/aient/prompt/agent.py +280 -0
  36. beswarm/aient/src/aient/utils/__init__.py +0 -0
  37. beswarm/aient/src/aient/utils/prompt.py +143 -0
  38. beswarm/aient/src/aient/utils/scripts.py +721 -0
  39. beswarm/aient/test/chatgpt.py +161 -0
  40. beswarm/aient/test/claude.py +32 -0
  41. beswarm/aient/test/test.py +2 -0
  42. beswarm/aient/test/test_API.py +6 -0
  43. beswarm/aient/test/test_Deepbricks.py +20 -0
  44. beswarm/aient/test/test_Web_crawler.py +262 -0
  45. beswarm/aient/test/test_aiwaves.py +25 -0
  46. beswarm/aient/test/test_aiwaves_arxiv.py +19 -0
  47. beswarm/aient/test/test_ask_gemini.py +8 -0
  48. beswarm/aient/test/test_class.py +17 -0
  49. beswarm/aient/test/test_claude.py +23 -0
  50. beswarm/aient/test/test_claude_zh_char.py +26 -0
  51. beswarm/aient/test/test_ddg_search.py +50 -0
  52. beswarm/aient/test/test_download_pdf.py +56 -0
  53. beswarm/aient/test/test_gemini.py +97 -0
  54. beswarm/aient/test/test_get_token_dict.py +21 -0
  55. beswarm/aient/test/test_google_search.py +35 -0
  56. beswarm/aient/test/test_jieba.py +32 -0
  57. beswarm/aient/test/test_json.py +65 -0
  58. beswarm/aient/test/test_langchain_search_old.py +235 -0
  59. beswarm/aient/test/test_logging.py +32 -0
  60. beswarm/aient/test/test_ollama.py +55 -0
  61. beswarm/aient/test/test_plugin.py +16 -0
  62. beswarm/aient/test/test_py_run.py +26 -0
  63. beswarm/aient/test/test_requests.py +162 -0
  64. beswarm/aient/test/test_search.py +18 -0
  65. beswarm/aient/test/test_tikitoken.py +19 -0
  66. beswarm/aient/test/test_token.py +94 -0
  67. beswarm/aient/test/test_url.py +33 -0
  68. beswarm/aient/test/test_whisper.py +14 -0
  69. beswarm/aient/test/test_wildcard.py +20 -0
  70. beswarm/aient/test/test_yjh.py +21 -0
  71. {beswarm-0.1.12.dist-info → beswarm-0.1.13.dist-info}/METADATA +1 -1
  72. beswarm-0.1.13.dist-info/RECORD +131 -0
  73. beswarm-0.1.12.dist-info/RECORD +0 -61
  74. {beswarm-0.1.12.dist-info → beswarm-0.1.13.dist-info}/WHEEL +0 -0
  75. {beswarm-0.1.12.dist-info → beswarm-0.1.13.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,92 @@
1
+ import json
2
+ import asyncio
3
+
4
+ from ..request import prepare_request_payload
5
+
6
+ """
7
+ 测试脚本: 用于测试core/request.py中的get_payload函数
8
+
9
+ 该测试脚本构造core/models.py中的RequestModel对象,然后调用core/request.py的get_payload函数,
10
+ 返回url, headers, payload。通过这种方式可以单独测试get_payload模块的功能。
11
+
12
+ 测试用例: 带工具函数的模型调用测试
13
+
14
+ 使用的API配置信息来自api.yaml中的'new-i1-pe'。
15
+
16
+ python -m core.test_payload
17
+ """
18
+
19
+ async def test_payload():
20
+ print("===== 开始测试 get_payload 函数 =====")
21
+
22
+ # 步骤1: 配置provider
23
+ provider = {
24
+ "provider": "new",
25
+ "base_url": "/v1/chat/completions",
26
+ "api": "",
27
+ "model": [
28
+ "gpt-4" # 使用支持工具功能的模型名称
29
+ ],
30
+ "tools": True # 启用工具支持
31
+ }
32
+
33
+ request_data = {
34
+ "model": "gpt-4",
35
+ "messages": [
36
+ {
37
+ "role": "system",
38
+ "content": "你是一个有用的AI助手。"
39
+ },
40
+ {
41
+ "role": "user",
42
+ "content": "你好,请介绍一下自己。"
43
+ }
44
+ ],
45
+ "stream": True,
46
+ "temperature": 0.7,
47
+ "max_tokens": 1000,
48
+ "tools": [
49
+ {
50
+ "type": "function",
51
+ "function": {
52
+ "name": "get_current_weather",
53
+ "description": "获取当前天气信息",
54
+ "parameters": {
55
+ "type": "object",
56
+ "properties": {
57
+ "location": {
58
+ "type": "string",
59
+ "description": "城市名称,例如:北京"
60
+ },
61
+ "unit": {
62
+ "type": "string",
63
+ "enum": ["celsius", "fahrenheit"],
64
+ "description": "温度单位"
65
+ }
66
+ },
67
+ "required": ["location"]
68
+ }
69
+ }
70
+ }
71
+ ],
72
+ "tool_choice": "auto" # 添加工具选择参数
73
+ }
74
+
75
+ # 调用函数处理请求并获取结果
76
+ url, headers, payload, engine = await prepare_request_payload(provider, request_data)
77
+
78
+ # 打印结果
79
+ print("\nURL:")
80
+ print(url)
81
+
82
+ print("\nHeaders:")
83
+ print(json.dumps(headers, indent=4, ensure_ascii=False))
84
+
85
+ print("\nPayload:")
86
+ print(json.dumps(payload, indent=4, ensure_ascii=False))
87
+
88
+ print("\n===== 测试完成 =====")
89
+
90
+ if __name__ == "__main__":
91
+ # 执行异步测试函数
92
+ asyncio.run(test_payload())