morphik 0.1.6__py3-none-any.whl → 0.1.8__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 +10 -10
- morphik/async_.py +16 -4
- morphik/models.py +3 -3
- morphik/sync.py +20 -26
- morphik/tests/test_async.py +1 -2
- morphik/tests/test_sync.py +1 -2
- {morphik-0.1.6.dist-info → morphik-0.1.8.dist-info}/METADATA +3 -1
- morphik-0.1.8.dist-info/RECORD +18 -0
- morphik-0.1.6.dist-info/RECORD +0 -18
- {morphik-0.1.6.dist-info → morphik-0.1.8.dist-info}/WHEEL +0 -0
morphik/__init__.py
CHANGED
morphik/_internal.py
CHANGED
@@ -11,9 +11,9 @@ from PIL import Image
|
|
11
11
|
from PIL.Image import Image as PILImage
|
12
12
|
from pydantic import BaseModel, Field
|
13
13
|
|
14
|
+
from .models import ChunkSource # Prompt override models
|
14
15
|
from .models import (
|
15
16
|
ChunkResult,
|
16
|
-
ChunkSource, # Prompt override models
|
17
17
|
CompletionResponse,
|
18
18
|
Document,
|
19
19
|
DocumentResult,
|
@@ -357,6 +357,7 @@ class _MorphikClientLogic:
|
|
357
357
|
sources: List[Union[ChunkSource, Dict[str, Any]]],
|
358
358
|
folder_name: Optional[Union[str, List[str]]],
|
359
359
|
end_user_id: Optional[str],
|
360
|
+
use_colpali: bool = True,
|
360
361
|
) -> Dict[str, Any]:
|
361
362
|
"""Prepare request for batch_get_chunks endpoint"""
|
362
363
|
source_dicts = []
|
@@ -366,15 +367,14 @@ class _MorphikClientLogic:
|
|
366
367
|
else:
|
367
368
|
source_dicts.append(source.model_dump())
|
368
369
|
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
return {"sources": source_dicts}
|
370
|
+
# Always include use_colpali flag so the server can decide how to
|
371
|
+
# enrich chunks. Keep any additional scoping parameters.
|
372
|
+
request: Dict[str, Any] = {"sources": source_dicts, "use_colpali": use_colpali}
|
373
|
+
if folder_name:
|
374
|
+
request["folder_name"] = folder_name
|
375
|
+
if end_user_id:
|
376
|
+
request["end_user_id"] = end_user_id
|
377
|
+
return request
|
378
378
|
|
379
379
|
def _prepare_create_graph_request(
|
380
380
|
self,
|
morphik/async_.py
CHANGED
@@ -8,9 +8,9 @@ import httpx
|
|
8
8
|
from pydantic import BaseModel
|
9
9
|
|
10
10
|
from ._internal import FinalChunkResult, RuleOrDict, _MorphikClientLogic
|
11
|
+
from .models import CompletionResponse # Prompt override models
|
11
12
|
from .models import (
|
12
13
|
ChunkSource,
|
13
|
-
CompletionResponse, # Prompt override models
|
14
14
|
Document,
|
15
15
|
DocumentResult,
|
16
16
|
FolderInfo,
|
@@ -460,6 +460,7 @@ class AsyncFolder:
|
|
460
460
|
self,
|
461
461
|
sources: List[Union[ChunkSource, Dict[str, Any]]],
|
462
462
|
additional_folders: Optional[List[str]] = None,
|
463
|
+
use_colpali: bool = True,
|
463
464
|
) -> List[FinalChunkResult]:
|
464
465
|
"""
|
465
466
|
Retrieve specific chunks by their document ID and chunk number in a single batch operation within this folder.
|
@@ -467,12 +468,15 @@ class AsyncFolder:
|
|
467
468
|
Args:
|
468
469
|
sources: List of ChunkSource objects or dictionaries with document_id and chunk_number
|
469
470
|
additional_folders: Optional list of additional folder names to further scope operations
|
471
|
+
use_colpali: Whether to use ColPali-style embedding model
|
470
472
|
|
471
473
|
Returns:
|
472
474
|
List[FinalChunkResult]: List of chunk results
|
473
475
|
"""
|
474
476
|
merged = self._merge_folders(additional_folders)
|
475
|
-
request = self._client._logic._prepare_batch_get_chunks_request(
|
477
|
+
request = self._client._logic._prepare_batch_get_chunks_request(
|
478
|
+
sources, merged, None, use_colpali
|
479
|
+
)
|
476
480
|
response = await self._client._request("POST", "batch/chunks", data=request)
|
477
481
|
return self._client._logic._parse_chunk_result_list_response(response)
|
478
482
|
|
@@ -998,6 +1002,7 @@ class AsyncUserScope:
|
|
998
1002
|
self,
|
999
1003
|
sources: List[Union[ChunkSource, Dict[str, Any]]],
|
1000
1004
|
folder_name: Optional[Union[str, List[str]]] = None,
|
1005
|
+
use_colpali: bool = True,
|
1001
1006
|
) -> List[FinalChunkResult]:
|
1002
1007
|
"""
|
1003
1008
|
Retrieve specific chunks by their document ID and chunk number in a single batch operation for this end user.
|
@@ -1005,11 +1010,14 @@ class AsyncUserScope:
|
|
1005
1010
|
Args:
|
1006
1011
|
sources: List of ChunkSource objects or dictionaries with document_id and chunk_number
|
1007
1012
|
folder_name: Optional folder name (or list of names) to scope the request
|
1013
|
+
use_colpali: Whether to use ColPali-style embedding model
|
1008
1014
|
|
1009
1015
|
Returns:
|
1010
1016
|
List[FinalChunkResult]: List of chunk results
|
1011
1017
|
"""
|
1012
|
-
request = self._client._logic._prepare_batch_get_chunks_request(
|
1018
|
+
request = self._client._logic._prepare_batch_get_chunks_request(
|
1019
|
+
sources, self._folder_name, self._end_user_id, use_colpali
|
1020
|
+
)
|
1013
1021
|
response = await self._client._request("POST", "batch/chunks", data=request)
|
1014
1022
|
return self._client._logic._parse_chunk_result_list_response(response)
|
1015
1023
|
|
@@ -2184,6 +2192,7 @@ class AsyncMorphik:
|
|
2184
2192
|
self,
|
2185
2193
|
sources: List[Union[ChunkSource, Dict[str, Any]]],
|
2186
2194
|
folder_name: Optional[Union[str, List[str]]] = None,
|
2195
|
+
use_colpali: bool = True,
|
2187
2196
|
) -> List[FinalChunkResult]:
|
2188
2197
|
"""
|
2189
2198
|
Retrieve specific chunks by their document ID and chunk number in a single batch operation.
|
@@ -2191,6 +2200,7 @@ class AsyncMorphik:
|
|
2191
2200
|
Args:
|
2192
2201
|
sources: List of ChunkSource objects or dictionaries with document_id and chunk_number
|
2193
2202
|
folder_name: Optional folder name (or list of names) to scope the request
|
2203
|
+
use_colpali: Whether to use ColPali-style embedding model
|
2194
2204
|
|
2195
2205
|
Returns:
|
2196
2206
|
List[FinalChunkResult]: List of chunk results
|
@@ -2215,7 +2225,9 @@ class AsyncMorphik:
|
|
2215
2225
|
print(f"Chunk from {chunk.document_id}, number {chunk.chunk_number}: {chunk.content[:50]}...")
|
2216
2226
|
```
|
2217
2227
|
"""
|
2218
|
-
request = self._logic._prepare_batch_get_chunks_request(
|
2228
|
+
request = self._logic._prepare_batch_get_chunks_request(
|
2229
|
+
sources, folder_name, None, use_colpali
|
2230
|
+
)
|
2219
2231
|
response = await self._request("POST", "batch/chunks", data=request)
|
2220
2232
|
return self._logic._parse_chunk_result_list_response(response)
|
2221
2233
|
|
morphik/models.py
CHANGED
@@ -303,15 +303,15 @@ class Graph(BaseModel):
|
|
303
303
|
|
304
304
|
@property
|
305
305
|
def is_processing(self) -> bool:
|
306
|
-
return self.status == "processing"
|
306
|
+
return self.system_metadata.get("status") == "processing"
|
307
307
|
|
308
308
|
@property
|
309
309
|
def is_completed(self) -> bool:
|
310
|
-
return self.status == "completed"
|
310
|
+
return self.system_metadata.get("status") == "completed"
|
311
311
|
|
312
312
|
@property
|
313
313
|
def is_failed(self) -> bool:
|
314
|
-
return self.status == "failed"
|
314
|
+
return self.system_metadata.get("status") == "failed"
|
315
315
|
|
316
316
|
@property
|
317
317
|
def error(self) -> str | None:
|
morphik/sync.py
CHANGED
@@ -8,9 +8,9 @@ import httpx
|
|
8
8
|
from pydantic import BaseModel
|
9
9
|
|
10
10
|
from ._internal import FinalChunkResult, RuleOrDict, _MorphikClientLogic
|
11
|
+
from .models import CompletionResponse # Prompt override models
|
11
12
|
from .models import (
|
12
13
|
ChunkSource,
|
13
|
-
CompletionResponse, # Prompt override models
|
14
14
|
Document,
|
15
15
|
DocumentResult,
|
16
16
|
FolderInfo,
|
@@ -474,27 +474,23 @@ class Folder:
|
|
474
474
|
self,
|
475
475
|
sources: List[Union[ChunkSource, Dict[str, Any]]],
|
476
476
|
additional_folders: Optional[List[str]] = None,
|
477
|
+
use_colpali: bool = True,
|
477
478
|
) -> List[FinalChunkResult]:
|
478
479
|
"""
|
479
|
-
Retrieve specific chunks by their document ID and chunk number in
|
480
|
+
Retrieve specific chunks by their document ID and chunk number in this folder.
|
480
481
|
|
481
482
|
Args:
|
482
483
|
sources: List of ChunkSource objects or dictionaries with document_id and chunk_number
|
483
484
|
additional_folders: Optional list of extra folders to include in the scope
|
485
|
+
use_colpali: Whether to request multimodal chunks when available
|
484
486
|
|
485
487
|
Returns:
|
486
488
|
List[FinalChunkResult]: List of chunk results
|
487
489
|
"""
|
488
|
-
# Convert to list of dictionaries if needed
|
489
|
-
source_dicts = []
|
490
|
-
for source in sources:
|
491
|
-
if isinstance(source, dict):
|
492
|
-
source_dicts.append(source)
|
493
|
-
else:
|
494
|
-
source_dicts.append(source.model_dump())
|
495
|
-
|
496
490
|
merged = self._merge_folders(additional_folders)
|
497
|
-
request =
|
491
|
+
request = self._client._logic._prepare_batch_get_chunks_request(
|
492
|
+
sources, merged, None, use_colpali
|
493
|
+
)
|
498
494
|
|
499
495
|
response = self._client._request("POST", "batch/chunks", data=request)
|
500
496
|
return self._client._logic._parse_chunk_result_list_response(response)
|
@@ -1078,30 +1074,23 @@ class UserScope:
|
|
1078
1074
|
self,
|
1079
1075
|
sources: List[Union[ChunkSource, Dict[str, Any]]],
|
1080
1076
|
additional_folders: Optional[List[str]] = None,
|
1077
|
+
use_colpali: bool = True,
|
1081
1078
|
) -> List[FinalChunkResult]:
|
1082
1079
|
"""
|
1083
|
-
Retrieve specific chunks by their document ID and chunk number in
|
1080
|
+
Retrieve specific chunks by their document ID and chunk number in this folder.
|
1084
1081
|
|
1085
1082
|
Args:
|
1086
1083
|
sources: List of ChunkSource objects or dictionaries with document_id and chunk_number
|
1087
1084
|
additional_folders: Optional list of extra folders to include in the scope
|
1085
|
+
use_colpali: Whether to request multimodal chunks when available
|
1088
1086
|
|
1089
1087
|
Returns:
|
1090
1088
|
List[FinalChunkResult]: List of chunk results
|
1091
1089
|
"""
|
1092
|
-
# Convert to list of dictionaries if needed
|
1093
|
-
source_dicts = []
|
1094
|
-
for source in sources:
|
1095
|
-
if isinstance(source, dict):
|
1096
|
-
source_dicts.append(source)
|
1097
|
-
else:
|
1098
|
-
source_dicts.append(source.model_dump())
|
1099
|
-
|
1100
1090
|
merged = self._merge_folders(additional_folders)
|
1101
|
-
request =
|
1102
|
-
|
1103
|
-
|
1104
|
-
request["folder_name"] = merged
|
1091
|
+
request = self._client._logic._prepare_batch_get_chunks_request(
|
1092
|
+
sources, merged, None, use_colpali
|
1093
|
+
)
|
1105
1094
|
|
1106
1095
|
response = self._client._request("POST", "batch/chunks", data=request)
|
1107
1096
|
return self._client._logic._parse_chunk_result_list_response(response)
|
@@ -2344,7 +2333,10 @@ class Morphik:
|
|
2344
2333
|
return docs
|
2345
2334
|
|
2346
2335
|
def batch_get_chunks(
|
2347
|
-
self,
|
2336
|
+
self,
|
2337
|
+
sources: List[Union[ChunkSource, Dict[str, Any]]],
|
2338
|
+
folder_name: Optional[Union[str, List[str]]] = None,
|
2339
|
+
use_colpali: bool = True,
|
2348
2340
|
) -> List[FinalChunkResult]:
|
2349
2341
|
"""
|
2350
2342
|
Retrieve specific chunks by their document ID and chunk number.
|
@@ -2376,7 +2368,9 @@ class Morphik:
|
|
2376
2368
|
print(f"Chunk from {chunk.document_id}, number {chunk.chunk_number}: {chunk.content[:50]}...")
|
2377
2369
|
```
|
2378
2370
|
"""
|
2379
|
-
request = self._logic._prepare_batch_get_chunks_request(
|
2371
|
+
request = self._logic._prepare_batch_get_chunks_request(
|
2372
|
+
sources, folder_name, None, use_colpali
|
2373
|
+
)
|
2380
2374
|
response = self._request("POST", "batch/chunks", data=request)
|
2381
2375
|
return self._logic._parse_chunk_result_list_response(response)
|
2382
2376
|
|
morphik/tests/test_async.py
CHANGED
@@ -4,9 +4,8 @@ import uuid
|
|
4
4
|
from pathlib import Path
|
5
5
|
|
6
6
|
import pytest
|
7
|
-
from pydantic import BaseModel, Field
|
8
|
-
|
9
7
|
from morphik.async_ import AsyncMorphik
|
8
|
+
from pydantic import BaseModel, Field
|
10
9
|
|
11
10
|
# Set to your local Morphik server - use localhost by default
|
12
11
|
# Default client connects to localhost:8000 automatically
|
morphik/tests/test_sync.py
CHANGED
@@ -4,9 +4,8 @@ import uuid
|
|
4
4
|
from pathlib import Path
|
5
5
|
|
6
6
|
import pytest
|
7
|
-
from pydantic import BaseModel, Field
|
8
|
-
|
9
7
|
from morphik.sync import Morphik
|
8
|
+
from pydantic import BaseModel, Field
|
10
9
|
|
11
10
|
# Set to your local Morphik server - use localhost by default
|
12
11
|
# Default client connects to localhost:8000 automatically
|
@@ -1,14 +1,16 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: morphik
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.8
|
4
4
|
Summary: Morphik Python Client
|
5
5
|
Author-email: Morphik <founders@morphik.ai>
|
6
6
|
Requires-Python: >=3.8
|
7
|
+
Requires-Dist: build>=1.2.2.post1
|
7
8
|
Requires-Dist: httpx>=0.24.0
|
8
9
|
Requires-Dist: pillow==10.4.0
|
9
10
|
Requires-Dist: pydantic==2.10.3
|
10
11
|
Requires-Dist: pyjwt>=2.0.0
|
11
12
|
Requires-Dist: requests>=2.32.3
|
13
|
+
Requires-Dist: twine>=6.1.0
|
12
14
|
Description-Content-Type: text/markdown
|
13
15
|
|
14
16
|
# Morphik
|
@@ -0,0 +1,18 @@
|
|
1
|
+
morphik/__init__.py,sha256=aefTQR9UbZAzbPCup-ooUscRpR8ExPknjd9b_GhMRQA,242
|
2
|
+
morphik/_internal.py,sha256=T0rwSrgbLEMq5_YYfIyGmCIF6I8-RNtgISYFXhEoJMo,18808
|
3
|
+
morphik/async_.py,sha256=HKUwMO2LGassUz5SqNeGA0YUvaki442ogVmfHrmKt-8,96490
|
4
|
+
morphik/exceptions.py,sha256=v4XGmfq5B0KrZEF6M1ID8A50-45-SRAQZTrXGXM6n0Q,260
|
5
|
+
morphik/models.py,sha256=JFMeGLbEke-Bls08JXCBv3y_z4eI3PBW_mbX-989i5I,20942
|
6
|
+
morphik/rules.py,sha256=fw0RovS0Pwtff8Dvo3nkM3Wl6WtR3ykSaxsU_sxdXKI,2565
|
7
|
+
morphik/sync.py,sha256=o8KOJPD4QYx6xw7aNQADK-FOI37h0otddFoJtWfV1Ig,100887
|
8
|
+
morphik/tests/README.md,sha256=jtJDDK8cS5E4SbygFQDy7t6Y-kQwNYtZajRwVJDR62U,1069
|
9
|
+
morphik/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
10
|
+
morphik/tests/example_usage.py,sha256=ls8n7355q-8gY43pZLKd4SzI-01MdFeXbT8bZ4U8MCg,11561
|
11
|
+
morphik/tests/test_async.py,sha256=HJY9g5eTMNxyxzQth29n93Df51vW7jOb7a9OSevIxTY,13901
|
12
|
+
morphik/tests/test_sync.py,sha256=Reqa25Q259mCr-tzWzc1RDcs5KZuDfBkJRKOyyxhDtE,13480
|
13
|
+
morphik/tests/test_docs/sample1.txt,sha256=Fx6TElSiKdxyFeBp1iHthzHctFVZm38DrqcbdZMoidY,507
|
14
|
+
morphik/tests/test_docs/sample2.txt,sha256=PE97gPv59J27A7CSNvi_0tRBIN3Mj6pyTFElCLfs3TE,686
|
15
|
+
morphik/tests/test_docs/sample3.txt,sha256=OzrnJ_XsDUntEV0jk-ansa3_KIa6GnpvS5EVmlh6BHo,732
|
16
|
+
morphik-0.1.8.dist-info/METADATA,sha256=Gc8XVr-VmlZLe4a8YmhvGDrUlNpSu_9-8yh1DisiT94,3439
|
17
|
+
morphik-0.1.8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
18
|
+
morphik-0.1.8.dist-info/RECORD,,
|
morphik-0.1.6.dist-info/RECORD
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
morphik/__init__.py,sha256=71PM_1UCwD19H11SscczHDND_lETA2jrOX_mOAA7r38,242
|
2
|
-
morphik/_internal.py,sha256=uKP2mP1G6thNYzxnAK_H8AlqPuEBQFH_8yK9XqVGuM4,18756
|
3
|
-
morphik/async_.py,sha256=agF0NAE9P5_tcXpYodTZFMVt0jhYgoCuZ3ikuFsIUVI,96058
|
4
|
-
morphik/exceptions.py,sha256=v4XGmfq5B0KrZEF6M1ID8A50-45-SRAQZTrXGXM6n0Q,260
|
5
|
-
morphik/models.py,sha256=fj6o9K1zMualdivFL7Hef8mS4WRSLJu04bCCNvkZabw,20873
|
6
|
-
morphik/rules.py,sha256=fw0RovS0Pwtff8Dvo3nkM3Wl6WtR3ykSaxsU_sxdXKI,2565
|
7
|
-
morphik/sync.py,sha256=LeUsuf3BlGhRlB4jvdOtddF1T4Hkzo5r-qBM9UV1a6Y,101116
|
8
|
-
morphik/tests/README.md,sha256=jtJDDK8cS5E4SbygFQDy7t6Y-kQwNYtZajRwVJDR62U,1069
|
9
|
-
morphik/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
10
|
-
morphik/tests/example_usage.py,sha256=ls8n7355q-8gY43pZLKd4SzI-01MdFeXbT8bZ4U8MCg,11561
|
11
|
-
morphik/tests/test_async.py,sha256=M-gET1TD_glTMYZl0DZjRFCb3Qe8n8hRAmQARwbGU-A,13902
|
12
|
-
morphik/tests/test_sync.py,sha256=uEKByKr0woCRKuZrI6Ovz-JVrK7KfZHLSJT7zqj1d7U,13481
|
13
|
-
morphik/tests/test_docs/sample1.txt,sha256=Fx6TElSiKdxyFeBp1iHthzHctFVZm38DrqcbdZMoidY,507
|
14
|
-
morphik/tests/test_docs/sample2.txt,sha256=PE97gPv59J27A7CSNvi_0tRBIN3Mj6pyTFElCLfs3TE,686
|
15
|
-
morphik/tests/test_docs/sample3.txt,sha256=OzrnJ_XsDUntEV0jk-ansa3_KIa6GnpvS5EVmlh6BHo,732
|
16
|
-
morphik-0.1.6.dist-info/METADATA,sha256=QjimRoP10I1tZbd5AGIZ-Wixe1osyDho5jLILhVT1mc,3377
|
17
|
-
morphik-0.1.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
18
|
-
morphik-0.1.6.dist-info/RECORD,,
|
File without changes
|