ahnlich-client-py 0.2.0__tar.gz → 0.3.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.
Files changed (34) hide show
  1. {ahnlich_client_py-0.2.0 → ahnlich_client_py-0.3.0}/PKG-INFO +100 -1
  2. {ahnlich_client_py-0.2.0 → ahnlich_client_py-0.3.0}/README.md +99 -0
  3. ahnlich_client_py-0.3.0/VERSION +2 -0
  4. {ahnlich_client_py-0.2.0 → ahnlich_client_py-0.3.0}/ahnlich_client_py/grpc/ai/models/__init__.py +1 -0
  5. {ahnlich_client_py-0.2.0 → ahnlich_client_py-0.3.0}/ahnlich_client_py/grpc/ai/server/__init__.py +10 -2
  6. {ahnlich_client_py-0.2.0 → ahnlich_client_py-0.3.0}/pyproject.toml +1 -1
  7. ahnlich_client_py-0.2.0/VERSION +0 -2
  8. {ahnlich_client_py-0.2.0 → ahnlich_client_py-0.3.0}/ahnlich_client_py/__init__.py +0 -0
  9. {ahnlich_client_py-0.2.0 → ahnlich_client_py-0.3.0}/ahnlich_client_py/config.py +0 -0
  10. {ahnlich_client_py-0.2.0 → ahnlich_client_py-0.3.0}/ahnlich_client_py/grpc/__init__.py +0 -0
  11. {ahnlich_client_py-0.2.0 → ahnlich_client_py-0.3.0}/ahnlich_client_py/grpc/ai/__init__.py +0 -0
  12. {ahnlich_client_py-0.2.0 → ahnlich_client_py-0.3.0}/ahnlich_client_py/grpc/ai/execution_provider/__init__.py +0 -0
  13. {ahnlich_client_py-0.2.0 → ahnlich_client_py-0.3.0}/ahnlich_client_py/grpc/ai/pipeline/__init__.py +0 -0
  14. {ahnlich_client_py-0.2.0 → ahnlich_client_py-0.3.0}/ahnlich_client_py/grpc/ai/preprocess/__init__.py +0 -0
  15. {ahnlich_client_py-0.2.0 → ahnlich_client_py-0.3.0}/ahnlich_client_py/grpc/ai/query/__init__.py +0 -0
  16. {ahnlich_client_py-0.2.0 → ahnlich_client_py-0.3.0}/ahnlich_client_py/grpc/algorithm/__init__.py +0 -0
  17. {ahnlich_client_py-0.2.0 → ahnlich_client_py-0.3.0}/ahnlich_client_py/grpc/algorithm/algorithms/__init__.py +0 -0
  18. {ahnlich_client_py-0.2.0 → ahnlich_client_py-0.3.0}/ahnlich_client_py/grpc/algorithm/nonlinear/__init__.py +0 -0
  19. {ahnlich_client_py-0.2.0 → ahnlich_client_py-0.3.0}/ahnlich_client_py/grpc/client/__init__.py +0 -0
  20. {ahnlich_client_py-0.2.0 → ahnlich_client_py-0.3.0}/ahnlich_client_py/grpc/db/__init__.py +0 -0
  21. {ahnlich_client_py-0.2.0 → ahnlich_client_py-0.3.0}/ahnlich_client_py/grpc/db/pipeline/__init__.py +0 -0
  22. {ahnlich_client_py-0.2.0 → ahnlich_client_py-0.3.0}/ahnlich_client_py/grpc/db/query/__init__.py +0 -0
  23. {ahnlich_client_py-0.2.0 → ahnlich_client_py-0.3.0}/ahnlich_client_py/grpc/db/server/__init__.py +0 -0
  24. {ahnlich_client_py-0.2.0 → ahnlich_client_py-0.3.0}/ahnlich_client_py/grpc/keyval/__init__.py +0 -0
  25. {ahnlich_client_py-0.2.0 → ahnlich_client_py-0.3.0}/ahnlich_client_py/grpc/metadata/__init__.py +0 -0
  26. {ahnlich_client_py-0.2.0 → ahnlich_client_py-0.3.0}/ahnlich_client_py/grpc/predicates/__init__.py +0 -0
  27. {ahnlich_client_py-0.2.0 → ahnlich_client_py-0.3.0}/ahnlich_client_py/grpc/server_types/__init__.py +0 -0
  28. {ahnlich_client_py-0.2.0 → ahnlich_client_py-0.3.0}/ahnlich_client_py/grpc/services/__init__.py +0 -0
  29. {ahnlich_client_py-0.2.0 → ahnlich_client_py-0.3.0}/ahnlich_client_py/grpc/services/ai_service/__init__.py +0 -0
  30. {ahnlich_client_py-0.2.0 → ahnlich_client_py-0.3.0}/ahnlich_client_py/grpc/services/db_service/__init__.py +0 -0
  31. {ahnlich_client_py-0.2.0 → ahnlich_client_py-0.3.0}/ahnlich_client_py/grpc/shared/__init__.py +0 -0
  32. {ahnlich_client_py-0.2.0 → ahnlich_client_py-0.3.0}/ahnlich_client_py/grpc/shared/info/__init__.py +0 -0
  33. {ahnlich_client_py-0.2.0 → ahnlich_client_py-0.3.0}/ahnlich_client_py/grpc/similarity/__init__.py +0 -0
  34. {ahnlich_client_py-0.2.0 → ahnlich_client_py-0.3.0}/ahnlich_client_py/grpc/version/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ahnlich-client-py
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: A python client for interacting with Ahnlich DB and AI
5
5
  Author: David Onuh
