palimpzest 0.6.1__tar.gz → 0.6.3__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.
- {palimpzest-0.6.1/src/palimpzest.egg-info → palimpzest-0.6.3}/PKG-INFO +1 -1
- {palimpzest-0.6.1 → palimpzest-0.6.3}/pyproject.toml +1 -1
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/prompts/prompt_factory.py +52 -32
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/optimizer/optimizer.py +3 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/processor/query_processor_factory.py +3 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3/src/palimpzest.egg-info}/PKG-INFO +1 -1
- {palimpzest-0.6.1 → palimpzest-0.6.3}/LICENSE +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/README.md +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/setup.cfg +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/__init__.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/constants.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/core/__init__.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/core/data/__init__.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/core/data/dataclasses.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/core/data/datareaders.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/core/elements/__init__.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/core/elements/filters.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/core/elements/groupbysig.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/core/elements/records.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/core/lib/__init__.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/core/lib/fields.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/core/lib/schemas.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/policy.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/prompts/__init__.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/prompts/code_synthesis_prompts.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/prompts/convert_prompts.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/prompts/critique_and_refine_convert_prompts.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/prompts/filter_prompts.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/prompts/moa_aggregator_convert_prompts.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/prompts/moa_proposer_convert_prompts.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/prompts/util_phrases.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/__init__.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/execution/__init__.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/execution/execution_strategy.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/execution/parallel_execution_strategy.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/execution/single_threaded_execution_strategy.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/generators/__init__.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/generators/generators.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/operators/__init__.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/operators/aggregate.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/operators/code_synthesis_convert.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/operators/convert.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/operators/critique_and_refine_convert.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/operators/filter.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/operators/limit.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/operators/logical.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/operators/mixture_of_agents_convert.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/operators/physical.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/operators/project.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/operators/rag_convert.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/operators/retrieve.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/operators/scan.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/operators/token_reduction_convert.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/optimizer/__init__.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/optimizer/cost_model.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/optimizer/optimizer_strategy.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/optimizer/plan.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/optimizer/primitives.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/optimizer/rules.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/optimizer/tasks.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/processor/__init__.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/processor/config.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/processor/mab_sentinel_processor.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/processor/nosentinel_processor.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/processor/query_processor.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/processor/random_sampling_sentinel_processor.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/processor/streaming_processor.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/schemabuilder/__init__.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/schemabuilder/schema_builder.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/sets.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/tools/README.md +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/tools/__init__.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/tools/allenpdf.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/tools/pdfparser.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/tools/skema_tools.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/utils/__init__.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/utils/datareader_helpers.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/utils/demo_helpers.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/utils/env_helpers.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/utils/field_helpers.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/utils/generation_helpers.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/utils/hash_helpers.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/utils/index_helpers.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/utils/model_helpers.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/utils/progress.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/utils/sandbox.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/utils/token_reduction_helpers.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/utils/udfs.py +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest.egg-info/SOURCES.txt +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest.egg-info/dependency_links.txt +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest.egg-info/requires.txt +0 -0
- {palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: palimpzest
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.3
|
|
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
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "palimpzest"
|
|
3
|
-
version = "0.6.
|
|
3
|
+
version = "0.6.3"
|
|
4
4
|
description = "Palimpzest is a system which enables anyone to process AI-powered analytical queries simply by defining them in a declarative language"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.8"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""This file contains factory methods which return template prompts and return messages for chat payloads."""
|
|
2
|
+
|
|
2
3
|
import base64
|
|
3
4
|
import json
|
|
4
5
|
from string import Formatter
|
|
@@ -82,6 +83,7 @@ from palimpzest.prompts.util_phrases import (
|
|
|
82
83
|
|
|
83
84
|
class PromptFactory:
|
|
84
85
|
"""Factory class for generating prompts for the Generator given the input(s)."""
|
|
86
|
+
|
|
85
87
|
BASE_SYSTEM_PROMPT_MAP = {
|
|
86
88
|
PromptStrategy.COT_BOOL: COT_BOOL_BASE_SYSTEM_PROMPT,
|
|
87
89
|
PromptStrategy.COT_BOOL_IMAGE: COT_BOOL_BASE_SYSTEM_PROMPT,
|
|
@@ -92,6 +94,7 @@ class PromptFactory:
|
|
|
92
94
|
PromptStrategy.COT_QA_IMAGE_CRITIC: None,
|
|
93
95
|
PromptStrategy.COT_QA_IMAGE_REFINE: None,
|
|
94
96
|
PromptStrategy.COT_MOA_PROPOSER: COT_MOA_PROPOSER_BASE_SYSTEM_PROMPT,
|
|
97
|
+
PromptStrategy.COT_MOA_PROPOSER_IMAGE: COT_MOA_PROPOSER_BASE_SYSTEM_PROMPT,
|
|
95
98
|
PromptStrategy.COT_MOA_AGG: COT_MOA_AGG_BASE_SYSTEM_PROMPT,
|
|
96
99
|
}
|
|
97
100
|
BASE_USER_PROMPT_MAP = {
|
|
@@ -104,6 +107,7 @@ class PromptFactory:
|
|
|
104
107
|
PromptStrategy.COT_QA_IMAGE_CRITIC: BASE_CRITIQUE_PROMPT,
|
|
105
108
|
PromptStrategy.COT_QA_IMAGE_REFINE: BASE_REFINEMENT_PROMPT,
|
|
106
109
|
PromptStrategy.COT_MOA_PROPOSER: COT_MOA_PROPOSER_BASE_USER_PROMPT,
|
|
110
|
+
PromptStrategy.COT_MOA_PROPOSER_IMAGE: COT_MOA_PROPOSER_BASE_USER_PROMPT,
|
|
107
111
|
PromptStrategy.COT_MOA_AGG: COT_MOA_AGG_BASE_USER_PROMPT,
|
|
108
112
|
}
|
|
109
113
|
|
|
@@ -148,13 +152,13 @@ class PromptFactory:
|
|
|
148
152
|
longest_field_name, longest_field_length = sorted_fields[0]
|
|
149
153
|
|
|
150
154
|
# trim the field
|
|
151
|
-
context_factor =
|
|
155
|
+
context_factor = MIXTRAL_LLAMA_CONTEXT_TOKENS_LIMIT / (total_context_len * TOKENS_PER_CHARACTER)
|
|
152
156
|
keep_frac_idx = int(longest_field_length * context_factor)
|
|
153
157
|
context[longest_field_name] = context[longest_field_name][:keep_frac_idx]
|
|
154
158
|
|
|
155
159
|
# update total context length
|
|
156
160
|
total_context_len = len(json.dumps(context, indent=2))
|
|
157
|
-
|
|
161
|
+
|
|
158
162
|
return json.dumps(context, indent=2)
|
|
159
163
|
|
|
160
164
|
def _get_input_fields(self, candidate: DataRecord, **kwargs) -> list[str]:
|
|
@@ -201,7 +205,11 @@ class PromptFactory:
|
|
|
201
205
|
"""
|
|
202
206
|
output_fields_desc = ""
|
|
203
207
|
output_schema: Schema = kwargs.get("output_schema")
|
|
204
|
-
if
|
|
208
|
+
if (
|
|
209
|
+
self.prompt_strategy.is_cot_qa_prompt()
|
|
210
|
+
or self.prompt_strategy.is_moa_proposer_prompt()
|
|
211
|
+
or self.prompt_strategy.is_moa_aggregator_prompt()
|
|
212
|
+
):
|
|
205
213
|
assert output_schema is not None, "Output schema must be provided for convert prompts."
|
|
206
214
|
|
|
207
215
|
field_desc_map = output_schema.field_desc_map()
|
|
@@ -230,14 +238,16 @@ class PromptFactory:
|
|
|
230
238
|
|
|
231
239
|
Args:
|
|
232
240
|
kwargs: The keyword arguments provided by the user.
|
|
233
|
-
|
|
241
|
+
|
|
234
242
|
Returns:
|
|
235
243
|
str | None: The original output.
|
|
236
244
|
"""
|
|
237
245
|
original_output = kwargs.get("original_output")
|
|
238
246
|
if self.prompt_strategy.is_critic_prompt() or self.prompt_strategy.is_refine_prompt():
|
|
239
|
-
assert original_output is not None,
|
|
240
|
-
|
|
247
|
+
assert original_output is not None, (
|
|
248
|
+
"Original output must be provided for critique and refinement operations."
|
|
249
|
+
)
|
|
250
|
+
|
|
241
251
|
return original_output
|
|
242
252
|
|
|
243
253
|
def _get_critique_output(self, **kwargs) -> str | None:
|
|
@@ -246,7 +256,7 @@ class PromptFactory:
|
|
|
246
256
|
|
|
247
257
|
Args:
|
|
248
258
|
kwargs: The keyword arguments provided by the user.
|
|
249
|
-
|
|
259
|
+
|
|
250
260
|
Returns:
|
|
251
261
|
str | None: The critique output.
|
|
252
262
|
"""
|
|
@@ -259,10 +269,10 @@ class PromptFactory:
|
|
|
259
269
|
def _get_model_responses(self, **kwargs) -> str | None:
|
|
260
270
|
"""
|
|
261
271
|
Returns the model responses for the mixture-of-agents aggregation operation.
|
|
262
|
-
|
|
272
|
+
|
|
263
273
|
Args:
|
|
264
274
|
kwargs: The keyword arguments provided by the user.
|
|
265
|
-
|
|
275
|
+
|
|
266
276
|
Returns:
|
|
267
277
|
str | None: The model responses.
|
|
268
278
|
"""
|
|
@@ -314,9 +324,7 @@ class PromptFactory:
|
|
|
314
324
|
critique_criteria = None
|
|
315
325
|
if self.prompt_strategy.is_critic_prompt():
|
|
316
326
|
critique_criteria = (
|
|
317
|
-
COT_QA_IMAGE_CRITIQUE_CRITERIA
|
|
318
|
-
if self.prompt_strategy.is_image_prompt()
|
|
319
|
-
else COT_QA_CRITIQUE_CRITERIA
|
|
327
|
+
COT_QA_IMAGE_CRITIQUE_CRITERIA if self.prompt_strategy.is_image_prompt() else COT_QA_CRITIQUE_CRITERIA
|
|
320
328
|
)
|
|
321
329
|
|
|
322
330
|
return critique_criteria
|
|
@@ -467,16 +475,18 @@ class PromptFactory:
|
|
|
467
475
|
|
|
468
476
|
return prompt_strategy_to_example_answer.get(self.prompt_strategy)
|
|
469
477
|
|
|
470
|
-
def _get_all_format_kwargs(
|
|
478
|
+
def _get_all_format_kwargs(
|
|
479
|
+
self, candidate: DataRecord, input_fields: list[str], output_fields: list[str], **kwargs
|
|
480
|
+
) -> dict:
|
|
471
481
|
"""
|
|
472
482
|
Returns a dictionary containing all the format kwargs for templating the prompts.
|
|
473
|
-
|
|
483
|
+
|
|
474
484
|
Args:
|
|
475
485
|
candidate (DataRecord): The input record.
|
|
476
486
|
input_fields (list[str]): The input fields.
|
|
477
487
|
output_fields (list[str]): The output fields.
|
|
478
488
|
kwargs: The keyword arguments provided by the user.
|
|
479
|
-
|
|
489
|
+
|
|
480
490
|
Returns:
|
|
481
491
|
dict: The dictionary containing all the format kwargs.
|
|
482
492
|
"""
|
|
@@ -517,7 +527,7 @@ class PromptFactory:
|
|
|
517
527
|
Args:
|
|
518
528
|
candidate (DataRecord): The input record.
|
|
519
529
|
input_fields (list[str]): The list of input fields.
|
|
520
|
-
|
|
530
|
+
|
|
521
531
|
Returns:
|
|
522
532
|
list[dict]: The image messages for the chat payload.
|
|
523
533
|
"""
|
|
@@ -529,15 +539,19 @@ class PromptFactory:
|
|
|
529
539
|
|
|
530
540
|
# image filepath (or list of image filepaths)
|
|
531
541
|
if isinstance(field_type, ImageFilepathField):
|
|
532
|
-
with open(field_value,
|
|
533
|
-
base64_image_str = base64.b64encode(f.read()).decode(
|
|
534
|
-
image_messages.append(
|
|
542
|
+
with open(field_value, "rb") as f:
|
|
543
|
+
base64_image_str = base64.b64encode(f.read()).decode("utf-8")
|
|
544
|
+
image_messages.append(
|
|
545
|
+
{"role": "user", "type": "image", "content": f"data:image/jpeg;base64,{base64_image_str}"}
|
|
546
|
+
)
|
|
535
547
|
|
|
536
548
|
elif hasattr(field_type, "element_type") and issubclass(field_type.element_type, ImageFilepathField):
|
|
537
549
|
for image_filepath in field_value:
|
|
538
|
-
with open(image_filepath,
|
|
539
|
-
base64_image_str = base64.b64encode(f.read()).decode(
|
|
540
|
-
image_messages.append(
|
|
550
|
+
with open(image_filepath, "rb") as f:
|
|
551
|
+
base64_image_str = base64.b64encode(f.read()).decode("utf-8")
|
|
552
|
+
image_messages.append(
|
|
553
|
+
{"role": "user", "type": "image", "content": f"data:image/jpeg;base64,{base64_image_str}"}
|
|
554
|
+
)
|
|
541
555
|
|
|
542
556
|
# image url (or list of image urls)
|
|
543
557
|
elif isinstance(field_type, ImageURLField):
|
|
@@ -550,12 +564,16 @@ class PromptFactory:
|
|
|
550
564
|
# pre-encoded images (or list of pre-encoded images)
|
|
551
565
|
elif isinstance(field_type, ImageBase64Field):
|
|
552
566
|
base64_image_str = field_value.decode("utf-8")
|
|
553
|
-
image_messages.append(
|
|
567
|
+
image_messages.append(
|
|
568
|
+
{"role": "user", "type": "image", "content": f"data:image/jpeg;base64,{base64_image_str}"}
|
|
569
|
+
)
|
|
554
570
|
|
|
555
571
|
elif hasattr(field_type, "element_type") and issubclass(field_type.element_type, ImageBase64Field):
|
|
556
572
|
for base64_image in field_value:
|
|
557
573
|
base64_image_str = base64_image.decode("utf-8")
|
|
558
|
-
image_messages.append(
|
|
574
|
+
image_messages.append(
|
|
575
|
+
{"role": "user", "type": "image", "content": f"data:image/jpeg;base64,{base64_image_str}"}
|
|
576
|
+
)
|
|
559
577
|
|
|
560
578
|
return image_messages
|
|
561
579
|
|
|
@@ -595,15 +613,15 @@ class PromptFactory:
|
|
|
595
613
|
|
|
596
614
|
# get any image messages for the chat payload (will be an empty list if this is not an image prompt)
|
|
597
615
|
image_messages = (
|
|
598
|
-
self._create_image_messages(candidate, input_fields)
|
|
599
|
-
if self.prompt_strategy.is_image_prompt()
|
|
600
|
-
else []
|
|
616
|
+
self._create_image_messages(candidate, input_fields) if self.prompt_strategy.is_image_prompt() else []
|
|
601
617
|
)
|
|
602
618
|
|
|
603
619
|
# get any original messages for critique and refinement operations
|
|
604
620
|
original_messages = kwargs.get("original_messages")
|
|
605
621
|
if self.prompt_strategy.is_critic_prompt() or self.prompt_strategy.is_refine_prompt():
|
|
606
|
-
assert original_messages is not None,
|
|
622
|
+
assert original_messages is not None, (
|
|
623
|
+
"Original messages must be provided for critique and refinement operations."
|
|
624
|
+
)
|
|
607
625
|
|
|
608
626
|
# construct the user messages based on the prompt strategy
|
|
609
627
|
user_messages = []
|
|
@@ -661,17 +679,19 @@ class PromptFactory:
|
|
|
661
679
|
f"Input fields: {input_fields}\n"
|
|
662
680
|
)
|
|
663
681
|
assert fields_check, err_msg
|
|
664
|
-
|
|
682
|
+
|
|
665
683
|
# build set of format kwargs
|
|
666
684
|
format_kwargs = {
|
|
667
|
-
field_name: "<bytes>"
|
|
685
|
+
field_name: "<bytes>"
|
|
686
|
+
if isinstance(candidate.get_field_type(field_name), BytesField)
|
|
687
|
+
else candidate[field_name]
|
|
668
688
|
for field_name in input_fields
|
|
669
689
|
}
|
|
670
690
|
|
|
671
691
|
# split prompt on <<image-placeholder>> if it exists
|
|
672
692
|
if "<<image-placeholder>>" in user_prompt:
|
|
673
693
|
raise NotImplementedError("Image prompts are not yet supported.")
|
|
674
|
-
|
|
694
|
+
|
|
675
695
|
prompt_sections = user_prompt.split("<<image-placeholder>>")
|
|
676
696
|
messages = [{"role": "user", "type": "text", "content": prompt_sections[0].format(**format_kwargs)}]
|
|
677
697
|
|
|
@@ -686,7 +706,7 @@ class PromptFactory:
|
|
|
686
706
|
def create_messages(self, candidate: DataRecord, output_fields: list[str], **kwargs) -> list[dict]:
|
|
687
707
|
"""
|
|
688
708
|
Creates the messages for the chat payload based on the prompt strategy.
|
|
689
|
-
|
|
709
|
+
|
|
690
710
|
Each message will be a dictionary with the following format:
|
|
691
711
|
{
|
|
692
712
|
"role": "user" | "system",
|
|
@@ -219,6 +219,9 @@ class Optimizer:
|
|
|
219
219
|
allow_conventional_query=self.allow_conventional_query,
|
|
220
220
|
allow_code_synth=self.allow_code_synth,
|
|
221
221
|
allow_token_reduction=self.allow_token_reduction,
|
|
222
|
+
allow_rag_reduction=self.allow_rag_reduction,
|
|
223
|
+
allow_mixtures=self.allow_mixtures,
|
|
224
|
+
allow_critic=self.allow_critic,
|
|
222
225
|
optimization_strategy_type=self.optimization_strategy_type,
|
|
223
226
|
use_final_op_quality=self.use_final_op_quality,
|
|
224
227
|
)
|
{palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/processor/query_processor_factory.py
RENAMED
|
@@ -123,6 +123,9 @@ class QueryProcessorFactory:
|
|
|
123
123
|
allow_conventional_query=config.allow_conventional_query,
|
|
124
124
|
allow_code_synth=config.allow_code_synth,
|
|
125
125
|
allow_token_reduction=config.allow_token_reduction,
|
|
126
|
+
allow_rag_reduction=config.allow_rag_reduction,
|
|
127
|
+
allow_mixtures=config.allow_mixtures,
|
|
128
|
+
allow_critic=config.allow_critic,
|
|
126
129
|
optimization_strategy_type=optimizer_strategy,
|
|
127
130
|
use_final_op_quality=config.use_final_op_quality
|
|
128
131
|
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: palimpzest
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.3
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/prompts/critique_and_refine_convert_prompts.py
RENAMED
|
File without changes
|
|
File without changes
|
{palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/prompts/moa_aggregator_convert_prompts.py
RENAMED
|
File without changes
|
{palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/prompts/moa_proposer_convert_prompts.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/execution/parallel_execution_strategy.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/operators/code_synthesis_convert.py
RENAMED
|
File without changes
|
|
File without changes
|
{palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/operators/critique_and_refine_convert.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/operators/mixture_of_agents_convert.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/operators/token_reduction_convert.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/processor/mab_sentinel_processor.py
RENAMED
|
File without changes
|
{palimpzest-0.6.1 → palimpzest-0.6.3}/src/palimpzest/query/processor/nosentinel_processor.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|