palimpzest 0.8.6__py3-none-any.whl → 0.8.7__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.
@@ -11,6 +11,8 @@ from pydantic.fields import FieldInfo
11
11
 
12
12
  from palimpzest.core.data import context
13
13
  from palimpzest.core.lib.schemas import (
14
+ AUDIO_FIELD_TYPES,
15
+ IMAGE_FIELD_TYPES,
14
16
  AudioBase64,
15
17
  AudioFilepath,
16
18
  ImageBase64,
@@ -303,9 +305,11 @@ class DataRecord:
303
305
  dct = {k: v for k, v in dct.items() if k in project_field_names}
304
306
 
305
307
  if not include_bytes:
308
+ bytes_field_types = [bytes, list[bytes], bytes | None, list[bytes] | None, bytes | Any, list[bytes] | Any]
309
+ bytes_field_types += AUDIO_FIELD_TYPES + IMAGE_FIELD_TYPES
306
310
  for k in dct:
307
311
  field_type = self.get_field_type(k)
308
- if field_type.annotation in [bytes, AudioBase64, ImageBase64, list[bytes], list[ImageBase64]]:
312
+ if field_type.annotation in bytes_field_types:
309
313
  dct[k] = "<bytes>"
310
314
 
311
315
  if bytes_to_str:
@@ -33,20 +33,27 @@ IMAGE_LIST_FIELD_TYPES = [
33
33
  list[ImageBase64] | None,
34
34
  list[ImageFilepath] | None,
35
35
  list[ImageURL] | None,
36
+ list[ImageBase64] | Any,
37
+ list[ImageFilepath] | Any,
38
+ list[ImageURL] | Any,
36
39
  ]
37
40
  IMAGE_FIELD_TYPES = IMAGE_LIST_FIELD_TYPES + [
38
41
  ImageBase64, ImageFilepath, ImageURL,
39
42
  ImageBase64 | None, ImageFilepath | None, ImageURL | None,
43
+ ImageBase64 | Any, ImageFilepath | Any, ImageURL | Any,
40
44
  ]
41
45
  AUDIO_LIST_FIELD_TYPES = [
42
46
  list[AudioBase64],
43
47
  list[AudioFilepath],
44
48
  list[AudioBase64] | None,
45
49
  list[AudioFilepath] | None,
50
+ list[AudioBase64] | Any,
51
+ list[AudioFilepath] | Any,
46
52
  ]
47
53
  AUDIO_FIELD_TYPES = AUDIO_LIST_FIELD_TYPES + [
48
54
  AudioBase64, AudioFilepath,
49
55
  AudioBase64 | None, AudioFilepath | None,
56
+ AudioBase64 | Any, AudioFilepath | Any,
50
57
  ]
51
58
 
52
59
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  import base64
4
4
  import json
5
+ from typing import Any
5
6
 
6
7
  from pydantic import BaseModel
7
8
 
@@ -747,14 +748,14 @@ class PromptFactory:
747
748
  field_type = candidate.get_field_type(field_name)
748
749
 
749
750
  # audio filepath (or list of audio filepaths)
750
- if field_type.annotation in [AudioFilepath, AudioFilepath | None]:
751
+ if field_type.annotation in [AudioFilepath, AudioFilepath | None, AudioFilepath | Any]:
751
752
  with open(field_value, "rb") as f:
752
753
  base64_audio_str = base64.b64encode(f.read()).decode("utf-8")
753
754
  audio_content.append(
754
755
  {"type": "input_audio", "input_audio": {"data": base64_audio_str, "format": "wav"}}
755
756
  )
756
757
 
757
- elif field_type.annotation in [list[AudioFilepath], list[AudioFilepath] | None]:
758
+ elif field_type.annotation in [list[AudioFilepath], list[AudioFilepath] | None, list[AudioFilepath] | Any]:
758
759
  for audio_filepath in field_value:
759
760
  with open(audio_filepath, "rb") as f:
760
761
  base64_audio_str = base64.b64encode(f.read()).decode("utf-8")
@@ -763,12 +764,12 @@ class PromptFactory:
763
764
  )
764
765
 
765
766
  # pre-encoded images (or list of pre-encoded images)