6
6
  Author-email: davidonuh1@gmail.com
@@ -790,6 +790,105 @@ async with Channel(host="127.0.0.1", port=1370) as channel:
790
790
  )
791
791
  ```
792
792
 
793
+ ### Convert Store Input To Embeddings
794
+
795
+ Converts raw inputs (text, images, audio) into embeddings without storing them.
796
+
797
+ **Basic Example:**
798
+ ```python
799
+ from grpclib.client import Channel
800
+ from ahnlich_client_py.grpc.services.ai_service import AiServiceStub
801
+ from ahnlich_client_py.grpc.ai import query as ai_query
802
+ from ahnlich_client_py.grpc.ai.models import AiModel
803
+ from ahnlich_client_py.grpc.ai import preprocess
804
+ from ahnlich_client_py.grpc import keyval
805
+
806
+ async with Channel(host="127.0.0.1", port=1370) as channel:
807
+ client = AiServiceStub(channel)
808
+
809
+ inputs = [keyval.StoreInput(raw_string="Hello world")]
810
+
811
+ response = await client.convert_store_input_to_embeddings(
812
+ ai_query.ConvertStoreInputToEmbeddings(
813
+ store_inputs=inputs,
814
+ preprocess_action=preprocess.PreprocessAction.NoPreprocessing,
815
+ model=AiModel.ALL_MINI_LM_L6_V2,
816
+ )
817
+ )
818
+
819
+ # Access embeddings
820
+ for item in response.values:
821
+ if item.single and item.single.embedding:
822
+ print(f"Embedding size: {len(item.single.embedding.key)}")
823
+ ```
824
+
825
+ **Face Detection with Bounding Box Metadata (v0.2.1+):**
826
+
827
+ Buffalo-L and SFace models return normalized bounding boxes (0-1 range) and confidence scores:
828
+
829
+ ```python
830
+ from grpclib.client import Channel
831
+ from ahnlich_client_py.grpc.services.ai_service import AiServiceStub
832
+ from ahnlich_client_py.grpc.ai import query as ai_query
833
+ from ahnlich_client_py.grpc.ai.models import AiModel
834
+ from ahnlich_client_py.grpc.ai import preprocess
835
+ from ahnlich_client_py.grpc import keyval
836
+
837
+ async with Channel(host="127.0.0.1", port=1370) as channel:
838
+ client = AiServiceStub(channel)
839
+
840
+ # Load image
841
+ with open("group_photo.jpg", "rb") as f:
842
+ image_bytes = f.read()
843
+
844
+ inputs = [keyval.StoreInput(image=image_bytes)]
845
+
846
+ response = await client.convert_store_input_to_embeddings(
847
+ ai_query.ConvertStoreInputToEmbeddings(
848
+ store_inputs=inputs,
849
+ preprocess_action=preprocess.PreprocessAction.ModelPreprocessing,
850
+ model=AiModel.BUFFALO_L,
851
+ )
852
+ )
853
+
854
+ # Process detected faces with metadata
855
+ for item in response.values:
856
+ if item.multiple:
857
+ print(f"Detected {len(item.multiple.embeddings)} faces")
858
+
859
+ for i, face_data in enumerate(item.multiple.embeddings):
860
+ # Access embedding
861
+ embedding = face_data.embedding.key # 512-dim for Buffalo_L
862
+ print(f"Face {i}: {len(embedding)}-dim embedding")
863
+
864
+ # Access bounding box metadata
865
+ if face_data.metadata:
866
+ metadata = face_data.metadata.value
867
+
868
+ bbox_x1 = float(metadata["bbox_x1"].value)
869
+ bbox_y1 = float(metadata["bbox_y1"].value)
870
+ bbox_x2 = float(metadata["bbox_x2"].value)
871
+ bbox_y2 = float(metadata["bbox_y2"].value)
872
+ confidence = float(metadata["confidence"].value)
873
+
874
+ print(f" BBox: ({bbox_x1:.3f}, {bbox_y1:.3f}) "
875
+ f"to ({bbox_x2:.3f}, {bbox_y2:.3f})")
876
+ print(f" Confidence: {confidence:.3f}")
877
+ ```
878
+
879
+ **Metadata Fields:**
880
+ - `bbox_x1`, `bbox_y1`, `bbox_x2`, `bbox_y2`: Normalized coordinates (0.0-1.0)
881
+ - `confidence`: Detection confidence score (0.0-1.0)
882
+
883
+ To convert to pixel coordinates:
884
+ ```python
885
+ from PIL import Image
886
+ img = Image.open("photo.jpg")
887
+ width, height = img.size
888
+ pixel_x1 = int(bbox_x1 * width)
889
+ pixel_y1 = int(bbox_y1 * height)
890
+ ```
891
+
793
892
 
794
893
  ## Bulk Requests
795
894
  Clients have the ability to send multiple requests at once, and these requests will be handled sequentially. The builder class takes care of this. The response is a list of all individual request responses.
@@ -773,6 +773,105 @@ async with Channel(host="127.0.0.1", port=1370) as channel:
773
773
  )
774
774
  ```
