Skip to content

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.

Feature/more open source models (#42)

Louis Choquel87ab9ba5b9ae
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3b34bf6c5..a4c4f9b65 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,7 +13,7 @@
**Major Model Additions** - Claude 4 (Opus & Sonnet), Grok-3, and GPT-4 image generation are now in the house.
### Pipeline Base Library update
-- **New pipe** - `extract_page_contents_and_views_from_pdf` transfered from cookbook to base library (congrats on the promotion!). This pipe extracts text, linked images, **AND** page_view images (rendered pages) - it's very useful if you want to use Vision in follow-up pipes
+- **New pipe** - `extract_page_contents_and_views_from_pdf` transferred from cookbook to base library (congrats on the promotion!). This pipe extracts text, linked images, **AND** page_view images (rendered pages) - it's very useful if you want to use Vision in follow-up pipes
### Added
@@ -56,7 +56,7 @@
- Include `pyproject.toml` inside the project build.
- Fix `ImggEngineFactory`: image generation (imgg) handle required format is `platform/model_name`
-- pipelex cli: Added `list-pipes` method that can list all the availables pipes with descriptions.
+- pipelex cli: Added `list-pipes` method that can list all the available pipes along with their descriptions.
- Use a minimum version for `uv` instead of a fixed version
- Implement `AGENTS.md` for Codex
- Add tests for some of the `tools.misc`
@@ -64,8 +64,8 @@
## [v0.2.8] - 2025-05-28
-- Defaults to `uv`
-- Simplify llm provider config: All the API keys, urls, and regions are to be set in `.env`.
+- Replaced `poetry` by `uv` for dependency management.
+- Simplify llm provider config: All the API keys, urls, and regions now live in the `.env`.
- Added logging level `OFF`, prevents any log from hitting the console
## [v0.2.7] - 2025-05-26
diff --git a/pipelex/cogt/llm/llm_models/llm_family.py b/pipelex/cogt/llm/llm_models/llm_family.py
index b1e2d00eb..9c870f359 100644
--- a/pipelex/cogt/llm/llm_models/llm_family.py
+++ b/pipelex/cogt/llm/llm_models/llm_family.py
@@ -13,6 +13,7 @@ class LLMCreator(StrEnum):
MISTRAL = "Mistral"
PERPLEXITY = "Perplexity"
XAI = "XAI"
+ ALIBABA = "Alibaba"
@property
def prompting_target(self) -> LLMPromptingTarget:
@@ -25,7 +26,7 @@ class LLMCreator(StrEnum):
return LLMPromptingTarget.MISTRAL
case LLMCreator.GOOGLE:
return LLMPromptingTarget.GEMINI
- case LLMCreator.AMAZON | LLMCreator.PERPLEXITY | LLMCreator.META | LLMCreator.DEEPSEEK | LLMCreator.XAI:
+ case LLMCreator.AMAZON | LLMCreator.PERPLEXITY | LLMCreator.META | LLMCreator.DEEPSEEK | LLMCreator.XAI | LLMCreator.ALIBABA:
return LLMPromptingTarget.OPENAI
@property
@@ -49,6 +50,8 @@ class LLMCreator(StrEnum):
return "red"
case LLMCreator.XAI:
return "green"
+ case LLMCreator.ALIBABA:
+ return "yellow"
class LLMFamily(StrEnum):
@@ -92,6 +95,8 @@ class LLMFamily(StrEnum):
CUSTOM_LLAMA_4 = "custom-llama-4"
CUSTOM_GEMMA_3 = "custom-gemma-3"
+ CUSTOM_MISTRAL_SMALL_3_1 = "custom-mistral-small3.1"
+ CUSTOM_QWEN_3 = "custom-qwen3"
@property
def creator(self) -> LLMCreator:
@@ -112,6 +117,7 @@ class LLMFamily(StrEnum):
| LLMFamily.MISTRAL_CODESTRAL
| LLMFamily.MINISTRAL
| LLMFamily.PIXTRAL
+ | LLMFamily.CUSTOM_MISTRAL_SMALL_3_1
):
return LLMCreator.MISTRAL
case LLMFamily.BEDROCK_MISTRAL_LARGE:
@@ -132,6 +138,8 @@ class LLMFamily(StrEnum):
return LLMCreator.XAI
case LLMFamily.CUSTOM_LLAMA_4 | LLMFamily.CUSTOM_GEMMA_3:
return LLMCreator.META
+ case LLMFamily.CUSTOM_QWEN_3:
+ return LLMCreator.ALIBABA
@property
def prompting_target(self) -> LLMPromptingTarget:
diff --git a/pipelex/cogt/llm/llm_models/llm_platform.py b/pipelex/cogt/llm/llm_models/llm_platform.py
index 8557be0e4..e3b1548ba 100644
--- a/pipelex/cogt/llm/llm_models/llm_platform.py
+++ b/pipelex/cogt/llm/llm_models/llm_platform.py
@@ -17,19 +17,19 @@ class LLMPlatform(StrEnum):
MISTRAL = "mistral"
OPENAI = "openai"
PERPLEXITY = "perplexity"
- VERTEXAI_OPENAI = "vertexai_openai"
+ VERTEXAI = "vertexai"
XAI = "xai"
- CUSTOM_OPENAI = "custom_openai"
+ CUSTOM_LLM = "custom_llm"
@staticmethod
def list_openai_related() -> list["LLMPlatform"]:
return [
LLMPlatform.OPENAI,
LLMPlatform.AZURE_OPENAI,
- LLMPlatform.VERTEXAI_OPENAI,
+ LLMPlatform.VERTEXAI,
LLMPlatform.PERPLEXITY,
LLMPlatform.XAI,
- LLMPlatform.CUSTOM_OPENAI,
+ LLMPlatform.CUSTOM_LLM,
]
@staticmethod
@@ -46,13 +46,13 @@ class LLMPlatform(StrEnum):
case (
LLMPlatform.OPENAI
| LLMPlatform.AZURE_OPENAI
- | LLMPlatform.VERTEXAI_OPENAI
+ | LLMPlatform.VERTEXAI
| LLMPlatform.PERPLEXITY
| LLMPlatform.ANTHROPIC
| LLMPlatform.MISTRAL
| LLMPlatform.BEDROCK_ANTHROPIC
| LLMPlatform.XAI
- | LLMPlatform.CUSTOM_OPENAI
+ | LLMPlatform.CUSTOM_LLM
):
return True
case LLMPlatform.BEDROCK:
@@ -75,11 +75,11 @@ class LLMPlatform(StrEnum):
return "spring_green2"
case LLMPlatform.PERPLEXITY:
return "gray"
- case LLMPlatform.VERTEXAI_OPENAI:
+ case LLMPlatform.VERTEXAI:
return "deep_sky_blue"
case LLMPlatform.XAI:
return "green"
- case LLMPlatform.CUSTOM_OPENAI:
+ case LLMPlatform.CUSTOM_LLM:
return "white"
diff --git a/pipelex/cogt/llm/llm_worker_factory.py b/pipelex/cogt/llm/llm_worker_factory.py
index d48a2eb44..38f70d400 100644
--- a/pipelex/cogt/llm/llm_worker_factory.py
+++ b/pipelex/cogt/llm/llm_worker_factory.py
@@ -41,7 +41,7 @@ class LLMWorkerFactory:
structure_method=structure_method,
report_delegate=report_delegate,
)
- case LLMPlatform.VERTEXAI_OPENAI:
+ case LLMPlatform.VERTEXAI:
try:
import google.auth # noqa: F401
except ImportError as exc:
@@ -61,7 +61,7 @@ class LLMWorkerFactory:
structure_method=StructureMethod.INSTRUCTOR_VERTEX_JSON,
report_delegate=report_delegate,
)
- case LLMPlatform.CUSTOM_OPENAI:
+ case LLMPlatform.CUSTOM_LLM:
from pipelex.plugins.openai.openai_factory import OpenAIFactory
from pipelex.plugins.openai.openai_llm_worker import OpenAILLMWorker
diff --git a/pipelex/cogt/plugin_manager.py b/pipelex/cogt/plugin_manager.py
index 2aa589064..85955cbf4 100644
--- a/pipelex/cogt/plugin_manager.py
+++ b/pipelex/cogt/plugin_manager.py
@@ -9,55 +9,55 @@ from pipelex.types import StrEnum
class PluginHandle(StrEnum):
- OPENAI_ASYNC = "openai_async"
- AZURE_OPENAI_ASYNC = "azure_openai_async"
- ANTHROPIC_ASYNC = "anthropic_async"
- BEDROCK_ANTHROPIC_ASYNC = "bedrock_anthropic_async"
- MISTRAL_ASYNC = "mistral_async"
- BEDROCK_ASYNC = "bedrock_async"
- PERPLEXITY_ASYNC = "perplexity_async"
- VERTEXAI_OPENAI_ASYNC = "vertexai_openai_async"
- XAI_OPENAI_ASYNC = "xai_openai_async"
- CUSTOM_OPENAI_ASYNC = "custom_openai_async"
- FAL_ASYNC = "fal_async"
+ OPENAI_SDK = "openai_sdk"
+ AZURE_OPENAI_SDK = "azure_openai_sdk"
+ ANTHROPIC_SDK = "anthropic_sdk"
+ BEDROCK_ANTHROPIC_SDK = "bedrock_anthropic_sdk"
+ MISTRAL_SDK = "mistral_sdk"
+ BEDROCK_SDK = "bedrock_sdk"
+ PERPLEXITY_OPENAI_SDK = "perplexity_openai_sdk"
+ VERTEXAI_OPENAI_SDK = "vertexai_openai_sdk"
+ XAI_OPENAI_SDK = "xai_openai_sdk"
+ CUSTOM_LLM_OPENAI_SDK = "custom_llm_openai_sdk"
+ FAL_SDK = "fal_sdk"
@staticmethod
def get_for_llm_platform(llm_platform: LLMPlatform) -> "PluginHandle":
match llm_platform:
case LLMPlatform.OPENAI:
- return PluginHandle.OPENAI_ASYNC
+ return PluginHandle.OPENAI_SDK
case LLMPlatform.AZURE_OPENAI:
- return PluginHandle.AZURE_OPENAI_ASYNC
+ return PluginHandle.AZURE_OPENAI_SDK
case LLMPlatform.ANTHROPIC:
- return PluginHandle.ANTHROPIC_ASYNC
+ return PluginHandle.ANTHROPIC_SDK
case LLMPlatform.MISTRAL:
- return PluginHandle.MISTRAL_ASYNC
+ return PluginHandle.MISTRAL_SDK
case LLMPlatform.BEDROCK:
- return PluginHandle.BEDROCK_ASYNC
+ return PluginHandle.BEDROCK_SDK
case LLMPlatform.BEDROCK_ANTHROPIC:
- return PluginHandle.BEDROCK_ANTHROPIC_ASYNC
+ return PluginHandle.BEDROCK_ANTHROPIC_SDK
case LLMPlatform.PERPLEXITY:
- return PluginHandle.PERPLEXITY_ASYNC
- case LLMPlatform.VERTEXAI_OPENAI:
- return PluginHandle.VERTEXAI_OPENAI_ASYNC
+ return PluginHandle.PERPLEXITY_OPENAI_SDK
+ case LLMPlatform.VERTEXAI:
+ return PluginHandle.VERTEXAI_OPENAI_SDK
case LLMPlatform.XAI:
- return PluginHandle.XAI_OPENAI_ASYNC
- case LLMPlatform.CUSTOM_OPENAI:
- return PluginHandle.CUSTOM_OPENAI_ASYNC
+ return PluginHandle.XAI_OPENAI_SDK
+ case LLMPlatform.CUSTOM_LLM:
+ return PluginHandle.CUSTOM_LLM_OPENAI_SDK
@staticmethod
def get_for_ocr_engine(ocr_platform: OcrPlatform) -> "PluginHandle":
match ocr_platform:
case OcrPlatform.MISTRAL:
- return PluginHandle.MISTRAL_ASYNC
+ return PluginHandle.MISTRAL_SDK
@staticmethod
def get_for_imgg_engine(imgg_platform: ImggPlatform) -> "PluginHandle":
match imgg_platform:
case ImggPlatform.FAL_AI:
- return PluginHandle.FAL_ASYNC
+ return PluginHandle.FAL_SDK
case ImggPlatform.OPENAI:
- return PluginHandle.OPENAI_ASYNC
+ return PluginHandle.OPENAI_SDK
PluginManagerRoot = Dict[str, Any]
diff --git a/pipelex/libraries/llm_integrations/custom.toml b/pipelex/libraries/llm_integrations/custom.toml
index 9e07a072c..a551366be 100644
--- a/pipelex/libraries/llm_integrations/custom.toml
+++ b/pipelex/libraries/llm_integrations/custom.toml
@@ -5,11 +5,25 @@ is_gen_object_supported = false
is_vision_supported = true
max_prompt_images = 3000
cost_per_million_tokens_usd = { input = 0, output = 0 }
-platform_llm_id = { custom_openai = "gemma3:4b" }
+platform_llm_id = { custom_llm = "gemma3:4b" }
[custom-llama-4."llama4:scout".latest]
is_gen_object_supported = false
is_vision_supported = true
max_prompt_images = 3000
cost_per_million_tokens_usd = { input = 0, output = 0 }
-platform_llm_id = { custom_openai = "llama4:scout" }
+platform_llm_id = { custom_llm = "llama4:scout" }
+
+["custom-mistral-small3.1"."mistral-small3.1".latest]
+is_gen_object_supported = false
+is_vision_supported = true
+max_prompt_images = 3000
+cost_per_million_tokens_usd = { input = 0, output = 0 }
+platform_llm_id = { custom_llm = "mistral-small3.1:24b" }
+
+["custom-qwen3"."qwen3:8b".latest]
+is_gen_object_supported = false
+is_vision_supported = false
+cost_per_million_tokens_usd = { input = 0, output = 0 }
+platform_llm_id = { custom_llm = "qwen3:8b" }
+# TODO: support <think> tokens
diff --git a/pipelex/libraries/llm_integrations/vertexai.toml b/pipelex/libraries/llm_integrations/vertexai.toml
index c338f2d6a..f7cc08242 100644
--- a/pipelex/libraries/llm_integrations/vertexai.toml
+++ b/pipelex/libraries/llm_integrations/vertexai.toml
@@ -5,39 +5,39 @@ is_gen_object_supported = true
is_vision_supported = true
max_prompt_images = 3000
cost_per_million_tokens_usd = { input = 0.075, output = 0.3 }
-platform_llm_id = { vertexai_openai = "google/gemini-1.5-flash" }
+platform_llm_id = { vertexai = "google/gemini-1.5-flash" }
[gemini."gemini-1.5-pro".latest]
is_gen_object_supported = true
is_vision_supported = true
max_prompt_images = 3000
cost_per_million_tokens_usd = { input = 1.25, output = 5.0 }
-platform_llm_id = { vertexai_openai = "google/gemini-1.5-pro" }
+platform_llm_id = { vertexai = "google/gemini-1.5-pro" }
[gemini."gemini-2.0-flash".latest]
is_gen_object_supported = true
is_vision_supported = true
max_prompt_images = 3000
cost_per_million_tokens_usd = { input = 0.1, output = 0.4 }
-platform_llm_id = { vertexai_openai = "google/gemini-2.0-flash" }
+platform_llm_id = { vertexai = "google/gemini-2.0-flash" }
[gemini."gemini-2.5-pro".latest]
is_gen_object_supported = true
is_vision_supported = true
max_prompt_images = 3000
cost_per_million_tokens_usd = { input = 0.0, output = 0.0 }
-platform_llm_id = { vertexai_openai = "google/gemini-2.5-pro-preview-05-06" }
+platform_llm_id = { vertexai = "google/gemini-2.5-pro-preview-05-06" }
[gemini."gemini-2.5-flash"."2025-04-17"]
is_gen_object_supported = true
is_vision_supported = true
max_prompt_images = 3000
cost_per_million_tokens_usd = { input = 0.15, output = 0.6 }
-platform_llm_id = { vertexai_openai = "google/gemini-2.5-flash-preview-04-17" }
+platform_llm_id = { vertexai = "google/gemini-2.5-flash-preview-04-17" }
[gemini."gemini-2.5-flash".latest]
is_gen_object_supported = true
is_vision_supported = true
max_prompt_images = 3000
cost_per_million_tokens_usd = { input = 0.15, output = 0.6 }
-platform_llm_id = { vertexai_openai = "google/gemini-2.5-flash-preview-05-20" }
+platform_llm_id = { vertexai = "google/gemini-2.5-flash-preview-05-20" }
diff --git a/pipelex/plugins/openai/openai_factory.py b/pipelex/plugins/openai/openai_factory.py
index 5fb4ae1d8..7cc9b6554 100644
--- a/pipelex/plugins/openai/openai_factory.py
+++ b/pipelex/plugins/openai/openai_factory.py
@@ -53,7 +53,7 @@ class OpenAIFactory:
openai_openai_config = get_config().plugins.openai_config
api_key = openai_openai_config.get_api_key(secrets_provider=get_secrets_provider())
the_client = openai.AsyncOpenAI(api_key=api_key)
- case LLMPlatform.VERTEXAI_OPENAI:
+ case LLMPlatform.VERTEXAI:
vertexai_config = get_config().plugins.vertexai_config
endpoint, api_key = vertexai_config.configure(secrets_provider=get_secrets_provider())
@@ -71,7 +71,7 @@ class OpenAIFactory:
api_key=api_key,
base_url=endpoint,
)
- case LLMPlatform.CUSTOM_OPENAI:
+ case LLMPlatform.CUSTOM_LLM:
custom_endpoint_config = get_config().plugins.custom_endpoint_config
base_url, api_key = custom_endpoint_config.configure(secrets_provider=get_secrets_provider())
diff --git a/pipelex/plugins/openai/openai_llm_worker.py b/pipelex/plugins/openai/openai_llm_worker.py
index 5d6c584a6..f027d3561 100644
--- a/pipelex/plugins/openai/openai_llm_worker.py
+++ b/pipelex/plugins/openai/openai_llm_worker.py
@@ -84,6 +84,8 @@ class OpenAILLMWorker(LLMWorkerAbstract):
| LLMFamily.GPT_4O
| LLMFamily.CUSTOM_LLAMA_4
| LLMFamily.CUSTOM_GEMMA_3
+ | LLMFamily.CUSTOM_MISTRAL_SMALL_3_1
+ | LLMFamily.CUSTOM_QWEN_3
| LLMFamily.PERPLEXITY_SEARCH
| LLMFamily.PERPLEXITY_RESEARCH
| LLMFamily.PERPLEXITY_REASONING
@@ -183,6 +185,8 @@ class OpenAILLMWorker(LLMWorkerAbstract):
| LLMFamily.GPT_4O
| LLMFamily.CUSTOM_LLAMA_4
| LLMFamily.CUSTOM_GEMMA_3
+ | LLMFamily.CUSTOM_MISTRAL_SMALL_3_1
+ | LLMFamily.CUSTOM_QWEN_3
| LLMFamily.PERPLEXITY_SEARCH
| LLMFamily.PERPLEXITY_RESEARCH
| LLMFamily.PERPLEXITY_REASONING
diff --git a/pipelex/plugins/openai/openai_llms.py b/pipelex/plugins/openai/openai_llms.py
index 4227709a5..93718486b 100644
--- a/pipelex/plugins/openai/openai_llms.py
+++ b/pipelex/plugins/openai/openai_llms.py
@@ -10,7 +10,7 @@ from pipelex.plugins.openai.openai_factory import OpenAIFactory
async def openai_list_available_models(llm_platform: LLMPlatform) -> List[Model]:
openai_client_async = OpenAIFactory.make_openai_client(llm_platform=llm_platform)
match llm_platform:
- case LLMPlatform.VERTEXAI_OPENAI | LLMPlatform.PERPLEXITY:
+ case LLMPlatform.VERTEXAI | LLMPlatform.PERPLEXITY:
raise LLMSDKError(f"Platform '{llm_platform}' does not support listing models with OpenAI SDK")
case _:
pass
diff --git a/pipelex/tools/templating/template_preprocessor.py b/pipelex/tools/templating/template_preprocessor.py
index 1bef8981f..115e97859 100644
--- a/pipelex/tools/templating/template_preprocessor.py
+++ b/pipelex/tools/templating/template_preprocessor.py
@@ -69,19 +69,19 @@ def preprocess_template(template: str) -> str:
# TODO: allow escape patterns
# Replace @?variable patterns (optional insertion) - must come before @variable
- new_template = re.sub(r"@\?([a-zA-Z0-9_.]+)", replace_optional_at_variable, processed_template)
+ new_template = re.sub(r"@\?(?![0-9])([a-zA-Z0-9_.]+)", replace_optional_at_variable, processed_template)
if new_template != processed_template:
changes_made = True
processed_template = new_template
# Replace @variable patterns
- new_template = re.sub(r"@([a-zA-Z0-9_.]+)", replace_at_variable, processed_template)
+ new_template = re.sub(r"@(?![0-9])([a-zA-Z0-9_.]+)", replace_at_variable, processed_template)
if new_template != processed_template:
changes_made = True
processed_template = new_template
# Replace $variable patterns
- new_template = re.sub(r"\$([a-zA-Z0-9_.]+)", replace_dollar_variable, processed_template)
+ new_template = re.sub(r"\$(?![0-9])([a-zA-Z0-9_.]+)", replace_dollar_variable, processed_template)
if new_template != processed_template:
changes_made = True
processed_template = new_template
diff --git a/tests/pipelex/cogt/conftest.py b/tests/pipelex/cogt/conftest.py
index 18959e70a..f5f68ca3c 100644
--- a/tests/pipelex/cogt/conftest.py
+++ b/tests/pipelex/cogt/conftest.py
@@ -70,6 +70,8 @@ def llm_handle(request: pytest.FixtureRequest) -> str:
# "gemini-2-pro",
# "gemini-2-5-pro",
# "gemini-2-5-flash",
+ # "mistral-small3.1",
+ # "qwen3:8b",
]
)
def llm_handle_for_vision(request: pytest.FixtureRequest) -> str:
@@ -128,7 +130,7 @@ def llm_creator(request: pytest.FixtureRequest) -> LLMCreator:
LLMPlatform.OPENAI,
# LLMPlatform.PERPLEXITY,
# LLMPlatform.VERTEXAI_OPENAI,
- # LLMPlatform.CUSTOM_OPENAI,
+ # LLMPlatform.CUSTOM_LLM,
# LLMPlatform.XAI,
]
)
@@ -158,6 +160,8 @@ def llm_platform(request: pytest.FixtureRequest) -> LLMPlatform:
# "sonar-pro",
# "gemma3:4b",
# "llama4:scout",
+ # "mistral-small3.1:24b",
+ # "qwen3:8b",
]
)
def llm_id(request: pytest.FixtureRequest) -> str:
diff --git a/tests/tools/templating/test_template_preprocessor.py b/tests/tools/templating/test_template_preprocessor.py
index ba72b0d44..16be6635c 100644
--- a/tests/tools/templating/test_template_preprocessor.py
+++ b/tests/tools/templating/test_template_preprocessor.py
@@ -80,3 +80,45 @@ Optional notes:
result = preprocess_template(template)
expected = '{% if optional %}{{ optional|tag("optional") }}{% endif %} {{ required|tag("required") }}'
assert result == expected
+
+ def test_dollar_amounts_not_processed(self):
+ """Test that dollar amounts are not processed as variables."""
+ template = "The price is $10M and the budget is $1000.50"
+ result = preprocess_template(template)
+ assert result == template
+
+ def test_mixed_dollar_amounts_and_variables(self):
+ """Test mixing dollar amounts with dollar variables."""
+ template = "The price is $10M and the budget is $budget_amount"
+ result = preprocess_template(template)
+ expected = "The price is $10M and the budget is {{ budget_amount|format() }}"
+ assert result == expected
+
+ def test_dollar_amounts_with_spaces(self):
+ """Test dollar amounts with spaces after the dollar sign."""
+ template = "The price is $ 10M and the budget is $ 1000.50"
+ result = preprocess_template(template)
+ assert result == template
+
+ def test_at_with_numbers_not_processed(self):
+ """Test that @ patterns followed by numbers are not processed."""
+ template = "The version is @1.0 and the build is @2.3.4"
+ result = preprocess_template(template)
+ assert result == template
+
+ def test_optional_at_with_numbers_not_processed(self):
+ """Test that @? patterns followed by numbers are not processed."""
+ template = "The version is @?1.0 and the build is @?2.3.4"
+ result = preprocess_template(template)
+ assert result == template
+
+ def test_mixed_at_patterns_with_numbers(self):
+ """Test mixing @ patterns with numbers and valid variables."""
+ template = "Version @1.0, build @?2.3.4, and @valid_var with @?optional_var"
+ result = preprocess_template(template)
+ expected = (
+ "Version @1.0, build @?2.3.4, and "
+ '{{ valid_var|tag("valid_var") }} with '
+ '{% if optional_var %}{{ optional_var|tag("optional_var") }}{% endif %}'
+ )
+ assert result == expected