766
- elif field_type.annotation in [AudioBase64, AudioBase64 | None]:
767
+ elif field_type.annotation in [AudioBase64, AudioBase64 | None, AudioBase64 | Any]:
767
768
  audio_content.append(
768
769
  {"type": "input_audio", "input_audio": {"data": field_value, "format": "wav"}}
769
770
  )
770
771
 
771
- elif field_type.annotation in [list[AudioBase64], list[AudioBase64] | None]:
772
+ elif field_type.annotation in [list[AudioBase64], list[AudioBase64] | None, list[AudioBase64] | Any]:
772
773
  for base64_audio in field_value:
773
774
  audio_content.append(
774
775
  {"type": "input_audio", "input_audio": {"data": base64_audio, "format": "wav"}}
@@ -794,14 +795,14 @@ class PromptFactory:
794
795
  field_type = candidate.get_field_type(field_name)
795
796
 
796
797
  # image filepath (or list of image filepaths)
797
- if field_type.annotation in [ImageFilepath, ImageFilepath | None]:
798
+ if field_type.annotation in [ImageFilepath, ImageFilepath | None, ImageFilepath | Any]:
798
799
  with open(field_value, "rb") as f:
799
800
  base64_image_str = base64.b64encode(f.read()).decode("utf-8")
800
801
  image_content.append(
801
802
  {"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{base64_image_str}"}}
802
803
  )
803
804
 
804
- elif field_type.annotation in [list[ImageFilepath], list[ImageFilepath] | None]:
805
+ elif field_type.annotation in [list[ImageFilepath], list[ImageFilepath] | None, list[ImageFilepath] | Any]:
805
806
  for image_filepath in field_value:
806
807
  with open(image_filepath, "rb") as f:
807
808
  base64_image_str = base64.b64encode(f.read()).decode("utf-8")
@@ -810,20 +811,20 @@ class PromptFactory:
810
811
  )
811
812
 
812
813
  # image url (or list of image urls)
813
- elif field_type.annotation in [ImageURL, ImageURL | None]:
814
+ elif field_type.annotation in [ImageURL, ImageURL | None, ImageURL | Any]:
814
815
  image_content.append({"type": "image_url", "image_url": {"url": field_value}})
815
816
 
816
- elif field_type.annotation in [list[ImageURL], list[ImageURL] | None]:
817
+ elif field_type.annotation in [list[ImageURL], list[ImageURL] | None, list[ImageURL] | Any]:
817
818
  for image_url in field_value:
818
819
  image_content.append({"type": "image_url", "image_url": {"url": image_url}})
819
820
 
820
821
  # pre-encoded images (or list of pre-encoded images)
821
- elif field_type.annotation in [ImageBase64, ImageBase64 | None]:
822
+ elif field_type.annotation in [ImageBase64, ImageBase64 | None, ImageBase64 | Any]:
822
823
  image_content.append(
823
824
  {"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{field_value}"}}
824
825
  )
825
826
 
826
- elif field_type.annotation in [list[ImageBase64], list[ImageBase64] | None]:
827
+ elif field_type.annotation in [list[ImageBase64], list[ImageBase64] | None, list[ImageBase64] | Any]:
827
828
  for base64_image in field_value:
828
829
  image_content.append(
829
830
  {"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{base64_image}"}}
@@ -2,8 +2,8 @@ import json
2
2
  import time
3
3
 
4
4
  import litellm
5
- from colorama import Fore, Style
6
5
 
6
+ # from colorama import Fore, Style
7
7
  from palimpzest.constants import MODEL_CARDS, Cardinality, Model, PromptStrategy
8
8
  from palimpzest.core.elements.records import DataRecord
9
9
  from palimpzest.core.models import GenerationStats
@@ -87,7 +87,7 @@ class Validator:
87
87
  input_messages = [msg for msg in messages if msg["role"] != "system"]
88
88
  output = json.dumps(output, indent=2)
89
89
  output_message = f"OUTPUT:\n--------\n{output}\n\nEVALUATION: "
90
- input_str = '\n'.join(list(map(lambda d: d['content'], input_messages + [{"role": "user", "content": output_message}])))
90
+ # input_str = '\n'.join(list(map(lambda d: d['content'], input_messages + [{"role": "user", "content": output_message}])))
91
91
 
