buildfunctions 0.2.0__tar.gz → 0.2.1__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 (45) hide show
  1. buildfunctions-0.2.1/.env.example +2 -0
  2. buildfunctions-0.2.1/.gitignore +18 -0
  3. buildfunctions-0.2.1/MANIFEST.in +5 -0
  4. buildfunctions-0.2.1/PKG-INFO +176 -0
  5. buildfunctions-0.2.1/README.md +156 -0
  6. buildfunctions-0.2.1/pyproject.toml +50 -0
  7. buildfunctions-0.2.1/src/buildfunctions/__init__.py +139 -0
  8. buildfunctions-0.2.1/src/buildfunctions/client.py +282 -0
  9. buildfunctions-0.2.1/src/buildfunctions/cpu_function.py +167 -0
  10. buildfunctions-0.2.1/src/buildfunctions/cpu_sandbox.py +393 -0
  11. buildfunctions-0.2.1/src/buildfunctions/dotdict.py +39 -0
  12. buildfunctions-0.2.1/src/buildfunctions/errors.py +90 -0
  13. buildfunctions-0.2.1/src/buildfunctions/framework.py +22 -0
  14. buildfunctions-0.2.1/src/buildfunctions/gpu_function.py +241 -0
  15. buildfunctions-0.2.1/src/buildfunctions/gpu_sandbox.py +443 -0
  16. buildfunctions-0.2.1/src/buildfunctions/http_client.py +97 -0
  17. buildfunctions-0.2.1/src/buildfunctions/memory.py +28 -0
  18. buildfunctions-0.2.1/src/buildfunctions/py.typed +0 -0
  19. buildfunctions-0.2.1/src/buildfunctions/resolve_code.py +109 -0
  20. buildfunctions-0.2.1/src/buildfunctions/types.py +227 -0
  21. buildfunctions-0.2.1/src/buildfunctions/uploader.py +198 -0
  22. buildfunctions-0.2.1/static/readme/buildfunctions-header.svg +1 -0
  23. buildfunctions-0.2.1/static/readme/buildfunctions-logo-and-servers-dark.svg +1 -0
  24. buildfunctions-0.2.1/static/readme/discord-button.png +0 -0
  25. buildfunctions-0.2.1/static/readme/read-the-docs-button.png +0 -0
  26. buildfunctions-0.2.1/tests/auth.py +62 -0
  27. buildfunctions-0.2.1/tests/cpu_function_code.py +9 -0
  28. buildfunctions-0.2.1/tests/cpu_sandbox_code.py +11 -0
  29. buildfunctions-0.2.1/tests/gpu_function_code.py +39 -0
  30. buildfunctions-0.2.1/tests/gpu_function_code_streaming.py +81 -0
  31. buildfunctions-0.2.1/tests/gpu_sandbox_code.py +39 -0
  32. buildfunctions-0.2.1/tests/test_cpu_function.py +89 -0
  33. buildfunctions-0.2.1/tests/test_cpu_sandbox.py +69 -0
  34. buildfunctions-0.2.1/tests/test_gpu_function.py +92 -0
  35. buildfunctions-0.2.1/tests/test_gpu_sandbox_with_local_model.py +73 -0
  36. buildfunctions-0.2.0/MANIFEST.in +0 -1
  37. buildfunctions-0.2.0/PKG-INFO +0 -6
  38. buildfunctions-0.2.0/pyproject.toml +0 -3
  39. buildfunctions-0.2.0/setup.cfg +0 -20
  40. buildfunctions-0.2.0/src/buildfunctions/__init__.py +0 -1
  41. buildfunctions-0.2.0/src/buildfunctions/api.py +0 -2
  42. buildfunctions-0.2.0/src/buildfunctions.egg-info/PKG-INFO +0 -6
  43. buildfunctions-0.2.0/src/buildfunctions.egg-info/SOURCES.txt +0 -9
  44. buildfunctions-0.2.0/src/buildfunctions.egg-info/dependency_links.txt +0 -1
  45. buildfunctions-0.2.0/src/buildfunctions.egg-info/top_level.txt +0 -1
