piyapi-memory 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.
- piyapi_memory-0.1.0/.gitignore +154 -0
- piyapi_memory-0.1.0/.hypothesis/constants/06e3365e02b2e166 +4 -0
- piyapi_memory-0.1.0/.hypothesis/constants/11a1a67f0f33ee09 +4 -0
- piyapi_memory-0.1.0/.hypothesis/constants/2b265d3187c08e49 +4 -0
- piyapi_memory-0.1.0/.hypothesis/constants/543182aa7a4ff3ae +4 -0
- piyapi_memory-0.1.0/.hypothesis/constants/5e5df5df602b1d1c +4 -0
- piyapi_memory-0.1.0/.hypothesis/constants/608097f1b41df816 +4 -0
- piyapi_memory-0.1.0/.hypothesis/constants/7358819e971e4257 +4 -0
- piyapi_memory-0.1.0/.hypothesis/constants/98729a9607e58626 +4 -0
- piyapi_memory-0.1.0/.hypothesis/constants/ba549cd877e142c6 +4 -0
- piyapi_memory-0.1.0/.hypothesis/constants/c0f58e0fe91c2515 +4 -0
- piyapi_memory-0.1.0/.hypothesis/examples/04e6b3400353b141/b7b150dbb9f9aecb +1 -0
- piyapi_memory-0.1.0/.hypothesis/examples/04e6b3400353b141/f3e38a16f9f9472c +1 -0
- piyapi_memory-0.1.0/.hypothesis/examples/04e6b3400353b141/f991af26f716516c +1 -0
- piyapi_memory-0.1.0/.hypothesis/examples/b7b150dbb9f9aecb/89682667928112e3 +1 -0
- piyapi_memory-0.1.0/.hypothesis/examples/f3e38a16f9f9472c/9977e7b16d417708 +1 -0
- piyapi_memory-0.1.0/.hypothesis/examples/f991af26f716516c/e4201915c9a55aa8 +1 -0
- piyapi_memory-0.1.0/.hypothesis/unicode_data/15.0.0/charmap.json.gz +0 -0
- piyapi_memory-0.1.0/.hypothesis/unicode_data/15.0.0/codec-utf-8.json.gz +0 -0
- piyapi_memory-0.1.0/LICENSE +21 -0
- piyapi_memory-0.1.0/PKG-INFO +275 -0
- piyapi_memory-0.1.0/README.md +235 -0
- piyapi_memory-0.1.0/pyproject.toml +78 -0
- piyapi_memory-0.1.0/src/piyapi_memory/__init__.py +63 -0
- piyapi_memory-0.1.0/src/piyapi_memory/async_client.py +472 -0
- piyapi_memory-0.1.0/src/piyapi_memory/client.py +556 -0
- piyapi_memory-0.1.0/src/piyapi_memory/exceptions.py +103 -0
- piyapi_memory-0.1.0/src/piyapi_memory/http_client.py +183 -0
- piyapi_memory-0.1.0/src/piyapi_memory/models.py +256 -0
- piyapi_memory-0.1.0/tests/__init__.py +1 -0
- piyapi_memory-0.1.0/tests/conftest.py +68 -0
- piyapi_memory-0.1.0/tests/test_exceptions.py +151 -0
- piyapi_memory-0.1.0/tests/test_models.py +276 -0
- piyapi_memory-0.1.0/tests/test_retry.py +207 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# Dependencies
|
|
2
|
+
node_modules/
|
|
3
|
+
npm-debug.log*
|
|
4
|
+
yarn-debug.log*
|
|
5
|
+
yarn-error.log*
|
|
6
|
+
pnpm-debug.log*
|
|
7
|
+
lerna-debug.log*
|
|
8
|
+
|
|
9
|
+
# Environment variables
|
|
10
|
+
.env
|
|
11
|
+
.env.*
|
|
12
|
+
!.env.example
|
|
13
|
+
!.env.production
|
|
14
|
+
.env.railway
|
|
15
|
+
.env.production.local
|
|
16
|
+
|
|
17
|
+
# Build output
|
|
18
|
+
dist/
|
|
19
|
+
build/
|
|
20
|
+
out/
|
|
21
|
+
*.tsbuildinfo
|
|
22
|
+
|
|
23
|
+
# Logs
|
|
24
|
+
logs/
|
|
25
|
+
*.log
|
|
26
|
+
npm-debug.log*
|
|
27
|
+
yarn-debug.log*
|
|
28
|
+
yarn-error.log*
|
|
29
|
+
lerna-debug.log*
|
|
30
|
+
pnpm-debug.log*
|
|
31
|
+
|
|
32
|
+
# Runtime data
|
|
33
|
+
pids/
|
|
34
|
+
*.pid
|
|
35
|
+
*.seed
|
|
36
|
+
*.pid.lock
|
|
37
|
+
|
|
38
|
+
# Coverage directory used by testing tools
|
|
39
|
+
coverage/
|
|
40
|
+
*.lcov
|
|
41
|
+
.nyc_output/
|
|
42
|
+
|
|
43
|
+
# IDEs and editors
|
|
44
|
+
.idea/
|
|
45
|
+
.vscode/
|
|
46
|
+
*.swp
|
|
47
|
+
*.swo
|
|
48
|
+
*~
|
|
49
|
+
.DS_Store
|
|
50
|
+
*.sublime-project
|
|
51
|
+
*.sublime-workspace
|
|
52
|
+
|
|
53
|
+
# Testing
|
|
54
|
+
.jest/
|
|
55
|
+
test-results/
|
|
56
|
+
junit.xml
|
|
57
|
+
|
|
58
|
+
# Load Testing
|
|
59
|
+
tests/load/results/*.json
|
|
60
|
+
tests/load/results/*.html
|
|
61
|
+
tests/load/reports/*.md
|
|
62
|
+
tests/load/reports/*.html
|
|
63
|
+
!tests/load/results/.gitkeep
|
|
64
|
+
!tests/load/reports/.gitkeep
|
|
65
|
+
|
|
66
|
+
# Temporary files
|
|
67
|
+
tmp/
|
|
68
|
+
temp/
|
|
69
|
+
*.tmp
|
|
70
|
+
|
|
71
|
+
# Database
|
|
72
|
+
*.db
|
|
73
|
+
*.sqlite
|
|
74
|
+
*.sqlite3
|
|
75
|
+
|
|
76
|
+
# Docker
|
|
77
|
+
docker-compose.override.yml
|
|
78
|
+
.dockerignore
|
|
79
|
+
|
|
80
|
+
# Secrets and keys
|
|
81
|
+
*.pem
|
|
82
|
+
*.key
|
|
83
|
+
*.cert
|
|
84
|
+
secrets/
|
|
85
|
+
.secrets/
|
|
86
|
+
|
|
87
|
+
# Backup files
|
|
88
|
+
*.backup
|
|
89
|
+
*.bak
|
|
90
|
+
*.old
|
|
91
|
+
|
|
92
|
+
# OS files
|
|
93
|
+
.DS_Store
|
|
94
|
+
Thumbs.db
|
|
95
|
+
Desktop.ini
|
|
96
|
+
|
|
97
|
+
# Package manager
|
|
98
|
+
yarn.lock
|
|
99
|
+
pnpm-lock.yaml
|
|
100
|
+
|
|
101
|
+
# TypeScript
|
|
102
|
+
*.tsbuildinfo
|
|
103
|
+
|
|
104
|
+
# Misc
|
|
105
|
+
.cache/
|
|
106
|
+
.parcel-cache/
|
|
107
|
+
.next/
|
|
108
|
+
.nuxt/
|
|
109
|
+
.vercel/
|
|
110
|
+
.netlify/
|
|
111
|
+
|
|
112
|
+
# Local development
|
|
113
|
+
.local/
|
|
114
|
+
local/
|
|
115
|
+
|
|
116
|
+
# Documentation build
|
|
117
|
+
docs/.vitepress/dist
|
|
118
|
+
docs/.vitepress/cache
|
|
119
|
+
|
|
120
|
+
# Sentry
|
|
121
|
+
.sentryclirc
|
|
122
|
+
|
|
123
|
+
# Terraform
|
|
124
|
+
*.tfstate
|
|
125
|
+
*.tfstate.backup
|
|
126
|
+
.terraform/
|
|
127
|
+
|
|
128
|
+
# Kubernetes
|
|
129
|
+
*.kubeconfig
|
|
130
|
+
|
|
131
|
+
# Monitoring
|
|
132
|
+
prometheus_data/
|
|
133
|
+
grafana_data/
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
# Production secrets (NEVER commit)
|
|
137
|
+
.env.production.railway
|
|
138
|
+
|
|
139
|
+
# Debug files
|
|
140
|
+
debug*.ts
|
|
141
|
+
debug*.log
|
|
142
|
+
debug_*.log
|
|
143
|
+
|
|
144
|
+
# Backup folders
|
|
145
|
+
node_modules_old/
|
|
146
|
+
*_old/
|
|
147
|
+
|
|
148
|
+
# Duplicate folders (from failed operations)
|
|
149
|
+
* 2/
|
|
150
|
+
* 3/
|
|
151
|
+
* 4/
|
|
152
|
+
* 5/
|
|
153
|
+
* 6/
|
|
154
|
+
.vercel
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
# file: /Users/piyushkumar/Desktop/project cloud/packages/python-sdk/src/piyapi_memory/async_client.py
|
|
2
|
+
# hypothesis_version: 6.148.5
|
|
3
|
+
|
|
4
|
+
[0.0, 0.7, 30.0, 200, 201, 202, 204, 400, 401, 404, 429, 500, '/', '/api/v1/graph', '/api/v1/graph/stats', '/api/v1/memories', 'Accept', 'AsyncPiyAPIClient', 'Authorization', 'Content-Type', 'DELETE', 'GET', 'Invalid request', 'PATCH', 'PIYAPI_API_KEY', 'PIYAPI_BASE_URL', 'POST', 'Rate limit exceeded', 'Request timed out', 'Resource not found', 'Retry-After', 'Server error', 'User-Agent', 'application/json', 'avgConnections', 'children', 'cursor', 'default', 'depth', 'direction', 'edges', 'errors', 'has_more', 'includeGhosts', 'limit', 'maxHops', 'memories', 'memory', 'memoryId', 'message', 'metadata', 'minWeight', 'namespace', 'namespaceBreakdown', 'nodes', 'parent', 'raw', 'relationshipType', 'relationships', 'results', 'rollback', 'score', 'total', 'totalEdges', 'totalNodes', 'totalVersions', 'version', 'versions']
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
# file: /Users/piyushkumar/Desktop/project cloud/packages/python-sdk/src/piyapi_memory/__init__.py
|
|
2
|
+
# hypothesis_version: 6.148.5
|
|
3
|
+
|
|
4
|
+
['0.1.0', 'AsyncPiyAPIClient', 'AuthenticationError', 'GraphEdge', 'GraphNode', 'GraphResponse', 'GraphStats', 'Memory', 'MemoryList', 'MemoryRelationships', 'NetworkError', 'NotFoundError', 'PiyAPIClient', 'PiyAPIError', 'RateLimitError', 'SearchResult', 'SearchResults', 'ServerError', 'ValidationError']
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
# file: /Users/piyushkumar/Desktop/project cloud/packages/python-sdk/src/piyapi_memory/models.py
|
|
2
|
+
# hypothesis_version: 6.148.5
|
|
3
|
+
|
|
4
|
+
[0.0, 0.7, 1.0, 100, 255, 10000, 100000, 'Associated memory ID', 'Average connections', 'Child memories', 'Connected memory ID', 'Cursor for next page', 'Custom metadata', 'Display label', 'Edge metadata', 'Edges per type', 'Filter by metadata', 'Full memory content', 'Ghost node flag', 'Graph edges', 'Graph metadata', 'Graph nodes', 'List of memories', 'List of versions', 'Memory ID', 'Memory content', 'Memory namespace', 'Metadata', 'Namespace', 'Namespaces', 'Nodes per namespace', 'Parent memory', 'Relationship type', 'Relationship weight', 'Relationships', 'Rollback details', 'Search query', 'Search results', 'Source memory ID', 'Target memory ID', 'The matched memory', 'The memory ID', 'The restored memory', 'The search query', 'The source memory', 'Total edges', 'Total memory nodes', 'Total nodes', 'Updated content', 'Updated metadata', 'Updated tags', 'Version record ID', 'Weight (0-1)', 'When created', 'default', 'incoming or outgoing', 'outgoing', 'semantic_similarity']
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
# file: /Users/piyushkumar/Desktop/project cloud/packages/python-sdk/src/piyapi_memory/http_client.py
|
|
2
|
+
# hypothesis_version: 6.148.5
|
|
3
|
+
|
|
4
|
+
[30.0, 200, 201, 202, 204, 400, 401, 404, 429, 500, '/', 'Accept', 'Authorization', 'Content-Type', 'DELETE', 'GET', 'HTTPClient', 'Invalid request', 'PATCH', 'PIYAPI_API_KEY', 'PIYAPI_BASE_URL', 'POST', 'PUT', 'Rate limit exceeded', 'Request timed out', 'Resource not found', 'Retry-After', 'Server error', 'T', 'User-Agent', 'application/json', 'errors', 'message', 'raw']
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
# file: /Users/piyushkumar/Desktop/project cloud/packages/python-sdk/src/piyapi_memory/async_client.py
|
|
2
|
+
# hypothesis_version: 6.148.5
|
|
3
|
+
|
|
4
|
+
[0.0, 0.7, 30.0, 200, 201, 202, 204, 400, 401, 404, 429, 500, '/', '/api/v1/graph', '/api/v1/graph/stats', '/api/v1/memories', 'Accept', 'AsyncPiyAPIClient', 'Authorization', 'Content-Type', 'DELETE', 'GET', 'Invalid request', 'PATCH', 'PIYAPI_API_KEY', 'PIYAPI_BASE_URL', 'POST', 'Rate limit exceeded', 'Request timed out', 'Resource not found', 'Retry-After', 'Server error', 'User-Agent', 'application/json', 'avgConnections', 'cursor', 'default', 'edges', 'errors', 'has_more', 'includeGhosts', 'limit', 'maxHops', 'memories', 'memory', 'memoryId', 'message', 'metadata', 'minWeight', 'namespace', 'namespaceBreakdown', 'nodes', 'raw', 'relationshipType', 'relationships', 'results', 'score', 'total', 'totalEdges', 'totalNodes']
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
# file: /Users/piyushkumar/Desktop/project cloud/packages/python-sdk/src/piyapi_memory/__init__.py
|
|
2
|
+
# hypothesis_version: 6.148.5
|
|
3
|
+
|
|
4
|
+
['0.1.0', 'AsyncPiyAPIClient', 'AuthenticationError', 'GraphEdge', 'GraphNode', 'GraphResponse', 'GraphStats', 'Memory', 'MemoryList', 'MemoryRelationships', 'MemoryVersion', 'NetworkError', 'NotFoundError', 'PiyAPIClient', 'PiyAPIError', 'RateLimitError', 'RollbackResult', 'SearchResult', 'SearchResults', 'ServerError', 'ValidationError', 'VersionHistory']
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
# file: /Users/piyushkumar/Desktop/project cloud/packages/python-sdk/src/piyapi_memory/models.py
|
|
2
|
+
# hypothesis_version: 6.148.5
|
|
3
|
+
|
|
4
|
+
[0.0, 0.7, 1.0, 100, 255, 10000, 100000, 'Associated memory ID', 'Average connections', 'Connected memory ID', 'Cursor for next page', 'Custom metadata', 'Display label', 'Edge metadata', 'Edges per type', 'Filter by metadata', 'Full memory content', 'Ghost node flag', 'Graph edges', 'Graph metadata', 'Graph nodes', 'List of memories', 'Memory ID', 'Memory content', 'Memory namespace', 'Metadata', 'Namespace', 'Namespaces', 'Nodes per namespace', 'Relationship type', 'Relationship weight', 'Relationships', 'Search query', 'Search results', 'Source memory ID', 'Target memory ID', 'The matched memory', 'The memory ID', 'The search query', 'Total edges', 'Total memory nodes', 'Total nodes', 'Updated content', 'Updated metadata', 'Updated tags', 'Weight (0-1)', 'When created', 'default', 'incoming or outgoing', 'outgoing', 'semantic_similarity']
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
# file: /Users/piyushkumar/Desktop/project cloud/packages/python-sdk/src/piyapi_memory/client.py
|
|
2
|
+
# hypothesis_version: 6.148.5
|
|
3
|
+
|
|
4
|
+
[0.0, 0.7, 30.0, '/api/v1/graph', '/api/v1/graph/stats', '/api/v1/memories', 'PiyAPIClient', 'avgConnections', 'cursor', 'default', 'edges', 'has_more', 'includeGhosts', 'limit', 'maxHops', 'memories', 'memory', 'memoryId', 'metadata', 'minWeight', 'namespace', 'namespaceBreakdown', 'nodes', 'relationshipType', 'relationships', 'results', 'score', 'total', 'totalEdges', 'totalNodes']
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
# file: /Users/piyushkumar/Desktop/project cloud/packages/python-sdk/src/piyapi_memory/client.py
|
|
2
|
+
# hypothesis_version: 6.148.5
|
|
3
|
+
|
|
4
|
+
[0.0, 0.7, 30.0, '/api/v1/graph', '/api/v1/graph/stats', '/api/v1/memories', 'PiyAPIClient', 'avgConnections', 'children', 'cursor', 'default', 'depth', 'direction', 'edges', 'has_more', 'includeGhosts', 'limit', 'maxHops', 'memories', 'memory', 'memoryId', 'metadata', 'minWeight', 'namespace', 'namespaceBreakdown', 'nodes', 'parent', 'relationshipType', 'relationships', 'results', 'rollback', 'score', 'total', 'totalEdges', 'totalNodes', 'totalVersions', 'version', 'versions']
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
m��%|���uoJ*�ˀ�O|҇i�!}�>��,+�<?��d��{��.secondary
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
m��%|���uoJ*�ˀ�O|҇i�!}�>��,+�<?��d��{��
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
����
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
A
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
A
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
A
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 PiyAPI
|
|
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,275 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: piyapi-memory
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Official Python SDK for PiyAPI Memory - AI-native memory and context management
|
|
5
|
+
Project-URL: Homepage, https://piyapi.cloud
|
|
6
|
+
Project-URL: Documentation, https://docs.piyapi.cloud
|
|
7
|
+
Project-URL: Repository, https://github.com/piyapi/piyapi-memory
|
|
8
|
+
Project-URL: Changelog, https://github.com/piyapi/piyapi-memory/blob/main/CHANGELOG.md
|
|
9
|
+
Author-email: PiyAPI Team <care.piyapi@outlook.com>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: ai,embeddings,langchain,llm,memory,semantic-search,vector-database
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
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 :: Scientific/Engineering :: Artificial Intelligence
|
|
24
|
+
Classifier: Typing :: Typed
|
|
25
|
+
Requires-Python: >=3.8
|
|
26
|
+
Requires-Dist: httpx>=0.24.0
|
|
27
|
+
Requires-Dist: pydantic>=2.0.0
|
|
28
|
+
Requires-Dist: tenacity>=8.0.0
|
|
29
|
+
Provides-Extra: async
|
|
30
|
+
Requires-Dist: httpx[http2]>=0.24.0; extra == 'async'
|
|
31
|
+
Provides-Extra: dev
|
|
32
|
+
Requires-Dist: hypothesis>=6.0.0; extra == 'dev'
|
|
33
|
+
Requires-Dist: mypy>=1.0.0; extra == 'dev'
|
|
34
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
|
|
35
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
|
|
36
|
+
Requires-Dist: pytest>=7.0.0; extra == 'dev'
|
|
37
|
+
Requires-Dist: respx>=0.20.0; extra == 'dev'
|
|
38
|
+
Requires-Dist: ruff>=0.1.0; extra == 'dev'
|
|
39
|
+
Description-Content-Type: text/markdown
|
|
40
|
+
|
|
41
|
+
# PiyAPI Memory Python SDK
|
|
42
|
+
|
|
43
|
+
Official Python SDK for [PiyAPI Memory](https://piyapi.cloud) - AI-native memory and context management for your applications.
|
|
44
|
+
|
|
45
|
+
## Installation
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip install piyapi-memory
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
For async support:
|
|
52
|
+
```bash
|
|
53
|
+
pip install piyapi-memory[async]
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Quick Start
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
from piyapi_memory import PiyAPIClient
|
|
60
|
+
|
|
61
|
+
# Initialize the client
|
|
62
|
+
client = PiyAPIClient(api_key="your-api-key")
|
|
63
|
+
|
|
64
|
+
# Create a memory
|
|
65
|
+
memory = client.create_memory(
|
|
66
|
+
content="The user prefers dark mode and uses Python primarily.",
|
|
67
|
+
metadata={"category": "preferences", "source": "onboarding"},
|
|
68
|
+
namespace="user-123"
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
# Search memories
|
|
72
|
+
results = client.semantic_search(
|
|
73
|
+
query="What are the user's preferences?",
|
|
74
|
+
namespace="user-123",
|
|
75
|
+
limit=5
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
for result in results:
|
|
79
|
+
print(f"Score: {result.score:.3f} - {result.content}")
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Async Usage
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
import asyncio
|
|
86
|
+
from piyapi_memory import AsyncPiyAPIClient
|
|
87
|
+
|
|
88
|
+
async def main():
|
|
89
|
+
client = AsyncPiyAPIClient(api_key="your-api-key")
|
|
90
|
+
|
|
91
|
+
# Create a memory
|
|
92
|
+
memory = await client.create_memory(
|
|
93
|
+
content="User completed the tutorial",
|
|
94
|
+
namespace="user-123"
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
# Search
|
|
98
|
+
results = await client.semantic_search(
|
|
99
|
+
query="tutorial progress",
|
|
100
|
+
namespace="user-123"
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
await client.close()
|
|
104
|
+
|
|
105
|
+
asyncio.run(main())
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Features
|
|
109
|
+
|
|
110
|
+
- **Memory CRUD**: Create, read, update, and delete memories
|
|
111
|
+
- **Semantic Search**: Find relevant memories using natural language
|
|
112
|
+
- **Keyword Search**: Traditional text-based search
|
|
113
|
+
- **Hybrid Search**: Combine semantic and keyword search
|
|
114
|
+
- **Namespaces**: Organize memories by user, project, or any grouping
|
|
115
|
+
- **Metadata Filtering**: Filter search results by metadata
|
|
116
|
+
- **Automatic Retry**: Built-in retry with exponential backoff for rate limits
|
|
117
|
+
- **Type Safety**: Full type hints and Pydantic models
|
|
118
|
+
|
|
119
|
+
## API Reference
|
|
120
|
+
|
|
121
|
+
### Client Initialization
|
|
122
|
+
|
|
123
|
+
```python
|
|
124
|
+
from piyapi_memory import PiyAPIClient
|
|
125
|
+
|
|
126
|
+
client = PiyAPIClient(
|
|
127
|
+
api_key="your-api-key",
|
|
128
|
+
base_url="https://api.piyapi.cloud", # Optional, defaults to production
|
|
129
|
+
timeout=30.0, # Request timeout in seconds
|
|
130
|
+
max_retries=3, # Max retries on rate limit
|
|
131
|
+
)
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Memory Operations
|
|
135
|
+
|
|
136
|
+
```python
|
|
137
|
+
# Create
|
|
138
|
+
memory = client.create_memory(
|
|
139
|
+
content="Memory content",
|
|
140
|
+
metadata={"key": "value"}, # Optional
|
|
141
|
+
namespace="default" # Optional
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
# Get
|
|
145
|
+
memory = client.get_memory(memory_id="mem_123")
|
|
146
|
+
|
|
147
|
+
# Update
|
|
148
|
+
memory = client.update_memory(
|
|
149
|
+
memory_id="mem_123",
|
|
150
|
+
content="Updated content",
|
|
151
|
+
metadata={"updated": True}
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
# Delete
|
|
155
|
+
client.delete_memory(memory_id="mem_123")
|
|
156
|
+
|
|
157
|
+
# List
|
|
158
|
+
memories = client.list_memories(
|
|
159
|
+
namespace="user-123",
|
|
160
|
+
limit=20,
|
|
161
|
+
cursor="cursor_token" # For pagination
|
|
162
|
+
)
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Search Operations
|
|
166
|
+
|
|
167
|
+
```python
|
|
168
|
+
# Semantic search
|
|
169
|
+
results = client.semantic_search(
|
|
170
|
+
query="natural language query",
|
|
171
|
+
namespace="user-123",
|
|
172
|
+
limit=10,
|
|
173
|
+
threshold=0.7, # Minimum similarity score
|
|
174
|
+
metadata_filter={"category": "preferences"}
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
# Keyword search
|
|
178
|
+
results = client.keyword_search(
|
|
179
|
+
query="exact keywords",
|
|
180
|
+
namespace="user-123",
|
|
181
|
+
limit=10
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
# Hybrid search (combines semantic + keyword)
|
|
185
|
+
results = client.hybrid_search(
|
|
186
|
+
query="search query",
|
|
187
|
+
namespace="user-123",
|
|
188
|
+
limit=10,
|
|
189
|
+
semantic_weight=0.7 # 0-1, weight for semantic vs keyword
|
|
190
|
+
)
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Memory Versioning
|
|
194
|
+
|
|
195
|
+
Track changes and rollback to previous versions:
|
|
196
|
+
|
|
197
|
+
```python
|
|
198
|
+
# Get version history
|
|
199
|
+
history = client.get_versions("mem_123", limit=10)
|
|
200
|
+
print(f"Total versions: {history['totalVersions']}")
|
|
201
|
+
for version in history["versions"]:
|
|
202
|
+
print(f"Version {version['version']}: {version['content'][:50]}...")
|
|
203
|
+
|
|
204
|
+
# Get specific version
|
|
205
|
+
version2 = client.get_version("mem_123", 2)
|
|
206
|
+
print(f"Version 2 content: {version2['version']['content']}")
|
|
207
|
+
|
|
208
|
+
# Rollback to previous version
|
|
209
|
+
result = client.rollback("mem_123", 2)
|
|
210
|
+
print(f"Rolled back to version {result['rollback']['restoredVersion']}")
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### Related Memories
|
|
214
|
+
|
|
215
|
+
Get parent-child memory relationships:
|
|
216
|
+
|
|
217
|
+
```python
|
|
218
|
+
# Get related memories
|
|
219
|
+
related = client.get_related("mem_123", direction="both", depth=2)
|
|
220
|
+
|
|
221
|
+
if related.get("parent"):
|
|
222
|
+
print(f"Parent: {related['parent']['content']}")
|
|
223
|
+
print(f"Children: {len(related['children'])}")
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## Error Handling
|
|
227
|
+
|
|
228
|
+
The SDK raises typed exceptions for different error conditions:
|
|
229
|
+
|
|
230
|
+
```python
|
|
231
|
+
from piyapi_memory import PiyAPIClient
|
|
232
|
+
from piyapi_memory.exceptions import (
|
|
233
|
+
AuthenticationError,
|
|
234
|
+
RateLimitError,
|
|
235
|
+
ValidationError,
|
|
236
|
+
NotFoundError,
|
|
237
|
+
ServerError,
|
|
238
|
+
)
|
|
239
|
+
|
|
240
|
+
client = PiyAPIClient(api_key="your-api-key")
|
|
241
|
+
|
|
242
|
+
try:
|
|
243
|
+
memory = client.create_memory(content="test")
|
|
244
|
+
except AuthenticationError:
|
|
245
|
+
print("Invalid API key")
|
|
246
|
+
except RateLimitError as e:
|
|
247
|
+
print(f"Rate limited. Retry after {e.retry_after} seconds")
|
|
248
|
+
except ValidationError as e:
|
|
249
|
+
print(f"Invalid request: {e.message}")
|
|
250
|
+
except NotFoundError:
|
|
251
|
+
print("Resource not found")
|
|
252
|
+
except ServerError:
|
|
253
|
+
print("Server error, please retry")
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
## Configuration
|
|
257
|
+
|
|
258
|
+
### Environment Variables
|
|
259
|
+
|
|
260
|
+
```bash
|
|
261
|
+
PIYAPI_API_KEY=your-api-key
|
|
262
|
+
PIYAPI_BASE_URL=https://api.piyapi.cloud # Optional
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
```python
|
|
266
|
+
import os
|
|
267
|
+
from piyapi_memory import PiyAPIClient
|
|
268
|
+
|
|
269
|
+
# Client will use PIYAPI_API_KEY from environment
|
|
270
|
+
client = PiyAPIClient()
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
## License
|
|
274
|
+
|
|
275
|
+
MIT License - see [LICENSE](LICENSE) for details.
|