775
775
 
776
+ ### Convert Store Input To Embeddings
777
+
778
+ Converts raw inputs (text, images, audio) into embeddings without storing them.
779
+
780
+ **Basic Example:**
781
+ ```python
782
+ from grpclib.client import Channel
783
+ from ahnlich_client_py.grpc.services.ai_service import AiServiceStub
784
+ from ahnlich_client_py.grpc.ai import query as ai_query
785
+ from ahnlich_client_py.grpc.ai.models import AiModel
786
+ from ahnlich_client_py.grpc.ai import preprocess
787
+ from ahnlich_client_py.grpc import keyval
788
+
789
+ async with Channel(host="127.0.0.1", port=1370) as channel:
790
+ client = AiServiceStub(channel)
791
+
792
+ inputs = [keyval.StoreInput(raw_string="Hello world")]
793
+
794
+ response = await client.convert_store_input_to_embeddings(
795
+ ai_query.ConvertStoreInputToEmbeddings(
796
+ store_inputs=inputs,
797
+ preprocess_action=preprocess.PreprocessAction.NoPreprocessing,
798
+ model=AiModel.ALL_MINI_LM_L6_V2,
799
+ )
800
+ )
801
+
802
+ # Access embeddings
803
+ for item in response.values:
804
+ if item.single and item.single.embedding:
805
+ print(f"Embedding size: {len(item.single.embedding.key)}")
806
+ ```
807
+
808
+ **Face Detection with Bounding Box Metadata (v0.2.1+):**
809
+
810
+ Buffalo-L and SFace models return normalized bounding boxes (0-1 range) and confidence scores:
811
+
812
+ ```python
813
+ from grpclib.client import Channel
814
+ from ahnlich_client_py.grpc.services.ai_service import AiServiceStub
815
+ from ahnlich_client_py.grpc.ai import query as ai_query
816
+ from ahnlich_client_py.grpc.ai.models import AiModel
817
+ from ahnlich_client_py.grpc.ai import preprocess
818
+ from ahnlich_client_py.grpc import keyval
819
+
820
+ async with Channel(host="127.0.0.1", port=1370) as channel:
821
+ client = AiServiceStub(channel)
822
+
823
+ # Load image
824
+ with open("group_photo.jpg", "rb") as f:
825
+ image_bytes = f.read()
826
+
827
+ inputs = [keyval.StoreInput(image=image_bytes)]
828
+
829
+ response = await client.convert_store_input_to_embeddings(
830
+ ai_query.ConvertStoreInputToEmbeddings(
831
+ store_inputs=inputs,
832
+ preprocess_action=preprocess.PreprocessAction.ModelPreprocessing,
833
+ model=AiModel.BUFFALO_L,
834
+ )
835
+ )
836
+
837
+ # Process detected faces with metadata
838
+ for item in response.values:
839
+ if item.multiple:
840
+ print(f"Detected {len(item.multiple.embeddings)} faces")
841
+
842
+ for i, face_data in enumerate(item.multiple.embeddings):
843
+ # Access embedding
844
+ embedding = face_data.embedding.key # 512-dim for Buffalo_L
845
+ print(f"Face {i}: {len(embedding)}-dim embedding")
846
+
847
+ # Access bounding box metadata
848
+ if face_data.metadata:
849
+ metadata = face_data.metadata.value
850
+
851
+ bbox_x1 = float(metadata["bbox_x1"].value)
852
+ bbox_y1 = float(metadata["bbox_y1"].value)
853
+ bbox_x2 = float(metadata["bbox_x2"].value)
854
+ bbox_y2 = float(metadata["bbox_y2"].value)
855
+ confidence = float(metadata["confidence"].value)
856
+
857
+ print(f" BBox: ({bbox_x1:.3f}, {bbox_y1:.3f}) "
858
+ f"to ({bbox_x2:.3f}, {bbox_y2:.3f})")
859
+ print(f" Confidence: {confidence:.3f}")
860
+ ```
861
+
862
+ **Metadata Fields:**
863
+ - `bbox_x1`, `bbox_y1`, `bbox_x2`, `bbox_y2`: Normalized coordinates (0.0-1.0)
864
+ - `confidence`: Detection confidence score (0.0-1.0)
865
+
866
+ To convert to pixel coordinates:
867
+ ```python
868
+ from PIL import Image
869
+ img = Image.open("photo.jpg")
870
+ width, height = img.size
871
+ pixel_x1 = int(bbox_x1 * width)
872
+ pixel_y1 = int(bbox_y1 * height)
873
+ ```
874
+
776
875
 
