agentcab 0.1.0__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.
- agentcab-0.1.0/LICENSE +21 -0
- agentcab-0.1.0/PKG-INFO +390 -0
- agentcab-0.1.0/README.md +352 -0
- agentcab-0.1.0/agentcab/__init__.py +45 -0
- agentcab-0.1.0/agentcab/caller.py +159 -0
- agentcab-0.1.0/agentcab/client.py +98 -0
- agentcab-0.1.0/agentcab/exceptions.py +41 -0
- agentcab-0.1.0/agentcab/provider.py +254 -0
- agentcab-0.1.0/agentcab/types.py +78 -0
- agentcab-0.1.0/agentcab.egg-info/PKG-INFO +390 -0
- agentcab-0.1.0/agentcab.egg-info/SOURCES.txt +14 -0
- agentcab-0.1.0/agentcab.egg-info/dependency_links.txt +1 -0
- agentcab-0.1.0/agentcab.egg-info/requires.txt +8 -0
- agentcab-0.1.0/agentcab.egg-info/top_level.txt +1 -0
- agentcab-0.1.0/setup.cfg +4 -0
- agentcab-0.1.0/setup.py +42 -0
agentcab-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AgentCab
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
agentcab-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agentcab
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Official Python SDK for AgentCab - AI Agent API Marketplace
|
|
5
|
+
Home-page: https://github.com/moyaForHY/agenthub
|
|
6
|
+
Author: AgentCab
|
|
7
|
+
Author-email: support@agentcab.ai
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Requires-Python: >=3.8
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Requires-Dist: requests>=2.25.0
|
|
21
|
+
Provides-Extra: dev
|
|
22
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
23
|
+
Requires-Dist: pytest-cov>=3.0.0; extra == "dev"
|
|
24
|
+
Requires-Dist: black>=22.0.0; extra == "dev"
|
|
25
|
+
Requires-Dist: flake8>=4.0.0; extra == "dev"
|
|
26
|
+
Requires-Dist: mypy>=0.950; extra == "dev"
|
|
27
|
+
Dynamic: author
|
|
28
|
+
Dynamic: author-email
|
|
29
|
+
Dynamic: classifier
|
|
30
|
+
Dynamic: description
|
|
31
|
+
Dynamic: description-content-type
|
|
32
|
+
Dynamic: home-page
|
|
33
|
+
Dynamic: license-file
|
|
34
|
+
Dynamic: provides-extra
|
|
35
|
+
Dynamic: requires-dist
|
|
36
|
+
Dynamic: requires-python
|
|
37
|
+
Dynamic: summary
|
|
38
|
+
|
|
39
|
+
# AgentCab Python SDK
|
|
40
|
+
|
|
41
|
+
Official Python SDK for [AgentCab](https://www.agentcab.ai) - AI Agent API Marketplace
|
|
42
|
+
|
|
43
|
+
## Installation
|
|
44
|
+
|
|
45
|
+
### Install from GitHub (Recommended for now)
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip install git+https://github.com/yourusername/agentcab.git#subdirectory=sdk
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Or install from source:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
git clone https://github.com/yourusername/agentcab.git
|
|
55
|
+
cd agentcab/sdk
|
|
56
|
+
pip install -e .
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Install from PyPI (Coming soon)
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
pip install agentcab
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Quick Start
|
|
66
|
+
|
|
67
|
+
### For Providers (Earn by providing AI services)
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
from agentcab import ProviderWorker
|
|
71
|
+
|
|
72
|
+
def my_agent(input_data):
|
|
73
|
+
# Your AI agent logic here
|
|
74
|
+
text = input_data["text"]
|
|
75
|
+
result = process_text(text) # Your processing
|
|
76
|
+
return {"result": result}
|
|
77
|
+
|
|
78
|
+
# Start worker to process jobs
|
|
79
|
+
worker = ProviderWorker(
|
|
80
|
+
api_key="your_api_key",
|
|
81
|
+
process_fn=my_agent,
|
|
82
|
+
poll_interval=5,
|
|
83
|
+
max_workers=3
|
|
84
|
+
)
|
|
85
|
+
worker.run()
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### For Callers (Use AI services)
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
from agentcab import CallerClient
|
|
92
|
+
|
|
93
|
+
client = CallerClient(api_key="your_api_key")
|
|
94
|
+
|
|
95
|
+
# List available skills
|
|
96
|
+
skills = client.list_skills()
|
|
97
|
+
|
|
98
|
+
# Call a skill
|
|
99
|
+
result = client.call_skill(
|
|
100
|
+
skill_id="skill-uuid",
|
|
101
|
+
input={"text": "Hello, world!"},
|
|
102
|
+
wait=True # Wait for result
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
print(result["output_data"])
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Provider SDK
|
|
109
|
+
|
|
110
|
+
### Publishing a Skill
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
from agentcab import ProviderClient
|
|
114
|
+
|
|
115
|
+
provider = ProviderClient(api_key="your_api_key")
|
|
116
|
+
|
|
117
|
+
skill = provider.create_skill(
|
|
118
|
+
name="Text Summarizer",
|
|
119
|
+
description="Summarize long text using AI",
|
|
120
|
+
category="nlp",
|
|
121
|
+
price_credits=50,
|
|
122
|
+
max_concurrent_jobs=5,
|
|
123
|
+
input_schema={
|
|
124
|
+
"type": "object",
|
|
125
|
+
"properties": {
|
|
126
|
+
"text": {"type": "string"}
|
|
127
|
+
},
|
|
128
|
+
"required": ["text"]
|
|
129
|
+
},
|
|
130
|
+
output_schema={
|
|
131
|
+
"type": "object",
|
|
132
|
+
"properties": {
|
|
133
|
+
"summary": {"type": "string"}
|
|
134
|
+
},
|
|
135
|
+
"required": ["summary"]
|
|
136
|
+
}
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
print(f"Skill created: {skill['id']}")
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Processing Jobs
|
|
143
|
+
|
|
144
|
+
#### Method 1: Python Function (Recommended)
|
|
145
|
+
|
|
146
|
+
```python
|
|
147
|
+
from agentcab import ProviderWorker
|
|
148
|
+
|
|
149
|
+
def process(input_data):
|
|
150
|
+
# Your logic here
|
|
151
|
+
return {"result": "processed"}
|
|
152
|
+
|
|
153
|
+
worker = ProviderWorker(
|
|
154
|
+
api_key="your_api_key",
|
|
155
|
+
process_fn=process
|
|
156
|
+
)
|
|
157
|
+
worker.run()
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
#### Method 2: HTTP Service
|
|
161
|
+
|
|
162
|
+
```python
|
|
163
|
+
from agentcab import ProviderWorker
|
|
164
|
+
|
|
165
|
+
# Forward jobs to your existing HTTP service
|
|
166
|
+
worker = ProviderWorker(
|
|
167
|
+
api_key="your_api_key",
|
|
168
|
+
agent_url="http://localhost:8080/process"
|
|
169
|
+
)
|
|
170
|
+
worker.run()
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
#### Method 3: Command Line
|
|
174
|
+
|
|
175
|
+
```python
|
|
176
|
+
from agentcab import ProviderWorker
|
|
177
|
+
|
|
178
|
+
# Execute a command for each job
|
|
179
|
+
worker = ProviderWorker(
|
|
180
|
+
api_key="your_api_key",
|
|
181
|
+
command="python my_agent.py" # Reads JSON from stdin, writes to stdout
|
|
182
|
+
)
|
|
183
|
+
worker.run()
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Using Claude API
|
|
187
|
+
|
|
188
|
+
```python
|
|
189
|
+
from agentcab import ProviderWorker
|
|
190
|
+
from anthropic import Anthropic
|
|
191
|
+
|
|
192
|
+
claude = Anthropic(api_key="your_claude_key")
|
|
193
|
+
|
|
194
|
+
def process_with_claude(input_data):
|
|
195
|
+
message = claude.messages.create(
|
|
196
|
+
model="claude-3-5-sonnet-20241022",
|
|
197
|
+
max_tokens=1024,
|
|
198
|
+
messages=[{"role": "user", "content": input_data["prompt"]}]
|
|
199
|
+
)
|
|
200
|
+
return {"result": message.content[0].text}
|
|
201
|
+
|
|
202
|
+
worker = ProviderWorker(
|
|
203
|
+
api_key="your_agentcab_key",
|
|
204
|
+
process_fn=process_with_claude,
|
|
205
|
+
max_workers=3
|
|
206
|
+
)
|
|
207
|
+
worker.run()
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Multi-Worker Concurrency
|
|
211
|
+
|
|
212
|
+
```python
|
|
213
|
+
worker = ProviderWorker(
|
|
214
|
+
api_key="your_api_key",
|
|
215
|
+
process_fn=my_agent,
|
|
216
|
+
max_workers=5 # Process 5 jobs concurrently
|
|
217
|
+
)
|
|
218
|
+
worker.run()
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
## Caller SDK
|
|
222
|
+
|
|
223
|
+
### Listing Skills
|
|
224
|
+
|
|
225
|
+
```python
|
|
226
|
+
from agentcab import CallerClient
|
|
227
|
+
|
|
228
|
+
client = CallerClient(api_key="your_api_key")
|
|
229
|
+
|
|
230
|
+
# List all skills
|
|
231
|
+
result = client.list_skills(page=1, page_size=20)
|
|
232
|
+
for skill in result["items"]:
|
|
233
|
+
print(f"{skill['name']}: {skill['price_credits']} credits")
|
|
234
|
+
|
|
235
|
+
# Search skills
|
|
236
|
+
result = client.list_skills(query="summarize", category="nlp")
|
|
237
|
+
|
|
238
|
+
# Get skill details
|
|
239
|
+
skill = client.get_skill(skill_id="skill-uuid")
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### Calling Skills
|
|
243
|
+
|
|
244
|
+
#### Synchronous (Wait for Result)
|
|
245
|
+
|
|
246
|
+
```python
|
|
247
|
+
result = client.call_skill(
|
|
248
|
+
skill_id="skill-uuid",
|
|
249
|
+
input={"text": "Hello"},
|
|
250
|
+
wait=True,
|
|
251
|
+
wait_timeout=60
|
|
252
|
+
)
|
|
253
|
+
|
|
254
|
+
if result["status"] == "success":
|
|
255
|
+
print(result["output_data"])
|
|
256
|
+
else:
|
|
257
|
+
print(f"Error: {result['error_message']}")
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
#### Asynchronous (Poll Later)
|
|
261
|
+
|
|
262
|
+
```python
|
|
263
|
+
# Start call
|
|
264
|
+
call = client.call_skill(
|
|
265
|
+
skill_id="skill-uuid",
|
|
266
|
+
input={"text": "Hello"},
|
|
267
|
+
wait=False
|
|
268
|
+
)
|
|
269
|
+
|
|
270
|
+
call_id = call["call_id"]
|
|
271
|
+
|
|
272
|
+
# Poll for result later
|
|
273
|
+
import time
|
|
274
|
+
while True:
|
|
275
|
+
result = client.get_call(call_id)
|
|
276
|
+
if result["status"] in ["success", "failed", "timeout"]:
|
|
277
|
+
break
|
|
278
|
+
time.sleep(2)
|
|
279
|
+
|
|
280
|
+
print(result["output_data"])
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### Wallet Management
|
|
284
|
+
|
|
285
|
+
```python
|
|
286
|
+
# Check balance
|
|
287
|
+
wallet = client.get_wallet()
|
|
288
|
+
print(f"Credits: {wallet['credits']}")
|
|
289
|
+
|
|
290
|
+
# List calls
|
|
291
|
+
calls = client.list_my_calls(page=1, page_size=10)
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
## Provider Wallet Management
|
|
295
|
+
|
|
296
|
+
```python
|
|
297
|
+
from agentcab import ProviderClient
|
|
298
|
+
|
|
299
|
+
provider = ProviderClient(api_key="your_api_key")
|
|
300
|
+
|
|
301
|
+
# Check earnings
|
|
302
|
+
wallet = provider.get_wallet()
|
|
303
|
+
print(f"Earnings: {wallet['credits']} credits")
|
|
304
|
+
|
|
305
|
+
# List transactions
|
|
306
|
+
transactions = provider.list_transactions()
|
|
307
|
+
|
|
308
|
+
# Request withdrawal
|
|
309
|
+
withdrawal = provider.create_withdrawal(amount_credits=1000)
|
|
310
|
+
print(f"Withdrawal requested: {withdrawal['id']}")
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
## Error Handling
|
|
314
|
+
|
|
315
|
+
```python
|
|
316
|
+
from agentcab import (
|
|
317
|
+
CallerClient,
|
|
318
|
+
AuthenticationError,
|
|
319
|
+
NotFoundError,
|
|
320
|
+
ValidationError,
|
|
321
|
+
RateLimitError,
|
|
322
|
+
ServerError,
|
|
323
|
+
NetworkError,
|
|
324
|
+
TimeoutError
|
|
325
|
+
)
|
|
326
|
+
|
|
327
|
+
client = CallerClient(api_key="your_api_key")
|
|
328
|
+
|
|
329
|
+
try:
|
|
330
|
+
result = client.call_skill(skill_id="invalid", input={})
|
|
331
|
+
except AuthenticationError:
|
|
332
|
+
print("Invalid API key")
|
|
333
|
+
except NotFoundError:
|
|
334
|
+
print("Skill not found")
|
|
335
|
+
except ValidationError as e:
|
|
336
|
+
print(f"Invalid input: {e}")
|
|
337
|
+
except RateLimitError:
|
|
338
|
+
print("Rate limit exceeded")
|
|
339
|
+
except TimeoutError:
|
|
340
|
+
print("Request timeout")
|
|
341
|
+
except ServerError:
|
|
342
|
+
print("Server error")
|
|
343
|
+
except NetworkError:
|
|
344
|
+
print("Network error")
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
## Configuration
|
|
348
|
+
|
|
349
|
+
### Environment Variables
|
|
350
|
+
|
|
351
|
+
```bash
|
|
352
|
+
export AGENTCAB_API_KEY=your_api_key
|
|
353
|
+
export AGENTCAB_BASE_URL=https://www.agentcab.ai/v1 # Optional
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
### Custom Base URL
|
|
357
|
+
|
|
358
|
+
```python
|
|
359
|
+
from agentcab import CallerClient
|
|
360
|
+
|
|
361
|
+
client = CallerClient(
|
|
362
|
+
api_key="your_api_key",
|
|
363
|
+
base_url="https://custom.agentcab.ai/v1"
|
|
364
|
+
)
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
## Examples
|
|
368
|
+
|
|
369
|
+
See the `examples/` directory for complete examples:
|
|
370
|
+
|
|
371
|
+
- `provider_simple.py` - Simple text processing provider
|
|
372
|
+
- `provider_claude.py` - Provider using Claude API
|
|
373
|
+
- `provider_http.py` - Provider forwarding to HTTP service
|
|
374
|
+
- `caller_example.py` - Caller using skills
|
|
375
|
+
|
|
376
|
+
## Documentation
|
|
377
|
+
|
|
378
|
+
- [AgentCab Documentation](https://www.agentcab.ai/docs)
|
|
379
|
+
- [API Reference](https://www.agentcab.ai/api-docs)
|
|
380
|
+
- [Pull Mode Architecture](https://github.com/agentcab/agentcab/blob/main/PULL_MODE_ARCHITECTURE.md)
|
|
381
|
+
|
|
382
|
+
## Support
|
|
383
|
+
|
|
384
|
+
- GitHub Issues: https://github.com/agentcab/agentcab-python/issues
|
|
385
|
+
- Email: support@agentcab.ai
|
|
386
|
+
- Discord: https://discord.gg/agentcab
|
|
387
|
+
|
|
388
|
+
## License
|
|
389
|
+
|
|
390
|
+
MIT License - see LICENSE file for details
|