ainative-python 2.0.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.
- ainative_python-2.0.0/PKG-INFO +551 -0
- ainative_python-2.0.0/README.md +480 -0
- ainative_python-2.0.0/ainative/__init__.py +46 -0
- ainative_python-2.0.0/ainative/agent_coordination.py +249 -0
- ainative_python-2.0.0/ainative/agent_identity_system.py +1566 -0
- ainative_python-2.0.0/ainative/agent_learning.py +239 -0
- ainative_python-2.0.0/ainative/agent_orchestration.py +202 -0
- ainative_python-2.0.0/ainative/agent_state.py +231 -0
- ainative_python-2.0.0/ainative/agent_swarm/__init__.py +510 -0
- ainative_python-2.0.0/ainative/auth.py +113 -0
- ainative_python-2.0.0/ainative/cli.py +698 -0
- ainative_python-2.0.0/ainative/cli_utils/__init__.py +13 -0
- ainative_python-2.0.0/ainative/cli_utils/diff.py +292 -0
- ainative_python-2.0.0/ainative/cli_utils/formatters.py +227 -0
- ainative_python-2.0.0/ainative/client.py +272 -0
- ainative_python-2.0.0/ainative/commands/__init__.py +28 -0
- ainative_python-2.0.0/ainative/commands/agents.py +238 -0
- ainative_python-2.0.0/ainative/commands/coordination.py +108 -0
- ainative_python-2.0.0/ainative/commands/inspect.py +483 -0
- ainative_python-2.0.0/ainative/commands/learning.py +119 -0
- ainative_python-2.0.0/ainative/commands/local.py +544 -0
- ainative_python-2.0.0/ainative/commands/state.py +144 -0
- ainative_python-2.0.0/ainative/commands/swarm.py +184 -0
- ainative_python-2.0.0/ainative/commands/sync.py +157 -0
- ainative_python-2.0.0/ainative/commands/tasks.py +191 -0
- ainative_python-2.0.0/ainative/exceptions.py +87 -0
- ainative_python-2.0.0/ainative/zerodb/__init__.py +89 -0
- ainative_python-2.0.0/ainative/zerodb/analytics.py +232 -0
- ainative_python-2.0.0/ainative/zerodb/memory.py +260 -0
- ainative_python-2.0.0/ainative/zerodb/projects.py +224 -0
- ainative_python-2.0.0/ainative/zerodb/tables.py +362 -0
- ainative_python-2.0.0/ainative/zerodb/vectors.py +231 -0
- ainative_python-2.0.0/ainative_python.egg-info/PKG-INFO +551 -0
- ainative_python-2.0.0/ainative_python.egg-info/SOURCES.txt +43 -0
- ainative_python-2.0.0/ainative_python.egg-info/dependency_links.txt +1 -0
- ainative_python-2.0.0/ainative_python.egg-info/entry_points.txt +2 -0
- ainative_python-2.0.0/ainative_python.egg-info/not-zip-safe +1 -0
- ainative_python-2.0.0/ainative_python.egg-info/requires.txt +33 -0
- ainative_python-2.0.0/ainative_python.egg-info/top_level.txt +1 -0
- ainative_python-2.0.0/setup.cfg +4 -0
- ainative_python-2.0.0/setup.py +110 -0
- ainative_python-2.0.0/tests/test_agent_operations.py +587 -0
- ainative_python-2.0.0/tests/test_cli.py +545 -0
- ainative_python-2.0.0/tests/test_new_cli_commands.py +767 -0
- ainative_python-2.0.0/tests/test_tables.py +439 -0
|
@@ -0,0 +1,551 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ainative-python
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: Official Python SDK for AINative Studio APIs with ZeroDB Local support
|
|
5
|
+
Home-page: https://github.com/ainative/ainative-python
|
|
6
|
+
Author: AINative Team
|
|
7
|
+
Author-email: support@ainative.studio
|
|
8
|
+
Project-URL: Documentation, https://docs.ainative.studio/sdk/python
|
|
9
|
+
Project-URL: API Reference, https://api.ainative.studio/docs-enhanced
|
|
10
|
+
Project-URL: Bug Reports, https://github.com/ainative/studio/issues
|
|
11
|
+
Project-URL: Source, https://github.com/ainative/ainative-python
|
|
12
|
+
Keywords: ainative,database,vector,embedding,ai,ml,machine learning,artificial intelligence,api,sdk,zerodb,agent swarm,postgresql,vector search,nosql,table operations,mongodb-style,crud
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Topic :: Database
|
|
24
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
|
|
25
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
26
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
27
|
+
Requires-Python: >=3.8
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
Requires-Dist: requests>=2.31.0
|
|
30
|
+
Requires-Dist: httpx>=0.24.0
|
|
31
|
+
Requires-Dist: pydantic>=2.0.0
|
|
32
|
+
Requires-Dist: python-dateutil>=2.8.0
|
|
33
|
+
Requires-Dist: typing-extensions>=4.7.0
|
|
34
|
+
Requires-Dist: aiohttp>=3.8.0
|
|
35
|
+
Requires-Dist: asyncio>=3.4.3
|
|
36
|
+
Requires-Dist: numpy>=1.24.0
|
|
37
|
+
Requires-Dist: PyYAML>=6.0.0
|
|
38
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
39
|
+
Requires-Dist: click>=8.1.0
|
|
40
|
+
Requires-Dist: rich>=13.0.0
|
|
41
|
+
Requires-Dist: tenacity>=8.2.0
|
|
42
|
+
Requires-Dist: backoff>=2.2.0
|
|
43
|
+
Provides-Extra: dev
|
|
44
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
45
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
|
|
46
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
47
|
+
Requires-Dist: pytest-mock>=3.10.0; extra == "dev"
|
|
48
|
+
Requires-Dist: black>=22.0.0; extra == "dev"
|
|
49
|
+
Requires-Dist: flake8>=5.0.0; extra == "dev"
|
|
50
|
+
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
51
|
+
Requires-Dist: isort>=5.10.0; extra == "dev"
|
|
52
|
+
Provides-Extra: docs
|
|
53
|
+
Requires-Dist: sphinx>=5.0.0; extra == "docs"
|
|
54
|
+
Requires-Dist: sphinx-rtd-theme>=1.2.0; extra == "docs"
|
|
55
|
+
Requires-Dist: sphinx-autodoc-typehints>=1.19.0; extra == "docs"
|
|
56
|
+
Provides-Extra: async
|
|
57
|
+
Requires-Dist: aiohttp>=3.8.0; extra == "async"
|
|
58
|
+
Requires-Dist: asyncio>=3.4.3; extra == "async"
|
|
59
|
+
Dynamic: author
|
|
60
|
+
Dynamic: author-email
|
|
61
|
+
Dynamic: classifier
|
|
62
|
+
Dynamic: description
|
|
63
|
+
Dynamic: description-content-type
|
|
64
|
+
Dynamic: home-page
|
|
65
|
+
Dynamic: keywords
|
|
66
|
+
Dynamic: project-url
|
|
67
|
+
Dynamic: provides-extra
|
|
68
|
+
Dynamic: requires-dist
|
|
69
|
+
Dynamic: requires-python
|
|
70
|
+
Dynamic: summary
|
|
71
|
+
|
|
72
|
+
# AINative Python SDK
|
|
73
|
+
|
|
74
|
+
Official Python SDK for AINative Studio APIs - unified database and AI operations platform.
|
|
75
|
+
|
|
76
|
+
## Features
|
|
77
|
+
|
|
78
|
+
- 🚀 **Simple Integration** - Get started with just an API key
|
|
79
|
+
- 🗄️ **ZeroDB Operations** - Full support for vector storage, search, and memory management
|
|
80
|
+
- 🤖 **Agent Swarm** - Orchestrate multiple AI agents for complex tasks
|
|
81
|
+
- 🔐 **Enterprise Security** - Multi-tenant authentication with API key management
|
|
82
|
+
- ⚡ **High Performance** - Async support and connection pooling
|
|
83
|
+
- 📊 **Analytics** - Built-in usage tracking and performance metrics
|
|
84
|
+
|
|
85
|
+
## Installation
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
pip install ainative-python
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
For development version:
|
|
92
|
+
```bash
|
|
93
|
+
pip install git+https://github.com/ainative/ainative-python.git
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Quick Start
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
from ainative import AINativeClient
|
|
100
|
+
|
|
101
|
+
# Initialize client
|
|
102
|
+
client = AINativeClient(api_key="your-api-key")
|
|
103
|
+
|
|
104
|
+
# Create a project
|
|
105
|
+
project = client.zerodb.projects.create(
|
|
106
|
+
name="My First Project",
|
|
107
|
+
description="Testing AINative SDK"
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
# Store vectors
|
|
111
|
+
client.zerodb.vectors.upsert(
|
|
112
|
+
project_id=project["id"],
|
|
113
|
+
vectors=[[0.1, 0.2, 0.3], [0.4, 0.5, 0.6]],
|
|
114
|
+
metadata=[{"text": "Hello"}, {"text": "World"}]
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
# Search vectors
|
|
118
|
+
results = client.zerodb.vectors.search(
|
|
119
|
+
project_id=project["id"],
|
|
120
|
+
vector=[0.15, 0.25, 0.35],
|
|
121
|
+
top_k=5
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
# Create memory
|
|
125
|
+
memory = client.zerodb.memory.create(
|
|
126
|
+
content="Important information to remember",
|
|
127
|
+
tags=["tutorial", "example"]
|
|
128
|
+
)
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Authentication
|
|
132
|
+
|
|
133
|
+
### Using Environment Variables
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
export AINATIVE_API_KEY="your-api-key"
|
|
137
|
+
export AINATIVE_API_SECRET="your-api-secret" # Optional
|
|
138
|
+
export AINATIVE_ORG_ID="your-org-id" # For multi-tenant scenarios
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
from ainative import AINativeClient
|
|
143
|
+
|
|
144
|
+
# Automatically uses environment variables
|
|
145
|
+
client = AINativeClient()
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Direct Configuration
|
|
149
|
+
|
|
150
|
+
```python
|
|
151
|
+
from ainative import AINativeClient, AuthConfig
|
|
152
|
+
|
|
153
|
+
auth_config = AuthConfig(
|
|
154
|
+
api_key="your-api-key",
|
|
155
|
+
api_secret="your-api-secret", # Optional for enhanced security
|
|
156
|
+
environment="production" # or "staging", "development"
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
client = AINativeClient(auth_config=auth_config)
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## ZeroDB Operations
|
|
163
|
+
|
|
164
|
+
### Project Management
|
|
165
|
+
|
|
166
|
+
```python
|
|
167
|
+
# List all projects
|
|
168
|
+
projects = client.zerodb.projects.list(limit=10)
|
|
169
|
+
|
|
170
|
+
# Get project details
|
|
171
|
+
project = client.zerodb.projects.get(project_id="proj_123")
|
|
172
|
+
|
|
173
|
+
# Update project
|
|
174
|
+
client.zerodb.projects.update(
|
|
175
|
+
project_id="proj_123",
|
|
176
|
+
name="Updated Name",
|
|
177
|
+
metadata={"version": "2.0"}
|
|
178
|
+
)
|
|
179
|
+
|
|
180
|
+
# Suspend/Activate project
|
|
181
|
+
client.zerodb.projects.suspend(project_id="proj_123", reason="Maintenance")
|
|
182
|
+
client.zerodb.projects.activate(project_id="proj_123")
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Vector Operations
|
|
186
|
+
|
|
187
|
+
```python
|
|
188
|
+
import numpy as np
|
|
189
|
+
|
|
190
|
+
# Upsert vectors with numpy arrays
|
|
191
|
+
vectors = np.random.rand(10, 768) # 10 vectors of dimension 768
|
|
192
|
+
metadata = [{"doc_id": i, "category": "test"} for i in range(10)]
|
|
193
|
+
|
|
194
|
+
client.zerodb.vectors.upsert(
|
|
195
|
+
project_id="proj_123",
|
|
196
|
+
vectors=vectors,
|
|
197
|
+
metadata=metadata,
|
|
198
|
+
namespace="documents"
|
|
199
|
+
)
|
|
200
|
+
|
|
201
|
+
# Search vectors
|
|
202
|
+
query_vector = np.random.rand(768)
|
|
203
|
+
results = client.zerodb.vectors.search(
|
|
204
|
+
project_id="proj_123",
|
|
205
|
+
vector=query_vector,
|
|
206
|
+
top_k=5,
|
|
207
|
+
namespace="documents",
|
|
208
|
+
filter={"category": "test"}
|
|
209
|
+
)
|
|
210
|
+
|
|
211
|
+
# Delete vectors
|
|
212
|
+
client.zerodb.vectors.delete(
|
|
213
|
+
project_id="proj_123",
|
|
214
|
+
ids=["vec_1", "vec_2"],
|
|
215
|
+
namespace="documents"
|
|
216
|
+
)
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### NoSQL Table Operations
|
|
220
|
+
|
|
221
|
+
```python
|
|
222
|
+
# Create a table with schema
|
|
223
|
+
table = client.zerodb.tables.create_table(
|
|
224
|
+
table_name="users",
|
|
225
|
+
schema={
|
|
226
|
+
"fields": {
|
|
227
|
+
"email": "string",
|
|
228
|
+
"name": "string",
|
|
229
|
+
"age": "number",
|
|
230
|
+
"active": "boolean"
|
|
231
|
+
},
|
|
232
|
+
"indexes": ["email"]
|
|
233
|
+
}
|
|
234
|
+
)
|
|
235
|
+
|
|
236
|
+
# Insert rows
|
|
237
|
+
result = client.zerodb.tables.insert_rows("users", [
|
|
238
|
+
{"email": "user@example.com", "name": "John", "age": 30, "active": True},
|
|
239
|
+
{"email": "jane@example.com", "name": "Jane", "age": 25, "active": True}
|
|
240
|
+
])
|
|
241
|
+
|
|
242
|
+
# Query rows with filters
|
|
243
|
+
users = client.zerodb.tables.query_rows(
|
|
244
|
+
"users",
|
|
245
|
+
filter={"age": {"$gte": 25}, "active": True},
|
|
246
|
+
sort={"age": -1},
|
|
247
|
+
limit=10
|
|
248
|
+
)
|
|
249
|
+
|
|
250
|
+
# Update rows
|
|
251
|
+
client.zerodb.tables.update_rows(
|
|
252
|
+
"users",
|
|
253
|
+
filter={"email": "user@example.com"},
|
|
254
|
+
update={"$set": {"age": 31}}
|
|
255
|
+
)
|
|
256
|
+
|
|
257
|
+
# Delete rows
|
|
258
|
+
client.zerodb.tables.delete_rows(
|
|
259
|
+
"users",
|
|
260
|
+
filter={"age": {"$lt": 18}}
|
|
261
|
+
)
|
|
262
|
+
|
|
263
|
+
# Count rows
|
|
264
|
+
total = client.zerodb.tables.count_rows("users")
|
|
265
|
+
active_users = client.zerodb.tables.count_rows("users", filter={"active": True})
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
See the complete [Table Operations Guide](TABLE_OPERATIONS.md) for advanced usage.
|
|
269
|
+
|
|
270
|
+
### Memory Management
|
|
271
|
+
|
|
272
|
+
```python
|
|
273
|
+
from ainative.zerodb.memory import MemoryPriority
|
|
274
|
+
|
|
275
|
+
# Create memory with priority
|
|
276
|
+
memory = client.zerodb.memory.create(
|
|
277
|
+
content="Critical system configuration",
|
|
278
|
+
title="System Config",
|
|
279
|
+
tags=["config", "system"],
|
|
280
|
+
priority=MemoryPriority.HIGH,
|
|
281
|
+
metadata={"version": "1.0"}
|
|
282
|
+
)
|
|
283
|
+
|
|
284
|
+
# Search memories
|
|
285
|
+
results = client.zerodb.memory.search(
|
|
286
|
+
query="system configuration",
|
|
287
|
+
semantic=True, # Use semantic search
|
|
288
|
+
limit=10
|
|
289
|
+
)
|
|
290
|
+
|
|
291
|
+
# List memories with filters
|
|
292
|
+
memories = client.zerodb.memory.list(
|
|
293
|
+
tags=["config"],
|
|
294
|
+
priority=MemoryPriority.HIGH
|
|
295
|
+
)
|
|
296
|
+
|
|
297
|
+
# Get related memories
|
|
298
|
+
related = client.zerodb.memory.get_related(
|
|
299
|
+
memory_id=memory["id"],
|
|
300
|
+
limit=5
|
|
301
|
+
)
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
## Agent Swarm
|
|
305
|
+
|
|
306
|
+
### Starting a Swarm
|
|
307
|
+
|
|
308
|
+
```python
|
|
309
|
+
from ainative.agent_swarm import AgentType
|
|
310
|
+
|
|
311
|
+
# Define agents
|
|
312
|
+
agents = [
|
|
313
|
+
{
|
|
314
|
+
"id": "researcher_1",
|
|
315
|
+
"type": AgentType.RESEARCHER.value,
|
|
316
|
+
"capabilities": ["web_search", "document_analysis"]
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
"id": "coder_1",
|
|
320
|
+
"type": AgentType.CODER.value,
|
|
321
|
+
"capabilities": ["python", "javascript", "testing"]
|
|
322
|
+
}
|
|
323
|
+
]
|
|
324
|
+
|
|
325
|
+
# Start swarm
|
|
326
|
+
swarm = client.agent_swarm.start_swarm(
|
|
327
|
+
project_id="proj_123",
|
|
328
|
+
agents=agents,
|
|
329
|
+
objective="Research and implement a new feature"
|
|
330
|
+
)
|
|
331
|
+
|
|
332
|
+
# Orchestrate task
|
|
333
|
+
result = client.agent_swarm.orchestrate(
|
|
334
|
+
swarm_id=swarm["id"],
|
|
335
|
+
task="Find best practices for implementing OAuth2",
|
|
336
|
+
context={"language": "Python", "framework": "FastAPI"}
|
|
337
|
+
)
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
### Managing Swarms
|
|
341
|
+
|
|
342
|
+
```python
|
|
343
|
+
# Get swarm status
|
|
344
|
+
status = client.agent_swarm.get_status(swarm_id="swarm_123")
|
|
345
|
+
|
|
346
|
+
# Get performance metrics
|
|
347
|
+
metrics = client.agent_swarm.get_metrics(swarm_id="swarm_123")
|
|
348
|
+
|
|
349
|
+
# Configure specific agent
|
|
350
|
+
client.agent_swarm.configure_agent(
|
|
351
|
+
swarm_id="swarm_123",
|
|
352
|
+
agent_id="coder_1",
|
|
353
|
+
config={"temperature": 0.7, "max_tokens": 2000}
|
|
354
|
+
)
|
|
355
|
+
|
|
356
|
+
# Pause/Resume swarm
|
|
357
|
+
client.agent_swarm.pause_swarm(swarm_id="swarm_123")
|
|
358
|
+
client.agent_swarm.resume_swarm(swarm_id="swarm_123")
|
|
359
|
+
|
|
360
|
+
# Stop swarm
|
|
361
|
+
client.agent_swarm.stop_swarm(swarm_id="swarm_123")
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
## Analytics
|
|
365
|
+
|
|
366
|
+
```python
|
|
367
|
+
from datetime import datetime, timedelta
|
|
368
|
+
|
|
369
|
+
# Get usage analytics
|
|
370
|
+
usage = client.zerodb.analytics.get_usage(
|
|
371
|
+
project_id="proj_123",
|
|
372
|
+
start_date=datetime.now() - timedelta(days=30),
|
|
373
|
+
end_date=datetime.now(),
|
|
374
|
+
granularity="daily"
|
|
375
|
+
)
|
|
376
|
+
|
|
377
|
+
# Get performance metrics
|
|
378
|
+
performance = client.zerodb.analytics.get_performance_metrics(
|
|
379
|
+
project_id="proj_123",
|
|
380
|
+
metric_type="latency"
|
|
381
|
+
)
|
|
382
|
+
|
|
383
|
+
# Get cost analysis
|
|
384
|
+
costs = client.zerodb.analytics.get_cost_analysis(
|
|
385
|
+
project_id="proj_123"
|
|
386
|
+
)
|
|
387
|
+
|
|
388
|
+
# Export analytics report
|
|
389
|
+
report = client.zerodb.analytics.export_report(
|
|
390
|
+
report_type="detailed",
|
|
391
|
+
project_id="proj_123",
|
|
392
|
+
format="pdf"
|
|
393
|
+
)
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
## Async Support
|
|
397
|
+
|
|
398
|
+
```python
|
|
399
|
+
import asyncio
|
|
400
|
+
from ainative import AsyncAINativeClient
|
|
401
|
+
|
|
402
|
+
async def main():
|
|
403
|
+
async with AsyncAINativeClient(api_key="your-api-key") as client:
|
|
404
|
+
# Async operations
|
|
405
|
+
project = await client.zerodb.projects.create(
|
|
406
|
+
name="Async Project"
|
|
407
|
+
)
|
|
408
|
+
|
|
409
|
+
# Concurrent operations
|
|
410
|
+
tasks = [
|
|
411
|
+
client.zerodb.vectors.search(project_id, vector)
|
|
412
|
+
for vector in vectors
|
|
413
|
+
]
|
|
414
|
+
results = await asyncio.gather(*tasks)
|
|
415
|
+
|
|
416
|
+
asyncio.run(main())
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
## Error Handling
|
|
420
|
+
|
|
421
|
+
```python
|
|
422
|
+
from ainative.exceptions import (
|
|
423
|
+
AuthenticationError,
|
|
424
|
+
RateLimitError,
|
|
425
|
+
ValidationError,
|
|
426
|
+
ResourceNotFoundError
|
|
427
|
+
)
|
|
428
|
+
|
|
429
|
+
try:
|
|
430
|
+
result = client.zerodb.projects.get("invalid_id")
|
|
431
|
+
except ResourceNotFoundError as e:
|
|
432
|
+
print(f"Project not found: {e.resource_id}")
|
|
433
|
+
except AuthenticationError:
|
|
434
|
+
print("Invalid API credentials")
|
|
435
|
+
except RateLimitError as e:
|
|
436
|
+
print(f"Rate limited. Retry after {e.retry_after} seconds")
|
|
437
|
+
except ValidationError as e:
|
|
438
|
+
print(f"Invalid input: {e.message}")
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
## Configuration
|
|
442
|
+
|
|
443
|
+
### Custom Base URL
|
|
444
|
+
|
|
445
|
+
```python
|
|
446
|
+
client = AINativeClient(
|
|
447
|
+
api_key="your-api-key",
|
|
448
|
+
base_url="https://custom.ainative.studio"
|
|
449
|
+
)
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
### Timeout and Retries
|
|
453
|
+
|
|
454
|
+
```python
|
|
455
|
+
from ainative.client import ClientConfig
|
|
456
|
+
|
|
457
|
+
config = ClientConfig(
|
|
458
|
+
timeout=60, # 60 seconds
|
|
459
|
+
max_retries=5,
|
|
460
|
+
retry_delay=2.0
|
|
461
|
+
)
|
|
462
|
+
|
|
463
|
+
client = AINativeClient(
|
|
464
|
+
api_key="your-api-key",
|
|
465
|
+
config=config
|
|
466
|
+
)
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
## CLI Tool
|
|
470
|
+
|
|
471
|
+
The SDK includes a CLI tool for quick operations:
|
|
472
|
+
|
|
473
|
+
```bash
|
|
474
|
+
# Configure credentials
|
|
475
|
+
ainative config set api_key YOUR_API_KEY
|
|
476
|
+
|
|
477
|
+
# List projects
|
|
478
|
+
ainative projects list
|
|
479
|
+
|
|
480
|
+
# Create project
|
|
481
|
+
ainative projects create --name "CLI Project"
|
|
482
|
+
|
|
483
|
+
# Search vectors
|
|
484
|
+
ainative vectors search --project proj_123 --query "test"
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
## Examples
|
|
488
|
+
|
|
489
|
+
Full examples are available in the [examples/](examples/) directory:
|
|
490
|
+
|
|
491
|
+
- [Basic Usage](examples/basic_usage.py)
|
|
492
|
+
- [Vector Search](examples/vector_search.py)
|
|
493
|
+
- [Memory Management](examples/memory_management.py)
|
|
494
|
+
- [Agent Swarm](examples/agent_swarm.py)
|
|
495
|
+
- [Analytics Dashboard](examples/analytics.py)
|
|
496
|
+
- [Multi-tenant Setup](examples/multi_tenant.py)
|
|
497
|
+
|
|
498
|
+
## Development
|
|
499
|
+
|
|
500
|
+
### Setting up development environment
|
|
501
|
+
|
|
502
|
+
```bash
|
|
503
|
+
# Clone repository
|
|
504
|
+
git clone https://github.com/ainative/ainative-python.git
|
|
505
|
+
cd ainative-python
|
|
506
|
+
|
|
507
|
+
# Install in development mode
|
|
508
|
+
pip install -e ".[dev]"
|
|
509
|
+
|
|
510
|
+
# Run tests
|
|
511
|
+
pytest
|
|
512
|
+
|
|
513
|
+
# Format code
|
|
514
|
+
black ainative/
|
|
515
|
+
isort ainative/
|
|
516
|
+
|
|
517
|
+
# Type checking
|
|
518
|
+
mypy ainative/
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
### Running Tests
|
|
522
|
+
|
|
523
|
+
```bash
|
|
524
|
+
# All tests
|
|
525
|
+
pytest
|
|
526
|
+
|
|
527
|
+
# With coverage
|
|
528
|
+
pytest --cov=ainative
|
|
529
|
+
|
|
530
|
+
# Specific module
|
|
531
|
+
pytest tests/test_zerodb.py
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
## Support
|
|
535
|
+
|
|
536
|
+
- **Documentation**: [https://docs.ainative.studio/sdk/python](https://docs.ainative.studio/sdk/python)
|
|
537
|
+
- **API Reference**: [https://api.ainative.studio/docs-enhanced](https://api.ainative.studio/docs-enhanced)
|
|
538
|
+
- **Issues**: [GitHub Issues](https://github.com/ainative/ainative-python/issues)
|
|
539
|
+
- **Discord**: [Join our community](https://discord.gg/ainative)
|
|
540
|
+
|
|
541
|
+
## License
|
|
542
|
+
|
|
543
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
|
544
|
+
|
|
545
|
+
## Contributing
|
|
546
|
+
|
|
547
|
+
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
548
|
+
|
|
549
|
+
## Changelog
|
|
550
|
+
|
|
551
|
+
See [CHANGELOG.md](CHANGELOG.md) for release history.
|