92
92
  # invoke the judge
93
93
  score, gen_stats = None, GenerationStats()
@@ -98,8 +98,8 @@ class Validator:
98
98
  completion = litellm.completion(model=self.model.value, messages=val_messages)
99
99
  completion_text = completion.choices[0].message.content
100
100
  gen_stats = self._get_gen_stats_from_completion(completion, start_time)
101
- print(f"INPUT:\n{input_str}")
102
- print(Fore.GREEN + f"{completion_text}\n" + Style.RESET_ALL)
101
+ # print(f"INPUT:\n{input_str}")
102
+ # print(Fore.GREEN + f"{completion_text}\n" + Style.RESET_ALL)
103
103
 
104
104
  # parse the evaluation
105
105
  eval_dict: dict = get_json_from_answer(completion_text, self.model, Cardinality.ONE_TO_ONE)
@@ -233,7 +233,7 @@ class Validator:
233
233
  input_messages = [msg for msg in messages if msg["role"] != "system"]
234
234
  output = json.dumps(output, indent=2)
235
235
  output_message = f"OUTPUT:\n--------\n{output}\n\nEVALUATION: "
236
- input_str = '\n'.join(list(map(lambda d: d['content'], input_messages + [{"role": "user", "content": output_message}])))
236
+ # input_str = '\n'.join(list(map(lambda d: d['content'], input_messages + [{"role": "user", "content": output_message}])))
237
237
 
238
238
  # invoke the judge
239
239
  score, gen_stats = None, GenerationStats()
@@ -245,8 +245,8 @@ class Validator:
245
245
  completion = litellm.completion(model="openai/o4-mini", messages=val_messages)
246
246
  completion_text = completion.choices[0].message.content
247
247
  gen_stats = self._get_gen_stats_from_completion(completion, start_time)
248
- print(f"INPUT:\n{input_str}")
249
- print(Fore.GREEN + f"{completion_text}\n" + Style.RESET_ALL)
248
+ # print(f"INPUT:\n{input_str}")
249
+ # print(Fore.GREEN + f"{completion_text}\n" + Style.RESET_ALL)
250
250
 
251
251
  # parse the evaluation
252
252
  eval_dict: dict = get_json_from_answer(completion_text, self.model, Cardinality.ONE_TO_ONE)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: palimpzest
3
- Version: 0.8.6
3
+ Version: 0.8.7
4
4
  Summary: Palimpzest is a system which enables anyone to process AI-powered analytical queries simply by defining them in a declarative language
5
5
  Author-email: MIT DSG Semantic Management Lab <michjc@csail.mit.edu>
6
6
  Project-URL: homepage, https://palimpzest.org
@@ -15,9 +15,9 @@ palimpzest/core/data/iter_dataset.py,sha256=K47ajOXsCZV3WhOuDkw3xfiHzn8mXPU976uN
15
15
  palimpzest/core/elements/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  palimpzest/core/elements/filters.py,sha256=fU2x0eWDwfP52_5fUmqJXTuhs4H0vvHtPZLdA3IIw8I,1642
17
17
  palimpzest/core/elements/groupbysig.py,sha256=oFH5UkZzcR0msAgfQiRQOOvyJ3HaW4Dwr03h7tVOcrM,2324
18
- palimpzest/core/elements/records.py,sha256=pqtuSgc-Jm5N57d6jtUXmQx0D-khqjOIQAFZjS1XmNM,17075
18
+ palimpzest/core/elements/records.py,sha256=gmMP3nzf6rGfYzbzwUCuiKxz2SrLYlDNktvktLJVRM0,17263
19
19
  palimpzest/core/lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
- palimpzest/core/lib/schemas.py,sha256=2fzbTZBTssKTl9CFGDEQneXasOwo-PLP2lCqHZn2eng,9318
20
+ palimpzest/core/lib/schemas.py,sha256=8hq12gZQwRNpbPNggJfhSvlGvplJArCthVMSUDMSiKw,9568
21
21
  palimpzest/prompts/__init__.py,sha256=942kdENfPU5mFjIxYm-FusL0FD6LNhoj6cYoSGiUsCI,1628
