ai-computer-client 0.2.0__tar.gz → 0.3.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.
@@ -44,4 +44,7 @@ htmlcov/
44
44
  .tox/
45
45
 
46
46
  # Misc
47
- .DS_Store
47
+ .DS_Store
48
+
49
+ # Interactive Shell
50
+ examples/interactive_shell.py
@@ -0,0 +1,147 @@
1
+ Metadata-Version: 2.4
2
+ Name: ai-computer-client
3
+ Version: 0.3.1
4
+ Summary: Python client for interacting with the AI Computer service
5
+ Project-URL: Homepage, https://github.com/ColeMurray/ai-computer-client-python
6
+ Project-URL: Documentation, https://github.com/ColeMurray/ai-computer-client-python#readme
7
+ Author: AI Computer
8
+ License: MIT
9
+ License-File: LICENSE
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.7
15
+ Classifier: Programming Language :: Python :: 3.8
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Requires-Python: >=3.7
20
+ Requires-Dist: aiohttp>=3.8.0
21
+ Requires-Dist: typing-extensions>=4.0.0
22
+ Provides-Extra: dev
23
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
24
+ Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
25
+ Requires-Dist: pytest>=7.0.0; extra == 'dev'
26
+ Description-Content-Type: text/markdown
27
+
28
+ # AI Computer Python Client
29
+
30
+ Python client library for interacting with the AI Computer Sandbox service.
31
+
32
+ ## Installation
33
+
34
+ ```bash
35
+ pip install ai-computer-client
36
+ ```
37
+
38
+ ## Usage
39
+
40
+ ### Basic Usage
41
+
42
+ ```python
43
+ from ai_computer import SandboxClient
44
+
45
+ async def main():
46
+ # Initialize client
47
+ client = SandboxClient()
48
+
49
+ # Setup sandbox environment
50
+ await client.setup()
51
+
52
+ try:
53
+ # Execute code
54
+ result = await client.execute_code("print('Hello, World!')")
55
+ print(result.data["output"])
56
+
57
+ # Upload a file
58
+ response = await client.upload_file("local/path/to/file.txt")
59
+ if response.success:
60
+ print(f"File uploaded to {response.path}")
61
+
62
+ # Download a file
63
+ response = await client.download_file(
64
+ "/workspace/file.txt",
65
+ "local/download/path.txt"
66
+ )
67
+ if response.success:
68
+ print(f"File downloaded to {response.path}")
69
+
70
+ # Work with bytes directly
71
+ content = b"Hello, World!"
72
+ response = await client.upload_bytes(
73
+ content=content,
74
+ filename="hello.txt"
75
+ )
76
+
77
+ # Download as bytes
78
+ content = await client.download_bytes("/workspace/hello.txt")
79
+ if isinstance(content, bytes):
80
+ print(content.decode())
81
+
82
+ finally:
83
+ # Cleanup
84
+ await client.cleanup()
85
+
86
+ # Run with asyncio
87
+ import asyncio
88
+ asyncio.run(main())
89
+ ```
90
+
91
+ ### Advanced Usage
92
+
93
+ ```python
94
+ # Stream code execution
95
+ async for event in client.execute_code_stream("print('Hello')\nprint('World')"):
96
+ if event.type == "stdout":
97
+ print(f"Output: {event.data}")
98
+ elif event.type == "stderr":
99
+ print(f"Error: {event.data}")
100
+ elif event.type == "completed":
101
+ print("Execution completed")
102
+
103
+ # Upload with custom settings
104
+ response = await client.upload_file(
105
+ "file.txt",
106
+ destination="/workspace/custom/path",
107
+ chunk_size=2*1024*1024, # 2MB chunks
108
+ timeout=600 # 10 minutes
109
+ )
110
+
111
+ # Work with file-like objects
112
+ from io import BytesIO
113
+
114
+ buffer = BytesIO(b"Hello from buffer!")
115
+ response = await client.upload_bytes(
116
+ content=buffer,
117
+ filename="buffer.txt",
118
+ content_type="text/plain"
119
+ )
120
+ ```
121
+
122
+ ## Development
123
+
124
+ ### Setup
125
+
126
+ ```bash
127
+ # Clone the repository
128
+ git clone https://github.com/ai-computer/ai-computer-client-python
129
+ cd ai-computer-client-python
130
+
131
+ # Create and activate virtual environment
132
+ python -m venv venv
133
+ source venv/bin/activate # or `venv\Scripts\activate` on Windows
134
+
135
+ # Install development dependencies
136
+ pip install -e ".[dev]"
137
+ ```
138
+
139
+ ### Running Tests
140
+
141
+ ```bash
142
+ pytest tests/
143
+ ```
144
+
145
+ ## License
146
+
147
+ MIT License
@@ -0,0 +1,120 @@
1
+ # AI Computer Python Client
2
+
3
+ Python client library for interacting with the AI Computer Sandbox service.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install ai-computer-client
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### Basic Usage
14
+
15
+ ```python
16
+ from ai_computer import SandboxClient
17
+
18
+ async def main():
19
+ # Initialize client
20
+ client = SandboxClient()
21
+
22
+ # Setup sandbox environment
23
+ await client.setup()
24
+
25
+ try:
26
+ # Execute code
27
+ result = await client.execute_code("print('Hello, World!')")
28
+ print(result.data["output"])
29
+
30
+ # Upload a file
31
+ response = await client.upload_file("local/path/to/file.txt")
32
+ if response.success:
33
+ print(f"File uploaded to {response.path}")
34
+
35
+ # Download a file
36
+ response = await client.download_file(
37
+ "/workspace/file.txt",
38
+ "local/download/path.txt"
39
+ )
40
+ if response.success:
41
+ print(f"File downloaded to {response.path}")
42
+
43
+ # Work with bytes directly
44
+ content = b"Hello, World!"
45
+ response = await client.upload_bytes(
46
+ content=content,
47
+ filename="hello.txt"
48
+ )
49
+
50
+ # Download as bytes
51
+ content = await client.download_bytes("/workspace/hello.txt")
52
+ if isinstance(content, bytes):
53
+ print(content.decode())
54
+
55
+ finally:
56
+ # Cleanup
57
+ await client.cleanup()
58
+
59
+ # Run with asyncio
60
+ import asyncio
61
+ asyncio.run(main())
62
+ ```
63
+
64
+ ### Advanced Usage
65
+
66
+ ```python
67
+ # Stream code execution
68
+ async for event in client.execute_code_stream("print('Hello')\nprint('World')"):
69
+ if event.type == "stdout":
70
+ print(f"Output: {event.data}")
71
+ elif event.type == "stderr":
72
+ print(f"Error: {event.data}")
73
+ elif event.type == "completed":
74
+ print("Execution completed")
75
+
76
+ # Upload with custom settings
77
+ response = await client.upload_file(
78
+ "file.txt",
79
+ destination="/workspace/custom/path",
80
+ chunk_size=2*1024*1024, # 2MB chunks
81
+ timeout=600 # 10 minutes
82
+ )
83
+
84
+ # Work with file-like objects
85
+ from io import BytesIO
86
+
87
+ buffer = BytesIO(b"Hello from buffer!")
88
+ response = await client.upload_bytes(
89
+ content=buffer,
90
+ filename="buffer.txt",
91
+ content_type="text/plain"
92
+ )
93
+ ```
94
+
95
+ ## Development
96
+
97
+ ### Setup
98
+
99
+ ```bash
100
+ # Clone the repository
101
+ git clone https://github.com/ai-computer/ai-computer-client-python
102
+ cd ai-computer-client-python
103
+
104
+ # Create and activate virtual environment
105
+ python -m venv venv
106
+ source venv/bin/activate # or `venv\Scripts\activate` on Windows
107
+
108
+ # Install development dependencies
109
+ pip install -e ".[dev]"
110
+ ```
111
+
112
+ ### Running Tests
113
+
114
+ ```bash
115
+ pytest tests/
116
+ ```
117
+
118
+ ## License
119
+
120
+ MIT License
@@ -0,0 +1,4 @@
1
+ from .client import SandboxClient, SandboxResponse, StreamEvent, FileOperationResponse
2
+
3
+ __version__ = "0.3.1"
4
+ __all__ = ["SandboxClient", "SandboxResponse", "StreamEvent", "FileOperationResponse"]