synapcores 0.2.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.
- synapcores-0.2.0/LICENSE +21 -0
- synapcores-0.2.0/PKG-INFO +249 -0
- synapcores-0.2.0/README.md +206 -0
- synapcores-0.2.0/pyproject.toml +69 -0
- synapcores-0.2.0/setup.cfg +4 -0
- synapcores-0.2.0/setup.py +8 -0
- synapcores-0.2.0/synapcores/__init__.py +142 -0
- synapcores-0.2.0/synapcores/automl.py +201 -0
- synapcores-0.2.0/synapcores/chat.py +214 -0
- synapcores-0.2.0/synapcores/client.py +1892 -0
- synapcores-0.2.0/synapcores/collection.py +356 -0
- synapcores-0.2.0/synapcores/exceptions.py +107 -0
- synapcores-0.2.0/synapcores/filesystem.py +127 -0
- synapcores-0.2.0/synapcores/graph.py +181 -0
- synapcores-0.2.0/synapcores/mcp.py +46 -0
- synapcores-0.2.0/synapcores/models.py +528 -0
- synapcores-0.2.0/synapcores/multimodal.py +97 -0
- synapcores-0.2.0/synapcores/nl2sql.py +63 -0
- synapcores-0.2.0/synapcores/nlp.py +193 -0
- synapcores-0.2.0/synapcores/recipes.py +147 -0
- synapcores-0.2.0/synapcores/schema.py +58 -0
- synapcores-0.2.0/synapcores/subscription.py +147 -0
- synapcores-0.2.0/synapcores/system.py +45 -0
- synapcores-0.2.0/synapcores/transactions.py +141 -0
- synapcores-0.2.0/synapcores/vector_ops.py +507 -0
- synapcores-0.2.0/synapcores.egg-info/PKG-INFO +249 -0
- synapcores-0.2.0/synapcores.egg-info/SOURCES.txt +29 -0
- synapcores-0.2.0/synapcores.egg-info/dependency_links.txt +1 -0
- synapcores-0.2.0/synapcores.egg-info/requires.txt +16 -0
- synapcores-0.2.0/synapcores.egg-info/top_level.txt +1 -0
- synapcores-0.2.0/tests/test_client.py +171 -0
synapcores-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 SynapCores
|
|
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.
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: synapcores
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Official Python SDK for SynapCores AI-Native Database
|
|
5
|
+
Author-email: SynapCores <release@synapcores.com>
|
|
6
|
+
Maintainer-email: SynapCores <release@synapcores.com>
|
|
7
|
+
License: MIT
|
|
8
|
+
Project-URL: Homepage, https://synapcores.com
|
|
9
|
+
Project-URL: Documentation, https://synapcores.com/developers
|
|
10
|
+
Project-URL: Source, https://github.com/SynapCores/synapcores-releases
|
|
11
|
+
Project-URL: Issues, https://github.com/SynapCores/synapcores-releases/issues
|
|
12
|
+
Keywords: database,ai,ml,vector,embedding,semantic
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Topic :: Database
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
17
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
24
|
+
Requires-Python: >=3.8
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Requires-Dist: httpx>=0.24.0
|
|
28
|
+
Requires-Dist: pydantic>=2.0.0
|
|
29
|
+
Requires-Dist: numpy>=1.21.0
|
|
30
|
+
Requires-Dist: pandas>=1.3.0
|
|
31
|
+
Requires-Dist: python-dateutil>=2.8.0
|
|
32
|
+
Requires-Dist: websockets>=11.0
|
|
33
|
+
Requires-Dist: typing-extensions>=4.0.0
|
|
34
|
+
Provides-Extra: dev
|
|
35
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
36
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
|
|
37
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
38
|
+
Requires-Dist: black>=23.0.0; extra == "dev"
|
|
39
|
+
Requires-Dist: flake8>=6.0.0; extra == "dev"
|
|
40
|
+
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
41
|
+
Requires-Dist: sphinx>=6.0.0; extra == "dev"
|
|
42
|
+
Dynamic: license-file
|
|
43
|
+
|
|
44
|
+
# SynapCores Python SDK
|
|
45
|
+
|
|
46
|
+
Official Python SDK for SynapCores - The AI-Native Database Management System.
|
|
47
|
+
|
|
48
|
+
> **0.2.0 — gateway v1.5.0-ce alignment.** This release rewires every
|
|
49
|
+
> module against the v1.5.0-ce route surface. AutoML moved from `/ai/*`
|
|
50
|
+
> to `/automl/*`, vector ops collapsed onto `/vector-algebra/operation`,
|
|
51
|
+
> WebSocket auth now uses ticket exchange, API keys are sent via the
|
|
52
|
+
> `X-API-Key` header (and accept the new `ak_*` prefix in addition to
|
|
53
|
+
> the legacy `aidb_*`), and we ship new top-level modules: `graph`,
|
|
54
|
+
> `nl2sql`, `filesystem`, `chat`, `multimodal`, `system`,
|
|
55
|
+
> `transactions`, `mcp`, `recipes`, and `schema`.
|
|
56
|
+
|
|
57
|
+
## What's new in 0.2.0
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
from synapcores import SynapCores
|
|
61
|
+
|
|
62
|
+
client = SynapCores(host="localhost", port=8080, api_key="ak_prod_xxx...")
|
|
63
|
+
|
|
64
|
+
# 1. Cypher-style graph traversal
|
|
65
|
+
friends = client.graph.cypher(
|
|
66
|
+
"MATCH (u:User {id:$id})-[:FRIEND]->(f) RETURN f",
|
|
67
|
+
{"id": "u-123"},
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
# 2. Natural language → SQL (with optional execution)
|
|
71
|
+
ans = client.nl2sql.ask(
|
|
72
|
+
"top 10 customers by revenue this quarter",
|
|
73
|
+
execute=True,
|
|
74
|
+
)
|
|
75
|
+
print(ans["sql"], ans.get("rows"))
|
|
76
|
+
|
|
77
|
+
# 3. AI chat sessions with streaming
|
|
78
|
+
session = client.chat.sessions.create(model="gpt-4o")
|
|
79
|
+
for chunk in client.chat.stream(session["id"], "Summarize today's alerts"):
|
|
80
|
+
if chunk.get("delta"):
|
|
81
|
+
print(chunk["delta"], end="", flush=True)
|
|
82
|
+
|
|
83
|
+
# 4. Filesystem-backed RAG collections with progress
|
|
84
|
+
fs = client.filesystem.collections.create(name="docs", path="/data/docs", watch=True)
|
|
85
|
+
for evt in client.filesystem.collections.subscribe_progress(fs["id"]):
|
|
86
|
+
print(evt.get("status"), evt.get("progress"), evt.get("filename"))
|
|
87
|
+
|
|
88
|
+
# 5. Server-side transactions with savepoints
|
|
89
|
+
with client.transactions.begin(isolation_level="SERIALIZABLE") as tx:
|
|
90
|
+
tx.execute("UPDATE accounts SET balance = balance - $1 WHERE id = $2", [100, "a"])
|
|
91
|
+
tx.savepoint("mid")
|
|
92
|
+
tx.execute("UPDATE accounts SET balance = balance + $1 WHERE id = $2", [100, "b"])
|
|
93
|
+
# commit() runs implicitly on clean exit; rollback() on exception.
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Other new surfaces:
|
|
97
|
+
|
|
98
|
+
- `client.multimodal.{similarity,search,join,embed}` for cross-modal retrieval.
|
|
99
|
+
- `client.system.vision.{get,set,delete,test}` for the admin vision config.
|
|
100
|
+
- `client.mcp.{invoke,batch,info}` for the Model Context Protocol gateway.
|
|
101
|
+
- `client.recipes.list_categories()/list_templates()/execute_template()/list_executions()`.
|
|
102
|
+
- `client.schema.list_databases()/preview_table()`.
|
|
103
|
+
|
|
104
|
+
### Breaking changes vs 0.1.0
|
|
105
|
+
|
|
106
|
+
- `embed()` routes to `/ai/embeddings` (single) or `/ai/embeddings/batch`.
|
|
107
|
+
- `automl.*` paths moved from `/ai/*` to `/automl/*`.
|
|
108
|
+
- All vector math goes through `POST /vector-algebra/operation` with an `op` discriminator.
|
|
109
|
+
- KNN/range/hybrid search routes to `/vectors/collections/:name/search` with a `mode` field.
|
|
110
|
+
- API keys are sent as the `X-API-Key` header (was previously `Authorization: Bearer`).
|
|
111
|
+
- WebSocket subscriptions now use ticket exchange via `POST /v1/ws/ticket` and connect to `/ws?token=...`.
|
|
112
|
+
- `nlp.analyze()` is implemented client-side as parallel calls to `/ai/sentiment`, `/ai/entities`, and `/ai/summarize` since `/ai/analyze` was removed.
|
|
113
|
+
- The `client.sql(query, params=...)` payload now matches `POST /v1/query/execute` (positional `parameters`); `params` is still accepted as a dict for backwards compatibility.
|
|
114
|
+
|
|
115
|
+
## Features
|
|
116
|
+
|
|
117
|
+
- **AI-Native Operations**: Built-in support for embeddings, vector search, and semantic analysis
|
|
118
|
+
- **Document & Vector Storage**: Seamlessly work with both structured and unstructured data
|
|
119
|
+
- **SQL with AI Extensions**: Use familiar SQL syntax enhanced with AI operations
|
|
120
|
+
- **Real-time Subscriptions**: WebSocket support for live data updates
|
|
121
|
+
- **AutoML Integration**: Automated machine learning model training and deployment
|
|
122
|
+
- **Type-Safe**: Full type hints and Pydantic models for better IDE support
|
|
123
|
+
|
|
124
|
+
## Installation
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
pip install synapcores
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Quick Start
|
|
131
|
+
|
|
132
|
+
```python
|
|
133
|
+
from synapcores import SynapCores
|
|
134
|
+
|
|
135
|
+
# Initialize client with API key authentication
|
|
136
|
+
# API keys can be created from your AIDB dashboard at Settings > API Keys
|
|
137
|
+
# Note: API keys must start with 'aidb_' prefix
|
|
138
|
+
client = SynapCores(
|
|
139
|
+
host="localhost",
|
|
140
|
+
port=8080,
|
|
141
|
+
api_key="aidb_sk_your_api_key_here" # Replace with your actual API key
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
# Create a collection
|
|
145
|
+
collection = client.create_collection(
|
|
146
|
+
name="products",
|
|
147
|
+
schema={
|
|
148
|
+
"name": "string",
|
|
149
|
+
"description": "string",
|
|
150
|
+
"price": "float",
|
|
151
|
+
"embedding": "vector[384]"
|
|
152
|
+
}
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
# Insert documents
|
|
156
|
+
collection.insert([
|
|
157
|
+
{
|
|
158
|
+
"name": "Laptop",
|
|
159
|
+
"description": "High-performance laptop for developers",
|
|
160
|
+
"price": 1299.99
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"name": "Mouse",
|
|
164
|
+
"description": "Ergonomic wireless mouse",
|
|
165
|
+
"price": 49.99
|
|
166
|
+
}
|
|
167
|
+
])
|
|
168
|
+
|
|
169
|
+
# Semantic search
|
|
170
|
+
results = collection.search(
|
|
171
|
+
query="computer accessories",
|
|
172
|
+
top_k=5
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
# SQL with AI extensions
|
|
176
|
+
df = client.sql("""
|
|
177
|
+
SELECT name, price,
|
|
178
|
+
similarity(embedding, embed('perfect for coding')) as relevance
|
|
179
|
+
FROM products
|
|
180
|
+
WHERE price < 1500
|
|
181
|
+
ORDER BY relevance DESC
|
|
182
|
+
LIMIT 10
|
|
183
|
+
""")
|
|
184
|
+
|
|
185
|
+
# Real-time subscriptions
|
|
186
|
+
async def handle_update(change):
|
|
187
|
+
print(f"Document {change.op}: {change.document}")
|
|
188
|
+
|
|
189
|
+
subscription = await collection.subscribe(
|
|
190
|
+
filter={"price": {"$lt": 100}},
|
|
191
|
+
on_change=handle_update
|
|
192
|
+
)
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## Advanced Features
|
|
196
|
+
|
|
197
|
+
### Vector Operations
|
|
198
|
+
|
|
199
|
+
```python
|
|
200
|
+
# Generate embeddings
|
|
201
|
+
embedding = client.embed("High-quality mechanical keyboard")
|
|
202
|
+
|
|
203
|
+
# Vector similarity search
|
|
204
|
+
similar_products = collection.vector_search(
|
|
205
|
+
vector=embedding,
|
|
206
|
+
top_k=10,
|
|
207
|
+
filter={"price": {"$between": [50, 200]}}
|
|
208
|
+
)
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### AutoML
|
|
212
|
+
|
|
213
|
+
```python
|
|
214
|
+
# Train a model
|
|
215
|
+
model = client.automl.train(
|
|
216
|
+
collection="sales_data",
|
|
217
|
+
target="revenue",
|
|
218
|
+
features=["product_category", "season", "price"],
|
|
219
|
+
task="regression"
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
# Make predictions
|
|
223
|
+
predictions = model.predict({
|
|
224
|
+
"product_category": "electronics",
|
|
225
|
+
"season": "holiday",
|
|
226
|
+
"price": 299.99
|
|
227
|
+
})
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### NLP Analysis
|
|
231
|
+
|
|
232
|
+
```python
|
|
233
|
+
# Analyze text
|
|
234
|
+
analysis = client.nlp.analyze(
|
|
235
|
+
text="This product exceeded my expectations. Highly recommend!",
|
|
236
|
+
tasks=["sentiment", "entities", "summary"]
|
|
237
|
+
)
|
|
238
|
+
|
|
239
|
+
print(f"Sentiment: {analysis.sentiment.label} ({analysis.sentiment.score})")
|
|
240
|
+
print(f"Entities: {[e.text for e in analysis.entities]}")
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## Documentation
|
|
244
|
+
|
|
245
|
+
For detailed documentation, visit [https://synapcores.com/developers](https://synapcores.com/developers)
|
|
246
|
+
|
|
247
|
+
## License
|
|
248
|
+
|
|
249
|
+
MIT License - see LICENSE file for details.
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
# SynapCores Python SDK
|
|
2
|
+
|
|
3
|
+
Official Python SDK for SynapCores - The AI-Native Database Management System.
|
|
4
|
+
|
|
5
|
+
> **0.2.0 — gateway v1.5.0-ce alignment.** This release rewires every
|
|
6
|
+
> module against the v1.5.0-ce route surface. AutoML moved from `/ai/*`
|
|
7
|
+
> to `/automl/*`, vector ops collapsed onto `/vector-algebra/operation`,
|
|
8
|
+
> WebSocket auth now uses ticket exchange, API keys are sent via the
|
|
9
|
+
> `X-API-Key` header (and accept the new `ak_*` prefix in addition to
|
|
10
|
+
> the legacy `aidb_*`), and we ship new top-level modules: `graph`,
|
|
11
|
+
> `nl2sql`, `filesystem`, `chat`, `multimodal`, `system`,
|
|
12
|
+
> `transactions`, `mcp`, `recipes`, and `schema`.
|
|
13
|
+
|
|
14
|
+
## What's new in 0.2.0
|
|
15
|
+
|
|
16
|
+
```python
|
|
17
|
+
from synapcores import SynapCores
|
|
18
|
+
|
|
19
|
+
client = SynapCores(host="localhost", port=8080, api_key="ak_prod_xxx...")
|
|
20
|
+
|
|
21
|
+
# 1. Cypher-style graph traversal
|
|
22
|
+
friends = client.graph.cypher(
|
|
23
|
+
"MATCH (u:User {id:$id})-[:FRIEND]->(f) RETURN f",
|
|
24
|
+
{"id": "u-123"},
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
# 2. Natural language → SQL (with optional execution)
|
|
28
|
+
ans = client.nl2sql.ask(
|
|
29
|
+
"top 10 customers by revenue this quarter",
|
|
30
|
+
execute=True,
|
|
31
|
+
)
|
|
32
|
+
print(ans["sql"], ans.get("rows"))
|
|
33
|
+
|
|
34
|
+
# 3. AI chat sessions with streaming
|
|
35
|
+
session = client.chat.sessions.create(model="gpt-4o")
|
|
36
|
+
for chunk in client.chat.stream(session["id"], "Summarize today's alerts"):
|
|
37
|
+
if chunk.get("delta"):
|
|
38
|
+
print(chunk["delta"], end="", flush=True)
|
|
39
|
+
|
|
40
|
+
# 4. Filesystem-backed RAG collections with progress
|
|
41
|
+
fs = client.filesystem.collections.create(name="docs", path="/data/docs", watch=True)
|
|
42
|
+
for evt in client.filesystem.collections.subscribe_progress(fs["id"]):
|
|
43
|
+
print(evt.get("status"), evt.get("progress"), evt.get("filename"))
|
|
44
|
+
|
|
45
|
+
# 5. Server-side transactions with savepoints
|
|
46
|
+
with client.transactions.begin(isolation_level="SERIALIZABLE") as tx:
|
|
47
|
+
tx.execute("UPDATE accounts SET balance = balance - $1 WHERE id = $2", [100, "a"])
|
|
48
|
+
tx.savepoint("mid")
|
|
49
|
+
tx.execute("UPDATE accounts SET balance = balance + $1 WHERE id = $2", [100, "b"])
|
|
50
|
+
# commit() runs implicitly on clean exit; rollback() on exception.
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Other new surfaces:
|
|
54
|
+
|
|
55
|
+
- `client.multimodal.{similarity,search,join,embed}` for cross-modal retrieval.
|
|
56
|
+
- `client.system.vision.{get,set,delete,test}` for the admin vision config.
|
|
57
|
+
- `client.mcp.{invoke,batch,info}` for the Model Context Protocol gateway.
|
|
58
|
+
- `client.recipes.list_categories()/list_templates()/execute_template()/list_executions()`.
|
|
59
|
+
- `client.schema.list_databases()/preview_table()`.
|
|
60
|
+
|
|
61
|
+
### Breaking changes vs 0.1.0
|
|
62
|
+
|
|
63
|
+
- `embed()` routes to `/ai/embeddings` (single) or `/ai/embeddings/batch`.
|
|
64
|
+
- `automl.*` paths moved from `/ai/*` to `/automl/*`.
|
|
65
|
+
- All vector math goes through `POST /vector-algebra/operation` with an `op` discriminator.
|
|
66
|
+
- KNN/range/hybrid search routes to `/vectors/collections/:name/search` with a `mode` field.
|
|
67
|
+
- API keys are sent as the `X-API-Key` header (was previously `Authorization: Bearer`).
|
|
68
|
+
- WebSocket subscriptions now use ticket exchange via `POST /v1/ws/ticket` and connect to `/ws?token=...`.
|
|
69
|
+
- `nlp.analyze()` is implemented client-side as parallel calls to `/ai/sentiment`, `/ai/entities`, and `/ai/summarize` since `/ai/analyze` was removed.
|
|
70
|
+
- The `client.sql(query, params=...)` payload now matches `POST /v1/query/execute` (positional `parameters`); `params` is still accepted as a dict for backwards compatibility.
|
|
71
|
+
|
|
72
|
+
## Features
|
|
73
|
+
|
|
74
|
+
- **AI-Native Operations**: Built-in support for embeddings, vector search, and semantic analysis
|
|
75
|
+
- **Document & Vector Storage**: Seamlessly work with both structured and unstructured data
|
|
76
|
+
- **SQL with AI Extensions**: Use familiar SQL syntax enhanced with AI operations
|
|
77
|
+
- **Real-time Subscriptions**: WebSocket support for live data updates
|
|
78
|
+
- **AutoML Integration**: Automated machine learning model training and deployment
|
|
79
|
+
- **Type-Safe**: Full type hints and Pydantic models for better IDE support
|
|
80
|
+
|
|
81
|
+
## Installation
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
pip install synapcores
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Quick Start
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
from synapcores import SynapCores
|
|
91
|
+
|
|
92
|
+
# Initialize client with API key authentication
|
|
93
|
+
# API keys can be created from your AIDB dashboard at Settings > API Keys
|
|
94
|
+
# Note: API keys must start with 'aidb_' prefix
|
|
95
|
+
client = SynapCores(
|
|
96
|
+
host="localhost",
|
|
97
|
+
port=8080,
|
|
98
|
+
api_key="aidb_sk_your_api_key_here" # Replace with your actual API key
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
# Create a collection
|
|
102
|
+
collection = client.create_collection(
|
|
103
|
+
name="products",
|
|
104
|
+
schema={
|
|
105
|
+
"name": "string",
|
|
106
|
+
"description": "string",
|
|
107
|
+
"price": "float",
|
|
108
|
+
"embedding": "vector[384]"
|
|
109
|
+
}
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
# Insert documents
|
|
113
|
+
collection.insert([
|
|
114
|
+
{
|
|
115
|
+
"name": "Laptop",
|
|
116
|
+
"description": "High-performance laptop for developers",
|
|
117
|
+
"price": 1299.99
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"name": "Mouse",
|
|
121
|
+
"description": "Ergonomic wireless mouse",
|
|
122
|
+
"price": 49.99
|
|
123
|
+
}
|
|
124
|
+
])
|
|
125
|
+
|
|
126
|
+
# Semantic search
|
|
127
|
+
results = collection.search(
|
|
128
|
+
query="computer accessories",
|
|
129
|
+
top_k=5
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
# SQL with AI extensions
|
|
133
|
+
df = client.sql("""
|
|
134
|
+
SELECT name, price,
|
|
135
|
+
similarity(embedding, embed('perfect for coding')) as relevance
|
|
136
|
+
FROM products
|
|
137
|
+
WHERE price < 1500
|
|
138
|
+
ORDER BY relevance DESC
|
|
139
|
+
LIMIT 10
|
|
140
|
+
""")
|
|
141
|
+
|
|
142
|
+
# Real-time subscriptions
|
|
143
|
+
async def handle_update(change):
|
|
144
|
+
print(f"Document {change.op}: {change.document}")
|
|
145
|
+
|
|
146
|
+
subscription = await collection.subscribe(
|
|
147
|
+
filter={"price": {"$lt": 100}},
|
|
148
|
+
on_change=handle_update
|
|
149
|
+
)
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Advanced Features
|
|
153
|
+
|
|
154
|
+
### Vector Operations
|
|
155
|
+
|
|
156
|
+
```python
|
|
157
|
+
# Generate embeddings
|
|
158
|
+
embedding = client.embed("High-quality mechanical keyboard")
|
|
159
|
+
|
|
160
|
+
# Vector similarity search
|
|
161
|
+
similar_products = collection.vector_search(
|
|
162
|
+
vector=embedding,
|
|
163
|
+
top_k=10,
|
|
164
|
+
filter={"price": {"$between": [50, 200]}}
|
|
165
|
+
)
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### AutoML
|
|
169
|
+
|
|
170
|
+
```python
|
|
171
|
+
# Train a model
|
|
172
|
+
model = client.automl.train(
|
|
173
|
+
collection="sales_data",
|
|
174
|
+
target="revenue",
|
|
175
|
+
features=["product_category", "season", "price"],
|
|
176
|
+
task="regression"
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
# Make predictions
|
|
180
|
+
predictions = model.predict({
|
|
181
|
+
"product_category": "electronics",
|
|
182
|
+
"season": "holiday",
|
|
183
|
+
"price": 299.99
|
|
184
|
+
})
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### NLP Analysis
|
|
188
|
+
|
|
189
|
+
```python
|
|
190
|
+
# Analyze text
|
|
191
|
+
analysis = client.nlp.analyze(
|
|
192
|
+
text="This product exceeded my expectations. Highly recommend!",
|
|
193
|
+
tasks=["sentiment", "entities", "summary"]
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
print(f"Sentiment: {analysis.sentiment.label} ({analysis.sentiment.score})")
|
|
197
|
+
print(f"Entities: {[e.text for e in analysis.entities]}")
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## Documentation
|
|
201
|
+
|
|
202
|
+
For detailed documentation, visit [https://synapcores.com/developers](https://synapcores.com/developers)
|
|
203
|
+
|
|
204
|
+
## License
|
|
205
|
+
|
|
206
|
+
MIT License - see LICENSE file for details.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=45", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "synapcores"
|
|
7
|
+
version = "0.2.0"
|
|
8
|
+
description = "Official Python SDK for SynapCores AI-Native Database"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.8"
|
|
11
|
+
license = {text = "MIT"}
|
|
12
|
+
authors = [{name = "SynapCores", email = "release@synapcores.com"}]
|
|
13
|
+
maintainers = [{name = "SynapCores", email = "release@synapcores.com"}]
|
|
14
|
+
keywords = ["database", "ai", "ml", "vector", "embedding", "semantic"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 3 - Alpha",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"Topic :: Database",
|
|
19
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
20
|
+
"License :: OSI Approved :: MIT License",
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"Programming Language :: Python :: 3.8",
|
|
23
|
+
"Programming Language :: Python :: 3.9",
|
|
24
|
+
"Programming Language :: Python :: 3.10",
|
|
25
|
+
"Programming Language :: Python :: 3.11",
|
|
26
|
+
"Programming Language :: Python :: 3.12",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
dependencies = [
|
|
30
|
+
"httpx>=0.24.0",
|
|
31
|
+
"pydantic>=2.0.0",
|
|
32
|
+
"numpy>=1.21.0",
|
|
33
|
+
"pandas>=1.3.0",
|
|
34
|
+
"python-dateutil>=2.8.0",
|
|
35
|
+
"websockets>=11.0",
|
|
36
|
+
"typing-extensions>=4.0.0",
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
[project.optional-dependencies]
|
|
40
|
+
dev = [
|
|
41
|
+
"pytest>=7.0.0",
|
|
42
|
+
"pytest-asyncio>=0.21.0",
|
|
43
|
+
"pytest-cov>=4.0.0",
|
|
44
|
+
"black>=23.0.0",
|
|
45
|
+
"flake8>=6.0.0",
|
|
46
|
+
"mypy>=1.0.0",
|
|
47
|
+
"sphinx>=6.0.0",
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
[project.urls]
|
|
51
|
+
Homepage = "https://synapcores.com"
|
|
52
|
+
Documentation = "https://synapcores.com/developers"
|
|
53
|
+
Source = "https://github.com/SynapCores/synapcores-releases"
|
|
54
|
+
Issues = "https://github.com/SynapCores/synapcores-releases/issues"
|
|
55
|
+
|
|
56
|
+
[tool.black]
|
|
57
|
+
line-length = 88
|
|
58
|
+
target-version = ['py38', 'py39', 'py310', 'py311', 'py312']
|
|
59
|
+
|
|
60
|
+
[tool.mypy]
|
|
61
|
+
python_version = "3.8"
|
|
62
|
+
warn_return_any = true
|
|
63
|
+
warn_unused_configs = true
|
|
64
|
+
disallow_untyped_defs = true
|
|
65
|
+
|
|
66
|
+
[tool.pytest.ini_options]
|
|
67
|
+
testpaths = ["tests"]
|
|
68
|
+
python_files = ["test_*.py", "*_test.py"]
|
|
69
|
+
addopts = "--strict-markers --cov=synapcores"
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# All packaging metadata lives in pyproject.toml (PEP 621). This file
|
|
2
|
+
# remains only as a compatibility shim for legacy tooling that still
|
|
3
|
+
# invokes `python setup.py …` directly. It must not duplicate fields
|
|
4
|
+
# from pyproject.toml — duplicates cause stale `Author:` /
|
|
5
|
+
# `Home-page:` lines to leak into the wheel METADATA.
|
|
6
|
+
from setuptools import setup
|
|
7
|
+
|
|
8
|
+
setup()
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"""
|
|
2
|
+
SynapCores Python SDK
|
|
3
|
+
|
|
4
|
+
Official Python SDK for SynapCores AI-Native Database Management System.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from .client import SynapCores
|
|
8
|
+
from .collection import Collection
|
|
9
|
+
from .exceptions import (
|
|
10
|
+
SynapCoresError,
|
|
11
|
+
ConnectionError,
|
|
12
|
+
AuthenticationError,
|
|
13
|
+
ValidationError,
|
|
14
|
+
NotFoundError,
|
|
15
|
+
ServerError,
|
|
16
|
+
TimeoutError,
|
|
17
|
+
RateLimitError,
|
|
18
|
+
SQLError,
|
|
19
|
+
VectorError,
|
|
20
|
+
TransactionError,
|
|
21
|
+
BatchOperationError,
|
|
22
|
+
IndexError,
|
|
23
|
+
ConstraintError,
|
|
24
|
+
PreparedStatementError,
|
|
25
|
+
)
|
|
26
|
+
from .models import (
|
|
27
|
+
Document,
|
|
28
|
+
QueryResult,
|
|
29
|
+
SearchResult,
|
|
30
|
+
Schema,
|
|
31
|
+
FieldType,
|
|
32
|
+
VectorSearchParams,
|
|
33
|
+
SubscriptionEvent,
|
|
34
|
+
# SQL Operation Models
|
|
35
|
+
ColumnDefinition,
|
|
36
|
+
CreateTableOptions,
|
|
37
|
+
AlterTableOptions,
|
|
38
|
+
IndexDefinition,
|
|
39
|
+
TableInfo,
|
|
40
|
+
TransactionOptions,
|
|
41
|
+
TransactionContext,
|
|
42
|
+
BatchInsertOptions,
|
|
43
|
+
BatchUpdateOptions,
|
|
44
|
+
BatchDeleteOptions,
|
|
45
|
+
BatchResult,
|
|
46
|
+
PreparedStatement,
|
|
47
|
+
CTEDefinition,
|
|
48
|
+
WindowFunction,
|
|
49
|
+
# Vector Operation Models
|
|
50
|
+
Vector,
|
|
51
|
+
VectorArithmeticResult,
|
|
52
|
+
VectorSimilarityResult,
|
|
53
|
+
VectorMagnitudeResult,
|
|
54
|
+
VectorSearchResult,
|
|
55
|
+
KNNSearchOptions,
|
|
56
|
+
RangeSearchOptions,
|
|
57
|
+
HybridSearchOptions,
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
# v0.2.0 modules
|
|
61
|
+
from .graph import GraphClient
|
|
62
|
+
from .nl2sql import NL2SqlClient
|
|
63
|
+
from .filesystem import FilesystemCollectionsClient
|
|
64
|
+
from .chat import ChatClient
|
|
65
|
+
from .multimodal import MultimodalClient
|
|
66
|
+
from .system import SystemClient
|
|
67
|
+
from .transactions import TransactionsClient, Tx
|
|
68
|
+
from .mcp import McpClient
|
|
69
|
+
from .recipes import RecipeClient
|
|
70
|
+
from .schema import SchemaClient
|
|
71
|
+
|
|
72
|
+
__version__ = "0.2.0"
|
|
73
|
+
__all__ = [
|
|
74
|
+
# Core Classes
|
|
75
|
+
"SynapCores",
|
|
76
|
+
"Collection",
|
|
77
|
+
|
|
78
|
+
# v0.2.0 sub-clients
|
|
79
|
+
"GraphClient",
|
|
80
|
+
"NL2SqlClient",
|
|
81
|
+
"FilesystemCollectionsClient",
|
|
82
|
+
"ChatClient",
|
|
83
|
+
"MultimodalClient",
|
|
84
|
+
"SystemClient",
|
|
85
|
+
"TransactionsClient",
|
|
86
|
+
"Tx",
|
|
87
|
+
"McpClient",
|
|
88
|
+
"RecipeClient",
|
|
89
|
+
"SchemaClient",
|
|
90
|
+
|
|
91
|
+
# Models
|
|
92
|
+
"Document",
|
|
93
|
+
"QueryResult",
|
|
94
|
+
"SearchResult",
|
|
95
|
+
"Schema",
|
|
96
|
+
"FieldType",
|
|
97
|
+
"VectorSearchParams",
|
|
98
|
+
"SubscriptionEvent",
|
|
99
|
+
|
|
100
|
+
# SQL Operation Models
|
|
101
|
+
"ColumnDefinition",
|
|
102
|
+
"CreateTableOptions",
|
|
103
|
+
"AlterTableOptions",
|
|
104
|
+
"IndexDefinition",
|
|
105
|
+
"TableInfo",
|
|
106
|
+
"TransactionOptions",
|
|
107
|
+
"TransactionContext",
|
|
108
|
+
"BatchInsertOptions",
|
|
109
|
+
"BatchUpdateOptions",
|
|
110
|
+
"BatchDeleteOptions",
|
|
111
|
+
"BatchResult",
|
|
112
|
+
"PreparedStatement",
|
|
113
|
+
"CTEDefinition",
|
|
114
|
+
"WindowFunction",
|
|
115
|
+
|
|
116
|
+
# Vector Operation Models
|
|
117
|
+
"Vector",
|
|
118
|
+
"VectorArithmeticResult",
|
|
119
|
+
"VectorSimilarityResult",
|
|
120
|
+
"VectorMagnitudeResult",
|
|
121
|
+
"VectorSearchResult",
|
|
122
|
+
"KNNSearchOptions",
|
|
123
|
+
"RangeSearchOptions",
|
|
124
|
+
"HybridSearchOptions",
|
|
125
|
+
|
|
126
|
+
# Exceptions
|
|
127
|
+
"SynapCoresError",
|
|
128
|
+
"ConnectionError",
|
|
129
|
+
"AuthenticationError",
|
|
130
|
+
"ValidationError",
|
|
131
|
+
"NotFoundError",
|
|
132
|
+
"ServerError",
|
|
133
|
+
"TimeoutError",
|
|
134
|
+
"RateLimitError",
|
|
135
|
+
"SQLError",
|
|
136
|
+
"VectorError",
|
|
137
|
+
"TransactionError",
|
|
138
|
+
"BatchOperationError",
|
|
139
|
+
"IndexError",
|
|
140
|
+
"ConstraintError",
|
|
141
|
+
"PreparedStatementError",
|
|
142
|
+
]
|