22
22
  palimpzest/prompts/agent_prompts.py,sha256=CUzBVLBiPSw8OShtKp4VTpQwtrNMtcMglo-IZHMvuDM,17459
23
23
  palimpzest/prompts/context_search.py,sha256=s3pti4XNRiIyiWzjVNL_NqmqEc31jzSKMF2SlN0Aaf8,357
@@ -27,7 +27,7 @@ palimpzest/prompts/filter_prompts.py,sha256=D-aY3-th1GzEHrVGbKORVN2R7x7coYGjp8Fr
27
27
  palimpzest/prompts/join_prompts.py,sha256=z-y4L1cw1O3I_F9DW6MvqeztdQoKDQawX6nK6vQAkdM,2916
28
28
  palimpzest/prompts/moa_aggregator_prompts.py,sha256=b5cz4G2oF86LlHOy8vmtxoMcZ9zaZoppKrURHgzCzNU,5248
29
29
  palimpzest/prompts/moa_proposer_prompts.py,sha256=yfZYwmCg-Tg9h0H7PJMEuDYPR45EbYnORmVX6cY2vRQ,3125
30
- palimpzest/prompts/prompt_factory.py,sha256=32GFAfvWOwRHUsAMRDPEiFzaObRK8FeVfGgkG-QKcYs,44187
30
+ palimpzest/prompts/prompt_factory.py,sha256=SlpvrbgBtJbtxBafUaIafmXnR-c-e_MYcrCySUv3KfY,44432
31
31
  palimpzest/prompts/split_merge_prompts.py,sha256=hX-MThmW4VU7rjgm7gb-bpniEMdj25mtp0o8qBeWvIQ,5573
32
32
  palimpzest/prompts/split_proposer_prompts.py,sha256=Ucqwfn4FqFk-b9E024EK4e_3_QndTJjggwiwa1x5CQs,3115
33
33
  palimpzest/prompts/utils.py,sha256=iFv4nuFRuON-DEAdO2JI-J84ukV8Ev27YYWPLwfk44A,5655
@@ -87,9 +87,9 @@ palimpzest/utils/model_helpers.py,sha256=X6SlMgD5I5Aj_cxaFaoGaaNvOOqTNZVmjj6zbfn
87
87
  palimpzest/utils/progress.py,sha256=7gucyZr82udMDZitrrkAOSKHZVljE3R2wv9nf5gA5TM,20807
88
88
  palimpzest/utils/udfs.py,sha256=LjHic54B1az-rKgNLur0wOpaz2ko_UodjLEJrazkxvY,1854
89
89
  palimpzest/validator/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
90
- palimpzest/validator/validator.py,sha256=vasnvAzEv9tDNLGz2X7MpMJBpn8MqSNelQSXk3X6MBs,16002
91
- palimpzest-0.8.6.dist-info/licenses/LICENSE,sha256=5GUlHy9lr-Py9kvV38FF1m3yy3NqM18fefuE9wkWumo,1079
92
- palimpzest-0.8.6.dist-info/METADATA,sha256=NuqbbYGwNa5VlbFP3d59-1KdXA1LjrfChElaSTkmZBk,7048
93
- palimpzest-0.8.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
94
- palimpzest-0.8.6.dist-info/top_level.txt,sha256=raV06dJUgohefUn3ZyJS2uqp_Y76EOLA9Y2e_fxt8Ew,11
95
- palimpzest-0.8.6.dist-info/RECORD,,
90
+ palimpzest/validator/validator.py,sha256=Ixm5cmDf2eaHJoY7eUz0NULklCanC2zcSNtTbmXo-vo,16016
91
+ palimpzest-0.8.7.dist-info/licenses/LICENSE,sha256=5GUlHy9lr-Py9kvV38FF1m3yy3NqM18fefuE9wkWumo,1079
92
+ palimpzest-0.8.7.dist-info/METADATA,sha256=NC6mWNLDZzoBmKe29GR0pwD92TXkg_KMRsVEZYeQKbg,7048
93
+ palimpzest-0.8.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
94
+ palimpzest-0.8.7.dist-info/top_level.txt,sha256=raV06dJUgohefUn3ZyJS2uqp_Y76EOLA9Y2e_fxt8Ew,11
95
+ palimpzest-0.8.7.dist-info/RECORD,,