Build AI methods with your coding agent, then run them anywhere: as an MCP for chatbots, as a webapp for people, or via API for your software.
Use plx_config to set length limit for multiline strings
Louis Choquel4fa524800837
diff --git a/pipelex/config.py b/pipelex/config.pyindex a41a7def0..53580d9f2 100644--- a/pipelex/config.py+++ b/pipelex/config.py@@ -13,6 +13,7 @@ from pipelex.tools.aws.aws_config import AwsConfigfrom pipelex.tools.config.config_model import ConfigModelfrom pipelex.tools.config.config_root import ConfigRootfrom pipelex.tools.log.log_config import LogConfig+from pipelex.tools.plx.plx_config import PlxConfigfrom pipelex.tools.templating.templating_models import PromptingStylefrom pipelex.types import StrEnum@@ -110,6 +111,7 @@ class Pipelex(ConfigModel):tracker_config: TrackerConfigstructure_config: StructureConfigprompting_config: PromptingConfig+ plx_config: PlxConfigdry_run_config: DryRunConfigpipe_run_config: PipeRunConfigdiff --git a/pipelex/pipelex.toml b/pipelex/pipelex.tomlindex 9d81049bd..0a42477f9 100644--- a/pipelex/pipelex.toml+++ b/pipelex/pipelex.toml@@ -215,3 +215,10 @@ image_urls = ["https://storage.googleapis.com/public_test_files_7fa6_4277_9ab/fashion/fashion_photo_2.png",]+####################################################################################################+# PLX config+####################################################################################################++[pipelex.plx_config]+length_limit_to_multiline_strings = 100+diff --git a/pipelex/tools/plx/plx_config.py b/pipelex/tools/plx/plx_config.pynew file mode 100644index 000000000..a43aff1cd--- /dev/null+++ b/pipelex/tools/plx/plx_config.py@@ -0,0 +1,5 @@+from pipelex.tools.config.config_model import ConfigModel+++class PlxConfig(ConfigModel):+ length_limit_to_multiline_strings: intdiff --git a/pipelex/tools/plx/plx_utils.py b/pipelex/tools/plx/plx_utils.pyindex dada4481c..9e2a0563d 100644--- a/pipelex/tools/plx/plx_utils.py+++ b/pipelex/tools/plx/plx_utils.py@@ -7,6 +7,7 @@ from tomlkit import array, document, inline_table, tablefrom tomlkit import string as tomlkit_stringfrom pipelex import log+from pipelex.config import get_configfrom pipelex.core.bundles.pipelex_bundle_blueprint import PipelexBundleBlueprintfrom pipelex.tools.misc.json_utils import remove_none_values_from_dictfrom pipelex.types import StrEnum@@ -48,7 +49,8 @@ def _format_tomlkit_string(- When multiline, `ensure_trailing_newline` puts the closing quotes on their own line.- When multiline, `ensure_leading_blank_line` inserts a real blank line at the start of the string."""- needs_multiline = force_multiline or ("\n" in text)+ length_limit = get_config().pipelex.plx_config.length_limit_to_multiline_strings+ needs_multiline = force_multiline or ("\n" in text) or len(text) > length_limitnormalized = textif needs_multiline:diff --git a/tests/unit/pipelex/core/interpreter/test_interpreter.py b/tests/unit/pipelex/core/interpreter/test_interpreter.pyindex c213b7f4d..df959ddef 100644--- a/tests/unit/pipelex/core/interpreter/test_interpreter.py+++ b/tests/unit/pipelex/core/interpreter/test_interpreter.py@@ -31,14 +31,6 @@ class TestPipelexInterpreter:pretty_print(expected_blueprint, title=f"Expected blueprint {test_name}")assert blueprint == expected_blueprint- @pytest.mark.parametrize("test_name,expected_plx_content,blueprint", InterpreterTestCases.VALID_TEST_CASES)- def test_output_make_plx_content(self, test_name: str, expected_plx_content: str, blueprint: PipelexBundleBlueprint):- """Test making blueprint from various valid PLX content."""- pretty_print(blueprint, title=f"Blueprint {test_name}")- pretty_print(expected_plx_content, title=f"Expected PLX content {test_name}")- plx_content = make_plx_content(blueprint=blueprint)- print(plx_content)-@pytest.mark.parametrize("test_name,expected_plx_content,blueprint", InterpreterTestCases.VALID_TEST_CASES)def test_make_plx_content(self, test_name: str, expected_plx_content: str, blueprint: PipelexBundleBlueprint):"""Test making blueprint from various valid PLX content."""diff --git a/tests/unit/pipelex/core/test_data/pipes/operators/llm/pipe_llm.py b/tests/unit/pipelex/core/test_data/pipes/operators/llm/pipe_llm.pyindex e59279f18..6fcedd3d3 100644--- a/tests/unit/pipelex/core/test_data/pipes/operators/llm/pipe_llm.py+++ b/tests/unit/pipelex/core/test_data/pipes/operators/llm/pipe_llm.py@@ -89,6 +89,34 @@ prompt_template = "Analyze the following data and provide insights"),)+# PipeLLM with long prompt+PIPE_LLM_WITH_LONG_PROMPT = (+ "pipe_llm_with_long_prompt",+ '''domain = "test_pipes"+definition = "Domain with pipe definitions"++[pipe.expert_analysis]+type = "PipeLLM"+definition = "Expert analysis with system prompt"+output = "Text"+prompt_template = """+Extract all articles/items from this invoice text: $extracted_text. For each item find: item name, quantity, unit price, total price, description, and product code if available. Return each article as separate structured data.+"""+''',+ PipelexBundleBlueprint(+ domain="test_pipes",+ definition="Domain with pipe definitions",+ pipe={+ "expert_analysis": PipeLLMBlueprint(+ type="PipeLLM",+ definition="Expert analysis with system prompt",+ output=NativeConceptEnum.TEXT,+ prompt_template="Extract all articles/items from this invoice text: $extracted_text. For each item find: item name, quantity, unit price, total price, description, and product code if available. Return each article as separate structured data.\n",+ ),+ },+ ),+)+# PipeLLM with multiple outputs (nb_output)PIPE_LLM_MULTIPLE_OUTPUTS = ("pipe_llm_multiple_outputs",@@ -338,6 +366,7 @@ PIPE_LLM_TEST_CASES = [PIPE_LLM_BASIC,PIPE_LLM_WITH_INPUTS,PIPE_LLM_WITH_SYSTEM_PROMPT,+ PIPE_LLM_WITH_LONG_PROMPT,PIPE_LLM_MULTIPLE_OUTPUTS,PIPE_LLM_DYNAMIC_MULTIPLE,PIPE_LLM_VISION,