agent-builder-gateway-sdk 0.3.0__tar.gz → 0.3.2__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.

Potentially problematic release.


This version of agent-builder-gateway-sdk might be problematic. Click here for more details.

Files changed (24) hide show
  1. {agent_builder_gateway_sdk-0.3.0 → agent_builder_gateway_sdk-0.3.2}/PKG-INFO +9 -1
  2. {agent_builder_gateway_sdk-0.3.0 → agent_builder_gateway_sdk-0.3.2}/README.md +8 -0
  3. {agent_builder_gateway_sdk-0.3.0 → agent_builder_gateway_sdk-0.3.2}/pyproject.toml +1 -1
  4. {agent_builder_gateway_sdk-0.3.0 → agent_builder_gateway_sdk-0.3.2}/src/gateway_sdk/client.py +5 -4
  5. agent_builder_gateway_sdk-0.3.2/test_real_file.py +64 -0
  6. agent_builder_gateway_sdk-0.3.2/test_whitelist_mode.py +69 -0
  7. {agent_builder_gateway_sdk-0.3.0 → agent_builder_gateway_sdk-0.3.2}/uv.lock +1 -1
  8. {agent_builder_gateway_sdk-0.3.0 → agent_builder_gateway_sdk-0.3.2}/.github/workflows/publish.yml +0 -0
  9. {agent_builder_gateway_sdk-0.3.0 → agent_builder_gateway_sdk-0.3.2}/.github/workflows/test.yml +0 -0
  10. {agent_builder_gateway_sdk-0.3.0 → agent_builder_gateway_sdk-0.3.2}/.gitignore +0 -0
  11. {agent_builder_gateway_sdk-0.3.0 → agent_builder_gateway_sdk-0.3.2}/LICENSE +0 -0
  12. {agent_builder_gateway_sdk-0.3.0 → agent_builder_gateway_sdk-0.3.2}/RELEASE_GUIDE.md +0 -0
  13. {agent_builder_gateway_sdk-0.3.0 → agent_builder_gateway_sdk-0.3.2}/SDK_IMPROVEMENTS.md +0 -0
  14. {agent_builder_gateway_sdk-0.3.0 → agent_builder_gateway_sdk-0.3.2}/examples/basic_usage.py +0 -0
  15. {agent_builder_gateway_sdk-0.3.0 → agent_builder_gateway_sdk-0.3.2}/examples/response_parsing.py +0 -0
  16. {agent_builder_gateway_sdk-0.3.0 → agent_builder_gateway_sdk-0.3.2}/examples/streaming.py +0 -0
  17. {agent_builder_gateway_sdk-0.3.0 → agent_builder_gateway_sdk-0.3.2}/src/gateway_sdk/__init__.py +0 -0
  18. {agent_builder_gateway_sdk-0.3.0 → agent_builder_gateway_sdk-0.3.2}/src/gateway_sdk/auth.py +0 -0
  19. {agent_builder_gateway_sdk-0.3.0 → agent_builder_gateway_sdk-0.3.2}/src/gateway_sdk/exceptions.py +0 -0
  20. {agent_builder_gateway_sdk-0.3.0 → agent_builder_gateway_sdk-0.3.2}/src/gateway_sdk/models.py +0 -0
  21. {agent_builder_gateway_sdk-0.3.0 → agent_builder_gateway_sdk-0.3.2}/src/gateway_sdk/streaming.py +0 -0
  22. {agent_builder_gateway_sdk-0.3.0 → agent_builder_gateway_sdk-0.3.2}/test_sdk_video_processing.py +0 -0
  23. {agent_builder_gateway_sdk-0.3.0 → agent_builder_gateway_sdk-0.3.2}/tests/__init__.py +0 -0
  24. {agent_builder_gateway_sdk-0.3.0 → agent_builder_gateway_sdk-0.3.2}/tests/test_models.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agent-builder-gateway-sdk
3
- Version: 0.3.0
3
+ Version: 0.3.2
4
4
  Summary: Python SDK for Agent Builder Gateway - 用于 AI 构建的程序调用预制件
5
5
  Author: Agent Builder Team
6
6
  License: MIT
@@ -52,8 +52,16 @@ client = GatewayClient(jwt_token="your-jwt-token")
52
52
 
53
53
  # 或使用 API Key
54
54
  client = GatewayClient(api_key="sk-xxx")