777
876
  ## Bulk Requests
778
877
  Clients have the ability to send multiple requests at once, and these requests will be handled sequentially. The builder class takes care of this. The response is a list of all individual request responses.
@@ -0,0 +1,2 @@
1
+ CLIENT="0.3.0"
2
+ PROTOCOL="0.3.0"
@@ -20,6 +20,7 @@ class AiModel(betterproto.Enum):
20
20
  SFACE_YUNET = 8
21
21
  CLAP_AUDIO = 9
22
22
  CLAP_TEXT = 10
23
+ JINA_EMBEDDINGS_V2_BASE_CODE = 11
23
24
 
24
25
 
25
26
  class AiStoreInputType(betterproto.Enum):
@@ -92,16 +92,24 @@ class AiStoreInfo(betterproto.Message):
92
92
  )
93
93
 
94
94
 
95
+ @dataclass(eq=False, repr=False)
96
+ class EmbeddingWithMetadata(betterproto.Message):
97
+ embedding: "__keyval__.StoreKey" = betterproto.message_field(1)
98
+ metadata: Optional["__keyval__.StoreValue"] = betterproto.message_field(
99
+ 2, optional=True
100
+ )
101
+
102
+
95
103
  @dataclass(eq=False, repr=False)
96
104
  class MultipleEmbedding(betterproto.Message):
97
- embeddings: List["__keyval__.StoreKey"] = betterproto.message_field(1)
105
+ embeddings: List["EmbeddingWithMetadata"] = betterproto.message_field(1)
98
106
 
99
107
 
100
108
  @dataclass(eq=False, repr=False)
101
109
  class SingleInputToEmbedding(betterproto.Message):
102
110
  input: "__keyval__.StoreInput" = betterproto.message_field(1)
103
111
  multiple: "MultipleEmbedding" = betterproto.message_field(2, group="variant")
104
- single: "__keyval__.StoreKey" = betterproto.message_field(3, group="variant")
112
+ single: "EmbeddingWithMetadata" = betterproto.message_field(3, group="variant")
105
113
 
106
114
 
107
115
  @dataclass(eq=False, repr=False)
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "ahnlich-client-py"
3
- version = "0.2.0"
3
+ version = "0.3.0"
4
4
  description = "A python client for interacting with Ahnlich DB and AI"
5
5
  authors = ["David Onuh <davidonuh1@gmail.com>"]
6
6
  readme = "README.md"
@@ -1,2 +0,0 @@
1
- CLIENT="0.2.0"
2
- PROTOCOL="0.2.0"