@@ -0,0 +1,2 @@
1
+ # Get an API token at https://www.buildfunctions.com/settings
2
+ BUILDFUNCTIONS_API_TOKEN=""
@@ -0,0 +1,18 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ dist/
5
+ build/
6
+ .eggs/
7
+ *.egg
8
+ .env*
9
+ !.env.example
10
+ !.env.*.example
11
+ .venv/
12
+ .mypy_cache/
13
+ .pytest_cache/
14
+ .ruff_cache/
15
+ *.log
16
+ .DS_Store
17
+ .claude*
18
+ .pytest_cache*
@@ -0,0 +1,5 @@
1
+ include README.md
2
+ include src/buildfunctions/py.typed
3
+ recursive-exclude tests *
4
+ exclude .env*
5
+ exclude .git*
@@ -0,0 +1,176 @@
1
+ Metadata-Version: 2.4
2
+ Name: buildfunctions
3
+ Version: 0.2.1
4
+ Summary: The Buildfunctions SDK for Agents: Hardware-isolated CPU and GPU Sandboxes for untrusted AI actions
5
+ Project-URL: Homepage, https://www.buildfunctions.com
6
+ Project-URL: Documentation, https://www.buildfunctions.com/docs/sdk/quickstart
7
+ Project-URL: Repository, https://github.com/buildfunctions/sdk-python
8
+ Project-URL: Issues, https://github.com/buildfunctions/sdk-python/issues
9
+ Author: Buildfunctions
10
+ Keywords: AIAgents,AIApps,AIInfrastructure,DeveloperExperience,GPUs,Sandboxes,Serverless
11
+ Requires-Python: >=3.10
12
+ Requires-Dist: httpx>=0.27
13
+ Requires-Dist: python-dotenv>=1.0
14
+ Provides-Extra: dev
15
+ Requires-Dist: mypy>=1.13; extra == 'dev'
16
+ Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
17
+ Requires-Dist: pytest>=8.0; extra == 'dev'
18
+ Requires-Dist: ruff>=0.8; extra == 'dev'
19
+ Description-Content-Type: text/markdown
20
+
21
+ <p align="center">
22
+ <h1 align="center">
23
+ <a href="https://www.buildfunctions.com" target="_blank">
24
+ <img src="./static/readme/buildfunctions-header.svg" alt="logo" width="900">
25
+ </a>
26
+ </h1>
27
+ </p>
28
+
29
+ <h1 align="center">The Buildfunctions SDK for Agents</h1>
30
+
31
+ <p align="center">
32
+ <!-- <a href="https://discord.com/users/buildfunctions" target="_blank">
33
+ <img src="./static/readme/discord-button.png" height="32" />
34
+ </a>&nbsp; -->
35
+ <a href="https://www.buildfunctions.com/docs/sdk/quickstart" target="_blank">
36
+ <img src="./static/readme/read-the-docs-button.png" height="32" />
37
+ </a>&nbsp;
38
+ </p>
39
+
40
+ <p align="center">
41
+ <a href="https://pypi.org/project/buildfunctions" target="_blank">
42
+ <img src="https://img.shields.io/badge/pypi-buildfunctions-green">
43
+ </a>
44
+ </p>
45
+
46
+ <p align="center">
47
+ <h1 align="center">
48
+ <a href="https://www.buildfunctions.com" target="_blank">
49
+ <img src="./static/readme/buildfunctions-logo-and-servers-dark.svg" alt="logo" width="900">
50
+ </a>
51
+ </h1>
52
+ </p>
53
+
54
+ > Hardware-isolated execution environments for AI agents
55
+
56
+ ## Installation
57
+
58
+ ```bash
59
+ pip install buildfunctions
60
+ ```
61
+
62
+ ## Quick Start
63
+
64
+ ### 1. Create an API Token
65
+
66
+ Get your API token at [buildfunctions.com/settings](https://www.buildfunctions.com/settings)
67
+
68
+ ### 2. CPU Function
69
+
70
+ ```python
71
+ import asyncio
72
+ import os
73
+ from buildfunctions import Buildfunctions, CPUFunction
74
+
75
+ async def main():
76
+ client = await Buildfunctions({"apiToken": os.environ["BUILDFUNCTIONS_API_TOKEN"]})
77
+
78
+ deployed_function = await CPUFunction.create({
79
+ "name": "my-cpu-function",
80
+ "code": "./cpu_function_code.py",
81
+ "language": "python",
82
+ "memory": 128,
83
+ "timeout": 30,
84
+ })
85
+
86
+ print(f"Endpoint: {deployed_function.endpoint}")
87
+
88
+ await deployed_function.delete()
89
+
90
+ asyncio.run(main())
91
+ ```
92
+
93
+ ### 3. CPU Sandbox
94
+
95
+ ```python
96
+ import asyncio
97
+ import os
98
+ from buildfunctions import Buildfunctions, CPUSandbox
99
+
100
+ async def main():
101
+ client = await Buildfunctions({"apiToken": os.environ["BUILDFUNCTIONS_API_TOKEN"]})
102
+
103
+ sandbox = await CPUSandbox.create({
104
+ "name": "my-cpu-sandbox",
105
+ "language": "python",
106
+ "code": "/path/to/code/cpu_sandbox_code.py",
107
+ "memory": 128,
108
+ "timeout": 30,
109
+ })
110
+
111
+ result = await sandbox.run()
112
+ print(f"Result: {result}")
113
+
114
+ await sandbox.delete()
115
+
116
+ asyncio.run(main())
117
+ ```
118
+
119
+ ### 4. GPU Function
120
+
121
+ ```python
122
+ import asyncio
123
+ import os
124
+ from buildfunctions import Buildfunctions, GPUFunction
125
+
126
+ async def main():
127
+ client = await Buildfunctions({"apiToken": os.environ["BUILDFUNCTIONS_API_TOKEN"]})
128
+
129
+ deployed_function = await GPUFunction.create({
130
+ "name": "my-gpu-function",
131
+ "code": "/path/to/code/gpu_function_code.py",
132
+ "language": "python",
133
+ "gpu": "T4",
134
+ "vcpus": 30,
135
+ "memory": "50000MB",
136
+ "timeout": 300,
137
+ "requirements": ["transformers==4.47.1", "torch", "accelerate"],
138
+ })
139
+
140
+ print(f"Endpoint: {deployed_function.endpoint}")
141
+
142
+ await deployed_function.delete()
143
+
144
+ asyncio.run(main())
145
+ ```
146
+
147
+ ### 5. GPU Sandbox with Local Model
148
+
149
+ ```python
150
+ import asyncio
151
+ import os
152
+ from buildfunctions import Buildfunctions, GPUSandbox
153
+
154
+ async def main():
155
+ client = await Buildfunctions({"apiToken": os.environ["BUILDFUNCTIONS_API_TOKEN"]})
156
+
157
+ sandbox = await GPUSandbox.create({
158
+ "name": "my-gpu-sandbox",
159
+ "language": "python",
160
+ "memory": 10000,
161
+ "timeout": 300,
162
+ "vcpus": 6,
163
+ "code": "./gpu_sandbox_code.py",
164
+ "model": "/path/to/models/Qwen/Qwen3-8B",
165
+ "requirements": "torch",
166
+ })
167
+
168
+ result = await sandbox.run()
169
+ print(f"Response: {result}")
170
+
171
+ await sandbox.delete()
172
+
173
+ asyncio.run(main())
174
+ ```
175
+
176
+ The SDK is currently in beta.
@@ -0,0 +1,156 @@
1
+ <p align="center">
2
+ <h1 align="center">
3
+ <a href="https://www.buildfunctions.com" target="_blank">
4
+ <img src="./static/readme/buildfunctions-header.svg" alt="logo" width="900">
5
+ </a>
6
+ </h1>
7
+ </p>
8
+
9
+ <h1 align="center">The Buildfunctions SDK for Agents</h1>
10
+
11
+ <p align="center">
12
+ <!-- <a href="https://discord.com/users/buildfunctions" target="_blank">
13
+ <img src="./static/readme/discord-button.png" height="32" />
14
+ </a>&nbsp; -->
15
+ <a href="https://www.buildfunctions.com/docs/sdk/quickstart" target="_blank">
16
+ <img src="./static/readme/read-the-docs-button.png" height="32" />
17
+ </a>&nbsp;
18
+ </p>
19
+
20
+ <p align="center">
21
+ <a href="https://pypi.org/project/buildfunctions" target="_blank">
22
+ <img src="https://img.shields.io/badge/pypi-buildfunctions-green">
23
+ </a>
24
+ </p>
25
+
26
+ <p align="center">
27
+ <h1 align="center">
28
+ <a href="https://www.buildfunctions.com" target="_blank">
29
+ <img src="./static/readme/buildfunctions-logo-and-servers-dark.svg" alt="logo" width="900">
30
+ </a>
31
+ </h1>
32
+ </p>
33
+
34
+ > Hardware-isolated execution environments for AI agents
35
+
36
+ ## Installation
37
+
38
+ ```bash
39
+ pip install buildfunctions
40
+ ```
41
+
42
+ ## Quick Start
43
+
44
+ ### 1. Create an API Token
45
+
46
+ Get your API token at [buildfunctions.com/settings](https://www.buildfunctions.com/settings)
47
+
48
+ ### 2. CPU Function
49
+
50
+ ```python
51
+ import asyncio
52
+ import os
53
+ from buildfunctions import Buildfunctions, CPUFunction
54
+
55
+ async def main():
56
+ client = await Buildfunctions({"apiToken": os.environ["BUILDFUNCTIONS_API_TOKEN"]})
57
+
58
+ deployed_function = await CPUFunction.create({
59
+ "name": "my-cpu-function",
60
+ "code": "./cpu_function_code.py",
61
+ "language": "python",
62
+ "memory": 128,
63
+ "timeout": 30,
64
+ })
65
+
66
+ print(f"Endpoint: {deployed_function.endpoint}")
67
+
68
+ await deployed_function.delete()
69
+
70
+ asyncio.run(main())
71
+ ```
72
+
73
+ ### 3. CPU Sandbox
74
+
75
+ ```python
76
+ import asyncio
77
+ import os
78
+ from buildfunctions import Buildfunctions, CPUSandbox
79
+
80
+ async def main():
81
+ client = await Buildfunctions({"apiToken": os.environ["BUILDFUNCTIONS_API_TOKEN"]})
82
+
83
+ sandbox = await CPUSandbox.create({
84
+ "name": "my-cpu-sandbox",
85
+ "language": "python",
86
+ "code": "/path/to/code/cpu_sandbox_code.py",
87
+ "memory": 128,
88
+ "timeout": 30,
89
+ })
90
+
91
+ result = await sandbox.run()
92
+ print(f"Result: {result}")
93
+
94
+ await sandbox.delete()
95
+
96
+ asyncio.run(main())
97
+ ```
98
+
99
+ ### 4. GPU Function
100
+
101
+ ```python
102
+ import asyncio
103
+ import os
104
+ from buildfunctions import Buildfunctions, GPUFunction
105
+
106
+ async def main():
107
+ client = await Buildfunctions({"apiToken": os.environ["BUILDFUNCTIONS_API_TOKEN"]})
108
+
109
+ deployed_function = await GPUFunction.create({
110
+ "name": "my-gpu-function",
111
+ "code": "/path/to/code/gpu_function_code.py",
112
+ "language": "python",
113
+ "gpu": "T4",
114
+ "vcpus": 30,
115
+ "memory": "50000MB",
116
+ "timeout": 300,
117
+ "requirements": ["transformers==4.47.1", "torch", "accelerate"],
118
+ })
119
+
120
+ print(f"Endpoint: {deployed_function.endpoint}")
121
+
122
+ await deployed_function.delete()
123
+
124
+ asyncio.run(main())
125
+ ```
126
+
127
+ ### 5. GPU Sandbox with Local Model
128
+
129
+ ```python
130
+ import asyncio
131
+ import os
132
+ from buildfunctions import Buildfunctions, GPUSandbox
133
+
134
+ async def main():
135
+ client = await Buildfunctions({"apiToken": os.environ["BUILDFUNCTIONS_API_TOKEN"]})
136
+
137
+ sandbox = await GPUSandbox.create({
138
+ "name": "my-gpu-sandbox",
139
+ "language": "python",
140
+ "memory": 10000,
141
+ "timeout": 300,
142
+ "vcpus": 6,
143
+ "code": "./gpu_sandbox_code.py",
144
+ "model": "/path/to/models/Qwen/Qwen3-8B",
145
+ "requirements": "torch",
146
+ })
147
+
148
+ result = await sandbox.run()
149
+ print(f"Response: {result}")
150
+
151
+ await sandbox.delete()
152
+
153
+ asyncio.run(main())
154
+ ```
155
+
156
+ The SDK is currently in beta.
@@ -0,0 +1,50 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "buildfunctions"
7
+ version = "0.2.1"
8
+ description = "The Buildfunctions SDK for Agents: Hardware-isolated CPU and GPU Sandboxes for untrusted AI actions"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ authors = [
12
+ { name = "Buildfunctions" }
13
+ ]
14
+ keywords = [
15
+ "AIAgents",
16
+ "AIInfrastructure",
17
+ "AIApps",
18
+ "Serverless",
19
+ "GPUs",
20
+ "Sandboxes",
21
+ "DeveloperExperience",
22
+ ]
23
+ dependencies = [
24
+ "httpx>=0.27",
25
+ "python-dotenv>=1.0",
26
+ ]
27
+
28
+ [project.optional-dependencies]
29
+ dev = [
30
+ "pytest>=8.0",
31
+ "pytest-asyncio>=0.24",
32
+ "mypy>=1.13",
33
+ "ruff>=0.8",
34
+ ]
35
+
36
+ [project.urls]
37
+ Homepage = "https://www.buildfunctions.com"
38
+ Documentation = "https://www.buildfunctions.com/docs/sdk/quickstart"
39
+ Repository = "https://github.com/buildfunctions/sdk-python"
40
+ Issues = "https://github.com/buildfunctions/sdk-python/issues"
41
+
42
+ [tool.hatch.build.targets.wheel]
43
+ packages = ["src/buildfunctions"]
44
+
45
+ [tool.pytest.ini_options]
46
+ asyncio_mode = "auto"
47
+
48
+ [tool.ruff]
49
+ target-version = "py311"
50
+ line-length = 120
@@ -0,0 +1,139 @@
1
+ """Buildfunctions SDK - Python SDK for the serverless platform for AI agents.
2
+
3
+ Example:
4
+ import asyncio
5
+ from buildfunctions import Buildfunctions, CPUSandbox, GPUSandbox, GPUFunction
6
+
7
+ async def main():
8
+ # Initialize the client (authenticates with the API)
9
+ client = await Buildfunctions({
10
+ "apiToken": os.environ["BUILDFUNCTIONS_API_TOKEN"]
11
+ })
12
+
13
+ # Access authenticated user info (supports both dot and bracket notation)
14
+ print(client.user.username)
15
+ print(client.authenticatedAt)
16
+
17
+ # Create a CPU sandbox
18
+ sandbox = await CPUSandbox.create({
19
+ "name": "my-sandbox",
20
+ "language": "python",
21
+ "memory": "512MB",
22
+ })
23
+
24
+ # Run code
25
+ result = await sandbox.run()
26
+ print(result.response)
27
+
28
+ # Clean up
29
+ await sandbox.delete()
30
+
31
+ asyncio.run(main())
32
+ """
33
+
34
+ # Client exports - match TypeScript SDK naming exactly
35
+ from buildfunctions.client import (
36
+ Buildfunctions,
37
+ buildfunctions,
38
+ createClient,
39
+ create_client,
40
+ init,
41
+ )
42
+
43
+ # Function builders - match TypeScript SDK naming exactly
44
+ from buildfunctions.cpu_function import CPUFunction, create_cpu_function
45
+ from buildfunctions.gpu_function import GPUFunction, create_gpu_function
46
+
47
+ # Sandbox factories - match TypeScript SDK naming exactly
48
+ from buildfunctions.cpu_sandbox import CPUSandbox, create_cpu_sandbox
49
+ from buildfunctions.gpu_sandbox import GPUSandbox, create_gpu_sandbox
50
+
51
+ # Errors
52
+ from buildfunctions.errors import (
53
+ AuthenticationError,
54
+ BuildfunctionsError,
55
+ CapacityError,
56
+ NotFoundError,
57
+ ValidationError,
58
+ )
59
+
60
+ # Types
61
+ from buildfunctions.types import (
62
+ AuthenticatedUser,
63
+ AuthResponse,
64
+ BuildfunctionsConfig,
65
+ CPUFunctionOptions,
66
+ CPUSandboxConfig,
67
+ CPUSandboxInstance,
68
+ CreateFunctionOptions,
69
+ DeployedFunction,
70
+ ErrorCode,
71
+ FileMetadata,
72
+ FindUniqueOptions,
73
+ Framework,
74
+ FunctionConfig,
75
+ GPUFunctionOptions,
76
+ GPUSandboxConfig,
77
+ GPUSandboxInstance,
78
+ GPUType,
79
+ Language,
80
+ ListOptions,
81
+ Memory,
82
+ RunResult,
83
+ Runtime,
84
+ SandboxInstance,
85
+ UploadOptions,
86
+ )
87
+
88
+ __all__ = [
89
+ # Client (PascalCase - matches TypeScript)
90
+ "Buildfunctions",
91
+ "createClient",
92
+ "init",
93
+ # Client (snake_case aliases)
94
+ "buildfunctions",
95
+ "create_client",
96
+ # Function builders (PascalCase - matches TypeScript)
97
+ "CPUFunction",
98
+ "GPUFunction",
99
+ # Function builders (snake_case aliases)
100
+ "create_cpu_function",
101
+ "create_gpu_function",
102
+ # Sandbox factories (PascalCase - matches TypeScript)
103
+ "CPUSandbox",
104
+ "GPUSandbox",
105
+ # Sandbox factories (snake_case aliases)
106
+ "create_cpu_sandbox",
107
+ "create_gpu_sandbox",
108
+ # Errors
109
+ "BuildfunctionsError",
110
+ "AuthenticationError",
111
+ "NotFoundError",
112
+ "ValidationError",
113
+ "CapacityError",
114
+ # Types
115
+ "BuildfunctionsConfig",
116
+ "AuthenticatedUser",
117
+ "AuthResponse",
118
+ "Language",
119
+ "Runtime",
120
+ "GPUType",
121
+ "Framework",
122
+ "Memory",
123
+ "FunctionConfig",
124
+ "CPUFunctionOptions",
125
+ "GPUFunctionOptions",
126
+ "CreateFunctionOptions",
127
+ "DeployedFunction",
128
+ "CPUSandboxConfig",
129
+ "GPUSandboxConfig",
130
+ "RunResult",
131
+ "UploadOptions",
132
+ "SandboxInstance",
133
+ "CPUSandboxInstance",
134
+ "GPUSandboxInstance",
135
+ "FindUniqueOptions",
136
+ "ListOptions",
137
+ "ErrorCode",
138
+ "FileMetadata",
139
+ ]