55
+
56
+ # 白名单模式(适用于 OpenHands 等白名单环境)
57
+ client = GatewayClient() # 无需提供认证信息
55
58
  ```
56
59
 
60
+ **白名单模式说明**:
61
+ - 如果你的环境已配置白名单(如 OpenHands、内部开发环境),可以直接创建客户端而无需提供认证信息
62
+ - SDK 会以无鉴权模式发送请求,由 Gateway 基于 IP 白名单进行验证
63
+ - 这种模式简化了开发流程,无需管理 token
64
+
57
65
  ### 调用预制件
58
66
 
59
67
  ```python
@@ -32,8 +32,16 @@ client = GatewayClient(jwt_token="your-jwt-token")
32
32
 
33
33
  # 或使用 API Key
34
34
  client = GatewayClient(api_key="sk-xxx")
35
+
36
+ # 白名单模式(适用于 OpenHands 等白名单环境)
37
+ client = GatewayClient() # 无需提供认证信息
35
38
  ```
36
39
 
40
+ **白名单模式说明**:
41
+ - 如果你的环境已配置白名单(如 OpenHands、内部开发环境),可以直接创建客户端而无需提供认证信息
42
+ - SDK 会以无鉴权模式发送请求,由 Gateway 基于 IP 白名单进行验证
43
+ - 这种模式简化了开发流程,无需管理 token
44
+
37
45
  ### 调用预制件
38
46
 
39
47
  ```python
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "agent-builder-gateway-sdk"
3
- version = "0.3.0"
3
+ version = "0.3.2"
4
4
  description = "Python SDK for Agent Builder Gateway - 用于 AI 构建的程序调用预制件"
