morphik 0.1.2__py3-none-any.whl → 0.1.4__py3-none-any.whl
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.
- morphik/__init__.py +1 -1
- morphik/_internal.py +1 -1
- morphik/async_.py +210 -23
- morphik/models.py +70 -0
- morphik/sync.py +212 -18
- morphik/tests/README.md +41 -0
- morphik/tests/__init__.py +0 -0
- morphik/tests/example_usage.py +280 -0
- morphik/tests/test_async.py +300 -0
- morphik/tests/test_docs/sample1.txt +11 -0
- morphik/tests/test_docs/sample2.txt +15 -0
- morphik/tests/test_docs/sample3.txt +17 -0
- morphik/tests/test_sync.py +293 -0
- morphik-0.1.4.dist-info/METADATA +153 -0
- morphik-0.1.4.dist-info/RECORD +18 -0
- morphik-0.1.2.dist-info/METADATA +0 -47
- morphik-0.1.2.dist-info/RECORD +0 -10
- {morphik-0.1.2.dist-info → morphik-0.1.4.dist-info}/WHEEL +0 -0
@@ -0,0 +1,153 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: morphik
|
3
|
+
Version: 0.1.4
|
4
|
+
Summary: Morphik Python Client
|
5
|
+
Author-email: Morphik <founders@morphik.ai>
|
6
|
+
Requires-Python: >=3.8
|
7
|
+
Requires-Dist: httpx>=0.24.0
|
8
|
+
Requires-Dist: pillow==10.4.0
|
9
|
+
Requires-Dist: pydantic==2.10.3
|
10
|
+
Requires-Dist: pyjwt>=2.0.0
|
11
|
+
Requires-Dist: requests>=2.32.3
|
12
|
+
Description-Content-Type: text/markdown
|
13
|
+
|
14
|
+
# Morphik
|
15
|
+
|
16
|
+
A Python client for Morphik API that enables document ingestion, semantic search, and retrieval augmented generation capabilities.
|
17
|
+
|
18
|
+
## Installation
|
19
|
+
|
20
|
+
```bash
|
21
|
+
pip install morphik
|
22
|
+
```
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
The SDK provides both synchronous and asynchronous clients:
|
27
|
+
|
28
|
+
### Synchronous Usage
|
29
|
+
|
30
|
+
```python
|
31
|
+
from morphik import Morphik
|
32
|
+
|
33
|
+
# Initialize client - connects to localhost:8000 by default
|
34
|
+
db = Morphik()
|
35
|
+
|
36
|
+
# Or with authentication URI (for production)
|
37
|
+
# db = Morphik("morphik://owner_id:token@api.morphik.ai")
|
38
|
+
|
39
|
+
# Ingest a text document
|
40
|
+
doc = db.ingest_text(
|
41
|
+
content="Your document content",
|
42
|
+
metadata={"title": "Example Document"}
|
43
|
+
)
|
44
|
+
|
45
|
+
# Ingest a file
|
46
|
+
doc = db.ingest_file(
|
47
|
+
file="path/to/document.pdf",
|
48
|
+
metadata={"category": "reports"}
|
49
|
+
)
|
50
|
+
|
51
|
+
# Retrieve relevant chunks
|
52
|
+
chunks = db.retrieve_chunks(
|
53
|
+
query="Your search query",
|
54
|
+
filters={"category": "reports"}
|
55
|
+
)
|
56
|
+
|
57
|
+
# Query with RAG
|
58
|
+
response = db.query(
|
59
|
+
query="Summarize the key points in the document",
|
60
|
+
filters={"category": "reports"}
|
61
|
+
)
|
62
|
+
|
63
|
+
print(response.completion)
|
64
|
+
```
|
65
|
+
|
66
|
+
### Asynchronous Usage
|
67
|
+
|
68
|
+
```python
|
69
|
+
import asyncio
|
70
|
+
from morphik.async_ import AsyncMorphik
|
71
|
+
|
72
|
+
async def main():
|
73
|
+
# Initialize async client - connects to localhost:8000 by default
|
74
|
+
async with AsyncMorphik() as db:
|
75
|
+
|
76
|
+
# Or with authentication URI (for production)
|
77
|
+
# async with AsyncMorphik("morphik://owner_id:token@api.morphik.ai") as db:
|
78
|
+
# Ingest a text document
|
79
|
+
doc = await db.ingest_text(
|
80
|
+
content="Your document content",
|
81
|
+
metadata={"title": "Example Document"}
|
82
|
+
)
|
83
|
+
|
84
|
+
# Query with RAG
|
85
|
+
response = await db.query(
|
86
|
+
query="Summarize the key points in the document",
|
87
|
+
)
|
88
|
+
|
89
|
+
print(response.completion)
|
90
|
+
|
91
|
+
# Run the async function
|
92
|
+
asyncio.run(main())
|
93
|
+
```
|
94
|
+
|
95
|
+
## Features
|
96
|
+
|
97
|
+
- Document ingestion (text, files, directories)
|
98
|
+
- Semantic search and retrieval
|
99
|
+
- Retrieval-augmented generation (RAG)
|
100
|
+
- Knowledge graph creation and querying
|
101
|
+
- Multi-user and multi-folder scoping
|
102
|
+
- Metadata filtering
|
103
|
+
- Document management
|
104
|
+
|
105
|
+
## Development
|
106
|
+
|
107
|
+
### Running Tests
|
108
|
+
|
109
|
+
To run the tests, first install the development dependencies:
|
110
|
+
|
111
|
+
```bash
|
112
|
+
pip install -r test_requirements.txt
|
113
|
+
```
|
114
|
+
|
115
|
+
Then run the tests:
|
116
|
+
|
117
|
+
```bash
|
118
|
+
# Run all tests (requires a running Morphik server)
|
119
|
+
pytest morphik/tests/ -v
|
120
|
+
|
121
|
+
# Run specific test modules
|
122
|
+
pytest morphik/tests/test_sync.py -v
|
123
|
+
pytest morphik/tests/test_async.py -v
|
124
|
+
|
125
|
+
# Skip tests if you don't have a running server
|
126
|
+
SKIP_LIVE_TESTS=1 pytest morphik/tests/ -v
|
127
|
+
|
128
|
+
# Specify a custom server URL for tests
|
129
|
+
MORPHIK_TEST_URL=http://custom-server:8000 pytest morphik/tests/ -v
|
130
|
+
```
|
131
|
+
|
132
|
+
### Example Usage Script
|
133
|
+
|
134
|
+
The SDK comes with an example script that demonstrates basic usage:
|
135
|
+
|
136
|
+
```bash
|
137
|
+
# Run synchronous example
|
138
|
+
python -m morphik.tests.example_usage
|
139
|
+
|
140
|
+
# Run asynchronous example
|
141
|
+
python -m morphik.tests.example_usage --async
|
142
|
+
```
|
143
|
+
|
144
|
+
The example script demonstrates:
|
145
|
+
- Text and file ingestion
|
146
|
+
- Creating folders and user scopes
|
147
|
+
- Retrieving chunks and documents
|
148
|
+
- Generating completions using RAG
|
149
|
+
- Batch operations and cleanup
|
150
|
+
|
151
|
+
## License
|
152
|
+
|
153
|
+
[License information]
|
@@ -0,0 +1,18 @@
|
|
1
|
+
morphik/__init__.py,sha256=y1Jd9M39Nq0byZAHDc-SWPWIukNlbSiTgsJ3MYm91gk,242
|
2
|
+
morphik/_internal.py,sha256=-wa8Jgkzjf92QwFYPnTVCmZHghqK12qbZ-CH6Eif2UA,17796
|
3
|
+
morphik/async_.py,sha256=QR8kqm9ebAu67PUzKpiFhWSov7c7APyjEYmvlUh7QyI,87784
|
4
|
+
morphik/exceptions.py,sha256=v4XGmfq5B0KrZEF6M1ID8A50-45-SRAQZTrXGXM6n0Q,260
|
5
|
+
morphik/models.py,sha256=9Sd7FG48JeD7hueiV6U8BXH6bj7529J0Z1-hsuighaM,19271
|
6
|
+
morphik/rules.py,sha256=nAEYseCxjrpK5QELeBxYI9RD4A8-aNThQkWV0d-Owjs,1512
|
7
|
+
morphik/sync.py,sha256=HKyMAbwb8MAJ552FdAggAxOnXUe-QuvUGvLrk_3GMLQ,91480
|
8
|
+
morphik/tests/README.md,sha256=LTKIoErLpdtIK7zmJDFyoXemW9NlxxIK3aXi_pUpkD4,1068
|
9
|
+
morphik/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
10
|
+
morphik/tests/example_usage.py,sha256=0Rr38aS762aE6Hfd8Ip7_wOacsSto1P1Dj2nOjjaMqM,11841
|
11
|
+
morphik/tests/test_async.py,sha256=u7NcK-azW-aEVt2FaO7_EqwMy5PTAONhs3nblFD2RQk,10754
|
12
|
+
morphik/tests/test_sync.py,sha256=TuZiAvGtc4i5Gf08-awPgzCQWGcnVijeLOEJbggjqfc,10292
|
13
|
+
morphik/tests/test_docs/sample1.txt,sha256=FiY9e9-M5aPO2avvroy3patV1hWkeKBBKqYIK1tacSI,506
|
14
|
+
morphik/tests/test_docs/sample2.txt,sha256=icV2m6vKCWcVaAa5lgI2z30gzjii68p3MIvrgrpxY6g,686
|
15
|
+
morphik/tests/test_docs/sample3.txt,sha256=gFaiiu3xTBzwgQ3lWUK5Ir_AhnAzEee-IiX761us0fo,731
|
16
|
+
morphik-0.1.4.dist-info/METADATA,sha256=g6LEpKjurEqet4COcj4-e0JMFEnSz5meUo160vHYG4c,3431
|
17
|
+
morphik-0.1.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
18
|
+
morphik-0.1.4.dist-info/RECORD,,
|
morphik-0.1.2.dist-info/METADATA
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.4
|
2
|
-
Name: morphik
|
3
|
-
Version: 0.1.2
|
4
|
-
Summary: Morphik Python Client
|
5
|
-
Author-email: Morphik <founders@morphik.ai>
|
6
|
-
Requires-Python: >=3.8
|
7
|
-
Requires-Dist: httpx>=0.24.0
|
8
|
-
Requires-Dist: pillow==10.4.0
|
9
|
-
Requires-Dist: pydantic==2.10.3
|
10
|
-
Requires-Dist: pyjwt>=2.0.0
|
11
|
-
Requires-Dist: requests>=2.32.3
|
12
|
-
Description-Content-Type: text/markdown
|
13
|
-
|
14
|
-
# Morphik
|
15
|
-
|
16
|
-
A Python client for Morphik API that enables document ingestion and semantic search capabilities.
|
17
|
-
|
18
|
-
## Installation
|
19
|
-
|
20
|
-
```bash
|
21
|
-
pip install morphik
|
22
|
-
```
|
23
|
-
|
24
|
-
```python
|
25
|
-
from morphik import Morphik
|
26
|
-
|
27
|
-
# Initialize client
|
28
|
-
db = Morphik("your-api-key")
|
29
|
-
|
30
|
-
# Ingest a document
|
31
|
-
doc_id = await db.ingest_document(
|
32
|
-
content="Your document content",
|
33
|
-
metadata={"title": "Example Document"}
|
34
|
-
)
|
35
|
-
|
36
|
-
# Query documents
|
37
|
-
results = await db.query(
|
38
|
-
query="Your search query",
|
39
|
-
filters={"title": "Example Document"}
|
40
|
-
)
|
41
|
-
|
42
|
-
# Process results
|
43
|
-
for result in results:
|
44
|
-
print(f"Content: {result.content}")
|
45
|
-
print(f"Score: {result.score}")
|
46
|
-
print(f"Metadata: {result.metadata}")
|
47
|
-
```
|
morphik-0.1.2.dist-info/RECORD
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
morphik/__init__.py,sha256=bVz-wlRg0XBZ2W6BxddpB086XNrVOQ_XJ1BNLhlwuIk,242
|
2
|
-
morphik/_internal.py,sha256=lvQa4jdgZHGroBjgUL_fuyneqP1NpyDbqqwBLe85Wy8,17821
|
3
|
-
morphik/async_.py,sha256=0aqU7K7508LviiGPpxgRGhubG5noK7_5RUUoO2CvY9s,80738
|
4
|
-
morphik/exceptions.py,sha256=v4XGmfq5B0KrZEF6M1ID8A50-45-SRAQZTrXGXM6n0Q,260
|
5
|
-
morphik/models.py,sha256=uWhfLBlTAxAY9GGvpXu7T8rtqNBt6SpfplC5SFGiHZM,16388
|
6
|
-
morphik/rules.py,sha256=nAEYseCxjrpK5QELeBxYI9RD4A8-aNThQkWV0d-Owjs,1512
|
7
|
-
morphik/sync.py,sha256=P8CxdAokIAgj8AXfVC4jjgvgBL7l2os2Y9kiI_hmBek,84280
|
8
|
-
morphik-0.1.2.dist-info/METADATA,sha256=xzcAnM3CjbOvWM6CYt_ac0epzAkCrcCAXzbU-2QNA_Y,1010
|
9
|
-
morphik-0.1.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
10
|
-
morphik-0.1.2.dist-info/RECORD,,
|
File without changes
|