5
5
  authors = [
6
6
  {name = "Agent Builder Team"}
@@ -17,7 +17,7 @@ from .exceptions import (
17
17
 
18
18
 
19
19
  # Gateway 地址
20
- DEFAULT_GATEWAY_URL = "http://nodeport.sensedeal.vip:30566"
20
+ DEFAULT_GATEWAY_URL = "http://agent-builder-gateway-test.sensedeal.vip"
21
21
 
22
22
 
23
23
  class GatewayClient:
@@ -38,14 +38,15 @@ class GatewayClient:
38
38
  api_key: API Key(优先级高)
39
39
  jwt_token: JWT Token(用于 AI 构建的程序)
40
40
  timeout: 请求超时时间(秒)
41
+
42
+ Note:
43
+ 如果不提供 api_key 或 jwt_token,客户端将在无鉴权模式下工作。
44
+ 这适用于配置了白名单的环境(如 OpenHands)。
41
45
  """
42
46
  self.base_url = base_url.rstrip("/")
43
47
  self.auth = AuthManager(api_key=api_key, jwt_token=jwt_token)
44
48
  self.timeout = timeout
45
49
 
46
- if not self.auth.is_authenticated():
47
- raise AuthenticationError("必须提供 api_key 或 jwt_token")
48
-
49
50
  def run(
50
51
  self,
51
52
  prefab_id: str,
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/env python3
2
+ """测试真实的 S3 文件"""
3
+
4
+ from gateway_sdk import GatewayClient
5
+
6
+ def test_real_s3_file():
7
+ """使用真实的 S3 文件测试白名单模式"""
8
+
9
+ print("🧪 测试白名单模式 + 真实 S3 文件")
10
+
11
+ # 无需 token,白名单模式
12
+ client = GatewayClient()
13
+
14
+ s3_url = "s3://cubeflow-dev/prefab-gateway/prefab-inputs/f94d31c2-154d-4363-8450-cc907117cbcb/2025/10/29/1761708431516-____.pdf"
15
+
16
+ print(f"📄 S3 文件: {s3_url}")
17
+ print("📤 调用 file-processing-prefab...")
18
+
19
+ try:
20
+ result = client.run(
21
+ prefab_id="file-processing-prefab",
22
+ version="0.1.5",
23
+ function_name="parse_file",
24
+ parameters={},
25
+ files={"input": [s3_url]}
26
+ )
27
+
28
+ print(f"\n📊 SDK 层状态: {result.status}")
29
+ print(f"📋 Job ID: {result.job_id}")
30
+
31
+ if result.is_success():
32
+ print("\n✅ 调用成功!")
33
+
34
+ # 获取函数返回值
35
+ function_result = result.get_function_result()
36
+ if function_result:
37
+ print(f"\n📦 函数返回值:")
38
+ print(f" success: {function_result.get('success')}")
39
+ print(f" message: {function_result.get('message')}")
40
+ if function_result.get('content'):
41
+ content = function_result.get('content')
42
+ print(f" content: {content[:200]}..." if len(content) > 200 else f" content: {content}")
43
+ print(f" input_file: {function_result.get('input_file')}")
44
+ print(f" output_file: {function_result.get('output_file')}")
45
+
46
+ if not function_result.get('success'):
47
+ print(f" error: {function_result.get('error')}")
48
+ print(f" error_code: {function_result.get('error_code')}")
49
+
50
+ # 获取输出文件
51
+ output_files = result.get_files()
52
+ if output_files:
53
+ print(f"\n📁 输出文件: {output_files}")
54
+ else:
55
+ print(f"\n❌ 调用失败")
56
+ print(f"错误: {result.error}")
57
+
58
+ except Exception as e:
59
+ print(f"\n❌ 异常: {e}")
60
+ import traceback
61
+ traceback.print_exc()
62
+
63
+ if __name__ == "__main__":
64
+ test_real_s3_file()
@@ -0,0 +1,69 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ 测试白名单模式(无鉴权)
4
+
5
+ 这个脚本测试 SDK 在白名单环境下是否能正常工作(不提供 api_key 或 jwt_token)
6
+ """
7
+
8
+ from gateway_sdk import GatewayClient
9
+
10
+ def test_whitelist_mode():
11
+ """测试白名单模式创建客户端"""
12
+
13
+ print("🧪 测试 1: 无参数创建客户端")
14
+ try:
15
+ # ✅ 在白名单环境下,可以直接创建客户端
16
+ client = GatewayClient()
17
+ print(" ✅ 客户端创建成功(无鉴权模式)")
18
+ print(f" - Gateway URL: {client.base_url}")
19
+ print(f" - 超时设置: {client.timeout}秒")
20
+ print(f" - 鉴权状态: {'已配置' if client.auth.is_authenticated() else '未配置(白名单模式)'}")
21
+ except Exception as e:
22
+ print(f" ❌ 失败: {e}")
23
+ return False
24
+
25
+ print("\n🧪 测试 2: 调用预制件(需要白名单环境)")
26
+ print(" ⚠️ 注意: 这个测试只有在白名单环境下才能成功")
27
+ print(" 如果不在白名单环境下,会返回 401 认证错误,这是正常的")
28
+
29
+ try:
30
+ result = client.run(
31
+ prefab_id="video-processing-prefab",
32
+ version="0.3.1",
33
+ function_name="video_to_audio",
34
+ parameters={},
35
+ files={"input": ["s3://test-bucket/sample.mp4"]}
36
+ )
37
+
38
+ if result.is_success():
39
+ print(" ✅ 预制件调用成功(白名单环境确认)")
40
+ function_result = result.get_function_result()
41
+ print(f" - 返回状态: {function_result}")
42
+ else:
43
+ print(f" ⚠️ 预制件调用返回失败: {result.error}")
44
+ print(" 这可能是业务逻辑错误,不是鉴权问题")
45
+
46
+ except Exception as e:
47
+ error_msg = str(e)
48
+ if "401" in error_msg or "认证" in error_msg or "Unauthorized" in error_msg:
49
+ print(f" ⚠️ 认证失败(预期行为,不在白名单环境下)")
50
+ print(f" 错误信息: {error_msg}")
51
+ else:
52
+ print(f" ❌ 其他错误: {error_msg}")
53
+
54
+ print("\n" + "="*60)
55
+ print("✅ SDK 无参数创建功能测试完成")
56
+ print("="*60)
57
+ print("\n📝 使用说明:")
58
+ print(" 在白名单环境(如 OpenHands)中,可以这样使用:")
59
+ print(" ```python")
60
+ print(" from gateway_sdk import GatewayClient")
61
+ print(" client = GatewayClient() # 无需提供 token")
62
+ print(" result = client.run(...)")
63
+ print(" ```")
64
+
65
+ return True
66
+
67
+ if __name__ == "__main__":
68
+ test_whitelist_mode()
69
+
@@ -4,7 +4,7 @@ requires-python = ">=3.11"
4
4
 
5
5
  [[package]]
6
6
  name = "agent-builder-gateway-sdk"
7
- version = "0.3.0"
7
+ version = "0.3.2"
8
8
  source = { editable = "." }
9
9
  dependencies = [
10
10
  { name = "httpx" },