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.

Initial commit

thomashebrardec0a78307697
diff --git a/.cursor/rules/llms.mdc b/.cursor/rules/llms.mdc
new file mode 100644
index 000000000..5951a1ab4
--- /dev/null
+++ b/.cursor/rules/llms.mdc
@@ -0,0 +1,75 @@
+---
+description: Use LLM models with approrpiate settings. Define LLM handles. Define LLM parameters directly in PipeLLM or through presets.
+globs:
+alwaysApply: false
+---
+# Rules to choose LLM models used in PipeLLMs.
+
+In order to use it in a pipe, an LLM is referenced by its llm_handle and possibly by an llm_preset.
+Both llm_handles and llm_presets are defined in this toml config file: [config_pipelex_llm_deck.toml](mdc:pipelex/config_pipelex_llm_deck.toml)
+
+## LLM Handles
+
+An llm_handle matches the handle (an id of sorts) with the full specification of the LLM to use, i.e.:
+- llm_name
+- llm_version
+- llm_platform_choice
+
+The declaration looks like this in toml syntax:
+```toml
+[cogt.llm_config.llm_deck.llm_handle_to_llm_engine_blueprint.gpt-4o-2024-05-13]
+llm_name = "gpt-4o"
+llm_version = "2024-05-13"
+llm_platform_choice = "openai"
+```
+
+In mosty cases, we only want to use version "latest" and llm_platform_choice "default" in which case the declaration is simply a match of the llm_handle to the llm_name, like this:
+```toml
+gemini-2-5-pro = "gemini-2.5-pro"
+```
+
+## Using an LLM Handle in a PipeLLM
+
+Here is an example of using an llm_handle to specify which LLM to use in a PipeLLM:
+
+```toml
+[pipe.hello_world]
+PipeLLM = "Write text about Hello World."
+output = "Text"
+llm = { llm_handle = "gpt-4o-mini", temperature = 0.9, max_tokens = "auto" }
+prompt = """
+Write a haiku about Hello World.
+"""
+```
+
+As you can see, to use the LLM, you must also indicate the temperature (float between 0 and 1) and max_tokens (either an int or the string "auto").
+
+## LLM Presets
+
+Presets are meant to record the choice of an llm with its hyper parameters (temperature and max_tokens) if it's good for a particular task. LLM Presets are skill-oriented.
+
+Examples:
+```toml
+llm_to_reason = { llm_handle = "o4-mini", temperature = 1, max_tokens = "auto" }
+llm_to_extract_invoice = { llm_handle = "claude-3-7-sonnet", temperature = 0.1, max_tokens = "auto" }
+```
+
+The interest is that these presets can be used to set the LLM choice in a PipeLLM, like this:
+
+```toml
+[pipe.extract_invoice]
+PipeLLM = "Extract invoice information from an invoice text transcript"
+input = "InvoiceText"
+output = "Invoice"
+llm = "llm_to_extract_invoice"
+prompt_template = """
+Extract invoice information from this invoice:
+
+The category of this invoice is: $invoice_details.category.
+
+@invoice_text
+"""
+```
+
+The setting here `llm = "llm_to_extract_invoice"` works because "llm_to_extract_invoice" has been declared as an llm_preset in the deck.
+You must not use an LLM preset in a PipeLLM that does not exist in the deck. If needed, you can add llm presets.
diff --git a/.cursor/rules/pipes.mdc b/.cursor/rules/pipes.mdc
new file mode 100644
index 000000000..6f61c7ac7
--- /dev/null
+++ b/.cursor/rules/pipes.mdc
@@ -0,0 +1,215 @@
+---
+description:
+globs: **/pipelex_libraries/pipelines/toml/**/*.toml
+alwaysApply: false
+---
+This rule explains how to build pipes.
+
+# File Naming & Structure
+
+## The pipelines/ directory
+
+- Pipelines and structures are defined in the `pipelex/pipelex_libraries/pipelines/` directory
+
+pipelex/pipelex_libraries
+└── pipelines
+ ├── structures
+ └── toml
+
+## Pipeline file naming
+
+- Pipeline TOML files should be placed in the `pipelex/pipelex_libraries/pipelines/toml/` directory or a subdirectory of it
+- The file name should be descriptive, in snake_case and end with `.toml`
+- The file should contain both concepts and pipes definitions
+
+## Pipeline file structure
+
+1- Domain statement (name, definition, other attributes)
+2- Concept definitions
+3- Pipe definitions
+
+# Domain statement
+
+- Format: `domain = "domain_name"`
+- Add a definition: `definition = "Description of the domain"`
+- Note: the domain name is usually the toml filename for domains that fit in a single toml file. Otherwise, the domain name should be the name of the subdirectory where the files of the domain are gathered
+
+# Concept definitions
+
+- Start with `[concept]` header
+- Naming: concepts are PascalCase, like python classes (e.g., `GanttTaskDetails`, `HtmlTable`)
+- Define the concept, i.e. just state what it means.
+ - Never include the usage context in the concept. The concept indicates what the stuff is in itself, it's not "for something", it just is something. e.g. don't define "TextToSummarize": it's just "Text". If you want to refine the concept for instance you can define "Essay".
+ - In particular, never define a concept as a plural form: if the context of the pipeline execution makes it multiple, it will just be handled using a ListContent (see below). e.g. don't define a concept for "Stories", just define "Story".
+ - Also, avoid including adjectives in concepts, e.g. don't define "LargeText", it's just "Text".
+
+- Define concepts in one of two ways:
+
+## Simple text-based concept definition
+
+```toml
+[concept]
+ConceptName = "Description of the concept"
+```
+
+## Detailed concept definition with `structure` and `refines`
+
+```toml
+[concept.ConceptName]
+Concept = "Description of the concept"
+structure = "StructureName"
+refines = ["ParentConcept"] # Optional, for concept inheritance
+```
+
+About the `structure` field:
+- It's Optional
+- It's the name of the Python BaseModel class used for the concept
+- The class must be a subclass of StuffContent
+- The class must be defined in a python module placed inside the `pipelex/pipelex_libraries/pipelines/structures/` directory
+- If the `structure` field is omitted but a class with the same name as the concept is defined in the structures directory, then it's implicitly applied to the concept
+
+About the `refines` field:
+- It's an Optional[List[str]]
+- It indicates that the concept refines one or several other concepts: "refines" in the sense that it makes things more specific. e.g. "Dog" refines "Animal" and "Pet"
+- As of this version, concept "refines" declaration are purely semantic guides
+
+
+## Native structures
+
+Pipelex provides the following structures natively:
+
+- TextContent (that one is used if you don't specify any structure and the Concept's name does not exist as a structure class)
+- NumberContent
+- ImageContent
+- HtmlContent
+- MermaidContent
+- LLMPromptContent
+
+The native structures are implied when using the native concepts: "native.Text", "native.Number", "native.Image"... do you don't have the state it.
+
+Some subclasses of StuffContent exist which you should never use directly:
+- ListContent: this is used internally to manipulate a list of stuff, but you should NEVER define a plural concept
+- StructuredContent
+- DynamicContent
+
+# Pipes Section
+
+- Start with `[pipe]` header
+- Naming: pipe names are snake_case, like python functions (e.g., `extract_gantt_tasks`)
+- Define pipes using as PipeLLM, PipeSequence, PipeParallel, PipeCondition
+
+# Full pipeline toml template
+
+Get inspiration from this template filled with appropriate examples:
+
+```toml
+domain = "template"
+definition = "Template file demonstrating different pipe types in Pipelex"
+
+[concept]
+InputText = "A text input for processing"
+OutputText = "A processed text output"
+TableScreenshot = "An image of a table"
+HtmlTable = "An HTML table representation"
+Question = "A question to be answered"
+FormattedAnswer = "A formatted answer to a question"
+ExpenseReportText = "Text content of an expense report"
+Composite = "A composite output containing multiple pieces of information"
+Expense = "An expense record"
+RulesToApply = "Rules to be applied to an expense"
+
+[pipe] ##############
+
+# Example of a PipeLLM that uses no input
+[pipe.write_poem]
+PipeLLM = "Write a poem"
+output = "Text"
+llm = "llm_for_creative_writing"
+prompt = """
+Write a poem about an AI that meets a Software and they fall in l0ve.
+"""
+
+# Example of a PipeLLM that uses @ prefix to insert a block of text
+[pipe.process_text]
+PipeLLM = "Process input text using an LLM"
+input = "Text"
+output = "Text"
+llm = "llm_to_summarize_text"
+system_prompt = """
+You are an expert in text summarization.
+"""
+prompt_template = """
+Summarize the following text:
+
+@text
+
+"""
+
+# Example of a PipeLLM that uses @ prefix to insert a block of text but also a $ prefix to insert text inline in a sentence (that is teh case for the $topic)
+[pipe.summarize_topic]
+PipeLLM = "Summarize a dense text with of focus on a specific topic."
+input = "Topic"
+output = "Summary"
+prompt_template = """
+Your goal is to summarize everything related to $topic in the provided text:
+
+@text
+
+Please provide only the summary, with no additional text or explanations.
+Your summary should not be longer than 2 sentences.
+"""
+
+# Example of a PipeLLM with image vision processing by a VLM
+[pipe.get_html_table_from_image]
+PipeLLM = "Convert table screenshot to HTML"
+input = "TableScreenshot"
+output = "HtmlTable"
+images = ["table_screenshot"]
+system_prompt = """
+You are a vision-based table extractor.
+"""
+prompt = """
+You are given a picture (screenshot) of a table, taken from a PDF document.
+Your goal is to extract the table from the image **in html**.
+Make sure you do not forget any text. Make sure you do not invent any text.
+Make sure your merge is consistent. Make sure you replicate the formatting
+(borders, text formatting, colors, text alignment...)
+"""
+llm = "llm_to_extract_tables"
+
+# Example of a PipeSequence
+[pipe.answer_question_with_instructions]
+PipeSequence = "Answer a question with instructions"
+input = "Question"
+output = "FormattedAnswer"
+steps = [
+ { pipe = "enrich_instructions", result = "instructions", },
+ { pipe = "answer_enriched_question", result = "answer" },
+ { pipe = "format_answer", result = "formatted_answer" },
+]
+
+# Example of a PipeParallel
+[pipe.extract_expense_report]
+PipeParallel = "Extract useful information from an expense report"
+input = "ExpenseReportText"
+output = "Composite"
+parallels = [
+ { pipe = "extract_employee_from_expense_report", result = "employee" },
+ { pipe = "extract_expenses_from_expense_report", result = "expenses" },
+]
+
+# Example of a PipeCondition
+[pipe.expense_conditional_validation]
+PipeCondition = "Choose the rules to apply"
+input = "Expense"
+output = "RulesToApply"
+expression = "expense_category.category"
+```
+
+# Building pipes
+
+When building a pipe:
+- First think about the logical steps you need to take. Then, plan the actual use of different patterns offered by Pipelex pipes, to apply them appropriately when you want to run things in sequence (PipeSequence) or in parallel, ot save time (PipeParallel).
+- Think about what PipeLLM you are going to need and which LLM skills they will need.
+- Write the pipe's toml and required structure in pipelex/pipelex_libraries/pipelines
+
diff --git a/.cursor/rules/piping.mdc b/.cursor/rules/piping.mdc
new file mode 100644
index 000000000..1858f28f0
--- /dev/null
+++ b/.cursor/rules/piping.mdc
@@ -0,0 +1,18 @@
+---
+description:
+globs:
+alwaysApply: false
+---
+Rules to write pipes:
+
+- To write the pipes toml, check out:
+[pipes.mdc](mdc:.cursor/rules/pipes.mdc)
+
+- To write the structure classes for concepts used in pipes with structured generations, check out:
+[structures.mdc](mdc:.cursor/rules/structures.mdc)
+
+- To write prompts using our telmplating syntax, check out:
+[prompt-templates.mdc](mdc:.cursor/rules/prompt-templates.mdc)
+
+- To choose an llm preset or define a new one, check out:
+[llms.mdc](mdc:.cursor/rules/llms.mdc)
diff --git a/.cursor/rules/prompt-templates.mdc b/.cursor/rules/prompt-templates.mdc
new file mode 100644
index 000000000..b8d086c04
--- /dev/null
+++ b/.cursor/rules/prompt-templates.mdc
@@ -0,0 +1,62 @@
+---
+description:
+globs: **/pipelex_libraries/pipelines/toml/**/*.toml
+alwaysApply: false
+---
+This rule explains how to write prompt templates in PipeLLM definitions. These prompts will be rendered and become the user_text or the system_prompt part of LLM chat completion queries.
+
+# Jinja2
+
+- We support jinja2 templates, so all the syntax capacities of jinja2 can be used such as variables inserted with double-curly-braces {{ like.this }}
+- But we don't support jinja2 importing other templates: our templates only work as self-contained
+
+# Preprocessing shorthands
+
+Before handing over templates to jinja2, we preprocess them in order to support a simpler more readable syntax that will generate jinja2 syntax to insert variables and use appropriate filters. Our shorthand syntax is presented here:
+
+## Insert stuff inside a tagged block
+
+If the inserted text is supposedly long text, made of several lines or paragraphs, you want it inserted inside a block, possibly a block tagged and delimlited with proper syntax as one would do in a markdown documentation. To include stuff as a block, use the "@" prefix.
+
+Example template:
+```python
+prompt_template = """
+Match the expense with its corresponding invoice:
+
+@expense
+
+@invoices
+"""
+```
+In this example, the expense data and the invoices data are obviously made of several lines each, that's why it makes sense to use the "@" prefix in order to have them delimited inside a block. Note that our preprocessor will automatically include the block's title, so it doens't need to be explictly written in the prompt template.
+
+**DO NOT write things like "Here is the expense: @expense".**
+**DO write simply "@expense" alone in an isolated line.**
+
+
+## Insert stuff inline
+
+If the inserted text is short text and it makes sense to have it inserted directly into a sentence, you want it inserted inline. To insert stuff inline, use the "$" prefix. This will insert the stuff without delimiters and the content will be rendered as plain text.
+
+Example template:
+```python
+prompt_template = """
+Your goal is to summarize everything related to $topic in the provided text:
+
+@text
+
+Please provide only the summary, with no additional text or explanations.
+Your summary should not be longer than 2 sentences.
+"""
+```
+
+Here, $topic will be inserted inline, whereas @text will be a a delimited block.
+Be sure to make the proper choice of prefix for each insertion.
+
+**DO NOT write "$topic" alone in an isolated line.**
+**DO write things like "Write an essay about $topic" included in an actual sentence.**
+
+## Style rule
+
+Always favor the @ and $ prefixes instead of the jinja2 double-curly-brackets syntax, unless explicitly instructed otherwise.
+
diff --git a/.cursor/rules/pydantic.mdc b/.cursor/rules/pydantic.mdc
new file mode 100644
index 000000000..777b15464
--- /dev/null
+++ b/.cursor/rules/pydantic.mdc
@@ -0,0 +1,14 @@
+---
+description:
+globs:
+alwaysApply: true
+---
+Rule to create BaseModels:
+
+- Respect Pydantic v2 standards
+- Keep models focused and single-purpose
+- Use descriptive field names
+- Use type hints for all fields
+- Document complex validations
+- Use Optional[] for nullable fields
+- Use Field(default_factory=...) for mutable defaults
diff --git a/.cursor/rules/pytest.mdc b/.cursor/rules/pytest.mdc
new file mode 100644
index 000000000..268bb9428
--- /dev/null
+++ b/.cursor/rules/pytest.mdc
@@ -0,0 +1,161 @@
+---
+description:
+globs: tests/**/*.py
+alwaysApply: false
+---
+These rules apply when writing unit tests.
+- Always use pytest
+
+## Test file structure
+
+- Name test files with `test_` prefix
+- Use descriptive names that match the functionality being tested
+- Place test files in the appropriate subdirectory of `tests/`:
+ - `tests/cogt/` for tests related to sub-package `pipelex.cogt`
+ - `tests/tools/` for tests related to sub-package `pipelex.tools`
+ - `tests/pipelex/` for tests related to `pipelex`and not its sub-packages
+- More precisely, for `pipelex` and `pipelex.cogt` place the tests inside subdirectories named either `asynch` for async test functions and `synchro` for normal non-async test functions
+
+## Markers
+
+Apply the appropriate markers:
+- "llm: uses an LLM to generate text or objects"
+- "imgg: uses an image generation AI"
+- "inference: uses either an LLM or an image generation AI"
+- "gha_disabled: will not be able to run properly on GitHub Actions"
+
+Several markers may be applied. For instance, if the test uses an LLM, then it uses inference, so you must mark with both `inference`and `llm`.
+
+## Test Class Structure
+
+Always group the tests of a module into a test class:
+
+```python
[email protected](loop_scope="class")
+class TestFooBar:
+ @pytest.mark.parametrize(
+ "topic test_case_blueprint",
+ [
+ TestCases.CASE_1,
+ TestCases.CASE_2,
+ ],
+ )
+ async def test_pipe_processing(
+ self,
+ request: FixtureRequest,
+ topic: str,
+ test_case_blueprint: StuffBlueprint,
+ ):
+ # Test implementation
+```
+
+Sometimes it can be convenient to access the test's name in its body, for instance to include into a job_id. To achieve that, add the argument `request: FixtureRequest` into the signature and then you can get th test name using `cast(str, request.node.originalname), # type: ignore`.
+
+# Pipe tests
+
+## Required imports for pipe tests
+
+```python
+import pytest
+from pytest import FixtureRequest
+from pipelex import log, pretty_print
+from pipelex.core.stuff_factory import StuffBlueprint, StuffFactory
+from pipelex.core.working_memory_factory import WorkingMemoryFactory
+from pipelex.hub import get_report_delegate
+from pipelex_libraries.pipelines.base_library.retrieve import RetrievedExcerpt
+from pipelex.config_pipelex import get_config
+
+from pipelex.core.pipe import PipeAbstract, update_job_metadata_for_pipe
+from pipelex.core.pipe_output import PipeOutput, PipeOutputType
+from pipelex.core.pipe_run_params import PipeRunParams
+from pipelex.core.pipe_run_params import PipeRunParams
+from pipelex.pipe_works.pipe_router_protocol import PipeRouterProtocol
+```
+
+## Pipe test implementation steps
+
+1. Create Stuff from blueprint:
+
+```python
+stuff = StuffFactory.make_stuff(
+ concept_code="RetrievedExcerpt",
+ domain="retrieve",
+ content=RetrievedExcerpt(text="<Some retrieved text>", justification="<Some justification>")
+ name="retrieved_text",
+)
+```
+
+2. Create Working Memory:
+
+```python
+working_memory = WorkingMemoryFactory.make_from_single_stuff(stuff=stuff)
+```
+
+3. Run the pipe:
+
+```python
+pipe_output: PipeOutput = await pipe_router.run_pipe(
+ pipe_code="pipe_name",
+ pipe_run_params=PipeRunParamsFactory.make_run_params(),
+ working_memory=working_memory,
+ job_metadata=JobMetadata(
+
+ top_job_id=cast(str, request.node.originalname), # type: ignore
+ ),
+)
+```
+
+4. Log output and generate report:
+
+```python
+pretty_print(pipe_output, title=f"Pipe output")
+get_report_delegate().generate_report()
+```
+
+5. Basic assertions:
+
+```python
+assert pipe_output is not None
+assert pipe_output.working_memory is not None
+assert pipe_output.main_stuff is not None
+```
+
+## Test Data Organization
+
+- If it's not already there, create a `test_data.py` file in the test directory
+- Define test cases using `StuffBlueprint`:
+
+```python
+class TestCases:
+ CASE_BLUEPRINT_1 = StuffBlueprint(
+ name="test_case_1",
+ concept_code="domain.ConceptName1",
+ value="test_value"
+ )
+ CASE_BLUEPRINT_2 = StuffBlueprint(
+ name="test_case_2",
+ concept_code="domain.ConceptName2",
+ value="test_value"
+ )
+
+ CASE_BLUEPRINTS: ClassVar[List[Tuple[str, str]]] = [ # topic, blueprint"
+ ("topic1", CASE_BLUEPRINT_1),
+ ("topic2", CASE_BLUEPRINT_2),
+ ]
+```
+
+Note how we avoid initializing a default mutable value within a class instance, instead we use ClassVar.
+Also note that we provide a topic for the test case, which is purely for convenience.
+
+## Best Practices for Testing
+
+- Use parametrize for multiple test cases
+- Test both success and failure cases
+- Verify working memory state
+- Check output structure and content
+- Use meaningful test case names
+- Include docstrings explaining test purpose
+- Log outputs for debugging
+- Generate reports for cost tracking
diff --git a/.cursor/rules/structures.mdc b/.cursor/rules/structures.mdc
new file mode 100644
index 000000000..e064b5bbb
--- /dev/null
+++ b/.cursor/rules/structures.mdc
@@ -0,0 +1,52 @@
+---
+description:
+globs: **/pipelex_libraries/pipelines/structures/**/*.py
+alwaysApply: false
+---
+Rules to write structure classes for concepts used in pipes with structured generations.
+In particular, these structures are generated by PipeLLM using structured generation.
+
+# Structured Models Rules
+
+## Model Location and Registration
+
+- Create models for structured generations related to "some_domain" in `pipelex/pipelex_libraries/pipelines/structures/<some_domain>.py`
+- Models must inherit from `StructuredContent` or appropriate content type
+
+## Model Structure
+
+```python
+from datetime import datetime
+from typing import List, Optional
+from pydantic import BaseModel, Field
+
+from pipelex.core.stuff_content import StructuredContent
+
+class YourModel(StructuredContent):
+ # Required fields
+ field1: str
+ field2: int
+
+ # Optional fields with defaults
+ field3: Optional[str] = Field(None, "Description of field3")
+ field4: List[str] = Field(default_factory=list)
+
+ # Date fields should remove timezone
+ date_field: Optional[datetime] = None
+
+ @field_validator("date_field")
+ @classmethod
+ def remove_tzinfo(cls, v: Optional[datetime]) -> Optional[datetime]:
+ if v is not None:
+ return v.replace(tzinfo=None)
+ return v
+```
+
+## Best Practices for structures
+
+- Respect Pydantic v2 standards
+- Use type hints for all fields
+- Use `Field` declaration and write the description
+- Use Pydantic validators for data cleaning/validation
+- Remove timezone info from datetime fields
+- Respect rules of [pydantic.mdc](mdc:.cursor/rules/pydantic.mdc)
diff --git a/.cursorignore b/.cursorignore
new file mode 100644
index 000000000..c342f09bf
--- /dev/null
+++ b/.cursorignore
@@ -0,0 +1,3 @@
+
+
+dist/
diff --git a/.env.example b/.env.example
new file mode 100644
index 000000000..d4a212441
--- /dev/null
+++ b/.env.example
@@ -0,0 +1,22 @@
+PYRIGHT_PYTHON_FORCE_VERSION=1.1.398
+
+OPENAI_API_KEY=
+
+AWS_ACCESS_KEY_ID=
+AWS_SECRET_ACCESS_KEY=
+AWS_REGION=
+
+AZURE_OPENAI_ENDPOINT=
+AZURE_OPENAI_API_VERSION=
+AZURE_OPENAI_API_KEY=
+AZURE_OPENAI_API_KEY_METHOD=
+
+GCP_CREDENTIALS_FILE_PATH=
+
+ANTHROPIC_API_KEY=
+
+MISTRAL_API_KEY=
+
+PERPLEXITY_API_KEY=
+
+FAL_API_KEY=
diff --git a/.github/DISCUSSION_TEMPLATE/new_idea.md b/.github/DISCUSSION_TEMPLATE/new_idea.md
new file mode 100644
index 000000000..96bed86b8
--- /dev/null
+++ b/.github/DISCUSSION_TEMPLATE/new_idea.md
@@ -0,0 +1,52 @@
+### 🤔 What's the current challenge?
+
+<!--
+Describe the pain point or limitation you're experiencing in your workflow:
+- What's difficult or frustrating in your current process?
+- What are you trying to achieve but can't?
+- How does this impact your productivity?
+-->
+
+### 💡 Your Idea
+
+<!--
+Share your thoughts on how to address this challenge:
+- What's your proposed solution?
+- How would it work?
+- What would the user experience be like?
+-->
+
+### 🎯 Use Cases
+
+<!--
+Help us understand how you would use this in practice:
+- Describe specific scenarios where this would be valuable
+- What kind of projects would benefit from this?
+- How frequently would you use this feature?
+-->
+
+### 📈 Expected Impact
+
+<!--
+How would this idea improve your development experience?
+- What would this enable you to do better/faster?
+- How would this make your life easier?
+- Would this benefit other developers in your team?
+-->
+
+### 🤝 Community Benefit
+
+<!--
+How might this idea benefit the broader Pipelex community?
+- What types of developers would benefit?
+- How might this attract new users?
+- Could this enable new use cases?
+-->
+
+---
+
+<!--
+Before submitting:
+- [ ] I have searched existing discussions to avoid duplicates
+- [ ] I'm willing to participate in the discussion and provide additional context if needed
+-->
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
new file mode 100644
index 000000000..761e86048
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -0,0 +1,32 @@
+---
+name: Bug Report
+about: Create a report to help us improve
+title: "[BUG] "
+labels: bug
+assignees: ""
+---
+
+**Description**
+A clear and concise description of the bug.
+
+**To Reproduce**
+Steps to reproduce the behavior:
+
+1. Install version '...'
+2. Run command '...'
+3. See error
+
+**Expected Behavior**
+What you expected to happen.
+
+**Actual Behavior**
+What actually happened.
+
+**Environment**
+
+- OS: [e.g. macOS 13.1]
+- Python version: [e.g. 3.11.2]
+- Package version: [e.g. 0.1.0]
+
+**Additional Context**
+Add any other context about the problem here.
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml
new file mode 100644
index 000000000..b68aa7f57
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug_report.yml
@@ -0,0 +1,65 @@
+name: 🐛 Report an Issue
+description: File a bug report to help improve Pipelex
+title: "bug: "
+labels: ["bug-unverified"]
+body:
+ - type: textarea
+ attributes:
+ label: Issue Description
+ description: Provide a clear and detailed description of the issue you encountered and what you expected to happen instead.
+ placeholder: |
+ What happened?
+ What did you expect to happen?
+ validations:
+ required: true
+
+ - type: textarea
+ attributes:
+ label: Reproduction Steps
+ description: Help us understand the issue by providing detailed steps to reproduce it. Include code examples, error messages, or configuration files if relevant.
+ placeholder: |
+ 1. Install package with '...'
+ 2. Configure pipeline with '...'
+ 3. Run the following code '...'
+ 4. Error occurs
+ validations:
+ required: true
+
+ - type: textarea
+ attributes:
+ label: Environment Details
+ description: Please provide information about your setup. This helps us identify if the issue is environment-specific.
+ placeholder: |
+ - Python Version:
+ - Pipelex Version:
+ - Operating System:
+ - Installation Method (pip/poetry/uv):
+ - Relevant Dependencies:
+
+ - type: textarea
+ attributes:
+ label: Additional Context
+ description: Add any other relevant information, screenshots, logs, or context that might help us understand and fix the issue.
+ placeholder: |
+ Error logs, related configuration, or other helpful details...
+
+ - type: dropdown
+ id: contribution
+ attributes:
+ label: Would you like to help fix this issue?
+ description: We welcome contributions and can provide guidance for first-time contributors!
+ options:
+ - "Not at this time"
+ - "Yes, I'd like to contribute"
+ validations:
+ required: true
+
+ - type: checkboxes
+ attributes:
+ label: Confirmations
+ description: Please confirm the following
+ options:
+ - label: I have checked that this issue hasn't already been reported
+ required: true
+ - label: I have tested with the latest version of Pipelex
+ required: true
\ No newline at end of file
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
new file mode 100644
index 000000000..69845f490
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -0,0 +1,19 @@
+---
+name: Feature Request
+about: Suggest an idea for this project
+title: "[FEATURE] "
+labels: enhancement
+assignees: ""
+---
+
+**Problem Statement**
+A clear and concise description of the problem you want to solve.
+
+**Proposed Solution**
+A clear and concise description of what you want to happen.
+
+**Alternative Solutions**
+Any alternative solutions or features you've considered.
+
+**Additional Context**
+Add any other context or screenshots about the feature request here.
diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml
new file mode 100644
index 000000000..a32483da0
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/feature_request.yml
@@ -0,0 +1,62 @@
+name: 💡 Feature Request
+description: Suggest a new feature or improvement
+title: "feat: "
+labels: ["enhancement"]
+body:
+ - type: textarea
+ attributes:
+ label: Problem Statement
+ description: Describe the problem you're trying to solve or the limitation you're facing.
+ placeholder: |
+ What's the challenge you're encountering?
+ Why is this important to address?
+ validations:
+ required: true
+
+ - type: textarea
+ attributes:
+ label: Proposed Solution
+ description: Describe your ideal solution to the problem. Be as specific as possible.
+ placeholder: |
+ How would you like this to work?
+ What would the user experience be like?
+ validations:
+ required: true
+
+ - type: textarea
+ attributes:
+ label: Alternative Approaches
+ description: Describe any alternative solutions or features you've considered.
+ placeholder: |
+ What other ways might this problem be solved?
+ What are the trade-offs of different approaches?
+
+ - type: textarea
+ attributes:
+ label: Implementation Ideas
+ description: If you have any thoughts on how this could be implemented, share them here.
+ placeholder: |
+ Technical considerations
+ Potential challenges
+ Integration points
+
+ - type: dropdown
+ id: contribution
+ attributes:
+ label: Would you like to help implement this feature?
+ description: We welcome contributions and can provide guidance!
+ options:
+ - "Not at this time"
+ - "Yes, I'd like to contribute"
+ validations:
+ required: true
+
+ - type: checkboxes
+ attributes:
+ label: Confirmations
+ description: Please confirm the following
+ options:
+ - label: I have searched for similar feature requests
+ required: true
+ - label: This feature would benefit the broader community
+ required: true
\ No newline at end of file
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
new file mode 100644
index 000000000..02818192d
--- /dev/null
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,23 @@
+
+### 🔗 Related Issues
+
+### 📝 Description
+
+### 🔄 Type of Change
+- [ ] 🐛 Bug fix
+- [ ] ✨ New feature
+- [ ] 💥 Breaking change
+- [ ] 📚 Documentation update
+- [ ] 🧹 Code refactor
+- [ ] ⚡ Performance improvement
+- [ ] ✅ Test update
+
+### 🧪 Tests
+
+### 📋 Checklist
+
+- [ ] Linting / type-checking / unit tests pass locally with my changes
+- [ ] I've added tests that prove my fix is effective or that my feature works
+- [ ] My code follows the style guidelines of this project
+- [ ] I've made corresponding changes to the documentation
+- [ ] My changes generate no new warnings
diff --git a/.github/assets/logo.png b/.github/assets/logo.png
new file mode 100644
index 000000000..1d32367a3
Binary files /dev/null and b/.github/assets/logo.png differ
diff --git a/.github/workflows/cla.yml b/.github/workflows/cla.yml
new file mode 100644
index 000000000..4ea9194cd
--- /dev/null
+++ b/.github/workflows/cla.yml
@@ -0,0 +1,31 @@
+name: "CLA Assistant bot"
+on:
+ issue_comment:
+ types: [created]
+ pull_request_target:
+ types: [opened, closed, synchronize]
+
+permissions:
+ actions: write
+ contents: read
+ pull-requests: write
+ statuses: write
+
+jobs:
+ CLAAssistant:
+ runs-on: ubuntu-latest
+ steps:
+ - name: "CLA Assistant"
+ if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target'
+ uses: contributor-assistant/[email protected]
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ PERSONAL_ACCESS_TOKEN: ${{ secrets.CLA_SIGNATURES }}
+ with:
+ path-to-signatures: "signatures/version1/cla.json"
+ path-to-document: "https://github.com/Pipelex/pipelex/blob/main/CLA.md"
+ branch: main
+ allowlist: lchoquel,thomashebrard,antoinepipelex,bot*
+ remote-organization-name: Pipelex
+ remote-repository-name: cla-signatures
+ signed-commit-message: "$contributorName has signed the CLA in $owner/$repo#$pullRequestNo"
diff --git a/.github/workflows/guard-branches.yml b/.github/workflows/guard-branches.yml
new file mode 100644
index 000000000..41b4509c1
--- /dev/null
+++ b/.github/workflows/guard-branches.yml
@@ -0,0 +1,63 @@
+name: Guard branch flow
+on:
+ pull_request_target:
+ types: [opened, edited, synchronize, reopened]
+
+jobs:
+ # ───────────────────────────────────────────────────────────────
+ # 1) Only release/vX.Y.Z → main
+ # ───────────────────────────────────────────────────────────────
+ gate-main:
+ if: github.event.pull_request.base.ref == 'main'
+ runs-on: ubuntu-latest
+ steps:
+ - name: Verify source branch is a Release
+ env:
+ HEAD: ${{ github.event.pull_request.head.ref }}
+ run: |
+ echo "PR → main from $HEAD"
+ if [[ ! "$HEAD" =~ ^release\/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
+ echo "::error::Only release/vX.Y.Z branches may merge into main."
+ exit 1
+ fi
+
+ # ───────────────────────────────────────────────────────────────
+ # 2) Only work-branches → release/vX.Y.Z
+ # ───────────────────────────────────────────────────────────────
+ gate-release:
+ if: startsWith(github.event.pull_request.base.ref, 'release/v') || github.event.pull_request.base.ref == 'dev'
+ runs-on: ubuntu-latest
+ steps:
+ - name: Verify source branch uses allowed prefix
+ env:
+ HEAD: ${{ github.event.pull_request.head.ref }}
+ run: |
+ echo "PR → ${{ github.event.pull_request.base.ref }} from $HEAD"
+ if [[ "$HEAD" == "dev" ]]; then
+ exit 0
+ fi
+ if [[ ! "$HEAD" =~ ^(fix|feature|refactor|chore|doc|ci-cd)\/[A-Za-z0-9._-]+$ ]]; then
+ echo "::error::Branch must start with fix/, feature/, refactor/, chore/, doc/, or ci-cd/."
+ exit 1
+ fi
+
+ # ───────────────────────────────────────────────────────────────
+ # 3) Prevent forks from editing your workflows
+ # ───────────────────────────────────────────────────────────────
+ protect-workflows:
+ runs-on: ubuntu-latest
+ # only block non-maintainers
+ if: github.event.pull_request.author_association == 'CONTRIBUTOR'
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+ - name: Detect workflow changes
+ run: |
+ git fetch origin "${{ github.event.pull_request.base.ref }}" --depth=1
+ CHANGED=$(git diff --name-only FETCH_HEAD HEAD | grep -E '^\.github/workflows/.*\.ya?ml$' || true)
+ if [ -n "$CHANGED" ]; then
+ echo "::error::External contributors may not modify workflow files: $CHANGED"
+ exit 1
+ fi
diff --git a/.github/workflows/lint-check.yml b/.github/workflows/lint-check.yml
new file mode 100644
index 000000000..eea9228b6
--- /dev/null
+++ b/.github/workflows/lint-check.yml
@@ -0,0 +1,38 @@
+name: Lint check
+
+on:
+ pull_request:
+ branches:
+ - main
+ - dev
+ - "release/v[0-9]+.[0-9]+.[0-9]+"
+
+jobs:
+ lint-check:
+ runs-on: ubuntu-latest
+ env:
+ VIRTUAL_ENV: ${{ github.workspace }}/.venv
+ steps:
+ - uses: actions/checkout@v2
+ - name: Set up Python
+ uses: actions/setup-python@v2
+ with:
+ python-version: "3.11"
+
+ - name: Install poetry package
+ run: pip install "poetry>=2.0.0,<2.1.0"
+
+ - name: Install dependencies
+ run: make install
+
+ - name: Run ruff format merge check
+ run: make merge-check-ruff-format
+
+ - name: Run ruff lint merge check
+ run: make merge-check-ruff-lint
+
+ - name: Run pyright merge check
+ run: make merge-check-pyright
+
+ - name: Run mypy merge check
+ run: make merge-check-mypy
diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml
new file mode 100644
index 000000000..2c33cdc21
--- /dev/null
+++ b/.github/workflows/publish-pypi.yml
@@ -0,0 +1,106 @@
+name: Publish Python 🐍 distribution 📦 to PyPI
+
+on:
+ push:
+ branches:
+ - main
+
+jobs:
+ build:
+ name: Build distribution 📦
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ persist-credentials: false
+ - name: Set up Python
+ uses: actions/setup-python@v5
+ with:
+ python-version: "3.x"
+ - name: Install pypa/build
+ run: >-
+ python3 -m
+ pip install
+ build
+ --user
+ - name: Build a binary wheel and a source tarball
+ run: python3 -m build
+ - name: Store the distribution packages
+ uses: actions/upload-artifact@v4
+ with:
+ name: python-package-distributions
+ path: dist/
+
+ publish-to-pypi:
+ name: >-
+ Publish Python 🐍 distribution 📦 to PyPI
+ needs:
+ - build
+ runs-on: ubuntu-latest
+ environment:
+ name: pypi
+ url: https://pypi.org/p/pipelex
+ permissions:
+ id-token: write # IMPORTANT: mandatory for trusted publishing
+
+ steps:
+ - name: Download all the dists
+ uses: actions/download-artifact@v4
+ with:
+ name: python-package-distributions
+ path: dist/
+ - name: Publish distribution 📦 to PyPI
+ uses: pypa/gh-action-pypi-publish@release/v1
+
+ github-release:
+ name: >-
+ Sign the Python 🐍 distribution 📦 with Sigstore
+ and upload them to GitHub Release
+ needs:
+ - publish-to-pypi
+ runs-on: ubuntu-latest
+
+ permissions:
+ contents: write # IMPORTANT: mandatory for making GitHub Releases
+ id-token: write # IMPORTANT: mandatory for sigstore
+
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ persist-credentials: false
+ - name: Extract version from pyproject.toml
+ id: get_version
+ run: |
+ VERSION=$(grep -m 1 'version = ' pyproject.toml | cut -d '"' -f 2)
+ echo "VERSION=$VERSION" >> $GITHUB_ENV
+ - name: Download all the dists
+ uses: actions/download-artifact@v4
+ with:
+ name: python-package-distributions
+ path: dist/
+ - name: Sign the dists with Sigstore
+ uses: sigstore/[email protected]
+ with:
+ inputs: >-
+ ./dist/*.tar.gz
+ ./dist/*.whl
+ - name: Create GitHub Release
+ env:
+ GITHUB_TOKEN: ${{ github.token }}
+ run: >-
+ gh release create
+ "v$VERSION"
+ --repo "$GITHUB_REPOSITORY"
+ --title "v$VERSION"
+ --notes ""
+ - name: Upload artifact signatures to GitHub Release
+ env:
+ GITHUB_TOKEN: ${{ github.token }}
+ # Upload to GitHub Release using the `gh` CLI.
+ # `dist/` contains the built packages, and the
+ # sigstore-produced signatures and certificates.
+ run: >-
+ gh release upload
+ "v$VERSION" dist/**
+ --repo "$GITHUB_REPOSITORY"
diff --git a/.github/workflows/tests-check.yml b/.github/workflows/tests-check.yml
new file mode 100644
index 000000000..f7af38666
--- /dev/null
+++ b/.github/workflows/tests-check.yml
@@ -0,0 +1,54 @@
+name: Tests check
+
+on:
+ pull_request:
+ branches:
+ - main
+ - dev
+ - "release/v[0-9]+.[0-9]+.[0-9]+"
+
+jobs:
+ tests-check:
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ id-token: write
+ env:
+ VIRTUAL_ENV: ${{ github.workspace }}/.venv
+ ENV: dev
+ GOOGLE_ENCRYPTED_CREDENTIALS_KEY: ${{ secrets.GOOGLE_ENCRYPTED_CREDENTIALS_KEY }}
+ GOOGLE_ENCRYPTED_CREDENTIALS_PATH: ${{ secrets.GOOGLE_ENCRYPTED_CREDENTIALS_PATH }}
+ COLUMNS: 120
+ steps:
+ - uses: actions/checkout@v2
+
+ - name: "Authenticate to Google Cloud"
+ uses: "google-github-actions/auth@v1"
+ with:
+ workload_identity_provider: "projects/634168471546/locations/global/workloadIdentityPools/github-wif/providers/githuboidc"
+ service_account: "[email protected]"
+
+ - name: "Get secret from Secret Manager"
+ id: get_secret
+ uses: "google-github-actions/get-secretmanager-secrets@v2"
+ with:
+ secrets: |-
+ GOOGLE_ENCRYPTED_CREDENTIALS:projects/634168471546/secrets/GOOGLE_ENCRYPTED_CREDENTIALS/versions/1
+
+ - name: "Create encrypted_credentials.txt file"
+ run: |
+ echo "${{ steps.get_secret.outputs.GOOGLE_ENCRYPTED_CREDENTIALS }}" > encrypted_credentials.txt
+
+ - name: Set up Python
+ uses: actions/setup-python@v2
+ with:
+ python-version: "3.11"
+
+ - name: Install poetry package
+ run: pip install "poetry>=2.0.0,<2.1.0"
+
+ - name: Install virtual env and dependencies from pyproject.toml
+ run: make install
+
+ - name: Run tests
+ run: make runtests
diff --git a/.github/workflows/version-check.yml b/.github/workflows/version-check.yml
new file mode 100644
index 000000000..a4e4d173c
--- /dev/null
+++ b/.github/workflows/version-check.yml
@@ -0,0 +1,134 @@
+name: Version check
+
+on:
+ pull_request:
+ branches:
+ - main
+ - "release/v[0-9]+.[0-9]+.[0-9]+"
+jobs:
+ version-check:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Get branch info
+ id: branch_info
+ run: |
+ echo "====== DEBUGGING BRANCH INFO ======"
+ echo "PR URL: ${{ github.event.pull_request.html_url }}"
+ echo "PR Number: ${{ github.event.pull_request.number }}"
+
+ BASE_BRANCH="${{ github.event.pull_request.base.ref }}"
+ SOURCE_BRANCH="${{ github.event.pull_request.head.ref }}"
+ echo "Source branch: $SOURCE_BRANCH"
+ echo "Target branch: $BASE_BRANCH"
+
+ echo "base_branch=$BASE_BRANCH" >> $GITHUB_OUTPUT
+ echo "source_branch=$SOURCE_BRANCH" >> $GITHUB_OUTPUT
+
+ # Check if target is a release branch
+ if [[ "$BASE_BRANCH" =~ ^release/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
+ echo "Target is a release branch"
+ echo "is_release_target=true" >> $GITHUB_OUTPUT
+ echo "target_release_version=${BASE_BRANCH#release/v}" >> $GITHUB_OUTPUT
+ echo "Extracted target release version: ${BASE_BRANCH#release/v}"
+ else
+ echo "Target is NOT a release branch"
+ echo "is_release_target=false" >> $GITHUB_OUTPUT
+ fi
+
+ # Check if source is a release branch
+ if [[ "$SOURCE_BRANCH" =~ ^release/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
+ echo "Source is a release branch"
+ echo "is_release_source=true" >> $GITHUB_OUTPUT
+ echo "source_release_version=${SOURCE_BRANCH#release/v}" >> $GITHUB_OUTPUT
+ echo "Extracted source release version: ${SOURCE_BRANCH#release/v}"
+ else
+ echo "Source is NOT a release branch"
+ echo "is_release_source=false" >> $GITHUB_OUTPUT
+ fi
+ echo "======================================="
+
+ - name: Checkout repo
+ uses: actions/checkout@v3
+ with:
+ fetch-depth: 0
+
+ - name: Get version from pyproject.toml
+ id: current_version
+ run: |
+ echo "====== DEBUGGING CURRENT VERSION ======"
+ VERSION=$(grep '^version' pyproject.toml | sed -E 's/version = "(.*)"/\1/')
+ echo "Current pyproject.toml version: $VERSION"
+ echo "version=$VERSION" >> $GITHUB_OUTPUT
+ echo "======================================="
+
+ # MAIN BRANCH CASE - Check that version is bumped
+ - name: Check version bump for main branch
+ if: steps.branch_info.outputs.base_branch == 'main'
+ run: |
+ echo "====== CHECKING VERSION BUMP FOR MAIN ======"
+ # Get version from main branch
+ git checkout ${{ github.event.pull_request.base.ref }}
+ MAIN_VERSION=$(grep '^version' pyproject.toml | sed -E 's/version = "(.*)"/\1/')
+
+ # Get version from PR branch
+ git checkout ${{ github.event.pull_request.head.sha }}
+ PR_VERSION="${{ steps.current_version.outputs.version }}"
+
+ echo "Main version: $MAIN_VERSION"
+ echo "PR version: $PR_VERSION"
+
+ # Check that PR version is greater than main version
+ if dpkg --compare-versions "$PR_VERSION" le "$MAIN_VERSION"; then
+ echo "❌ ERROR: PR version ($PR_VERSION) is not greater than main version ($MAIN_VERSION)."
+ echo "Please bump the version."
+ exit 1
+ else
+ echo "✅ Version was properly bumped from $MAIN_VERSION to $PR_VERSION"
+ fi
+ echo "======================================="
+
+ # TARGET RELEASE BRANCH CASE - Check that version matches release branch name
+ - name: Check version matches target release branch
+ if: steps.branch_info.outputs.is_release_target == 'true'
+ run: |
+ echo "====== CHECKING VERSION MATCH FOR TARGET RELEASE BRANCH ======"
+ # Extract version from branch name
+ RELEASE_VERSION="${{ steps.branch_info.outputs.target_release_version }}"
+
+ # Get version from PR branch
+ PR_VERSION="${{ steps.current_version.outputs.version }}"
+
+ echo "Target release branch version: $RELEASE_VERSION"
+ echo "PR version: $PR_VERSION"
+
+ # Check if versions match
+ if [[ "$PR_VERSION" != "$RELEASE_VERSION" ]]; then
+ echo "❌ ERROR: Version in pyproject.toml ($PR_VERSION) does not match target release branch version ($RELEASE_VERSION)"
+ exit 1
+ else
+ echo "✅ Version in pyproject.toml matches target release branch version"
+ fi
+ echo "======================================="
+
+ # SOURCE RELEASE BRANCH CASE - Check that version matches release branch name
+ - name: Check version matches source release branch
+ if: steps.branch_info.outputs.is_release_source == 'true'
+ run: |
+ echo "====== CHECKING VERSION MATCH FOR SOURCE RELEASE BRANCH ======"
+ # Extract version from branch name
+ RELEASE_VERSION="${{ steps.branch_info.outputs.source_release_version }}"
+
+ # Get version from PR branch
+ PR_VERSION="${{ steps.current_version.outputs.version }}"
+
+ echo "Source release branch version: $RELEASE_VERSION"
+ echo "PR version: $PR_VERSION"
+
+ # Check if versions match
+ if [[ "$PR_VERSION" != "$RELEASE_VERSION" ]]; then
+ echo "❌ ERROR: Version in pyproject.toml ($PR_VERSION) does not match source release branch version ($RELEASE_VERSION)"
+ exit 1
+ else
+ echo "✅ Version in pyproject.toml matches source release branch version"
+ fi
+ echo "======================================="
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000000000..196c6b21f
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,50 @@
+
+
+# Byte-compiled / optimized / DLL files
+__pycache__/
+*.py[cod]
+*$py.class
+
+# Distribution / packaging
+dist/
+build/
+*.egg-info/
+
+# Unit test / coverage reports
+htmlcov/
+.pytest_cache/
+.coverage
+coverage.xml
+
+# Environments
+.env
+.venv
+env/
+venv/
+ENV/
+env.bak/
+venv.bak/
+
+# mypy
+.mypy_cache/
+
+# Ruff
+.ruff_cache/
+
+# General System Files
+*.log
+.DS_Store
+Thumbs.db
+
+# Files generated by unit tests
+reports/
+results/
+
+# Pipelex libraries, duplicated from pipelex/libraries/ by `pipelex init`
+pipelex_libraries/
+
+# personnal pipelex config file that overrides the default one
+pipelex_super.toml
+
+# temporary files
+temp/
diff --git a/.vscode/launch.json b/.vscode/launch.json
new file mode 100644
index 000000000..603ab5c97
--- /dev/null
+++ b/.vscode/launch.json
@@ -0,0 +1,47 @@
+{
+ // Use IntelliSense to learn about possible attributes.
+ // Hover to view descriptions of existing attributes.
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "name": "Debug tests",
+ "type": "debugpy",
+ "request": "launch",
+ "module": "pytest",
+ "args": [
+ "-s",
+ "-vv",
+ "-m inference",
+ "-k test_pipe_run"
+ ],
+ "console": "integratedTerminal"
+ },
+ {
+ "name": "Debug legacy check",
+ "type": "debugpy",
+ "request": "launch",
+ "module": "pipelex.cli._cli",
+ "args": [
+ "check",
+ ],
+ "console": "integratedTerminal",
+ "justMyCode": true
+ },
+ {
+ "name": "Debug Expense Report",
+ "type": "debugpy",
+ "request": "launch",
+ "module": "pipelex.cli",
+ "args": [
+ "expense",
+ "--pipe",
+ "process_expense_report",
+ "--expense-report",
+ "expense_report_diner"
+ ],
+ "console": "integratedTerminal",
+ "justMyCode": false
+ }
+ ]
+}
\ No newline at end of file
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 000000000..f06faf615
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,23 @@
+{
+ "[python]": {
+ "editor.defaultFormatter": "charliermarsh.ruff"
+ },
+ "ruff.configuration": "--config=pyproject.toml",
+ "mypy.enabled": true,
+ "mypy.runUsingActiveInterpreter": true,
+ "search.exclude": {
+ ".mypy_cache/*": true,
+ "**/dev_context": true
+ },
+ "files.exclude": {
+ "**/__pycache__": true,
+ ".mypy_cache": true,
+ ".pytest_cache": true,
+ ".ruff_cache": true,
+ },
+ "python.testing.pytestArgs": [
+ "tests"
+ ],
+ "python.testing.unittestEnabled": false,
+ "python.testing.pytestEnabled": true
+}
\ No newline at end of file
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
new file mode 100644
index 000000000..3c6da0647
--- /dev/null
+++ b/.vscode/tasks.json
@@ -0,0 +1,29 @@
+{
+ "version": "2.0.0",
+ "tasks": [
+ {
+ "label": "make c",
+ "type": "shell",
+ "command": "make",
+ "args": [
+ "c",
+ ],
+ "group": {
+ "kind": "build",
+ "isDefault": true
+ }
+ },
+ {
+ "label": "make run-setup",
+ "type": "shell",
+ "command": "make",
+ "args": [
+ "run-setup",
+ ],
+ "group": {
+ "kind": "test",
+ "isDefault": true
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 000000000..6da85873a
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,38 @@
+# Changelog
+
+## [v0.2.6] - 2025-05-26
+
+- Refactor: use ActivityManagerProtocol, rename BaseModelTypeVar
+
+## [v0.2.5] - 2025-05-25
+
+- Add custom LLM integration via OpenAI sdk with custom base_url
+
+## [v0.2.4] - 2025-05-25
+
+- Tidy tools
+- Tidy inference API plugins
+- Tidy WIP feature ActivityManager
+- Replace license ELv2 by MIT and remove Reuse dependency
+
+## [v0.2.2] - 2025-05-22
+
+- Simplify the use of native concepts
+- Include "page views" in the outputs of Ocr features
+
+## [v0.2.1] - 2025-05-22
+
+- Added OcrWorkerAbstract and MistralOcrWorker, along with PipeOcr for OCR processing of images and PDFs.
+- Introduced MissionManager for managing missions, cost reports, and activity tracking.
+- Added detection and handling for pipe stack overflow, configurable with pipe_stack_limit.
+- More possibilities for dependency injection and better class structure.
+- Misc updates including simplified PR template, LLM deck overrides, removal of unused config vars, and disabling of an LLM platform id.
+
+## [v0.2.0] - 2025-05-19
+
+- Added OCR, thanks to Mistral
+- Refactoring and cleanup
+
+## [v0.1.14] - 2025-05-13
+
+- Initial release 🎉
diff --git a/CLA.md b/CLA.md
new file mode 100644
index 000000000..9991f30cc
--- /dev/null
+++ b/CLA.md
@@ -0,0 +1,94 @@
+# Pipelex (Evotis SAS) Grant and Contributor License Agreement (“Agreement”)
+
+This agreement is based on the Apache Software Foundation Contributor License
+Agreement.
+
+Thank you for your interest in software projects stewarded by Pipelex
+(Evotis SAS) (“Pipelex”). In order to clarify the intellectual property
+license granted with Contributions from any person or entity, Pipelex must
+have a Contributor License Agreement (CLA) on file that has been agreed to by
+each Contributor, indicating agreement to the license terms below. This license
+is for your protection as a Contributor as well as the protection of Pipelex
+and its users; it does not change your rights to use your own Contributions for
+any other purpose. This Agreement allows an individual to contribute to
+Pipelex on that individual’s own behalf, or an entity (the “Corporation”) to
+submit Contributions to Pipelex, to authorize Contributions submitted by its
+designated employees to Pipelex, and to grant copyright and patent licenses
+thereto.
+
+You accept and agree to the following terms and conditions for Your present and
+future Contributions submitted to Pipelex. Except for the license granted
+herein to Pipelex and recipients of software distributed by Pipelex, You
+reserve all right, title, and interest in and to Your Contributions.
+
+1. Definitions. “You” (or “Your”) shall mean the copyright owner or legal
+ entity authorized by the copyright owner that is making this Agreement with
+ Pipelex. For legal entities, the entity making a Contribution and all
+ other entities that control, are controlled by, or are under common control
+ with that entity are considered to be a single Contributor. For the purposes
+ of this definition, “control” means (i) the power, direct or indirect, to
+ cause the direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+ “Contribution” shall mean any work, as well as any modifications or
+ additions to an existing work, that is intentionally submitted by You to
+ Pipelex for inclusion in, or documentation of, any of the products owned
+ or managed by Pipelex (the “Work”, distributed under its own license).
+ For the purposes of this definition, “submitted” means any form of electronic,
+ verbal, or written communication sent to Pipelex or its representatives,
+ including but not limited to communication on electronic mailing lists,
+ source code control systems (such as GitHub), and issue tracking systems
+ that are managed by, or on behalf of, Pipelex for the purpose of discussing
+ and improving the Work, but excluding communication that is conspicuously
+ marked or otherwise designated in writing by You as “Not a Contribution.”
+
+2. Grant of Copyright License. Subject to the terms and conditions of this
+ Agreement, You hereby grant to Pipelex and to recipients of software
+ distributed by Pipelex a perpetual, worldwide, non-exclusive, no-charge,
+ royalty-free, irrevocable copyright license to reproduce, prepare derivative
+ works of, publicly display, publicly perform, sublicense, and distribute
+ Your Contributions and such derivative works.
+
+3. Grant of Patent License. Subject to the terms and conditions of this
+ Agreement, You hereby grant to Pipelex and to recipients of software
+ distributed by Pipelex a perpetual, worldwide, non-exclusive, no-charge,
+ royalty-free, irrevocable (except as stated in this section) patent license
+ to make, have made, use, offer to sell, sell, import, and otherwise transfer
+ the Work, where such license applies only to those patent claims licensable
+ by You that are necessarily infringed by Your Contribution(s) alone or by
+ combination of Your Contribution(s) with the Work to which such
+ Contribution(s) were submitted. If any entity institutes patent litigation
+ against You or any other entity (including a cross-claim or counterclaim in
+ a lawsuit) alleging that your Contribution, or the Work to which you have
+ contributed, constitutes direct or contributory patent infringement, then
+ any patent licenses granted to that entity under this Agreement for that
+ Contribution or Work shall terminate as of the date such litigation is
+ filed.
+
+4. You represent that You are legally entitled to grant the above license. If
+ You are an individual, and if Your employer(s) has rights to intellectual
+ property that you create that includes Your Contributions, you represent
+ that You have received permission to make Contributions on behalf of that
+ employer, or that Your employer has waived such rights for your
+ Contributions to Pipelex. If You are a Corporation, any individual who
+ makes a contribution from an account associated with You will be considered
+ authorized to Contribute on Your behalf.
+
+5. You represent that each of Your Contributions is Your original creation (see
+ section 7 for submissions on behalf of others).
+
+6. You are not expected to provide support for Your Contributions,except to the
+ extent You desire to provide support. You may provide support for free, for
+ a fee, or not at all. Unless required by applicable law or agreed to in
+ writing, You provide Your Contributions on an “AS IS” BASIS, WITHOUT
+ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including,
+ without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT,
+ MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
+
+7. Should You wish to submit work that is not Your original creation, You may
+ submit it to Pipelex separately from any Contribution, identifying the
+ complete details of its source and of any license or other restriction
+ (including, but not limited to, related patents, trademarks, and license
+ agreements) of which you are personally aware, and conspicuously marking the
+ work as “Submitted on behalf of a third-party: [named here]”.
+
\ No newline at end of file
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
new file mode 100644
index 000000000..be82710c9
--- /dev/null
+++ b/CODE_OF_CONDUCT.md
@@ -0,0 +1,122 @@
+# Contributor Covenant Code of Conduct
+
+## Our Pledge
+
+We as members, contributors, and leaders pledge to make participation in our
+community a harassment-free experience for everyone, regardless of age, body
+size, visible or invisible disability, ethnicity, sex characteristics, gender
+identity and expression, level of experience, education, socio-economic status,
+nationality, personal appearance, race, caste, color, religion, or sexual
+identity and orientation.
+
+We pledge to act and interact in ways that contribute to an open, welcoming,
+diverse, inclusive, and healthy community.
+
+## Our Standards
+
+Examples of behavior that contributes to a positive environment for our
+community include:
+
+- Demonstrating empathy and kindness toward other people
+- Being respectful of differing opinions, viewpoints, and experiences
+- Giving and gracefully accepting constructive feedback
+- Accepting responsibility and apologizing to those affected by our mistakes,
+ and learning from the experience
+- Focusing on what is best not just for us as individuals, but for the overall
+ community
+
+Examples of unacceptable behavior include:
+
+- The use of sexualized language or imagery, and sexual attention or advances of
+ any kind
+- Trolling, insulting or derogatory comments, and personal or political attacks
+- Public or private harassment
+- Publishing others' private information, such as a physical or email address,
+ without their explicit permission
+- Other conduct which could reasonably be considered inappropriate in a
+ professional setting
+
+## Enforcement Responsibilities
+
+Community leaders are responsible for clarifying and enforcing our standards of
+acceptable behavior and will take appropriate and fair corrective action in
+response to any behavior that they deem inappropriate, threatening, offensive,
+or harmful.
+
+Community leaders have the right and responsibility to remove, edit, or reject
+comments, commits, code, wiki edits, issues, and other contributions that are
+not aligned to this Code of Conduct, and will communicate reasons for moderation
+decisions when appropriate.
+
+## Scope
+
+This Code of Conduct applies within all community spaces, and also applies when
+an individual is officially representing the community in public spaces.
+Examples of representing our community include using an official email address,
+posting via an official social media account, or acting as an appointed
+representative at an online or offline event.
+
+## Enforcement
+
+Instances of abusive, harassing, or otherwise unacceptable behavior may be
+reported to the community leaders responsible for enforcement at
+All complaints will be reviewed and investigated promptly and fairly.
+
+All community leaders are obligated to respect the privacy and security of the
+reporter of any incident.
+
+## Enforcement Guidelines
+
+Community leaders will follow these Community Impact Guidelines in determining
+the consequences for any action they deem in violation of this Code of Conduct:
+
+### 1. Correction
+
+**Community Impact**: Use of inappropriate language or other behavior deemed
+unprofessional or unwelcome in the community.
+
+**Consequence**: A private, written warning from community leaders, providing
+clarity around the nature of the violation and an explanation of why the
+behavior was inappropriate. A public apology may be requested.
+
+### 2. Warning
+
+**Community Impact**: A violation through a single incident or series of
+actions.
+
+**Consequence**: A warning with consequences for continued behavior. No
+interaction with the people involved, including unsolicited interaction with
+those enforcing the Code of Conduct, for a specified period of time. This
+includes avoiding interactions in community spaces as well as external channels
+like social media. Violating these terms may lead to a temporary or permanent
+ban.
+
+### 3. Temporary Ban
+
+**Community Impact**: A serious violation of community standards, including
+sustained inappropriate behavior.
+
+**Consequence**: A temporary ban from any sort of interaction or public
+communication with the community for a specified period of time. No public or
+private interaction with the people involved, including unsolicited interaction
+with those enforcing the Code of Conduct, is allowed during this period.
+Violating these terms may lead to a permanent ban.
+
+### 4. Permanent Ban
+
+**Community Impact**: Demonstrating a pattern of violation of community
+standards, including sustained inappropriate behavior, harassment of an
+individual, or aggression toward or disparagement of classes of individuals.
+
+**Consequence**: A permanent ban from any sort of public interaction within the
+community.
+
+## Attribution
+
+This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org/),
+version 2.1, available at
+[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html](https://www.contributor-covenant.org/version/2/1/code_of_conduct.html).
+
+Community Impact Guidelines were inspired by
+[Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/inclusion).
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 000000000..68a768f6e
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,82 @@
+# Contributing to Pipelex
+
+Thank you for your interest in contributing! Contributions are very welcome. We appreciate first time contributors and we are happy help you get started. Join our community on Discord and feel free to reach out with questions in the #code-contributions and #pipeline-contributions channels.
+
+Everyone interacting in Discord, codebases, mailing lists, events, or any other Pipelex activities is expected to follow the [Code of Conduct](CODE_OF_CONDUCT.md). Please review it before getting started.
+
+Most of the issues that are open for contributions are tagged with `good first issue` or `help-welcome`. If you see an issue that isn't tagged that you're interested in, post a comment with your approach, and we'll be happy to assign it to you. If you submit a fix that isn't linked to an issue you're assigned, there's chance it won't be accepted. Don't hesitate to ping the Pipelex team on Discord to discuss your choice of issue before getting to work.
+
+We are open to contributions in all areas of our core Pipelex library:
+
+- **Bug fixes**: Crashes, incorrect output, performance issues
+- **Feature**: New API, CLI flag, module, test coverage
+- **Refactor**: Rethink architecture
+- **Chore**: Dependency updates, config tweaks, file renames
+- **Doc**: Main docs, SWE Agent rules, tutorials, examples, READMEs
+- **CI/CD**: GitHub Actions, packaging, release tooling
+
+## Contribution process
+
+- Fork the Pipelex repository
+- Clone the repository locally
+- Install dependencies: `make install` (creates .venv and installs dependencies)
+- Copy `.env.example` to `.env` and fill in required API keys (at least OpenAI)
+- Run checks to make sure all is good: `make check` & `make runtests`
+- Create a branch with the format user_name/category/short_slug where category is one of: `feature`, `fix`, `refactor`, `doc`, `cicd` or `chore`
+- Make and commit changes
+- Push your local branch to your fork
+- Open a PR that [links to an existing Issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue) which does not include the `needs triage` label
+- Write a PR title and description by filling the template
+- CI tests will be triggered and maintainers will review the code
+- Respond to feedback if required
+- Merge the contribution
+
+## Requirements
+
+- Python ≥ 3.11 < 3.12
+- poetry ≥ 2.0.1
+
+## Development Setup
+
+- Fork & clone the repository
+- Run `make install` to set up virtualenv and dependencies
+- Copy `.env.example` to `.env` and configure API keys
+- Use Poetry for dependency management:
+ - Runtime deps: `poetry add <package>`
+ - Dev deps: `poetry add --group dev <package>`
+ - Keep dependencies alphabetically ordered in pyproject.toml
+
+## Pull Request Process
+
+- Fork the Pipelex repository
+- Clone the repository locally
+- Install dependencies: `make install` (creates .venv and installs dependencies)
+- Copy `.env.example` to `.env` and fill in required API keys (at least OpenAI)
+- Run checks to make sure all is good: `make check` & `make runtests`
+- Create a branch for your feature/bug-fix with the format user_name/feature/some_feature or user_name/fix/some_bugfix
+- Make and commit changes
+- Push your local branch to your fork
+- When it's ready, run quality tests:
+- Run `make fix-unused-imports` to removed unused imports
+- Run `make check` for formatting & linting with Ruff, and type-checking with Pyright and Mypy
+- Run `make runtests` for test suite
+- Open a PR that [links to an existing Issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue) including a PR title and description
+- Mark as Draft until CI passes
+- Maintainers will review the code
+- Respond to feedback if required
+- Merge the contribution
+
+## Environment Setup
+
+- Copy `.env.example` to `.env`
+- Fill in required credentials (OPENAI_API_KEY, AWS_ACCESS_KEY_ID, etc.)
+- Never commit `.env`
+
+## For Maintainers
+
+- Use `make bump-version` to update version in pyproject.toml
+
+## License
+
+* **CLA** – The first time you open a PR, the CLA-assistant bot will guide you through signing the Contributor License Agreement. The process signature uses the [CLA assistant lite](https://github.com/marketplace/actions/cla-assistant-lite).
+* **Code of Conduct** – Be kind. All interactions fall under [`CODE_OF_CONDUCT.md`](CODE_OF_CONDUCT.md).
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 000000000..db5bb8b16
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2025 Evotis S.A.S.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/Makefile b/Makefile
new file mode 100644
index 000000000..2cec6c223
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,338 @@
+
+
+ifeq ($(wildcard .env),.env)
+include .env
+export
+endif
+VIRTUAL_ENV := $(CURDIR)/.venv
+LOCAL_PYTHON := $(VIRTUAL_ENV)/bin/python3.11
+PROJECT_NAME := $(shell grep '^name = ' pyproject.toml | sed -E 's/name = "(.*)"/\1/')
+
+LOCAL_MYPY := $(VIRTUAL_ENV)/bin/mypy
+LOCAL_PYTEST := $(VIRTUAL_ENV)/bin/pytest
+LOCAL_PYRIGHT := $(VIRTUAL_ENV)/bin/pyright
+LOCAL_RUFF := $(VIRTUAL_ENV)/bin/ruff
+
+define PRINT_TITLE
+ $(eval PADDED_PROJECT_NAME := $(shell printf '%-15s' "[$(PROJECT_NAME)] " | sed 's/ /=/g'))
+ $(eval PADDED_TARGET_NAME := $(shell printf '%-15s' "($@) " | sed 's/ /=/g'))
+ $(if $(1),\
+ $(eval TITLE := $(shell printf '%s' "=== $(PADDED_PROJECT_NAME) $(PADDED_TARGET_NAME)" | sed 's/[[:space:]]/ /g')$(shell echo " $(1) " | sed 's/[[:space:]]/ /g')),\
+ $(eval TITLE := $(shell printf '%s' "=== $(PADDED_PROJECT_NAME) $(PADDED_TARGET_NAME)" | sed 's/[[:space:]]/ /g'))\
+ )
+ $(eval PADDED_TITLE := $(shell printf '%-126s' "$(TITLE)" | sed 's/ /=/g'))
+ @echo ""
+ @echo "$(PADDED_TITLE)"
+endef
+
+define HELP
+Manage $(PROJECT_NAME) located in $(CURDIR).
+Usage:
+
+make env - Create python virtual env
+make lock - Refresh poetry.lock without updating anything
+make install - Create local virtualenv & install all dependencies
+make update - Upgrade dependencies via poetry
+make run-setup - Run the setup sequence
+make build - Build the wheels
+
+make format - format with ruff format
+make lint - lint with ruff check
+make pyright - Check types with pyright
+make mypy - Check types with mypy
+
+make cleanenv - Remove virtual env and lock files
+make cleanderived - Remove extraneous compiled files, caches, logs, etc.
+make cleanlibraries - Remove pipelex_libraries
+make cleanall - Remove all -> cleanenv + cleanderived + cleanlibraries
+make reinitlibraries - Remove pipelex_libraries and init libraries again
+
+make merge-check-ruff-lint - Run ruff merge check without updating files
+make merge-check-ruff-format - Run ruff merge check without updating files
+make merge-check-mypy - Run mypy merge check without updating files
+make merge-check-pyright - Run pyright merge check without updating files
+
+make rl - Shorthand -> reinitlibraries
+make s - Shorthand -> run-setup
+make init - Run pipelex init
+make runtests - Run tests for github actions (exit on first failure) (no inference)
+make test - Run unit tests (no inference)
+make test-with-prints - Run tests with prints (no inference)
+make t - Shorthand -> test-with-prints
+make test-inference - Run unit tests only for inference (with prints)
+make ti - Shorthand -> test-inference
+make test-ocr - Run unit tests only for ocr (with prints)
+make to - Shorthand -> test-ocr
+make test-imgg - Run unit tests only for imgg (with prints)
+make test-g - Shorthand -> test-imgg
+
+make check - Shorthand -> format lint mypy
+make c - Shorthand -> check
+make cc - Shorthand -> cleanderived check
+make li - Shorthand -> lock install
+make check-unused-imports - Check for unused imports without fixing
+make fix-unused-imports - Fix unused imports with ruff
+
+endef
+export HELP
+
+.PHONY: all help env lock install update format lint pyright mypy build cleanderived cleanenv run-setup s runtests test test-with-prints t test-inference ti test-imgg tg test-ocr to check cc li merge-check-ruff-lint merge-check-ruff-format merge-check-mypy check-unused-imports fix-unused-imports test-name bump-version
+
+all help:
+ @echo "$$HELP"
+
+
+##########################################################################################
+### SETUP
+##########################################################################################
+
+env:
+ $(call PRINT_TITLE,"Creating virtual environment")
+ @if [ ! -d $(VIRTUAL_ENV) ]; then \
+ echo "Creating Python virtual env in \`${VIRTUAL_ENV}\`"; \
+ python3.11 -m venv $(VIRTUAL_ENV); \
+ . $(VIRTUAL_ENV)/bin/activate && \
+ echo "Created Python virtual env in \`${VIRTUAL_ENV}\`"; \
+ else \
+ echo "Python virtual env already exists in \`${VIRTUAL_ENV}\`"; \
+ fi
+
+init: env
+ $(call PRINT_TITLE,"Running `pipelex init` with overwrite")
+ pipelex init --overwrite
+
+install: env
+ $(call PRINT_TITLE,"Installing dependencies")
+ @. $(VIRTUAL_ENV)/bin/activate && \
+ $(LOCAL_PYTHON) -m pip install --upgrade pip setuptools wheel && \
+ $(LOCAL_PYTHON) -m pip install "poetry>=2.0.0,<2.1.0" && \
+ $(LOCAL_PYTHON) -m poetry install --extras "anthropic google mistralai bedrock fal" && \
+ pipelex init --overwrite && \
+ echo "Installed Pipelex dependencies in ${VIRTUAL_ENV} with all extras and initialized Pipelex";
+
+lock: env
+ $(call PRINT_TITLE,"Resolving dependencies without update")
+ @. $(VIRTUAL_ENV)/bin/activate && \
+ poetry lock && \
+ echo poetry lock without update;
+
+update: env
+ $(call PRINT_TITLE,"Updating all dependencies")
+ @. $(VIRTUAL_ENV)/bin/activate && \
+ $(LOCAL_PYTHON) -m pip install --upgrade pip setuptools wheel && \
+ poetry update && \
+ echo "Updated dependencies in ${VIRTUAL_ENV}";
+
+run-setup: env
+ $(call PRINT_TITLE,"Running setup sequence")
+ pipelex run-setup
+
+build: env
+ $(call PRINT_TITLE,"Building the wheels")
+ @. $(VIRTUAL_ENV)/bin/activate && \
+ $(LOCAL_PYTHON) -m poetry build
+
+##############################################################################################
+############################ Cleaning ############################
+##############################################################################################
+
+cleanderived:
+ $(call PRINT_TITLE,"Erasing derived files and directories")
+ @find . -name '.coverage' -delete && \
+ find . -wholename '**/*.pyc' -delete && \
+ find . -type d -wholename '__pycache__' -exec rm -rf {} + && \
+ find . -type d -wholename './.cache' -exec rm -rf {} + && \
+ find . -type d -wholename './.mypy_cache' -exec rm -rf {} + && \
+ find . -type d -wholename './.ruff_cache' -exec rm -rf {} + && \
+ find . -type d -wholename '.pytest_cache' -exec rm -rf {} + && \
+ find . -type d -wholename '**/.pytest_cache' -exec rm -rf {} + && \
+ find . -type d -wholename './logs/*.log' -exec rm -rf {} + && \
+ find . -type d -wholename './.reports/*' -exec rm -rf {} + && \
+ echo "Cleaned up derived files and directories";
+
+cleanenv:
+ $(call PRINT_TITLE,"Erasing virtual environment")
+ find . -name '.Pipfile.lock' -delete && \
+ find . -type d -wholename './.venv' -exec rm -rf {} + && \
+ echo "Cleaned up virtual env and dependency lock files";
+
+cleanlibraries:
+ $(call PRINT_TITLE,"Erasing derived files and directories")
+ @find . -type d -wholename './pipelex_libraries' -exec rm -rf {} + && \
+ echo "Cleaned up pipelex_libraries";
+
+reinitlibraries: cleanlibraries init
+ @echo "Reinitialized pipelex_libraries";
+
+rl: reinitlibraries
+ @echo "> done: rl = reinitlibraries"
+
+cleanall: cleanderived cleanenv cleanlibraries
+ @echo "Cleaned up all derived files and directories";
+
+##########################################################################################
+### TESTING
+##########################################################################################
+
+runtests: env
+ $(call PRINT_TITLE,"Unit testing for github actions")
+ @echo "• Running unit tests (excluding inference, and gha_disabled)"
+ $(LOCAL_PYTEST) --exitfirst --quiet -m "not inference and not gha_disabled" || [ $$? = 5 ]
+
+run-all-tests: env
+ $(call PRINT_TITLE,"Running all unit tests")
+ @echo "• Running all unit tests"
+ $(LOCAL_PYTEST) --exitfirst --quiet
+
+run-manual-trigger-gha-tests: env
+ $(call PRINT_TITLE,"Running GHA tests")
+ @echo "• Running GHA unit tests for inference, llm, and not gha_disabled"
+ $(LOCAL_PYTEST) --exitfirst --quiet -m "not gha_disabled and (inference or llm)" || [ $$? = 5 ]
+
+run-gha_disabled-tests: env
+ $(call PRINT_TITLE,"Running GHA disabled tests")
+ @echo "• Running GHA disabled unit tests"
+ $(LOCAL_PYTEST) --exitfirst --quiet -m "gha_disabled" || [ $$? = 5 ]
+
+test: env
+ $(call PRINT_TITLE,"Unit testing without prints but displaying logs via pytest for WARNING level and above")
+ @echo "• Running unit tests"
+ @if [ -n "$(TEST)" ]; then \
+ $(LOCAL_PYTEST) -s -o log_cli=true -o log_level=WARNING -k "$(TEST)" $(if $(filter 2,$(VERBOSE)),-vv,$(if $(filter 3,$(VERBOSE)),-vvv,-v)); \
+ else \
+ $(LOCAL_PYTEST) -s -o log_cli=true -o log_level=WARNING $(if $(filter 2,$(VERBOSE)),-vv,$(if $(filter 3,$(VERBOSE)),-vvv,-v)); \
+ fi
+
+test-with-prints: env
+ $(call PRINT_TITLE,"Unit testing with prints and our rich logs")
+ @echo "• Running unit tests"
+ @if [ -n "$(TEST)" ]; then \
+ $(LOCAL_PYTEST) -s -k "$(TEST)" $(if $(filter 2,$(VERBOSE)),-vv,$(if $(filter 3,$(VERBOSE)),-vvv,-v)); \
+ else \
+ $(LOCAL_PYTEST) -s $(if $(filter 2,$(VERBOSE)),-vv,$(if $(filter 3,$(VERBOSE)),-vvv,-v)); \
+ fi
+
+t: test-with-prints
+ @echo "> done: t = test-with-prints"
+
+test-inference: env
+ $(call PRINT_TITLE,"Unit testing")
+ @if [ -n "$(TEST)" ]; then \
+ $(LOCAL_PYTEST) --exitfirst -m "inference and not imgg" -s -k "$(TEST)" $(if $(filter 2,$(VERBOSE)),-vv,$(if $(filter 3,$(VERBOSE)),-vvv,-v)); \
+ else \
+ $(LOCAL_PYTEST) --exitfirst -m "inference and not imgg" -s $(if $(filter 2,$(VERBOSE)),-vv,$(if $(filter 3,$(VERBOSE)),-vvv,-v)); \
+ fi
+
+ti: test-inference
+ @echo "> done: ti = test-inference"
+
+test-ocr: env
+ $(call PRINT_TITLE,"Unit testing ocr")
+ @if [ -n "$(TEST)" ]; then \
+ $(LOCAL_PYTEST) --exitfirst -m "ocr" -s -k "$(TEST)" $(if $(filter 2,$(VERBOSE)),-vv,$(if $(filter 3,$(VERBOSE)),-vvv,-v)); \
+ else \
+ $(LOCAL_PYTEST) --exitfirst -m "ocr" -s $(if $(filter 2,$(VERBOSE)),-vv,$(if $(filter 3,$(VERBOSE)),-vvv,-v)); \
+ fi
+
+to: test-ocr
+ @echo "> done: to = test-ocr"
+
+test-imgg: env
+ $(call PRINT_TITLE,"Unit testing")
+ @if [ -n "$(TEST)" ]; then \
+ $(LOCAL_PYTEST) --exitfirst -m "imgg" -s -k "$(TEST)" $(if $(filter 2,$(VERBOSE)),-vv,$(if $(filter 3,$(VERBOSE)),-vvv,-v)); \
+ else \
+ $(LOCAL_PYTEST) --exitfirst -m "imgg" -s $(if $(filter 2,$(VERBOSE)),-vv,$(if $(filter 3,$(VERBOSE)),-vvv,-v)); \
+ fi
+
+tg: test-imgg
+ @echo "> done: tg = test-imgg"
+
+############################################################################################
+############################ Linting ############################
+############################################################################################
+
+format: env
+ $(call PRINT_TITLE,"Formatting with ruff")
+ @$(LOCAL_RUFF) format .
+
+lint: env
+ $(call PRINT_TITLE,"Linting with ruff")
+ @$(LOCAL_RUFF) check . --fix
+
+pyright: env
+ $(call PRINT_TITLE,"Typechecking with pyright")
+ @$(LOCAL_PYRIGHT) --pythonpath $(LOCAL_PYTHON) && \
+ echo "Done typechecking with pyright — disregard warning about latest version, it's giving us false positives"
+
+mypy: env
+ $(call PRINT_TITLE,"Typechecking with mypy")
+ @$(LOCAL_PYTHON) $(LOCAL_MYPY)
+
+
+##########################################################################################
+### MERGE CHECKS
+##########################################################################################
+
+merge-check-ruff-format: env
+ $(call PRINT_TITLE,"Formatting with ruff")
+ . $(VIRTUAL_ENV)/bin/activate && \
+ $(LOCAL_RUFF) format --check -v .
+
+merge-check-ruff-lint: env check-unused-imports
+ $(call PRINT_TITLE,"Linting with ruff without fixing files")
+ . $(VIRTUAL_ENV)/bin/activate && \
+ $(LOCAL_RUFF) check -v .
+
+merge-check-pyright: env
+ $(call PRINT_TITLE,"Typechecking with pyright")
+ . $(VIRTUAL_ENV)/bin/activate && \
+ $(LOCAL_PYRIGHT) -p pyproject.toml
+
+merge-check-mypy: env
+ $(call PRINT_TITLE,"Typechecking with mypy")
+ . $(VIRTUAL_ENV)/bin/activate && \
+ $(LOCAL_PYTHON) $(LOCAL_MYPY) --version && \
+ $(LOCAL_PYTHON) $(LOCAL_MYPY) --config-file pyproject.toml
+
+##########################################################################################
+### SHORTHANDS
+##########################################################################################
+
+check-unused-imports: env
+ $(call PRINT_TITLE,"Checking for unused imports without fixing")
+ . $(VIRTUAL_ENV)/bin/activate && \
+ $(LOCAL_RUFF) check --select=F401 --no-fix .
+
+c: init format lint pyright mypy
+ @echo "> done: c = check"
+
+cc: init cleanderived c
+ @echo "> done: cc = init cleanderived init format lint pyright mypy"
+
+check: cc check-unused-imports
+ @echo "> done: check"
+
+s: init run-setup
+ @echo "> done: s = run-setup"
+
+li: lock install
+ @echo "> done: lock install"
+
+check-TODOs: env
+ $(call PRINT_TITLE,"Checking for TODOs")
+ . $(VIRTUAL_ENV)/bin/activate && \
+ $(LOCAL_RUFF) check --select=TD -v .
+
+fix-unused-imports: env
+ $(call PRINT_TITLE,"Fixing unused imports")
+ . $(VIRTUAL_ENV)/bin/activate && \
+ $(LOCAL_RUFF) check --select=F401 --fix -v .
+
+CURRENT_VERSION := $(shell grep '^version = ' pyproject.toml | sed -E 's/version = "(.*)"/\1/')
+NEXT_VERSION := $(shell echo $(CURRENT_VERSION) | awk -F. '{$$NF = $$NF + 1;} 1' | sed 's/ /./g')
+
+bump-version: env
+ $(call PRINT_TITLE,"Bumping version from $(CURRENT_VERSION) to $(NEXT_VERSION)")
+ @. $(VIRTUAL_ENV)/bin/activate && poetry version $(NEXT_VERSION)
+ @echo "Version bumped to $(NEXT_VERSION)"
diff --git a/README.md b/README.md
new file mode 100644
index 000000000..8a9883389
--- /dev/null
+++ b/README.md
@@ -0,0 +1,124 @@
+<div align="center">
+ <a href="https://www.pipelex.com/"><img src="https://raw.githubusercontent.com/Pipelex/pipelex/dev/.github/assets/logo.png" alt="Pipelex Logo" width="400" style="max-width: 100%; height: auto;"></a>
+
+ <h3 align="center">The simpler way to build reliable LLM Pipelines</h3>
+ <p align="center">Pipelex is an open‑source dev tool based on a simple declarative language<br/>that lets you define replicable, structured, composable LLM pipelines.</p>
+
+ <div>
+ <a href="https://github.com/Pipelex/pipelex/blob/dev/doc/Documentation.md"><strong>Docs</strong></a> -
+ <a href="https://github.com/Pipelex/pipelex/issues"><strong>Report Bug</strong></a> -
+ <a href="https://github.com/Pipelex/pipelex/discussions"><strong>Feature Request</strong></a>
+ </div>
+ <br/>
+
+ <p align="center">
+ <a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="MIT License"></a>
+ <img src="https://img.shields.io/pypi/v/pipelex?logo=pypi&logoColor=white&color=blue&style=flat-square"
+ alt="PyPI – latest release">
+ <br/>
+ <br/>
+ <a href="https://www.youtube.com/@PipelexAI"><img src="https://img.shields.io/badge/YouTube-FF0000?logo=youtube&logoColor=white" alt="YouTube"></a>
+ <a href="https://pipelex.com"><img src="https://img.shields.io/badge/Web-pipelex.com-03bb95?logo=google-chrome&logoColor=white&style=flat" alt="Website"></a>
+ <br/>
+ <br/>
+</div>
+
+# 📑 Table of Contents
+
+- [Introduction](#introduction)
+- [Quick start](#-quick-start)
+ - [Prerequisites](#prerequisites)
+ - [Installation](#installation)
+ - [Optional features](#optional-features)
+- [Contributing](#-contributing)
+- [Support](#-support)
+- [License](#-license)
+
+# Introduction
+
+Pipelex™ is a developer tool designed to simplify building reliable AI applications. At its core is a clear, declarative pipeline language specifically crafted for knowledge-processing tasks.
+
+**The Pipelex language uses pipelines,** or "pipes", each capable of integrating different language models (LLMs) or software to process knowledge. Pipes consistently deliver **structured, predictable outputs** at each stage.
+
+Pipelex employs user-friendly TOML syntax, enabling developers to intuitively define workflows in a narrative-like manner. This approach facilitates collaboration between business professionals, developers, and language models (LLMs), ensuring clarity and ease of communication.
+
+Pipes function like modular building blocks, **assembled by connecting other pipes sequentially, in parallel, or by calling sub-pipes.** This assembly resembles function calls in traditional programming but emphasizes a more intuitive, plug-and-play structure, focused explicitly on clear knowledge input and output.
+
+Pipelex is distributed as an **open-source Python library,** with a hosted API launching soon, enabling effortless integration into existing software systems and automation frameworks. Additionally, Pipelex will provide an MCP server that will enable AI Agents to run pipelines like any other tool.
+
+# 🚀 Quick start
+
+> :books: Note that you can check out the [Pipelex Documentation](doc/Documentation.md) for more information and clone the [Pipelex Cookbook](https://github.com/Pipelex/pipelex-cookbook) repository for ready-to-run samples.
+
+Follow these steps to get started:
+
+## Installation
+
+### Prerequisites
+
+- Python >=3.11,<3.12
+- [pip](https://pip.pypa.io/en/stable/), [poetry](https://python-poetry.org/), or [uv](https://github.com/astral-sh/uv) package manager
+
+### Install the package
+
+```bash
+# Using pip
+pip install pipelex
+
+# Using Poetry
+poetry add pipelex
+
+# Using uv (Recommended)
+uv pip install pipelex
+```
+
+## IDE extension
+
+We **highly** recommend installing an extension for TOML files into your IDE of choice. For VS Code, the [Even Better TOML](https://marketplace.visualstudio.com/items?itemName=tamasfe.even-better-toml) extension does a great job of syntax coloring and checking.
+
+### Optional Features
+
+The package supports additional features that can be installed separately:
+
+```bash
+# Using pip
+pip install "pipelex[anthropic]" # For Anthropic/Claude support
+pip install "pipelex[google]" # For Google API support
+pip install "pipelex[mistralai]" # For Mistral AI support
+pip install "pipelex[bedrock]" # For AWS Bedrock support
+pip install "pipelex[fal]" # For image generation with Black Forest Labs "FAL" service
+
+# Using poetry
+poetry add "pipelex[anthropic,google,mistralai,bedrock,fal]" # Install all features
+
+# Using uv
+uv pip install "pipelex[anthropic,google,mistralai,bedrock,fal]"
+```
+
+## 🤝 Contributing
+
+We welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for details on how to get started, including development setup and testing information.
+
+## 💬 Support
+
+- **GitHub Issues**: For bug reports and feature requests
+- **Discussions**: For questions and community discussions
+- [**Documentation**](doc/Documentation.md)
+
+## ⭐ Star Us!
+
+If you find Pipelex helpful, please consider giving us a star! It helps us reach more developers and continue improving the tool.
+
+## 👥 Contributors
+
+Contributions are welcome, check out our [Contributing to Pipelex](CONTRIBUTING.md) guide.
+
+## 📝 License
+
+This project is licensed under the [MIT license](LICENSE). Runtime dependencies are distributed under their own licenses via PyPI.
+
+---
+
+"Pipelex" is a trademark of Evotis S.A.S.
+
+© 2025 Evotis S.A.S.
diff --git a/doc/Documentation.md b/doc/Documentation.md
new file mode 100644
index 000000000..337f0bad1
--- /dev/null
+++ b/doc/Documentation.md
@@ -0,0 +1,24 @@
+# Documentation
+
+Pipelex is a Python framework for defining and running LLM-based knowledge pipelines with high reliability and replicability.
+
+## Table of Contents
+
+[Installation](pages/Installation/Installation.md)
+
+[Quick-start](pages/Quick-start/Quick-start.md)
+
+[Pipelex paradigm](pages/Pipelex%20paradigm/Pipelex%20paradigm.md)
+
+[Libraries](pages/Libraries/libraries.md)
+
+[Concepts](pages/Concepts/Concepts.md)
+
+[Pipes](pages/Pipes/Pipes.md)
+
+
+---
+
+"Pipelex" is a trademark of Evotis S.A.S.
+
+© 2025 Evotis S.A.S.
diff --git a/doc/pages/Concepts/Concepts.md b/doc/pages/Concepts/Concepts.md
new file mode 100644
index 000000000..3ebd06184
--- /dev/null
+++ b/doc/pages/Concepts/Concepts.md
@@ -0,0 +1,184 @@
+# Concepts
+
+A concept **defines** **what is processed** through pipes: they represent the **knowledge** that is processed as input and generated as output in Pipelex pipelines.
+
+**Rigorous concept definitions are the key to ensure controlled, reliable outputs in pipelines.**
+
+Concepts are defined both with **natural language** (so non-developers and LLMs can understand and write them) and optionally also **with code** (to ensure deterministic validation with software).
+
+Based on concepts, pipes embed **validation** on their inputs and outputs, so **we make sure of the knowledge we process and produce**.
+
+## Concept definition
+
+Concepts are defined using a **`toml` syntax** and (optional) **Python code ([BaseModel](https://docs.pydantic.dev/latest/concepts/models/)).**
+
+- The `toml` part is meant to be **written in a library `toml` file.**
+
+ - 💡*In the quick-start example (character generator) this is the role of `character.toml`[.](https://www.notion.so/Pipelex-Documentation-1b34fbe82c898062af44d70f6aa0f461?pvs=21)*
+
+- The python code related to the Concept definition **must be saved in a `pipelex_libraries` folder at the root of your project.**
+
+As seen in the quick-start, we use Python to instantiate concepts into Stuff objects.
+
+![*Concepts can be defined both with toml and code. Stuffs are instantiated from Concepts with Python code.*](concept_and_stuff.png)
+
+_Concepts can be defined both with toml and code. Stuff are instantiated from Concepts with Python code._
+
+## Concept with text
+
+In the 1st quick-start example, `character.toml` includes a text-based definition of a Concept (Character).
+
+It is a good example of how to define a Concept. Just describe what the stuff is.
+
+```toml
+# Library header
+domain = "character"
+definition = "Tools for creating characters"
+
+[concept]
+Character = "A detailed description of a character"
+```
+
+## Structured concepts with text and code
+
+Once you are familiar with defining Concepts with text, you may be interested in using a BaseModel to improve LLM reliability by structuring the knowledge you manipulate.
+
+**_This is mandatory if you want your outputs to have a controlled structure and benefit from Pipe validation_**
+
+For that purpose, you will need both `toml` and Python.
+
+In this example, we define a `Summary` structured concept. It consists of a text and a creation date.
+
+```toml
+# summarize.toml
+
+domain = "summarize"
+definition = "Summarize text using LLMs."
+
+[concept]
+Summary = "A concise and organized rewriting of a large and dense text."
+```
+
+```python
+# summarize_models.py
+
+from datetime import datetime
+from pydantic import Field
+from pipelex.core.stuff_content import StructuredContent
+
+# Class definition, inherits from StructuredContent
+class Summary(StructuredContent):
+ text: str
+ created_at: datetime = Field(default_factory=datetime.now)
+```
+
+:bulb: We take benefit of the `Field` pydantic class to automatically set the `created_at` attribute to the current date and time.
+
+**Super important: How do you bind Models and Concepts?**
+
+:right_arrow: They have the same name! `Summary` and `Summary`
+
+💡 When you define a BaseModel for one of your concepts, **make sure it inherits from a StructuredContent class.**
+
+## Fields description
+
+Defining a list of concepts is done in the `toml` file. Just define a list of concepts with their definition.
+
+```toml
+[concept] # Required
+Concept1 = "Concept1 definition with Natural Language" # Required, str
+Concept2 = "Concept2 definition with Natural Language" # Required, str
+...
+ConceptN = "ConceptN definition with Natural Language" # Required, str
+```
+
+- `Concept` _(required, str)_: The Concept definition.
+
+## Usage in code
+
+A concept instance is called a `Stuff`. Once instantiated **it can be loaded into the working memory and processed by Pipes.**
+
+### Stuff overview
+
+**A stuff object** has:
+
+- **metadata** (code, domain, concept_code, …)
+- **a content object** (that stores the data)
+
+For your information, this is what the Stuff and StuffContent classes look like:
+
+- **Stuff class (optional attributes removed)**
+
+```python
+class Stuff(BaseModel):
+ concept_code: str # To indicate what concept to instantiate: <domain>.<concept_name>
+ stuff_name: str # To identify the stuff
+ content: StuffContent # To store the data
+```
+
+- **StuffContent classes:**
+
+Stuff content objects are instances of a subclass of the StuffContent class. They are very useful when you want to manipulate specific objects and render them.
+
+```python
+# Base Classes
+class StuffContent(ABC, BaseModel):
+ """Base class for all content types. Provides methods to render content in different formats
+ (plain text, HTML, Markdown, JSON, spreadsheet)."""
+```
+
+### Make stuffs for text-only Concepts
+
+In this example we load a contract content and make a stuff from it. We assume that a legal.Contract concept already exists.
+
+```python
+from pipelex.core.stuff_factory import StuffFactory
+
+with open("contract.txt", "r") as file:
+ contract_content = file.read()
+
+question_stuff = StuffFactory.make_from_str(
+ concept_code="legal.Contract", # <domain>.<concept_name>
+ str_value=contract_content, # The str content to add to the stuff
+ stuff_name="contract", # The name of the stuff
+)
+```
+
+### Make stuffs for structured Concepts
+
+Make stuff easily using the StuffFactory class.
+
+```python
+from pipelex.core.stuff_factory import StuffFactory
+from pipelex_libraries.character_model import Character
+
+
+character = Character(
+ name="Elias",
+ age=38,
+ gender="man",
+ occupation="unemployed",
+ description="""Elias Varrin is a 38-year-old man, standing at approximately 1.85 meters tall, with a lean,
+weathered frame shaped by decades of travel through remote and often unforgiving landscapes.
+His name, though not widely known, carries weight among historians, explorers, and those who trade in whispered legends.
+Elias has piercing storm-gray eyes that scan every environment with sharp precision, and his ash-blond hair—flecked with
+early streaks of grey—is usually tucked beneath a wide-brimmed, timeworn hat.His hands are etched with fine scars and stained
+with ink, each mark a silent record of years spent charting unrecorded lands and handling fragile relics of lost civilizations.
+He moves with quiet purpose and speaks with a calm, thoughtful cadence that suggests he’s always listening for more than just what’s said.""",
+)
+character_stuff = StuffFactory.make_stuff(
+ concept_code="character.Character",
+ stuff_name="character",
+ content=character,
+)
+```
+
+:arrow_left: [**Back to Libraries**](../Libraries/libraries.md)
+
+:arrow_right: [**Next section: Pipes**](../Pipes/Pipes.md)
+
+---
+
+"Pipelex" is a trademark of Evotis S.A.S.
+
+© 2025 Evotis S.A.S.
diff --git a/doc/pages/Concepts/concept_and_stuff.png b/doc/pages/Concepts/concept_and_stuff.png
new file mode 100644
index 000000000..e91ef9c26
Binary files /dev/null and b/doc/pages/Concepts/concept_and_stuff.png differ
diff --git a/doc/pages/Installation/Installation.md b/doc/pages/Installation/Installation.md
new file mode 100644
index 000000000..27e413fbf
--- /dev/null
+++ b/doc/pages/Installation/Installation.md
@@ -0,0 +1,42 @@
+# Installation
+
+## 📋 Prerequisites
+
+Pipelex requires `python 3.11`, and access to LLM api keys, if you want to run pipelines locally, or an API key provided by Pipelex to use our cloud-hosted service.
+
+## 🧭 Getting Started
+
+Everything you need to discover and test Pipelex is available in our **Getting Started repository**.
+Along with [our Documentation](../Quick-start/Quick-start.md), we recommend you review it before any further usage: [Cookbook](https://github.com/Pipelex/pipelex-cookbook).
+
+- **Install Pipelex using**
+
+```bash
+pip install pipelex
+```
+
+- **Make sure you have a .env** file at the root of your project that contains the following fields
+
+```bash
+OPENAI_API_KEY=sk_...
+```
+
+- **Make sure your project looks like this:**
+
+```bash
+<your_repo>
+├── pipelex.toml # the config file for pipelex
+├── .env # the .env file to put your API keys and other pipelex variables in
+├── pipelex_libraries # a directory to store your pipelex related code
+│ ├── __init__.py
+```
+
+💡 _Any troubles? Have a look at our [Cookbook](https://github.com/Pipelex/pipelex-cookbook)!_
+
+:arrow_right: [**Next section: Quick-start**](../Quick-start/Quick-start.md)
+
+---
+
+"Pipelex" is a trademark of Evotis S.A.S.
+
+© 2025 Evotis S.A.S.
diff --git a/doc/pages/Libraries/libraries.md b/doc/pages/Libraries/libraries.md
new file mode 100644
index 000000000..fc092b866
--- /dev/null
+++ b/doc/pages/Libraries/libraries.md
@@ -0,0 +1,58 @@
+# Libraries
+
+Pipelex proposes a Python framework along with a syntax for defining and running knowledge processing workflows.
+
+## Scripts
+
+What we call _scripts_ are the `TOML` files containing the concept and pipe definitions written using the Pipelex syntax.
+
+## `pipelex_libraries` folder
+
+Concepts, Pipelines and code are meant to be stored in a `pipelex_libraries` folder at the root of your project.
+
+## Pipelex Libraries
+
+Within a consistent **domain** (domain is the Pipelex name for topic), scripts constitute a library.
+
+A library is a set of scripts along with their corresponding Python code (used for structuring LLM outputs through structured Concepts).
+
+## Library structure
+
+A library is defined by a `toml` file in a `pipelex_libraries` folder.
+
+The `toml` file contains the concepts and pipes definitions.
+
+It looks like this:
+
+![Schema showing Pipelex library structure](library_structure.png)
+
+## Fields
+
+### Domain definition
+
+As a library `toml` file header, you need to define the domain of the library.
+
+```toml
+domain = "domain_name"
+definition = "Definition of the domain"
+```
+
+:bulb: Optional global settings (such as `system_prompt`) can be defined at the library level, in the header.
+
+### Concepts
+
+See [Concepts](../Concepts/Concepts.md)
+
+### Pipes
+
+See [Pipes](../Pipes/Pipes.md)
+
+:arrow_left: [**Back to Quick-start**](../Quick-start/Quick-start.md)
+
+:arrow_right: [**Next section: Concepts**](../Concepts/Concepts.md)
+
+---
+
+"Pipelex" is a trademark of Evotis S.A.S.
+
+© 2025 Evotis S.A.S.
diff --git a/doc/pages/Libraries/library_structure.png b/doc/pages/Libraries/library_structure.png
new file mode 100644
index 000000000..93a543691
Binary files /dev/null and b/doc/pages/Libraries/library_structure.png differ
diff --git a/doc/pages/Pipelex paradigm/Pipelex paradigm.md b/doc/pages/Pipelex paradigm/Pipelex paradigm.md
new file mode 100644
index 000000000..a777d6308
--- /dev/null
+++ b/doc/pages/Pipelex paradigm/Pipelex paradigm.md
@@ -0,0 +1,73 @@
+# Pipelex paradigm
+
+Pipelex is a **Python framework** for **defining** and **running** **LLM-based knowledge pipelines** with high **reliability** and **replicability**.
+
+As an **LLM scaffolding middleware**, Pipelex introduces relevant mechanisms to leverage the capabilities of these ai models while ensuring their **production readiness.**
+
+**_Before going further with Pipelex, we suggest you have a look at the most important mechanisms._**
+
+## TLDR
+
+The Pipelex framework **processes knowledge through pipelines**, which consist of **sequential knowledge processing units called pipes**. Pipes access other pipes' outputs via the **Working Memory** system, making **processed knowledge available throughout the pipeline**. To ensure **reliability**, we implement **deterministic validation**: all pipe inputs and outputs (defined as Stuffs) **conform to specific concepts defined by the user (or by AI)**.
+
+## Knowledge
+
+Knowledge refers to information **extracted**, **processed**, or **organized** from various data sources such as documents, PDFs, images, or information output by our pipelines. It has been structured in a way that enables **understanding**, **interpretation**, and **actionable insights**.
+
+## Pipeline
+
+A pipeline is the Pipelex term for "Workflow". **It aims at processing knowledge using organized, consistent, validated steps.**
+
+![Schema explaining a Pipelex pipeline](pipeline.png)
+
+:bulb: **Remember the Quick-start chapter?** We defined a pipeline (in toml, using the [pipe] section) to generate a character!
+
+## Pipe
+
+A pipe is an **elementary step in a pipeline**. A pipeline is made of pipes.
+Each pipe can integrate **both LLM-based** or software-based knowledge processing.
+
+![Schema explaining a Pipelex elementary pipe](pipe.png)
+
+:bulb: **Remember the Quick-start chapter?** We defined a pipe (in toml, using the [pipe.create_character] section) to generate a character. This was a very short pipeline as it comprised only one pipe.
+
+## Working Memory
+
+A pipe has access to all inputs as well as all the knowledge that was processed along the pipeline: **everything is stored in the Pipeline's Working Memory**. So can then **use all that stuff at any point in the pipeline.**
+
+![*Working Memory: Pipe C can use Pipe A and Pipe B outputs. Pipe D can use Pipe C and Pipe B outputs, Pipe E …*](working_memory.png)
+_Working Memory: Pipe C can use Pipe A and Pipe B outputs. Pipe D can use Pipe C and Pipe B outputs, Pipe E …_
+
+:bulb: **Remember the Quick-start chapter?** We used the working memory to store a character before processing it (and extract metadata from it).
+
+## Concepts
+
+A concept **defines** **what is processed** through pipes.
+
+**Rigorous concept definitions are the key to ensure controlled, reliable outputs.**
+
+Concepts are defined both with **natural language** (so non-developer and LLM can understand and write them) and **with code** (to validate them deterministically with software).
+
+Pipes embed **validation** of their outputs, so **we make sure of the knowledge we process and produce**.
+
+![Schema explaining structured output validation](output_validation.png)
+
+
+:bulb: **Remember the Quick-start chapter?** We defined a `Character` concept and a `CharacterMetadata` concept (in toml, using the [concept] section and with Python BaseModels) to define the input and output of the pipe!
+
+:bulb: Soon we will also add input validation for pipes.
+
+
+## Stuff
+
+On the code side, **when a concept is instantiated** (to be processed or added to the working memory), **we call it a Stuff**.
+
+:arrow_left: [**Back to Quick-start**](../Quick-start/Quick-start.md)
+
+:arrow_right: [**Next section: Libraries**](../Libraries/libraries.md)
+
+---
+
+"Pipelex" is a trademark of Evotis S.A.S.
+
+© 2025 Evotis S.A.S.
diff --git a/doc/pages/Pipelex paradigm/output_validation.png b/doc/pages/Pipelex paradigm/output_validation.png
new file mode 100644
index 000000000..6a4e68605
Binary files /dev/null and b/doc/pages/Pipelex paradigm/output_validation.png differ
diff --git a/doc/pages/Pipelex paradigm/pipe.png b/doc/pages/Pipelex paradigm/pipe.png
new file mode 100644
index 000000000..f564f0cc1
Binary files /dev/null and b/doc/pages/Pipelex paradigm/pipe.png differ
diff --git a/doc/pages/Pipelex paradigm/pipeline.png b/doc/pages/Pipelex paradigm/pipeline.png
new file mode 100644
index 000000000..c8f90f084
Binary files /dev/null and b/doc/pages/Pipelex paradigm/pipeline.png differ
diff --git a/doc/pages/Pipelex paradigm/working_memory.png b/doc/pages/Pipelex paradigm/working_memory.png
new file mode 100644
index 000000000..bf5f43b6f
Binary files /dev/null and b/doc/pages/Pipelex paradigm/working_memory.png differ
diff --git a/doc/pages/Pipes/Pipes.md b/doc/pages/Pipes/Pipes.md
new file mode 100644
index 000000000..fb68c658b
--- /dev/null
+++ b/doc/pages/Pipes/Pipes.md
@@ -0,0 +1,357 @@
+# Pipes
+
+A pipe is a **Pipeline step**.
+It can integrate **both LLM-based** or software-based knowledge processing.
+
+:bulb: **Remember the Quick-start chapter?** We defined a pipe (in toml, using the [pipe.create_character] section) to generate a character. It constituted a one-pipe-long pipeline.
+
+## Define pipes
+
+Like concepts, Pipes are defined using a **`toml` syntax.**
+
+- This part is meant to be **written in a library `toml` file, in the same one as concepts** (see [Libraries](../Libraries/library.md)).
+ 💡*In the quick-start example (text summary generator) this is the role of `summarize.toml`.*
+
+### General case
+
+This is how to define a Pipe using the Pipelex `toml` syntax.
+
+![Diagram showing the general structure of a Pipe definition in TOML format](pipe_toml.png)
+
+#### **Fields definition**
+
+```toml
+[pipe]
+[pipe.<pipe_name>]
+Pipe<Type> = "Pipe definition" # required, str
+input = "InputConcept" # required, str
+output = "OutputConcept" # required, str
+... then come the Pipe specific fields
+```
+
+- `Pipe<Type>`(str, required) The presence of this field indicates what type of pipe your are defining and adds a specific definition for it (explaining what it does).
+- Productive Pipes:
+ - `PipeLLM`: A call to an LLM whihc generates either text or a structured object, or a list of those.
+ - `PipeJinja2`: Application of a Jinja2 template to generate Text.
+- Control Pipes, to orchestrate the flow of the pipeline:
+
+ - `PipeSequence`: Sequence of Pipes that share a common working memory
+ - `PipeParallel`: Executes several pipes in parallel (asynchronously) and output a list of the results
+ - `PipeBatch`: Executes the same pipe on each item of a list and output a list of the results
+ - `PipeCondition`: Evaluate a test expression and choose which pipe to run according to the test's result
+
+- `input` (str, required) The expected input Concept (PascalCase)
+- `output` (str, required) The expected output Concept (PascalCase)
+- `additional specific fields` depending on the kind of Pipe you define.
+
+### Type 1: Pipe LLM
+
+If you specifically want to call an LLM and benefit from Pipelex scaffolding, PipeLLM is made for you.
+
+Pipe LLM embeds all you need to run reliable LLM calls in your pipeline.
+
+#### **PipeLLM fields description**
+
+```toml
+[pipe.<pipe_name>]
+PipeLLM = "Pipe definition" # required, str
+input = "InputConcept" # required, str
+output = "OutputConcept" # required, str
+llm = "llm_preset_name" # optional, str
+llm_to_structure = "llm_preset_name" # optional, str
+llm_to_structure_direct = "llm_preset_name" # optional, str
+system_prompt = """system prompt""" # optional, str
+prompt_template = """jinja2 prompt template""" # required, str
+images = [] # optional
+```
+
+- `PipeLLM`(str, required) The presence of this field indicates that your pipe is a PipeLLM and stores a definition of it (explaining what it does).
+- `input` (str, required) The expected input Concept (PascalCase)
+- `output` (str, required) The expected output Concept (PascalCase)
+- `llm` (str, optional) What llm_preset to use for text generation
+- `llm_to_structure` (str, optional) What llm_preset to use for structured object generation
+- `llm_to_structure_direct` (str, optional) What llm_preset to use for structured object list generation
+- `system_prompt` (str, optional) system prompt used in the LLM call
+- `prompt_template` (str, optional) prompt used in the LLM call. This can be a jinja template. See #Jinja
+- `images` (List[str], optional) A list of stuff names that contains images.
+
+#### **Example**
+
+This pipe outputs an html table from a table screenshot. It basically converts an image of a table into the html representation of it.
+
+```toml
+[pipe.get_html_table_from_image]
+PipeLLM = "Get an HTML table"
+input = "TableScreenshot"
+output = "HtmlTable"
+images = ["table_screenshot"]
+system_prompt = """
+You are a vision-based table extractor.
+"""
+prompt_template = """
+You are given a picture (screenshot) of a table, taken from a PDF document. Your goal is to extract the table from the image **in html**.
+Make sure you do not forget any text. Make sure you do not invent any text. Make sure your merge is consistent. Make sure you replicate the formatting (borders, text formatting, colors, text alignment...)
+"""
+llm = "llm_to_extract_tables"
+llm_to_structure = "llm_to_extract_tables"
+```
+
+### Type 2: PipeSequence
+
+PipeSequence embeds all you need to run multi-steps processing with a sequence of pipes.
+
+#### **PipeSequence fields description**
+
+- `PipeSequence` (str, required) The presence of this field indicates that your pipe is a PipeSequence and stores a definition of it (explaining what it does).
+- `input` (str, required) The expected input Concept (PascalCase)
+- `output` (str, required) The expected output Concept (PascalCase)
+- `steps` (List[Dict], required) The steps in the Pipe
+ - `result` (str, required) The name of the output stuff
+ - `pipe` (str, required) The `pipe_code` of the Pipe used for this step.
+
+```toml
+[pipe.<pipe_name>]
+PipeSequence = "Pipe definition" # required, str
+input = "InputConcept" # required, str
+output = "OutputConcept" # required, str
+steps = [ # required, List[Dict]
+ { result = "pipe_1_output_name", pipe = "pipe_1" },
+ { result = "pipe_2_output_name", pipe = "pipe_2" },
+ ...,
+ {result = "pipe_n_output_name", pipe = "pipe_n" },
+]
+```
+
+#### **PipeSequence example**
+
+```toml
+[pipe.answer_question_with_instructions]
+PipeSequence = "Answer a question with instructions"
+input = "Question"
+output = "FormattedAnswer"
+steps = [
+{ result = "instructions", pipe = "enrich_instructions" },
+{ result = "answer", pipe = "answer_enriched_question" },
+{ result = "formatted_answer", pipe = "format_answer" },
+]
+```
+
+#### **PipeParallel example**
+
+```toml
+[pipe.extract_expense_report]
+PipeParallel = "Extract useful information from an expense report"
+input = "ExpenseReportText"
+output = "Composite"
+parallels = [
+ { pipe = "extract_employee_from_expense_report", result = "employee" },
+ { pipe = "extract_expenses_from_expense_report", result = "expenses" },
+]
+```
+
+#### **PipeCondition example**
+
+```toml
+[pipe.expense_conditional_validation]
+PipeCondition = "Choose the rules to apply"
+input = "Expense"
+output = "RulesToApply"
+expression = "expense_category.category"
+```
+
+## Working Memory
+
+![Pipelex working memory cloud](working_memory_cloud.png)
+
+In a pipeline, processed Stuff are stored in the **Working** **Memory.** The working memory is accessible from any Pipe in the pipeline.
+
+Basically, the Working Memory is a wrapper on a Dict of Stuff objects.
+
+```python
+StuffDict = Dict[str, Stuff]
+
+class WorkingMemory(BaseModel):
+ root: StuffDict = Field(default_factory=dict)
+```
+
+**You can easily preload the memory with the dedicated Factory**
+
+```python
+from pipelex.core.stuff_factory import StuffFactory
+from pipelex.core.working_memory_factory import WorkingMemoryFactory
+
+# Here is a Stuff object
+table_screenshot_stuff = StuffFactory.make_from_str(
+ name="table_screenshot",
+ concept_code="TableScreenshot",
+ str_value=table_screenshot,
+)
+
+# And we load it in the memory
+working_memory = WorkingMemoryFactory.make_from_single_stuff(
+ table_screenshot_stuff,
+)
+```
+
+### Access memory in prompts
+
+You can access working memory stuffs directly in prompts using the jinja2 syntax.
+
+You just need to call them by their name.
+
+_PS: what comes after the | (stuff("extract") for instance) will be explained later._
+
+```toml
+[pipe.get_answer_with_extract]
+PipeLLM = "Answer the question with extract"
+input = "QuestionWithExtract"
+output = "AnswerToAQuestionWithExtract"
+prompt_template = """
+I am asking you to read an extract and answer a question about it.
+{{ question_with_extract|tag("extract") }} # question_with_extract
+{{ question_with_extract|tag("question") }}
+Please return your answer in english.
+"""
+```
+
+## Run Pipes
+
+Running pipes requires:
+
+### **A Pipe**
+
+```toml
+[concept]
+[concept.TableImage]
+Concept = "An image of a table, in the sense of a data structure used to organize information in rows and columns."
+structure = "ImageContent"
+refines = ["Image"]
+
+[concept.HtmlTable]
+Concept = "An HTML table"
+structure = "HtmlTable"
+
+[pipe]
+[pipe.get_html_table_from_image]
+PipeLLM = "Get an HTML table"
+input = "TableImage"
+output = "HtmlTable"
+images = ["table_image"]
+system_prompt = """You are a vision-based table extractor."""
+prompt_template = """You are given a picture (screenshot) of a table,
+taken from a PDF document.
+Your goal is to extract the table from the image **in html**.
+Make sure you do not forget any text.
+Make sure you do not invent any text.
+Make sure your merge is consistent.
+Make sure you replicate the formatting (borders, text formatting, colors, text alignment...)
+"""
+
+[pipe.review_html_table]
+PipeLLM = "Review an HTML table"
+input = "HtmlTable"
+output = "HtmlTable"
+images = ["table_image"]
+system_prompt = "You are a vision-based html checker."
+prompt_template = """Your role is to correct an html_table to make sure that it matches the one in the provided image.
+Here is the html table:{{ html_table|tag("html_table") }}
+Pay attention to the text and formatting (color, borders, ...).
+Rewrite the entire html table with your potential corrections.
+Make sure you do not forget any text.
+"""
+
+[pipe.get_html_table_and_review]
+PipeSequence = "Get an HTML table and review it"
+input = "TableScreenshot"
+output = "HtmlTable"
+steps = [
+ { pipe = "get_html_table_from_image", result = "html_table" },
+ { pipe = "review_html_table", result = "reviewed_html_table" },
+]
+```
+
+### Loading the Working Memory with the required Pipes and running it
+
+TODO
+
+## Run pipes with any LLM
+
+How to use a specific LLM for a specific pipe?
+
+### **`.env`**
+
+Make sure you have the appropriate API key(s) in your .env.
+
+| **LLM provider** | **API KEY NAME** |
+| ---------------- | ----------------------- |
+| Anthropic | `ANTHROPIC_API_KEY` |
+| Azure OpenAI | `AZURE_OPENAI_API_KEY` |
+| AWS | `AWS_ACCESS_KEY_ID` |
+| AWS | `AWS_SECRET_ACCESS_KEY` |
+| Mistral AI | `MISTRAL_API_KEY` |
+| OpenAI | `OPENAI_API_KEY` |
+
+### **`config_<your_workdir_name>_llm_presets.toml`**
+
+Create LLM presets to specify your model settings:
+
+```python
+[cogt.llm_config.llm_deck.llm_presets]
+llm_for_reviewing_code = { llm_handle = "gpt-4-turbo", prompting_target = "openai", temperature = 0.1, max_tokens = "auto" }
+```
+
+- `llm_preset_<your_name_for_this_llm_preset>`(optional): Define LLM presets to store your LLM settings and use them when running pipes
+ - `llm_handle` (required, str) the codename for the LLM
+- `prompting_target` (required, str) indicates what prompting style to apply when processing your input prompt_templates.
+- `temperature`(required, float) LLM temperature
+- `max_tokens` (required, int or "auto") auto means maximum value provided by the LLM provider
+
+#### Available LLMs
+
+- **Anthropic**
+
+| **Model Family** | **Model** | **LLM handle** |
+| ---------------- | -------------------- | ---------------------- |
+| claude-3 | Claude 3 Haiku | `claude-3-haiku` |
+| claude-3 | Claude 3 Opus | `claude-3-opus` |
+| claude-3.5 | Claude 3.5 Sonnet | `claude-3-5-sonnet` |
+| claude-3.5 | Claude 3.5 Sonnet v2 | `claude-3-5-sonnet-v2` |
+| claude-3.7 | Claude 3.7 Sonnet | `claude-3-7-sonnet` |
+
+- **Mistral AI**
+
+| **Model Family** | **Model** | **LLM handle** |
+| ---------------- | ------------- | ------------------- |
+| Ministral | Ministral 3B | `ministral-3b` |
+| Ministral | Ministral 8B | `ministral-8b` |
+| Mistral | Mistral 7B | `mistral-7b` |
+| Mistral | Mixtral 8x7B | `mistral-8x7b` |
+| Mistral | Codestral | `mistral-codestral` |
+| Mistral | Mistral Large | `mistral-large` |
+| Mistral | Mistral Small | `mistral-small` |
+| Pixtral | Pixtral 12B | `pixtral-12b` |
+| Pixtral | Pixtral Large | `pixtral-large` |
+
+- **Open AI**
+
+| **Model Family** | **Model** | **LLM handle** |
+| ---------------- | ---------------------- | ------------------------ |
+| GPT-4 | GPT-4 Turbo | `gpt-4-turbo` |
+| GPT-4 | GPT-4o (May 2024) | `gpt-4o-2024-05-13` |
+| GPT-4 | GPT-4o (Aug 2024) | `gpt-4o-2024-08-06` |
+| GPT-4 | GPT-4o (Nov 2024) | `gpt-4o-2024-11-20` |
+| GPT-4 | GPT-4o | `gpt-4o` |
+| GPT-4 | GPT-4o Mini (Jul 2024) | `gpt-4o-mini-2024-07-18` |
+| GPT-4 | GPT-4o Mini | `gpt-4o-mini` |
+| GPT-4.5 | GPT-4.5 Preview | `gpt-4.5-preview` |
+| o | o1-mini | `o1-mini` |
+| o | o1 | `o1` |
+| o | o3-mini | `o3-mini` |
+
+:arrow_left: [**Back to Concepts**](../Concepts/Concepts.md)
+
+---
+
+"Pipelex" is a trademark of Evotis S.A.S.
+
+© 2025 Evotis S.A.S.
diff --git a/doc/pages/Pipes/pipe_toml.png b/doc/pages/Pipes/pipe_toml.png
new file mode 100644
index 000000000..9c95c5c5d
Binary files /dev/null and b/doc/pages/Pipes/pipe_toml.png differ
diff --git a/doc/pages/Pipes/working_memory_cloud.png b/doc/pages/Pipes/working_memory_cloud.png
new file mode 100644
index 000000000..085960451
Binary files /dev/null and b/doc/pages/Pipes/working_memory_cloud.png differ
diff --git a/doc/pages/Quick-start/Quick-start.md b/doc/pages/Quick-start/Quick-start.md
new file mode 100644
index 000000000..6038b060d
--- /dev/null
+++ b/doc/pages/Quick-start/Quick-start.md
@@ -0,0 +1,265 @@
+# Quick-start
+
+In this section, we introduce the basics of Pipelex for the simplest use-cases: LLM calling and structured outputs.
+
+You can **run the following examples** directly from the [Getting-started repository](https://github.com/Pipelex/ev-getting-started).
+No need to create files in the getting-started repo, they are already there.
+
+## Your first LLM call with Pipelex
+
+Let's start by running your very first LLM call using the Pipelex framework.
+For illustration purposes, let's build **a character generator.**
+
+### **🖊️ Write your first Pipelex script:**
+
+You have to create a `TOML` library file that will store your Pipelex script.
+If you are using Pipelex elsewhere than in the Getting Started repository, make sure you add this file to the `pipelex_libraries` folder.
+
+```toml
+# character.toml
+
+# Library definition
+domain = "characters"
+definition = "Tools for creating characters"
+
+# Pipe definition
+[pipe]
+[pipe.create_character]
+PipeLLM = "Creates a character."
+output = "Text"
+prompt_template = """You are a book writer. Your task is to create a character.
+Think of it and then output the character description."""
+```
+
+### **🏃 Run your first Pipelex script:**
+
+You have to create a `python` file to run your script. You can save it anywhere in your repository.
+
+```python
+# character.py
+
+import asyncio
+from pipelex.pipelex import Pipelex
+from pipelex.run import execute_pipe
+
+async def create_character() -> str:
+ # Run the script with execute_pipe
+ pipe_output = await execute_pipe(
+ pipe_code="create_character",
+ )
+ # Print the output
+ print(pipe_output.main_stuff_as_text)
+
+# Setup required to initialize the Pipelex framework and load the pipeline libraries
+Pipelex.make()
+
+# Run using asyncio because our APIs are all async
+asyncio.run(create_character())
+```
+
+### **🎉 Get your first Pipelex result!**
+
+```bash
+python character.py
+```
+
+![Example of a generated character sheet](character_sheet.png)
+
+## How to use a specific LLM
+
+### **🖊️ Indicate your LLM selection explicitly using the `llm` attribute:**
+
+```toml
+[pipe.create_character]
+PipeLLM = "Create a character."
+output = "Text"
+prompt_template = """You are a book writer. Your task is to create a character.
+Think of it and then output the character description."""
+llm = { llm_handle = "gpt-4o-mini", temperature = 0.9, max_tokens = "auto" }
+```
+
+### **🖊️ Or use an LLM preset:**
+
+```toml
+[pipe.create_character]
+PipeLLM = "Create a character."
+output = "Text"
+prompt_template = """You are a book writer. Your task is to create a character.
+Think of it and then output the character description."""
+llm = "llm_for_creative_writing"
+
+# The llm preset above is defined in `pipelex_libraries/llm_deck/base_llm_deck.toml` as:
+# llm_for_creative_writing = { llm_handle = "best-claude", temperature = 0.9 }
+# it's a base preset but you can add your own
+```
+
+💡We have a lot of [LLM presets available](https://github.com/Pipelex/pipelex/tree/main/pipelex/libraries/llm_deck/base_llm_deck.toml).
+Make sure you have credentials for the underlying LLM provider (and added your API key to the `.env`) and select the one you want!
+
+### **Generate a structured output**
+
+Let's say that we no longer want plain text as output but a rigorous, structured Character object.
+
+### **🖊️ Define the model**
+
+Using the [Pydantic Basemodel](https://docs.pydantic.dev/latest/) syntax, define your object structure as a Python class.
+
+```python
+# pipelex_libraries/pipelines/characters.py
+
+from pipelex.core.stuff_content import StructuredContent
+
+# Define the structure of your output here
+# This class must inherit from StructuredContent
+class Character(StructuredContent):
+ name: str
+ age: int
+ gender: str
+ description: str
+```
+
+### **🖊️ Write the script**
+
+It's time to specify that your output should be a `Character` instance. Use the `output` field for that purpose.
+
+💡 Here, the concept name matches the class name (ie. `Character`), the `Character` class will automatically be considered as the structure to output.
+
+```toml
+domain = "characters"
+definition = "Tools for creating characters"
+
+[concept]
+[concept.Character]
+Concept = "A character is a fiction story"
+# Concept matches class name. Structure is automatically used for structuring the output
+
+[pipe]
+[pipe.create_character]
+PipeLLM = "Create a character. Get a structured result."
+output = "Character"
+prompt_template = """You are a book writer. Your task is to create a character.
+Think of it and then output the character description."""
+```
+
+💡 Defining the `Character` concept as "A character is a fiction story" might seem obvious but… think of it: "character" can also mean a letter or symbol in a text. Defining concepts is the best way to avoid any ambiguity and make sure the LLMs understand what you mean.
+
+### **🏃 Run**
+
+![Example of a generated character sheet with structure](structured_character_sheet.png)
+
+As you can see, the output is a `Character` instance.
+
+![Example of a generated character sheet with structure in JSON](structured_character_sheet_json.png)
+
+
+## Generate using information in a prompt template
+
+What if you want to integrate some data into prompts?
+You can do that using a prompt template.
+
+In this example, we no longer want to generate characters. We want to process existing ones, especially their description attributes.
+
+We want to extract structured information from the description field. Thus we have a `Character` input and a `CharacterMetadata` output.
+
+### **Define the output structure**
+
+```python
+# pipelex_libraries/character_model.py
+from pipelex.core.stuff_content import StructuredContent
+
+# input class
+class Character(StructuredContent):
+ name: str
+ age: int
+ gender: str
+ occupation: str
+ description: str
+
+# output class
+class CharacterMetadata(StructuredContent):
+ name: str
+ age: int
+ height: float
+```
+
+### **Let's use a template to fill prompts with data:**
+
+💡Our template syntax is based on [Jinja2 syntax](https://jinja.palletsprojects.com/en/stable/) so you can include a variable using the classic {{ double.curly.braces }} and to make it simpler, we've added the possibility to just prefix your variable with the "@" symbol:
+
+```toml
+[concept]
+Character = "A character from a book"
+CharacterMetadata = "Metadata regarding a character."
+
+[pipe]
+[pipe.extract_character_1]
+PipeLLM = "Get character information from a description."
+input = "Character"
+output = "CharacterMetadata"
+prompt_template = """
+You are given a text description of a character.
+Your task is to extract specific data from the following description.
+
+"""
+```
+
+### **This is how you do it from the code side**
+
+```python
+from pipelex.core.stuff_factory import StuffFactory
+from pipelex.run import run_pipe_code
+from pipelex_libraries.pipeline.characters import Character, CharacterMetadata
+
+async def process_existing_character():
+ # Your existing data
+ character = Character(
+ name="Elias",
+ age=38,
+ gender="man",
+ description = """Elias Varrin is a 38-year-old man, standing at approximately 1.85 meters tall, with a lean,
+ weathered frame shaped by decades of travel through remote and often unforgiving landscapes.
+ His name, though not widely known, carries weight among historians, explorers, and those who trade in whispered legends.
+ Elias has piercing storm-gray eyes that scan every environment with sharp precision, and his ash-blond hair—flecked with
+ early streaks of grey—is usually tucked beneath a wide-brimmed, timeworn hat.His hands are etched with fine scars and stained
+ with ink, each mark a silent record of years spent charting unrecorded lands and handling fragile relics of lost civilizations.
+ He moves with quiet purpose and speaks with a calm, thoughtful cadence that suggests he's always listening for more than just what's said."""
+ )
+ # Wrap it into a stuff object
+ character_stuff = StuffFactory.make_stuff(
+ concept_code="character.Character",
+ name="character",
+ content=character,
+ )
+ # Add it to the working memory
+ working_memory = WorkingMemoryFactory.make_from_single_stuff(
+ stuff=character_stuff,
+ )
+ # Run the pipe identified by its pipe_code (it's the name of the pipe)
+ pipe_output = await run_pipe_code(
+ pipe_code="extract_character_1",
+ working_memory=working_memory,
+ )
+
+ # Get the result as a porperly typed instance
+ extracted_metadata = pipe_output.main_stuff_as(content_type=CharacterMetadata)
+
+ print(CharacterMetadata)
+
+Pipelex.make()
+asyncio.run(create_character())
+```
+
+### **Get result**
+
+![Example of extracted character metadata](extracted_character_metadata)
+
+:arrow_left: [**Back to Installation**](../Installation/Installation.md)
+
+:arrow_right: [**Next section: Pipelex paradigm**](../Pipelex%20paradigm/Pipelex%20paradigm.md)
+
+---
+
+"Pipelex" is a trademark of Evotis S.A.S.
+
+© 2025 Evotis S.A.S.
diff --git a/doc/pages/Quick-start/character_sheet.png b/doc/pages/Quick-start/character_sheet.png
new file mode 100644
index 000000000..359cd760b
Binary files /dev/null and b/doc/pages/Quick-start/character_sheet.png differ
diff --git a/doc/pages/Quick-start/extracted_character_metadata.png b/doc/pages/Quick-start/extracted_character_metadata.png
new file mode 100644
index 000000000..bd4c235a9
Binary files /dev/null and b/doc/pages/Quick-start/extracted_character_metadata.png differ
diff --git a/doc/pages/Quick-start/structured_character_sheet.png b/doc/pages/Quick-start/structured_character_sheet.png
new file mode 100644
index 000000000..0b659c76d
Binary files /dev/null and b/doc/pages/Quick-start/structured_character_sheet.png differ
diff --git a/doc/pages/Quick-start/structured_character_sheet_json.png b/doc/pages/Quick-start/structured_character_sheet_json.png
new file mode 100644
index 000000000..8ec628cf5
Binary files /dev/null and b/doc/pages/Quick-start/structured_character_sheet_json.png differ
diff --git a/doc/templates/pipes.toml b/doc/templates/pipes.toml
new file mode 100644
index 000000000..edea6cfba
--- /dev/null
+++ b/doc/templates/pipes.toml
@@ -0,0 +1,78 @@
+
+
+domain = "template"
+definition = "Template file demonstrating different pipe types in Pipelex"
+
+[concept]
+InputText = "A text input for processing"
+OutputText = "A processed text output"
+TableScreenshot = "An image of a table"
+HtmlTable = "An HTML table representation"
+Question = "A question to be answered"
+FormattedAnswer = "A formatted answer to a question"
+ExpenseReportText = "Text content of an expense report"
+Composite = "A composite output containing multiple pieces of information"
+Expense = "An expense record"
+RulesToApply = "Rules to be applied to an expense"
+
+[pipe]
+# Example of a PipeLLM
+[pipe.process_text]
+PipeLLM = "Process input text using an LLM"
+input = "Text"
+output = "Text"
+llm = "llm_to_summarize_text"
+system_prompt = """
+You are an expert in text summarization.
+"""
+prompt_template = """
+Summarize the following text:
+@text
+"""
+
+# Example of a PipeLLM with image processing
+[pipe.get_html_table_from_image]
+PipeLLM = "Convert table screenshot to HTML"
+input = "TableScreenshot"
+output = "HtmlTable"
+images = ["table_screenshot"]
+system_prompt = """
+You are a vision-based table extractor.
+"""
+prompt_template = """
+You are given a picture (screenshot) of a table, taken from a PDF document.
+Your goal is to extract the table from the image **in html**.
+Make sure you do not forget any text. Make sure you do not invent any text.
+Make sure your merge is consistent. Make sure you replicate the formatting
+(borders, text formatting, colors, text alignment...)
+"""
+llm = "llm_to_extract_tables"
+llm_to_structure = "llm_to_extract_tables"
+
+# Example of a PipeSequence
+[pipe.answer_question_with_instructions]
+PipeSequence = "Answer a question with instructions"
+input = "Question"
+output = "FormattedAnswer"
+steps = [
+ { result = "instructions", pipe = "enrich_instructions" },
+ { result = "answer", pipe = "answer_enriched_question" },
+ { result = "formatted_answer", pipe = "format_answer" },
+]
+
+# Example of a PipeParallel
+[pipe.extract_expense_report]
+PipeParallel = "Extract useful information from an expense report"
+input = "ExpenseReportText"
+output = "Composite"
+parallels = [
+ { pipe = "extract_employee_from_expense_report", result = "employee" },
+ { pipe = "extract_expenses_from_expense_report", result = "expenses" },
+]
+
+# Example of a PipeCondition
+[pipe.expense_conditional_validation]
+PipeCondition = "Choose the rules to apply"
+input = "Expense"
+output = "RulesToApply"
+expression = "expense_category.category"
diff --git a/pipelex/__init__.py b/pipelex/__init__.py
new file mode 100644
index 000000000..191fc7df8
--- /dev/null
+++ b/pipelex/__init__.py
@@ -0,0 +1,7 @@
+from pipelex.tools.log.log import log
+from pipelex.tools.misc.pretty import pretty_print
+
+__all__ = [
+ "log",
+ "pretty_print",
+]
diff --git a/pipelex/cli/__init__.py b/pipelex/cli/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/pipelex/cli/__init__.py
@@ -0,0 +1 @@
+
diff --git a/pipelex/cli/_cli.py b/pipelex/cli/_cli.py
new file mode 100644
index 000000000..262e69979
--- /dev/null
+++ b/pipelex/cli/_cli.py
@@ -0,0 +1,65 @@
+from typing import Annotated, Optional
+
+import typer
+from click import Command, Context
+from typer.core import TyperGroup
+from typing_extensions import override
+
+from pipelex import log, pretty_print
+from pipelex.libraries.library_config import LibraryConfig
+from pipelex.pipelex import Pipelex
+from pipelex.tools.config.manager import config_manager
+
+
+class PipelexCLI(TyperGroup):
+ @override
+ def get_command(self, ctx: Context, cmd_name: str) -> Optional[Command]:
+ cmd = super().get_command(ctx, cmd_name)
+ if cmd is None:
+ typer.echo(ctx.get_help())
+ ctx.exit(1)
+ return cmd
+
+
+app = typer.Typer(
+ add_completion=False,
+ no_args_is_help=True,
+ pretty_exceptions_show_locals=False,
+ cls=PipelexCLI,
+)
+
+
+def init(
+ overwrite: Annotated[bool, typer.Option("--overwrite", "-o", help="Warning: If set, existing files will be overwritten.")] = False,
+) -> None:
+ """Initialize pipelex configuration in the current directory."""
+ if overwrite:
+ typer.echo("Overwriting existing pipelex library files.")
+
+ # Duplicate pipelines and other libraries from the base library
+ LibraryConfig.export_libraries(overwrite=overwrite)
+
+
+def run_setup() -> None:
+ """Run the setup sequence."""
+ LibraryConfig.export_libraries()
+ Pipelex.make()
+ log.info("Running setup sequence passed OK.")
+
+
+def show_config() -> None:
+ """Show the pipelex configuration."""
+ try:
+ final_config = config_manager.load_config()
+ pretty_print(final_config, title=f"Pipelex configuration for project: {config_manager.get_project_name()}")
+ except Exception as e:
+ typer.echo(f"Error: {e}", err=True)
+ raise typer.Exit(1)
+
+
+def main() -> None:
+ """Entry point for the pipelex CLI."""
+ app()
diff --git a/pipelex/client/api_client.py b/pipelex/client/api_client.py
new file mode 100644
index 000000000..a395e642d
--- /dev/null
+++ b/pipelex/client/api_client.py
@@ -0,0 +1,159 @@
+from typing import Any, Optional, cast
+
+import httpx
+from kajson import kajson
+from typing_extensions import override
+
+from pipelex.client.protocol import (
+ ApiResponse,
+ PipelexProtocol,
+ PipeRequest,
+ PipeStartResponse,
+ PipeStatus,
+)
+from pipelex.tools.environment import get_required_env
+
+
+class PipelexApiClient(PipelexProtocol):
+ """
+ A protocol-compliant client for interacting with Pipelex pipes via API.
+
+ This client implements the PipelexProtocol interface for pure API communication.
+ """
+
+ def __init__(
+ self,
+ api_token: str,
+ ):
+ """
+ Initialize the PipelexApiClient.
+
+ Args:
+ api_token: Authentication token for the API
+ """
+ self.api_token = api_token
+ self.api_base_url = get_required_env("EV_API_BASE_URL")
+
+ def start_client(self) -> "PipelexApiClient":
+ self.client = httpx.AsyncClient(base_url=self.api_base_url, headers={"Authorization": f"Bearer {self.api_token}"})
+ return self
+
+ async def close(self):
+ """Close the HTTP client."""
+ await self.client.aclose()
+
+ async def _make_api_call(self, endpoint: str, request: Optional[str] = None) -> Any:
+ """Make an API call to the Pipelex server.
+
+ Args:
+ endpoint: The API endpoint to call, relative to the base URL
+ request: A JSON-formatted string to send as the request body, or None if no body is needed
+
+ Returns:
+ Any: The JSON-decoded response from the server
+
+ Raises:
+ httpx.HTTPError: If the request fails or returns a non-200 status code
+ """
+ # Convert JSON string to UTF-8 bytes if not None
+ content = request.encode("utf-8") if request is not None else None
+ response = await self.client.post(f"/{endpoint}", content=content, headers={"Content-Type": "application/json"}, timeout=120.0)
+ response.raise_for_status()
+ return response.json()
+
+ @override
+ async def execute_pipe(
+ self,
+ pipe_code: str,
+ request: PipeRequest,
+ ) -> PipeStatus:
+ """
+ Execute a pipe with the given request and wait for completion.
+
+ This is a blocking operation that does not return until the pipe execution
+ is complete. For long-running pipes, consider using start_pipe instead.
+
+ Args:
+ pipe_code: The unique identifier for the pipe to execute
+ request: PipeRequest containing memory and output concept
+
+ Returns:
+ PipeStatus with the final execution status and pipe output
+
+ Raises:
+ HTTPException: If the request fails or returns a non-200 status code
+ """
+ response = await self._make_api_call(f"pipelex/v1/pipes/{pipe_code}/execute", request=kajson.dumps(request))
+ return cast(PipeStatus, kajson.loads(response))
+
+ @override
+ async def start_pipe(
+ self,
+ pipe_code: str,
+ request: PipeRequest,
+ ) -> PipeStartResponse:
+ """
+ Start a pipe execution in the background without waiting for completion.
+
+ This is a non-blocking operation that returns immediately with an execution ID.
+ The execution will continue in the background, and the status can be checked
+ using get_pipe_status.
+
+ Args:
+ pipe_code: The unique identifier for the pipe to execute
+ request: PipeRequest containing memory and output concept
+
+ Returns:
+ PipeStartResponse with the pipe_execution_id and created_at timestamp
+
+ Raises:
+ HTTPException: If the request fails or returns a non-200 status code
+ """
+ response = await self._make_api_call(f"pipelex/v1/pipes/{pipe_code}/start", request=kajson.dumps(request))
+ return cast(PipeStartResponse, kajson.loads(response))
+
+ @override
+ async def get_pipe_status(
+ self,
+ pipe_execution_id: str,
+ ) -> PipeStatus:
+ """
+ Get the current status of a pipe execution.
+
+ This method allows checking the current status of a pipe execution
+ that was started with start_pipe.
+
+ Args:
+ pipe_execution_id: The unique identifier for the pipe execution
+
+ Returns:
+ PipeStatus with the current execution status and pipe output if completed
+
+ Raises:
+ HTTPException: If the request fails or returns a non-200 status code
+ """
+ response = await self._make_api_call(f"pipelex/v1/pipes/{pipe_execution_id}/status", request=None)
+ return cast(PipeStatus, kajson.loads(response))
+
+ @override
+ async def cancel_pipe(
+ self,
+ pipe_execution_id: str,
+ ) -> ApiResponse:
+ """
+ Cancel a running pipe execution.
+
+ This method attempts to cancel a pipe execution that is currently in progress.
+ Once cancelled, a pipe cannot be resumed and must be started again if needed.
+
+ Args:
+ pipe_execution_id: The unique identifier for the pipe execution
+
+ Returns:
+ ApiResponse indicating success or failure of the cancellation
+
+ Raises:
+ HTTPException: If the request fails or returns a non-200 status code
+ """
+ response = await self._make_api_call(f"pipelex/v1/pipes/{pipe_execution_id}/cancel", request=None)
+ return ApiResponse(**response)
diff --git a/pipelex/client/client.py b/pipelex/client/client.py
new file mode 100644
index 000000000..e8ea401fd
--- /dev/null
+++ b/pipelex/client/client.py
@@ -0,0 +1,137 @@
+from typing import Optional
+
+from pipelex.client.api_client import PipelexApiClient
+from pipelex.client.protocol import (
+ PipeRequest,
+ PipeStartResponse,
+ PipeState,
+ PipeStatus,
+)
+from pipelex.exceptions import ClientAuthenticationError
+from pipelex.run import run_pipe_code
+
+
+class PipelexClient:
+ """
+ A high-level client for interacting with Pipelex pipes.
+
+ This client provides a user-friendly interface for executing pipes either locally
+ or through the remote API, with automatic handling of both modes.
+ """
+
+ def __init__(
+ self,
+ api_token: Optional[str] = None,
+ ):
+ """
+ Initialize the PipelexClient.
+
+ Args:
+ api_token: Authentication token for the API
+ """
+ self.api_token = api_token
+ self.api_client: Optional[PipelexApiClient] = None
+
+ async def start_api_client(self) -> PipelexApiClient:
+ """
+ Start the API client.
+ """
+ if not self.api_token:
+ raise ClientAuthenticationError("API token is required for API execution")
+
+ self.api_client = PipelexApiClient(api_token=self.api_token).start_client()
+ return self.api_client
+
+ async def close_api_client(self):
+ """
+ Close the API client.
+ """
+ if self.api_client:
+ await self.api_client.close()
+ self.api_client = None
+
+ async def execute_pipe(
+ self,
+ pipe_code: str,
+ pipe_execute_request: PipeRequest,
+ use_local_execution: bool = True,
+ ) -> PipeStatus:
+ """
+ Execute a pipe with the given request and wait for completion.
+
+ Args:
+ pipe_code: The code of the pipe to execute
+ pipe_execute_request: The request containing memory and output concept
+ use_local_execution: Whether to execute locally (True) or via API (False)
+
+ Returns:
+ PipeStatus with execution results and pipe output
+ """
+ # Local execution
+ if use_local_execution:
+ pipe_output = await run_pipe_code(
+ pipe_code=pipe_code,
+ working_memory=pipe_execute_request.memory,
+ dynamic_output_concept_code=pipe_execute_request.dynamic_output_concept,
+ )
+ return PipeStatus(
+ pipe_execution_id="local",
+ pipe_code=pipe_code,
+ state=PipeState.COMPLETED,
+ pipe_output=pipe_output,
+ )
+ # api_client = await self.start_api_client()
+ # return await api_client.execute_pipe(pipe_code, pipe_execute_request)
+ raise NotImplementedError("Pipelex API functionality is coming soon!")
+
+ async def start_pipe(
+ self,
+ pipe_code: str,
+ pipe_execute_request: PipeRequest,
+ ) -> PipeStartResponse:
+ """
+ Start a pipe execution in the background without waiting for completion.
+
+ This is a non-blocking operation that returns immediately with an execution ID.
+ The execution will continue in the background, and the status can be checked
+ using get_pipe_status. Note that this method always uses API execution.
+
+ Args:
+ pipe_code: The code of the pipe to execute
+ pipe_execute_request: The request containing memory and output concept
+
+ Returns:
+ PipeStartResponse with the pipe_execution_id and created_at timestamp
+
+ Raises:
+ ValueError: If API token is not provided
+ HTTPException: If the API request fails
+ """
+ # api_client = await self.start_api_client()
+ # return await api_client.start_pipe(pipe_code, pipe_execute_request)
+ raise NotImplementedError("Pipelex API functionality is coming soon!")
+
+ async def get_pipe_status(
+ self,
+ pipe_execution_id: str,
+ ) -> PipeStatus:
+ """
+ Get the current status of a pipe execution.
+
+ This method allows checking the current status of a pipe execution
+ that was started with start_pipe. Note that this method always uses
+ API execution.
+
+ Args:
+ pipe_execution_id: The unique identifier for the pipe execution
+
+ Returns:
+ PipeStatus with the current execution status and pipe output if completed
+
+ Raises:
+ ValueError: If API token is not provided
+ HTTPException: If the API request fails or the execution ID is invalid
+ """
+ # api_client = await self.start_api_client()
+ # return await api_client.get_pipe_status(pipe_execution_id)
+ raise NotImplementedError("Pipelex API functionality is coming soon!")
diff --git a/pipelex/client/protocol.py b/pipelex/client/protocol.py
new file mode 100644
index 000000000..0177d5948
--- /dev/null
+++ b/pipelex/client/protocol.py
@@ -0,0 +1,180 @@
+from abc import abstractmethod
+from enum import StrEnum
+from typing import Optional, Protocol
+
+from pydantic import BaseModel, Field
+from typing_extensions import runtime_checkable
+
+from pipelex.core.pipe_output import PipeOutput
+from pipelex.core.pipe_run_params import PipeOutputMultiplicity
+from pipelex.core.working_memory import WorkingMemory
+
+
+class PipeState(StrEnum):
+ """
+ Enum representing the possible states of a pipe execution.
+ """
+
+ RUNNING = "running"
+ COMPLETED = "completed"
+ FAILED = "failed"
+ CANCELLED = "cancelled"
+ ERROR = "error"
+
+
+class ApiResponse(BaseModel):
+ """
+ Base response class for Pipelex API calls.
+
+ Attributes:
+ status: Status of the API call ("success", "error", etc.)
+ message: Optional message providing additional information
+ error: Optional error message when status is not "success"
+ """
+
+ status: str
+ message: Optional[str] = None
+ error: Optional[str] = None
+
+
+class PipeStatus(BaseModel):
+ """
+ Status information for a pipe execution.
+
+ Attributes:
+ pipe_execution_id: Unique identifier for this execution
+ pipe_code: Code of the pipe that was executed
+ state: Current state of execution (running, completed, failed, etc.)
+ created_at: ISO 8601 formatted timestamp (YYYY-MM-DDThh:mm:ss.sssZ) when execution started
+ finished_at: ISO 8601 formatted timestamp (YYYY-MM-DDThh:mm:ss.sssZ) when execution finished,
+ only populated for completed or failed executions
+ result: Complete WorkingMemory with all results, only populated when execution is finished
+ main_output: Primary output Stuff instance, only populated when execution is finished
+ """
+
+ pipe_execution_id: str
+ pipe_code: str
+ state: PipeState
+ created_at: Optional[str] = None # ISO format timestamp, only populated when execution is finished
+ finished_at: Optional[str] = None # ISO format timestamp, only populated when execution is finished
+ pipe_output: Optional[PipeOutput] = None
+
+
+class PipeStartResponse(ApiResponse):
+ """
+ Response for pipe execution requests when starting a pipe in non-blocking mode.
+
+ This response is returned when a pipe execution is started but does not wait for completion.
+ It contains only the minimal details needed to identify and track the execution.
+ For results, the client must call get_pipe_status with the pipe_execution_id.
+
+ Attributes:
+ pipe_execution_id: Unique identifier for this execution, used to check status later
+ created_at: ISO 8601 formatted timestamp (YYYY-MM-DDThh:mm:ss.sssZ) when execution started
+
+ # Inherited from ApiResponse:
+ status: Status of the API call ("success", "error", etc.)
+ message: Optional message providing additional information
+ error: Optional error message when status is not "success"
+ """
+
+ pipe_execution_id: str
+ created_at: str
+
+
+class PipeRequest(BaseModel):
+ """
+ Request model for executing a pipe.
+ """
+
+ memory: WorkingMemory = Field(..., description="Input memory for the pipe")
+ dynamic_output_concept: Optional[str] = Field(default=None, description="Concept code of the output stuff")
+ output_multiplicity: Optional[PipeOutputMultiplicity] = Field(default=None, description="Multiplicity of the output stuff")
+
+
+@runtime_checkable
+class PipelexProtocol(Protocol):
+ """
+ Protocol defining the contract for the Pipelex API.
+
+ This protocol specifies the interface that any Pipelex API implementation must adhere to.
+ The protocol includes methods for executing pipes both synchronously and asynchronously,
+ as well as cancelling running executions.
+ """
+
+ @abstractmethod
+ async def execute_pipe(self, pipe_code: str, request: PipeRequest) -> PipeStatus:
+ """
+ Execute a pipe with the given memory and wait for completion.
+
+ This is a blocking operation that does not return until the pipe execution
+ is complete. For long-running pipes, consider using start_pipe instead.
+
+ Args:
+ pipe_code: The unique identifier for the pipe to execute
+ request: PipeRequest containing the input instances required by the pipe
+
+ Returns:
+ PipeStatus with the final execution status including complete results.
+
+ Raises:
+ HTTPException: If the execution fails or encounters an error
+ """
+ ...
+
+ @abstractmethod
+ async def start_pipe(self, pipe_code: str, request: PipeRequest) -> PipeStartResponse:
+ """
+ Start a pipe execution in the background without waiting for completion.
+
+ This is a non-blocking operation that returns immediately with an execution ID.
+
+ Args:
+ pipe_code: The unique identifier for the pipe to execute
+ request: PipeRequest containing the input instances required by the pipe
+
+ Returns:
+ PipeStartResponse with the pipe_execution_id and created_at timestamp.
+
+ Raises:
+ HTTPException: If starting the execution fails
+ """
+ ...
+
+ @abstractmethod
+ async def cancel_pipe(self, pipe_execution_id: str) -> ApiResponse:
+ """
+ Cancel a running pipe execution.
+
+ This method allows clients to stop a pipe execution that is currently in progress.
+ Once cancelled, a pipe cannot be resumed and must be started again if needed.
+
+ Args:
+ pipe_execution_id: The unique identifier for the pipe execution
+
+ Returns:
+ ApiResponse indicating success or failure of the cancellation
+
+ Raises:
+ HTTPException: If the cancellation fails or the execution ID is invalid
+ """
+ ...
+
+ @abstractmethod
+ async def get_pipe_status(self, pipe_execution_id: str) -> PipeStatus:
+ """
+ Get the current status of a pipe execution.
+
+ This method allows clients to check the current status of a pipe execution
+ that was started with start_pipe.
+
+ Args:
+ pipe_execution_id: The unique identifier for the pipe execution
+
+ Returns:
+ PipeStatus with the current execution status
+
+ Raises:
+ HTTPException: If the status check fails or the execution ID is invalid
+ """
+ ...
diff --git a/pipelex/cogt/__init__.py b/pipelex/cogt/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/pipelex/cogt/__init__.py
@@ -0,0 +1 @@
+
diff --git a/pipelex/cogt/config_cogt.py b/pipelex/cogt/config_cogt.py
new file mode 100644
index 000000000..b2b6754ee
--- /dev/null
+++ b/pipelex/cogt/config_cogt.py
@@ -0,0 +1,94 @@
+from typing import Dict, List, Optional, cast
+
+from pydantic import Field, field_validator
+
+from pipelex.cogt.imgg.imgg_handle import ImggHandle
+from pipelex.cogt.imgg.imgg_job_components import ImggJobConfig, ImggJobParams, ImggJobParamsDefaults
+from pipelex.cogt.llm.llm_job_components import LLMJobConfig
+from pipelex.cogt.llm.llm_models.llm_platform import LLMPlatform
+from pipelex.cogt.plugin.anthropic.anthropic_config import AnthropicConfig
+from pipelex.cogt.plugin.bedrock.bedrock_config import BedrockConfig
+from pipelex.cogt.plugin.mistral.mistral_config import MistralConfig
+from pipelex.cogt.plugin.openai.azure_openai_config import AzureOpenAIConfig
+from pipelex.cogt.plugin.openai.custom_openai_config import CustomOpenAIConfig
+from pipelex.cogt.plugin.openai.openai_config import OpenAIOpenAIConfig
+from pipelex.cogt.plugin.openai.perplexity_config import PerplexityConfig
+from pipelex.cogt.plugin.openai.vertexai_config import VertexAIConfig
+from pipelex.tools.config.models import ConfigModel
+
+
+class CogtReportConfig(ConfigModel):
+ is_log_costs_to_console: bool
+ is_generate_cost_report_file_enabled: bool
+ cost_report_dir_path: str
+ cost_report_base_name: str
+ cost_report_extension: str
+ cost_report_unit_scale: float
+
+
+class OcrConfig(ConfigModel):
+ ocr_handles: List[str]
+ page_output_text_file_name: str
+
+
+class ImggConfig(ConfigModel):
+ default_imgg_handle: ImggHandle = Field(strict=False)
+ imgg_job_config: ImggJobConfig
+ imgg_param_defaults: ImggJobParamsDefaults
+ imgg_handles: List[str]
+
+ def make_default_imgg_job_params(self) -> ImggJobParams:
+ return self.imgg_param_defaults.make_imgg_job_params()
+
+
+class InstructorConfig(ConfigModel):
+ is_openai_structured_output_enabled: bool
+
+
+class LLMConfig(ConfigModel):
+ preferred_platforms: Dict[str, LLMPlatform]
+
+ anthropic_config: AnthropicConfig
+ azure_openai_config: AzureOpenAIConfig
+ bedrock_config: BedrockConfig
+ vertexai_config: VertexAIConfig
+ mistral_config: MistralConfig
+ openai_openai_config: OpenAIOpenAIConfig
+ perplexity_config: PerplexityConfig
+ custom_openai_config: CustomOpenAIConfig
+
+ instructor_config: InstructorConfig
+ llm_job_config: LLMJobConfig
+
+ default_max_images: int
+
+ @field_validator("preferred_platforms", mode="before")
+ def validate_preferred_platforms_enums(cls, value: Dict[str, str]) -> Dict[str, LLMPlatform]:
+ """
+ Transform what we got for preferred_platforms (Dict[str, str]) into what the field requires: Dict[str, LLMPlatform]
+ """
+ the_dict = cast(
+ Dict[str, LLMPlatform],
+ ConfigModel.transform_dict_str_to_enum(
+ input_dict=value,
+ value_enum_cls=LLMPlatform,
+ ),
+ )
+ return the_dict
+
+ def get_preferred_platform(self, llm_name: str) -> Optional[LLMPlatform]:
+ return self.preferred_platforms.get(llm_name)
+
+
+class InferenceManagerConfig(ConfigModel):
+ is_auto_setup_preset_llm: bool
+ is_auto_setup_preset_imgg: bool
+ is_auto_setup_preset_ocr: bool
+
+
+class Cogt(ConfigModel):
+ inference_manager_config: InferenceManagerConfig
+ cogt_report_config: CogtReportConfig
+ llm_config: LLMConfig
+ imgg_config: ImggConfig
+ ocr_config: OcrConfig
diff --git a/pipelex/cogt/content_generation/__init__.py b/pipelex/cogt/content_generation/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/pipelex/cogt/content_generation/__init__.py
@@ -0,0 +1 @@
+
diff --git a/pipelex/cogt/content_generation/assignment_models.py b/pipelex/cogt/content_generation/assignment_models.py
new file mode 100644
index 000000000..686fbff66
--- /dev/null
+++ b/pipelex/cogt/content_generation/assignment_models.py
@@ -0,0 +1,133 @@
+from typing import Any, Dict, Optional, Type
+
+from kajson.class_registry import class_registry
+from pydantic import BaseModel
+from typing_extensions import override
+
+from pipelex import log
+from pipelex.cogt.exceptions import LLMAssignmentError
+from pipelex.cogt.imgg.imgg_handle import ImggHandle
+from pipelex.cogt.imgg.imgg_job_components import ImggJobConfig, ImggJobParams
+from pipelex.cogt.imgg.imgg_prompt import ImggPrompt
+from pipelex.cogt.llm.llm_job_components import LLMJobParams
+from pipelex.cogt.llm.llm_models.llm_setting import LLMSetting
+from pipelex.cogt.llm.llm_prompt import LLMPrompt
+from pipelex.cogt.llm.llm_prompt_factory_abstract import LLMPromptFactoryAbstract
+from pipelex.cogt.ocr.ocr_handle import OcrHandle
+from pipelex.cogt.ocr.ocr_input import OcrInput
+from pipelex.cogt.ocr.ocr_job_components import OcrJobConfig, OcrJobParams
+from pipelex.mission.job_metadata import JobMetadata
+from pipelex.tools.templating.jinja2_environment import Jinja2TemplateCategory
+from pipelex.tools.templating.templating_models import PromptingStyle
+
+
+class LLMAssignmentFactory(BaseModel):
+ job_metadata: JobMetadata
+ llm_setting: LLMSetting
+ llm_prompt_factory: LLMPromptFactoryAbstract
+
+ async def make_llm_assignment(
+ self,
+ job_metadata: Optional[JobMetadata] = None,
+ llm_setting: Optional[LLMSetting] = None,
+ **prompt_arguments: Any,
+ ) -> "LLMAssignment":
+ log.verbose(f"Making LLMAssignment with prompt arguments: {prompt_arguments}, using {self.llm_prompt_factory.desc}")
+ llm_prompt = await self.llm_prompt_factory.make_llm_prompt_from_args(**prompt_arguments)
+ return LLMAssignment(
+ job_metadata=job_metadata or self.job_metadata,
+ llm_setting=llm_setting or self.llm_setting,
+ llm_prompt=llm_prompt,
+ )
+
+
+class LLMAssignment(BaseModel):
+ job_metadata: JobMetadata
+ llm_setting: LLMSetting
+ llm_prompt: LLMPrompt
+
+ def clone_with_new_prompt(self, new_prompt: LLMPrompt) -> "LLMAssignment":
+ return LLMAssignment(
+ job_metadata=self.job_metadata,
+ llm_setting=self.llm_setting,
+ llm_prompt=new_prompt,
+ )
+
+ @property
+ def desc(self) -> str:
+ description = "LLMAssignment:"
+ description += f"\n llm_setting: {self.llm_setting}\n"
+ description += f"\n llm_prompt: {self.llm_prompt}\n"
+ return description
+
+ @override
+ def __str__(self) -> str:
+ return self.desc
+
+ @property
+ def llm_handle(self) -> str:
+ log.dev(f"Using llm_setting {self.llm_setting}")
+ return self.llm_setting.llm_handle
+
+ @property
+ def llm_job_params(self) -> LLMJobParams:
+ return self.llm_setting.make_llm_job_params()
+
+
+class ObjectAssignment(BaseModel):
+ object_class_name: str
+ llm_assignment_for_object: LLMAssignment
+
+ def __init__(self, **kwargs: Any):
+ super().__init__(**kwargs)
+ if not class_registry.has_class(name=self.object_class_name):
+ error_msg = f"Could not create ObjectAssignment for class '{self.object_class_name}' because it is not in the class registry."
+ raise LLMAssignmentError(error_msg)
+
+ @staticmethod
+ def make_for_class(
+ object_class: Type[BaseModel],
+ llm_assignment: LLMAssignment,
+ ) -> "ObjectAssignment":
+ object_class_name = object_class.__name__
+ class_registry.register_class(
+ class_type=object_class,
+ name=object_class_name,
+ should_warn_if_already_registered=False,
+ )
+
+ return ObjectAssignment(
+ object_class_name=object_class_name,
+ llm_assignment_for_object=llm_assignment,
+ )
+
+
+class TextThenObjectAssignment(BaseModel):
+ object_class_name: str
+ llm_assignment_for_text: LLMAssignment
+ llm_assignment_factory_to_object: LLMAssignmentFactory
+
+
+class ImggAssignment(BaseModel):
+ job_metadata: JobMetadata
+ imgg_handle: ImggHandle
+ imgg_prompt: ImggPrompt
+ imgg_job_params: ImggJobParams
+ imgg_job_config: ImggJobConfig
+ nb_images: int
+
+
+class Jinja2Assignment(BaseModel):
+ context: Dict[str, Any]
+ jinja2_name: Optional[str] = None
+ jinja2: Optional[str] = None
+ prompting_style: Optional[PromptingStyle] = None
+ template_category: Jinja2TemplateCategory = Jinja2TemplateCategory.LLM_PROMPT
+
+
+class OcrAssignment(BaseModel):
+ job_metadata: JobMetadata
+ ocr_handle: OcrHandle
+ ocr_input: OcrInput
+ ocr_job_params: OcrJobParams
+ ocr_job_config: OcrJobConfig
diff --git a/pipelex/cogt/content_generation/content_generator.py b/pipelex/cogt/content_generation/content_generator.py
new file mode 100644
index 000000000..5d1486cd8
--- /dev/null
+++ b/pipelex/cogt/content_generation/content_generator.py
@@ -0,0 +1,288 @@
+from typing import Any, Dict, List, Optional, Type, cast
+
+from typing_extensions import override
+
+from pipelex import log
+from pipelex.cogt.content_generation.assignment_models import (
+ ImggAssignment,
+ Jinja2Assignment,
+ LLMAssignment,
+ LLMAssignmentFactory,
+ ObjectAssignment,
+ OcrAssignment,
+ TextThenObjectAssignment,
+)
+from pipelex.cogt.content_generation.content_generator_protocol import ContentGeneratorProtocol, update_job_metadata
+from pipelex.cogt.content_generation.imgg_generate import imgg_gen_image_list, imgg_gen_single_image
+from pipelex.cogt.content_generation.jinja2_generate import jinja2_gen_text
+from pipelex.cogt.content_generation.llm_generate import llm_gen_object, llm_gen_object_list, llm_gen_text
+from pipelex.cogt.content_generation.ocr_generate import ocr_gen_extract_pages
+from pipelex.cogt.image.generated_image import GeneratedImage
+from pipelex.cogt.imgg.imgg_handle import ImggHandle
+from pipelex.cogt.imgg.imgg_job_components import ImggJobConfig, ImggJobParams
+from pipelex.cogt.imgg.imgg_prompt import ImggPrompt
+from pipelex.cogt.llm.llm_models.llm_setting import LLMSetting
+from pipelex.cogt.llm.llm_prompt import LLMPrompt
+from pipelex.cogt.llm.llm_prompt_factory_abstract import LLMPromptFactoryAbstract
+from pipelex.cogt.llm.llm_prompt_template import LLMPromptTemplate
+from pipelex.cogt.ocr.ocr_handle import OcrHandle
+from pipelex.cogt.ocr.ocr_input import OcrInput
+from pipelex.cogt.ocr.ocr_job_components import OcrJobConfig, OcrJobParams
+from pipelex.cogt.ocr.ocr_output import OcrOutput
+from pipelex.config import get_config
+from pipelex.mission.job_metadata import JobMetadata
+from pipelex.tools.templating.jinja2_environment import Jinja2TemplateCategory
+from pipelex.tools.templating.templating_models import PromptingStyle
+from pipelex.tools.typing.pydantic_utils import BaseModelTypeVar
+
+
+class ContentGenerator(ContentGeneratorProtocol):
+ @override
+ @update_job_metadata
+ async def make_llm_text( # pyright: ignore[reportIncompatibleMethodOverride]
+ self,
+ job_metadata: JobMetadata,
+ llm_setting_main: LLMSetting,
+ llm_prompt_for_text: LLMPrompt,
+ wfid: Optional[str] = None,
+ ) -> str:
+ log.verbose(f"{self.__class__.__name__} make_llm_text: {llm_prompt_for_text}")
+ log.verbose(f"llm_setting_main: {llm_setting_main}")
+ llm_assignment = LLMAssignment(
+ job_metadata=job_metadata,
+ llm_setting=llm_setting_main,
+ llm_prompt=llm_prompt_for_text,
+ )
+ log.verbose(llm_assignment.desc, title="llm_assignment")
+ generated_text = await llm_gen_text(llm_assignment=llm_assignment)
+ log.verbose(f"{self.__class__.__name__} generated text: {generated_text}")
+ return generated_text
+
+ @override
+ @update_job_metadata
+ async def make_object_direct( # pyright: ignore[reportIncompatibleMethodOverride]
+ self,
+ job_metadata: JobMetadata,
+ object_class: Type[BaseModelTypeVar],
+ llm_setting_for_object: LLMSetting,
+ llm_prompt_for_object: LLMPrompt,
+ wfid: Optional[str] = None,
+ ) -> BaseModelTypeVar:
+ log.verbose(f"{self.__class__.__name__} make_object_direct: {llm_prompt_for_object}")
+ llm_assignment_for_object = LLMAssignment(
+ job_metadata=job_metadata,
+ llm_setting=llm_setting_for_object,
+ llm_prompt=llm_prompt_for_object,
+ )
+ object_assignment = ObjectAssignment.make_for_class(
+ object_class=object_class,
+ llm_assignment=llm_assignment_for_object,
+ )
+ obj = await llm_gen_object(object_assignment=object_assignment)
+ log.verbose(f"{self.__class__.__name__} generated object direct: {obj}")
+ return cast(BaseModelTypeVar, obj)
+
+ @override
+ @update_job_metadata
+ async def make_text_then_object( # pyright: ignore[reportIncompatibleMethodOverride]
+ self,
+ job_metadata: JobMetadata,
+ object_class: Type[BaseModelTypeVar],
+ llm_setting_main: LLMSetting,
+ llm_setting_for_object: LLMSetting,
+ llm_prompt_for_text: LLMPrompt,
+ llm_prompt_factory_for_object: Optional[LLMPromptFactoryAbstract] = None,
+ wfid: Optional[str] = None,
+ ) -> BaseModelTypeVar:
+ llm_assignment_for_text = LLMAssignment(
+ job_metadata=job_metadata,
+ llm_setting=llm_setting_main,
+ llm_prompt=llm_prompt_for_text,
+ )
+
+ llm_assignment_factory_to_object = LLMAssignmentFactory(
+ job_metadata=job_metadata,
+ llm_setting=llm_setting_for_object,
+ llm_prompt_factory=llm_prompt_factory_for_object or LLMPromptTemplate.for_structure_from_preliminary_text(),
+ )
+ workflow_arg = TextThenObjectAssignment(
+ object_class_name=object_class.__name__,
+ llm_assignment_for_text=llm_assignment_for_text,
+ llm_assignment_factory_to_object=llm_assignment_factory_to_object,
+ )
+
+ preliminary_text = await llm_gen_text(llm_assignment=llm_assignment_for_text)
+
+ log.dev(f"preliminary_text: {preliminary_text}")
+
+ fup_llm_assignment = await workflow_arg.llm_assignment_factory_to_object.make_llm_assignment(
+ preliminary_text=preliminary_text,
+ )
+
+ fup_obj_assignment = ObjectAssignment(
+ llm_assignment_for_object=fup_llm_assignment,
+ object_class_name=object_class.__name__,
+ )
+
+ obj = await llm_gen_object(object_assignment=fup_obj_assignment)
+ log.verbose(f"{self.__class__.__name__} generated object after text: {obj}")
+ return cast(BaseModelTypeVar, obj)
+
+ @override
+ @update_job_metadata
+ async def make_object_list_direct( # pyright: ignore[reportIncompatibleMethodOverride]
+ self,
+ job_metadata: JobMetadata,
+ object_class: Type[BaseModelTypeVar],
+ llm_setting_for_object_list: LLMSetting,
+ llm_prompt_for_object_list: LLMPrompt,
+ wfid: Optional[str] = None,
+ ) -> List[BaseModelTypeVar]:
+ llm_assignment_for_object = LLMAssignment(
+ job_metadata=job_metadata,
+ llm_setting=llm_setting_for_object_list,
+ llm_prompt=llm_prompt_for_object_list,
+ )
+ object_assignment = ObjectAssignment.make_for_class(
+ object_class=object_class,
+ llm_assignment=llm_assignment_for_object,
+ )
+ obj_list = await llm_gen_object_list(object_assignment=object_assignment)
+ log.verbose(f"{self.__class__.__name__} generated object list direct: {obj_list}")
+ return cast(List[BaseModelTypeVar], obj_list)
+
+ @override
+ @update_job_metadata
+ async def make_text_then_object_list( # pyright: ignore[reportIncompatibleMethodOverride]
+ self,
+ job_metadata: JobMetadata,
+ object_class: Type[BaseModelTypeVar],
+ llm_setting_main: LLMSetting,
+ llm_setting_for_object_list: LLMSetting,
+ llm_prompt_for_text: LLMPrompt,
+ llm_prompt_factory_for_object_list: Optional[LLMPromptFactoryAbstract] = None,
+ wfid: Optional[str] = None,
+ ) -> List[BaseModelTypeVar]:
+ llm_assignment_for_text = LLMAssignment(
+ job_metadata=job_metadata,
+ llm_setting=llm_setting_main,
+ llm_prompt=llm_prompt_for_text,
+ )
+
+ llm_assignment_factory_to_object = LLMAssignmentFactory(
+ job_metadata=job_metadata,
+ llm_setting=llm_setting_for_object_list,
+ llm_prompt_factory=llm_prompt_factory_for_object_list or LLMPromptTemplate.for_structure_from_preliminary_text(),
+ )
+ workflow_arg = TextThenObjectAssignment(
+ object_class_name=object_class.__name__,
+ llm_assignment_for_text=llm_assignment_for_text,
+ llm_assignment_factory_to_object=llm_assignment_factory_to_object,
+ )
+
+ preliminary_text = await llm_gen_text(llm_assignment=llm_assignment_for_text)
+
+ log.dev(f"preliminary_text: {preliminary_text}")
+
+ fup_llm_assignment = await workflow_arg.llm_assignment_factory_to_object.make_llm_assignment(
+ preliminary_text=preliminary_text,
+ )
+
+ fup_obj_assignment = ObjectAssignment(
+ llm_assignment_for_object=fup_llm_assignment,
+ object_class_name=object_class.__name__,
+ )
+
+ obj_list = await llm_gen_object_list(object_assignment=fup_obj_assignment)
+ log.verbose(f"{self.__class__.__name__} generated object list after text: {obj_list}")
+ return cast(List[BaseModelTypeVar], obj_list)
+
+ @override
+ @update_job_metadata
+ async def make_single_image( # pyright: ignore[reportIncompatibleMethodOverride]
+ self,
+ job_metadata: JobMetadata,
+ imgg_handle: ImggHandle,
+ imgg_prompt: ImggPrompt,
+ imgg_job_params: Optional[ImggJobParams] = None,
+ imgg_job_config: Optional[ImggJobConfig] = None,
+ wfid: Optional[str] = None,
+ ) -> GeneratedImage:
+ imgg_config = get_config().cogt.imgg_config
+ imgg_assignment = ImggAssignment(
+ job_metadata=job_metadata,
+ imgg_handle=imgg_handle,
+ imgg_prompt=imgg_prompt,
+ imgg_job_params=imgg_job_params or imgg_config.make_default_imgg_job_params(),
+ imgg_job_config=imgg_job_config or imgg_config.imgg_job_config,
+ nb_images=1,
+ )
+ generated_image = await imgg_gen_single_image(imgg_assignment=imgg_assignment)
+ log.dev(f"{self.__class__.__name__} generated image: {generated_image}")
+ return generated_image
+
+ @override
+ @update_job_metadata
+ async def make_image_list( # pyright: ignore[reportIncompatibleMethodOverride]
+ self,
+ job_metadata: JobMetadata,
+ imgg_handle: ImggHandle,
+ imgg_prompt: ImggPrompt,
+ nb_images: int,
+ imgg_job_params: Optional[ImggJobParams] = None,
+ imgg_job_config: Optional[ImggJobConfig] = None,
+ wfid: Optional[str] = None,
+ ) -> List[GeneratedImage]:
+ imgg_config = get_config().cogt.imgg_config
+ imgg_assignment = ImggAssignment(
+ job_metadata=job_metadata,
+ imgg_handle=imgg_handle,
+ imgg_prompt=imgg_prompt,
+ imgg_job_params=imgg_job_params or imgg_config.make_default_imgg_job_params(),
+ imgg_job_config=imgg_job_config or imgg_config.imgg_job_config,
+ nb_images=nb_images,
+ )
+ generated_image_list = await imgg_gen_image_list(imgg_assignment=imgg_assignment)
+ log.dev(f"{self.__class__.__name__} generated image list: {generated_image_list}")
+ return generated_image_list
+
+ @override
+ async def make_jinja2_text(
+ self,
+ context: Dict[str, Any],
+ jinja2_name: Optional[str] = None,
+ jinja2: Optional[str] = None,
+ prompting_style: Optional[PromptingStyle] = None,
+ template_category: Jinja2TemplateCategory = Jinja2TemplateCategory.LLM_PROMPT,
+ wfid: Optional[str] = None,
+ ) -> str:
+ jinja2_assignment = Jinja2Assignment(
+ context=context,
+ jinja2_name=jinja2_name,
+ jinja2=jinja2,
+ prompting_style=prompting_style,
+ template_category=template_category,
+ )
+ jinja2_text = await jinja2_gen_text(jinja2_assignment=jinja2_assignment)
+ log.dev(f"{self.__class__.__name__} jinja2: {jinja2_text}")
+ return jinja2_text
+
+ @override
+ async def make_ocr_extract_pages(
+ self,
+ job_metadata: JobMetadata,
+ ocr_input: OcrInput,
+ ocr_handle: OcrHandle,
+ ocr_job_params: Optional[OcrJobParams] = None,
+ ocr_job_config: Optional[OcrJobConfig] = None,
+ wfid: Optional[str] = None,
+ ) -> OcrOutput:
+ ocr_assignment = OcrAssignment(
+ job_metadata=job_metadata,
+ ocr_input=ocr_input,
+ ocr_handle=ocr_handle,
+ ocr_job_params=ocr_job_params or OcrJobParams.make_default_ocr_job_params(),
+ ocr_job_config=ocr_job_config or OcrJobConfig(),
+ )
+ ocr_output = await ocr_gen_extract_pages(ocr_assignment=ocr_assignment)
+ return ocr_output
diff --git a/pipelex/cogt/content_generation/content_generator_protocol.py b/pipelex/cogt/content_generation/content_generator_protocol.py
new file mode 100644
index 000000000..f14f6a902
--- /dev/null
+++ b/pipelex/cogt/content_generation/content_generator_protocol.py
@@ -0,0 +1,134 @@
+from functools import wraps
+from typing import Any, Awaitable, Callable, Coroutine, Dict, List, Optional, ParamSpec, Protocol, Type, TypeVar
+
+from pipelex.cogt.image.generated_image import GeneratedImage
+from pipelex.cogt.imgg.imgg_handle import ImggHandle
+from pipelex.cogt.imgg.imgg_job_components import ImggJobConfig, ImggJobParams
+from pipelex.cogt.imgg.imgg_prompt import ImggPrompt
+from pipelex.cogt.llm.llm_models.llm_setting import LLMSetting
+from pipelex.cogt.llm.llm_prompt import LLMPrompt
+from pipelex.cogt.llm.llm_prompt_factory_abstract import LLMPromptFactoryAbstract
+from pipelex.cogt.ocr.ocr_handle import OcrHandle
+from pipelex.cogt.ocr.ocr_input import OcrInput
+from pipelex.cogt.ocr.ocr_job_components import OcrJobConfig, OcrJobParams
+from pipelex.cogt.ocr.ocr_output import OcrOutput
+from pipelex.mission.job_metadata import JobMetadata
+from pipelex.tools.templating.jinja2_environment import Jinja2TemplateCategory
+from pipelex.tools.templating.templating_models import PromptingStyle
+from pipelex.tools.typing.pydantic_utils import BaseModelTypeVar
+
+F = TypeVar("F", bound=Callable[..., Awaitable[Any]])
+P = ParamSpec("P")
+R = TypeVar("R")
+
+
+def update_job_metadata(func: Callable[P, Coroutine[Any, Any, R]]) -> Callable[P, Coroutine[Any, Any, R]]:
+ @wraps(func)
+ async def wrapper(*args: P.args, **kwargs: P.kwargs) -> R:
+ # Attempt to get job_metadata from kwargs or from args
+ job_metadata = kwargs.get("job_metadata")
+ if job_metadata is None:
+ raise RuntimeError("job_metadata argument is required for this decorated function.")
+
+ if not isinstance(job_metadata, JobMetadata):
+ raise TypeError("The job_metadata argument must be of type JobMetadata.")
+
+ updated_metadata = JobMetadata(
+ content_generation_job_id=func.__name__,
+ )
+ job_metadata.update(updated_metadata=updated_metadata)
+
+ return await func(*args, **kwargs)
+
+ return wrapper
+
+
+class ContentGeneratorProtocol(Protocol):
+ async def make_llm_text(
+ self,
+ job_metadata: JobMetadata,
+ llm_setting_main: LLMSetting,
+ llm_prompt_for_text: LLMPrompt,
+ wfid: Optional[str] = None,
+ ) -> str: ...
+
+ async def make_object_direct(
+ self,
+ job_metadata: JobMetadata,
+ object_class: Type[BaseModelTypeVar],
+ llm_setting_for_object: LLMSetting,
+ llm_prompt_for_object: LLMPrompt,
+ wfid: Optional[str] = None,
+ ) -> BaseModelTypeVar: ...
+
+ async def make_text_then_object(
+ self,
+ job_metadata: JobMetadata,
+ object_class: Type[BaseModelTypeVar],
+ llm_setting_main: LLMSetting,
+ llm_setting_for_object: LLMSetting,
+ llm_prompt_for_text: LLMPrompt,
+ llm_prompt_factory_for_object: Optional[LLMPromptFactoryAbstract] = None,
+ wfid: Optional[str] = None,
+ ) -> BaseModelTypeVar: ...
+
+ async def make_object_list_direct(
+ self,
+ job_metadata: JobMetadata,
+ object_class: Type[BaseModelTypeVar],
+ llm_setting_for_object_list: LLMSetting,
+ llm_prompt_for_object_list: LLMPrompt,
+ wfid: Optional[str] = None,
+ ) -> List[BaseModelTypeVar]: ...
+
+ async def make_text_then_object_list(
+ self,
+ job_metadata: JobMetadata,
+ object_class: Type[BaseModelTypeVar],
+ llm_setting_main: LLMSetting,
+ llm_setting_for_object_list: LLMSetting,
+ llm_prompt_for_text: LLMPrompt,
+ llm_prompt_factory_for_object_list: Optional[LLMPromptFactoryAbstract] = None,
+ wfid: Optional[str] = None,
+ ) -> List[BaseModelTypeVar]: ...
+
+ async def make_single_image(
+ self,
+ job_metadata: JobMetadata,
+ imgg_handle: ImggHandle,
+ imgg_prompt: ImggPrompt,
+ imgg_job_params: Optional[ImggJobParams] = None,
+ imgg_job_config: Optional[ImggJobConfig] = None,
+ wfid: Optional[str] = None,
+ ) -> GeneratedImage: ...
+
+ async def make_image_list(
+ self,
+ job_metadata: JobMetadata,
+ imgg_handle: ImggHandle,
+ imgg_prompt: ImggPrompt,
+ nb_images: int,
+ imgg_job_params: Optional[ImggJobParams] = None,
+ imgg_job_config: Optional[ImggJobConfig] = None,
+ wfid: Optional[str] = None,
+ ) -> List[GeneratedImage]: ...
+
+ async def make_jinja2_text(
+ self,
+ context: Dict[str, Any],
+ jinja2_name: Optional[str] = None,
+ jinja2: Optional[str] = None,
+ prompting_style: Optional[PromptingStyle] = None,
+ template_category: Jinja2TemplateCategory = Jinja2TemplateCategory.LLM_PROMPT,
+ wfid: Optional[str] = None,
+ ) -> str: ...
+
+ async def make_ocr_extract_pages(
+ self,
+ job_metadata: JobMetadata,
+ ocr_input: OcrInput,
+ ocr_handle: OcrHandle,
+ ocr_job_params: OcrJobParams,
+ ocr_job_config: OcrJobConfig,
+ wfid: Optional[str] = None,
+ ) -> OcrOutput: ...
diff --git a/pipelex/cogt/content_generation/imgg_generate.py b/pipelex/cogt/content_generation/imgg_generate.py
new file mode 100644
index 000000000..870a4f35c
--- /dev/null
+++ b/pipelex/cogt/content_generation/imgg_generate.py
@@ -0,0 +1,43 @@
+from typing import List, Union
+
+from pipelex import log
+from pipelex.cogt.content_generation.assignment_models import ImggAssignment
+from pipelex.cogt.image.generated_image import GeneratedImage
+from pipelex.cogt.imgg.imgg_job_factory import ImggJobFactory
+from pipelex.hub import get_imgg_worker
+
+
+async def imgg_gen_single_image(imgg_assignment: ImggAssignment) -> GeneratedImage:
+ imgg_worker = get_imgg_worker(imgg_handle=imgg_assignment.imgg_handle)
+ imgg_job = ImggJobFactory.make_imgg_job_from_prompt(
+ imgg_prompt=imgg_assignment.imgg_prompt,
+ imgg_job_params=imgg_assignment.imgg_job_params,
+ imgg_job_config=imgg_assignment.imgg_job_config,
+ job_metadata=imgg_assignment.job_metadata,
+ )
+ generated_image = await imgg_worker.gen_image(imgg_job=imgg_job)
+ log.verbose(f"generated_image:\n{generated_image}")
+ return generated_image
+
+
+async def imgg_gen_image_list(imgg_assignment: ImggAssignment) -> List[GeneratedImage]:
+ imgg_worker = get_imgg_worker(imgg_handle=imgg_assignment.imgg_handle)
+ imgg_job = ImggJobFactory.make_imgg_job_from_prompt(
+ imgg_prompt=imgg_assignment.imgg_prompt,
+ imgg_job_params=imgg_assignment.imgg_job_params,
+ imgg_job_config=imgg_assignment.imgg_job_config,
+ job_metadata=imgg_assignment.job_metadata,
+ )
+ generated_image_list = await imgg_worker.gen_image_list(
+ imgg_job=imgg_job,
+ nb_images=imgg_assignment.nb_images,
+ )
+ log.verbose(f"generated_image_list:\n{generated_image_list}")
+ return generated_image_list
+
+
+async def imgg_gen_image(imgg_assignment: ImggAssignment) -> Union[GeneratedImage, List[GeneratedImage]]:
+ if imgg_assignment.nb_images > 1:
+ return await imgg_gen_image_list(imgg_assignment)
+ else:
+ return await imgg_gen_single_image(imgg_assignment)
diff --git a/pipelex/cogt/content_generation/jinja2_generate.py b/pipelex/cogt/content_generation/jinja2_generate.py
new file mode 100644
index 000000000..4062cfafb
--- /dev/null
+++ b/pipelex/cogt/content_generation/jinja2_generate.py
@@ -0,0 +1,17 @@
+from pipelex.cogt.content_generation.assignment_models import Jinja2Assignment
+from pipelex.hub import get_template_provider
+from pipelex.tools.templating.jinja2_rendering import render_jinja2
+
+
+# TODO: get rid of this intermediate call which seems useless, or explain why it stays
+async def jinja2_gen_text(jinja2_assignment: Jinja2Assignment) -> str:
+ jinja2_text: str = await render_jinja2(
+ template_category=jinja2_assignment.template_category,
+ template_provider=get_template_provider(),
+ temlating_context=jinja2_assignment.context,
+ jinja2_name=jinja2_assignment.jinja2_name,
+ jinja2=jinja2_assignment.jinja2,
+ prompting_style=jinja2_assignment.prompting_style,
+ )
+
+ return jinja2_text
diff --git a/pipelex/cogt/content_generation/llm_generate.py b/pipelex/cogt/content_generation/llm_generate.py
new file mode 100644
index 000000000..918da4f8c
--- /dev/null
+++ b/pipelex/cogt/content_generation/llm_generate.py
@@ -0,0 +1,62 @@
+from typing import List
+
+from kajson.class_registry import class_registry
+from pydantic import BaseModel
+
+from pipelex import log
+from pipelex.cogt.content_generation.assignment_models import LLMAssignment, ObjectAssignment
+from pipelex.cogt.llm.llm_job_factory import LLMJobFactory
+from pipelex.hub import get_llm_worker
+
+
+async def llm_gen_text(llm_assignment: LLMAssignment) -> str:
+ llm_worker = get_llm_worker(llm_handle=llm_assignment.llm_handle)
+ llm_job = LLMJobFactory.make_llm_job(
+ job_metadata=llm_assignment.job_metadata,
+ llm_prompt=llm_assignment.llm_prompt,
+ llm_job_params=llm_assignment.llm_job_params,
+ )
+ generated_text = await llm_worker.gen_text(llm_job=llm_job)
+ log.verbose(generated_text, title="llm_gen_text")
+ return generated_text
+
+
+async def llm_gen_object(object_assignment: ObjectAssignment) -> BaseModel:
+ llm_assignment = object_assignment.llm_assignment_for_object
+ log.verbose(f"llm_gen_object to generate a: '{object_assignment.object_class_name}'")
+ llm_worker = get_llm_worker(llm_handle=llm_assignment.llm_handle)
+ llm_job = LLMJobFactory.make_llm_job(
+ job_metadata=llm_assignment.job_metadata,
+ llm_prompt=llm_assignment.llm_prompt,
+ llm_job_params=llm_assignment.llm_job_params,
+ )
+ content_class_name = object_assignment.object_class_name
+ content_class = class_registry.get_required_base_model(name=content_class_name)
+ generated_object: BaseModel = await llm_worker.gen_object(
+ llm_job=llm_job,
+ schema=content_class,
+ )
+ return generated_object
+
+
+async def llm_gen_object_list(object_assignment: ObjectAssignment) -> List[BaseModel]:
+ llm_assignment = object_assignment.llm_assignment_for_object
+ log.verbose(f"llm_gen_object_list to generate a list of '{object_assignment.object_class_name}'")
+ llm_worker = get_llm_worker(llm_handle=llm_assignment.llm_handle)
+ llm_job = LLMJobFactory.make_llm_job(
+ job_metadata=llm_assignment.job_metadata,
+ llm_prompt=llm_assignment.llm_prompt,
+ llm_job_params=llm_assignment.llm_job_params,
+ )
+ item_class_name = object_assignment.object_class_name
+ item_class = class_registry.get_required_class(name=item_class_name)
+
+ class ListSchema(BaseModel):
+ items: List[item_class] # type: ignore
+
+ wrapped_list: ListSchema = await llm_worker.gen_object(
+ llm_job=llm_job,
+ schema=ListSchema,
+ )
+ generated_list: List[BaseModel] = wrapped_list.items # pyright: ignore[reportUnknownMemberType]
+ return generated_list
diff --git a/pipelex/cogt/content_generation/ocr_generate.py b/pipelex/cogt/content_generation/ocr_generate.py
new file mode 100644
index 000000000..91c3205ee
--- /dev/null
+++ b/pipelex/cogt/content_generation/ocr_generate.py
@@ -0,0 +1,16 @@
+from pipelex.cogt.content_generation.assignment_models import OcrAssignment
+from pipelex.cogt.ocr.ocr_job_factory import OcrJobFactory
+from pipelex.cogt.ocr.ocr_output import OcrOutput
+from pipelex.hub import get_ocr_worker
+
+
+async def ocr_gen_extract_pages(ocr_assignment: OcrAssignment) -> OcrOutput:
+ ocr_worker = get_ocr_worker(ocr_handle=ocr_assignment.ocr_handle)
+ ocr_job = OcrJobFactory.make_ocr_job(
+ ocr_input=ocr_assignment.ocr_input,
+ ocr_job_params=ocr_assignment.ocr_job_params,
+ ocr_job_config=ocr_assignment.ocr_job_config,
+ job_metadata=ocr_assignment.job_metadata,
+ )
+ ocr_output = await ocr_worker.ocr_extract_pages(ocr_job=ocr_job)
+ return ocr_output
diff --git a/pipelex/cogt/exceptions.py b/pipelex/cogt/exceptions.py
new file mode 100644
index 000000000..f6d237134
--- /dev/null
+++ b/pipelex/cogt/exceptions.py
@@ -0,0 +1,116 @@
+from typing import Optional
+
+from pipelex.tools.exceptions import FatalError, RootException
+
+
+class CogtError(RootException):
+ pass
+
+
+class InferenceManagerWorkerSetupError(CogtError, FatalError):
+ pass
+
+
+class CostRegistryError(CogtError):
+ pass
+
+
+class InferenceReportManagerError(CogtError):
+ pass
+
+
+class SdkTypeError(CogtError):
+ pass
+
+
+class LLMWorkerError(CogtError):
+ pass
+
+
+class LLMEngineParameterError(CogtError):
+ pass
+
+
+class LLMSDKError(CogtError):
+ pass
+
+
+class LLMPresetNotFoundError(CogtError):
+ pass
+
+
+class LLMSettingsValidationError(CogtError):
+ pass
+
+
+class LLMDeckValidatonError(CogtError):
+ pass
+
+
+class LLMHandleNotFoundError(CogtError):
+ pass
+
+
+class LLMModelProviderError(CogtError):
+ pass
+
+
+class LLMModelPlatformError(ValueError, CogtError):
+ pass
+
+
+class LLMModelDefinitionError(CogtError):
+ pass
+
+
+class LLMCapabilityError(CogtError):
+ pass
+
+
+class LLMCompletionError(CogtError):
+ pass
+
+
+class LLMAssignmentError(CogtError):
+ pass
+
+
+class LLMPromptFactoryError(CogtError):
+ pass
+
+
+class LLMPromptTemplateInputsError(CogtError):
+ pass
+
+
+class LLMPromptError(CogtError):
+ pass
+
+
+class PromptImageFactoryError(CogtError):
+ pass
+
+
+class PromptImageFormatError(CogtError):
+ pass
+
+
+class ImggPromptError(CogtError):
+ pass
+
+
+class MissingDependencyError(CogtError):
+ """Raised when a required dependency is not installed."""
+
+ def __init__(self, dependency_name: str, extra_name: str, message: Optional[str] = None):
+ self.dependency_name = dependency_name
+ self.extra_name = extra_name
+ error_msg = f"Required dependency '{dependency_name}' is not installed."
+ if message:
+ error_msg += f" {message}"
+ error_msg += f" Please install it with 'pip install pipelex[{extra_name}]'."
+ super().__init__(error_msg)
+
+
+class OcrCapabilityError(CogtError):
+ pass
diff --git a/pipelex/cogt/image/__init__.py b/pipelex/cogt/image/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/pipelex/cogt/image/__init__.py
@@ -0,0 +1 @@
+
diff --git a/pipelex/cogt/image/generated_image.py b/pipelex/cogt/image/generated_image.py
new file mode 100644
index 000000000..48c2f468c
--- /dev/null
+++ b/pipelex/cogt/image/generated_image.py
@@ -0,0 +1,9 @@
+from pydantic import BaseModel
+
+
+class GeneratedImage(BaseModel):
+ # TODO: add image_format
+ # image_format: str = "jpeg"
+ url: str
+ width: int
+ height: int
diff --git a/pipelex/cogt/image/prompt_image.py b/pipelex/cogt/image/prompt_image.py
new file mode 100644
index 000000000..92fe8aa68
--- /dev/null
+++ b/pipelex/cogt/image/prompt_image.py
@@ -0,0 +1,60 @@
+from abc import ABC
+from typing import Union
+
+from pydantic import BaseModel
+from typing_extensions import override
+
+from pipelex.tools.misc.filetype_utils import FileType, detect_file_type_from_base64, detect_file_type_from_path
+
+
+class PromptImageTypedBytes(BaseModel):
+ image_bytes: bytes
+ file_type: FileType
+
+
+PromptImageTypedBytesOrUrl = Union[PromptImageTypedBytes, str]
+
+
+class PromptImage(BaseModel, ABC):
+ pass
+
+
+class PromptImagePath(PromptImage):
+ file_path: str
+
+ def get_file_type(self) -> FileType:
+ return detect_file_type_from_path(self.file_path)
+
+ @override
+ def __str__(self) -> str:
+ return f"PromptImagePath(file_path='{self.file_path}')"
+
+
+class PromptImageUrl(PromptImage):
+ url: str
+
+ @override
+ def __str__(self) -> str:
+ return f"PromptImageUrl(url='{self.url}')"
+
+
+class PromptImageBytes(PromptImage):
+ b64_image_bytes: bytes
+
+ def get_file_type(self) -> FileType:
+ return detect_file_type_from_base64(self.b64_image_bytes)
+
+ @override
+ def __str__(self) -> str:
+ bytes_sample: str = str(self.b64_image_bytes[:20])
+ if len(self.b64_image_bytes) > 20:
+ bytes_sample += "..."
+ bytes_preview = f"{len(self.b64_image_bytes)} bytes: {bytes_sample}"
+ return f"PromptImageBytes(image_bytes={bytes_preview})"
+
+ @override
+ def __repr__(self) -> str:
+ return self.__str__()
+
+ def make_prompt_image_typed_bytes(self) -> PromptImageTypedBytes:
+ return PromptImageTypedBytes(image_bytes=self.b64_image_bytes, file_type=self.get_file_type())
diff --git a/pipelex/cogt/image/prompt_image_factory.py b/pipelex/cogt/image/prompt_image_factory.py
new file mode 100644
index 000000000..b7f875fee
--- /dev/null
+++ b/pipelex/cogt/image/prompt_image_factory.py
@@ -0,0 +1,60 @@
+from typing import Optional
+
+from pipelex.cogt.exceptions import PromptImageFactoryError
+from pipelex.cogt.image.prompt_image import PromptImage, PromptImageBytes, PromptImagePath, PromptImageUrl
+from pipelex.tools.misc.base_64_utils import (
+ encode_to_base64_async,
+ load_binary_as_base64_async,
+)
+from pipelex.tools.misc.file_fetch_utils import fetch_file_from_url_httpx_async
+from pipelex.tools.misc.path_utils import clarify_path_or_url
+
+
+class PromptImageFactory:
+ @classmethod
+ def make_prompt_image(
+ cls,
+ file_path: Optional[str] = None,
+ url: Optional[str] = None,
+ base_64: Optional[bytes] = None,
+ ) -> PromptImage:
+ if file_path:
+ return PromptImagePath(file_path=file_path)
+ elif url:
+ return PromptImageUrl(url=url)
+ elif base_64:
+ return PromptImageBytes(b64_image_bytes=base_64)
+ else:
+ raise PromptImageFactoryError("PromptImageFactory requires one of file_path, url, or image_bytes")
+
+ @classmethod
+ def make_prompt_image_from_uri(
+ cls,
+ uri: str,
+ ) -> PromptImage:
+ file_path, url = clarify_path_or_url(path_or_uri=uri)
+ return PromptImageFactory.make_prompt_image(
+ file_path=file_path,
+ url=url,
+ )
+
+ @classmethod
+ async def make_promptimagebytes_from_url_async(
+ cls,
+ prompt_image_url: PromptImageUrl,
+ ) -> PromptImageBytes:
+ raw_image_bytes = await fetch_file_from_url_httpx_async(prompt_image_url.url)
+ b64_image_bytes = await encode_to_base64_async(raw_image_bytes)
+ return PromptImageBytes(b64_image_bytes=b64_image_bytes)
+
+ @classmethod
+ async def promptimage_to_b64_async(cls, image_prompt: PromptImage) -> bytes:
+ if isinstance(image_prompt, PromptImagePath):
+ return await load_binary_as_base64_async(image_prompt.file_path)
+ elif isinstance(image_prompt, PromptImageBytes):
+ return image_prompt.b64_image_bytes
+ elif isinstance(image_prompt, PromptImageUrl):
+ image_bytes = await cls.make_promptimagebytes_from_url_async(image_prompt)
+ return image_bytes.b64_image_bytes
+ else:
+ raise PromptImageFactoryError(f"Unknown PromptImage type: {image_prompt}")
diff --git a/pipelex/cogt/imgg/__init__.py b/pipelex/cogt/imgg/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/pipelex/cogt/imgg/__init__.py
@@ -0,0 +1 @@
+
diff --git a/pipelex/cogt/imgg/imgg_engine.py b/pipelex/cogt/imgg/imgg_engine.py
new file mode 100644
index 000000000..cf4e0f382
--- /dev/null
+++ b/pipelex/cogt/imgg/imgg_engine.py
@@ -0,0 +1,12 @@
+from pydantic import BaseModel
+
+from pipelex.cogt.imgg.imgg_platform import ImggPlatform
+
+
+class ImggEngine(BaseModel):
+ imgg_platform: ImggPlatform
+ imgg_model_name: str
+
+ @property
+ def desc(self) -> str:
+ return f"Imgg Engine {self.imgg_platform}/{self.imgg_model_name}"
diff --git a/pipelex/cogt/imgg/imgg_engine_factory.py b/pipelex/cogt/imgg/imgg_engine_factory.py
new file mode 100644
index 000000000..4db3befcb
--- /dev/null
+++ b/pipelex/cogt/imgg/imgg_engine_factory.py
@@ -0,0 +1,27 @@
+from pipelex.cogt.exceptions import CogtError
+from pipelex.cogt.imgg.imgg_engine import ImggEngine
+from pipelex.cogt.imgg.imgg_platform import ImggPlatform
+
+
+class ImggEngineFactoryError(CogtError):
+ pass
+
+
+class ImggEngineFactory:
+ @classmethod
+ def make_imgg_engine(
+ cls,
+ imgg_handle: str,
+ ) -> ImggEngine:
+ parts = imgg_handle.split("/")
+ if len(parts) != 2:
+ raise ImggEngineFactoryError(f"Invalid Imgg handle: {imgg_handle}")
+
+ try:
+ imgg_platform = ImggPlatform(parts[0])
+ except ValueError:
+ raise ImggEngineFactoryError(f"Invalid Imgg platform: {parts[0]}")
+
+ imgg_model_name = parts[1]
+
+ return ImggEngine(imgg_platform=imgg_platform, imgg_model_name=imgg_model_name)
diff --git a/pipelex/cogt/imgg/imgg_handle.py b/pipelex/cogt/imgg/imgg_handle.py
new file mode 100644
index 000000000..fae2bea4b
--- /dev/null
+++ b/pipelex/cogt/imgg/imgg_handle.py
@@ -0,0 +1,9 @@
+from enum import StrEnum
+
+
+# List of classic Img generation preset handles, for convenience
+class ImggHandle(StrEnum):
+ FLUX_1_PRO_LEGACY = "fal-ai/flux-pro"
+ FLUX_1_1_PRO = "fal-ai/flux-pro/v1.1"
+ FLUX_1_1_ULTRA = "fal-ai/flux-pro/v1.1-ultra"
+ SDXL_LIGHTNING = "fal-ai/fast-lightning-sdxl"
diff --git a/pipelex/cogt/imgg/imgg_job.py b/pipelex/cogt/imgg/imgg_job.py
new file mode 100644
index 000000000..b6bf70906
--- /dev/null
+++ b/pipelex/cogt/imgg/imgg_job.py
@@ -0,0 +1,29 @@
+from datetime import datetime
+
+from typing_extensions import override
+
+from pipelex.cogt.imgg.imgg_engine import ImggEngine
+from pipelex.cogt.imgg.imgg_job_components import ImggJobConfig, ImggJobParams, ImggJobReport
+from pipelex.cogt.imgg.imgg_prompt import ImggPrompt
+from pipelex.cogt.inference.inference_job_abstract import InferenceJobAbstract
+
+
+class ImggJob(InferenceJobAbstract):
+ imgg_prompt: ImggPrompt
+ job_params: ImggJobParams
+ job_config: ImggJobConfig
+ job_report: ImggJobReport
+
+ @override
+ def validate_before_execution(self):
+ self.imgg_prompt.validate_before_execution()
+
+ def imgg_job_before_start(self, imgg_engine: ImggEngine):
+ # Reset metadata
+ self.job_metadata.started_at = datetime.now()
+
+ # Reset outputs
+ self.job_report = ImggJobReport()
+
+ def imgg_job_after_complete(self):
+ self.job_metadata.completed_at = datetime.now()
diff --git a/pipelex/cogt/imgg/imgg_job_components.py b/pipelex/cogt/imgg/imgg_job_components.py
new file mode 100644
index 000000000..2797fac1d
--- /dev/null
+++ b/pipelex/cogt/imgg/imgg_job_components.py
@@ -0,0 +1,74 @@
+from enum import StrEnum
+from typing import Literal, Optional, Union
+
+from pydantic import BaseModel, Field
+
+from pipelex.tools.config.models import ConfigModel
+
+
+class AspectRatio(StrEnum):
+ SQUARE = "square"
+ LANDSCAPE_4_3 = "landscape_4_3"
+ LANDSCAPE_16_9 = "landscape_16_9"
+ LANDSCAPE_21_9 = "landscape_21_9"
+ PORTRAIT_3_4 = "portrait_4_3"
+ PORTRAIT_9_16 = "portrait_9_16"
+ PORTRAIT_9_21 = "portrait_9_21"
+
+
+class OutputFormat(StrEnum):
+ PNG = "png"
+ JPG = "jpg"
+ WEBP = "webp"
+
+
+class ImggJobParams(BaseModel):
+ aspect_ratio: AspectRatio = Field(strict=False)
+ nb_steps: int = Field(..., gt=0)
+ guidance_scale: float = Field(..., gt=0)
+ is_safety_checker_enabled: bool
+ safety_tolerance: int = Field(..., ge=1, le=6)
+ is_raw: bool
+ output_format: OutputFormat = Field(strict=False)
+ seed: Optional[int] = Field(None, ge=0)
+
+
+class ImggJobParamsDefaults(ConfigModel):
+ aspect_ratio: AspectRatio = Field(strict=False)
+ nb_steps: int = Field(..., gt=0)
+ guidance_scale: float = Field(..., gt=0)
+ is_safety_checker_enabled: bool
+ safety_tolerance: int = Field(..., ge=1, le=6)
+ is_raw: bool
+ output_format: OutputFormat = Field(strict=False)
+ seed: Union[int, Literal["auto"]]
+
+ def make_imgg_job_params(self) -> ImggJobParams:
+ seed: Optional[int]
+ if isinstance(self.seed, str) and self.seed == "auto":
+ seed = None
+ else:
+ seed = self.seed
+ return ImggJobParams(
+ aspect_ratio=self.aspect_ratio,
+ nb_steps=self.nb_steps,
+ guidance_scale=self.guidance_scale,
+ is_safety_checker_enabled=self.is_safety_checker_enabled,
+ safety_tolerance=self.safety_tolerance,
+ is_raw=self.is_raw,
+ output_format=self.output_format,
+ seed=seed,
+ )
+
+
+class ImggJobConfig(ConfigModel):
+ is_sync_mode: bool
+
+
+########################################################################
+### Outputs
+########################################################################
+
+
+class ImggJobReport(ConfigModel):
+ pass
diff --git a/pipelex/cogt/imgg/imgg_job_factory.py b/pipelex/cogt/imgg/imgg_job_factory.py
new file mode 100644
index 000000000..106111bc5
--- /dev/null
+++ b/pipelex/cogt/imgg/imgg_job_factory.py
@@ -0,0 +1,64 @@
+from typing import Optional
+
+from pipelex.cogt.imgg.imgg_job import ImggJob
+from pipelex.cogt.imgg.imgg_job_components import ImggJobConfig, ImggJobParams, ImggJobReport
+from pipelex.cogt.imgg.imgg_prompt import ImggPrompt
+from pipelex.config import get_config
+from pipelex.mission.job_metadata import JobCategory, JobMetadata
+
+
+class ImggJobFactory:
+ # straightforward: the prompt is provided
+
+ @classmethod
+ def make_imgg_job_from_prompt(
+ cls,
+ imgg_prompt: ImggPrompt,
+ imgg_job_params: Optional[ImggJobParams] = None,
+ imgg_job_config: Optional[ImggJobConfig] = None,
+ job_metadata: Optional[JobMetadata] = None,
+ ) -> ImggJob:
+ config = get_config()
+ imgg_config = get_config().cogt.imgg_config
+ job_metadata = job_metadata or JobMetadata(
+ top_job_id=f"IMGGJob for {config.project_name}",
+ job_category=JobCategory.IMGG_JOB,
+ )
+ job_params = imgg_job_params or imgg_config.make_default_imgg_job_params()
+ job_config = imgg_job_config or imgg_config.imgg_job_config
+ job_report = ImggJobReport()
+
+ return ImggJob(
+ job_metadata=job_metadata,
+ imgg_prompt=imgg_prompt,
+ job_params=job_params,
+ job_config=job_config,
+ job_report=job_report,
+ )
+
+ @classmethod
+ def make_imgg_job_from_prompt_contents(
+ cls,
+ positive_text: Optional[str] = None,
+ imgg_job_params: Optional[ImggJobParams] = None,
+ imgg_job_config: Optional[ImggJobConfig] = None,
+ job_metadata: Optional[JobMetadata] = None,
+ ) -> ImggJob:
+ config = get_config()
+ imgg_config = get_config().cogt.imgg_config
+ job_metadata = job_metadata or JobMetadata(
+ top_job_id=f"IMGGJob for {config.project_name}",
+ job_category=JobCategory.IMGG_JOB,
+ )
+ imgg_prompt = ImggPrompt(positive_text=positive_text)
+ job_params = imgg_job_params or imgg_config.make_default_imgg_job_params()
+ job_config = imgg_job_config or imgg_config.imgg_job_config
+ job_report = ImggJobReport()
+
+ return ImggJob(
+ job_metadata=job_metadata,
+ imgg_prompt=imgg_prompt,
+ job_params=job_params,
+ job_config=job_config,
+ job_report=job_report,
+ )
diff --git a/pipelex/cogt/imgg/imgg_platform.py b/pipelex/cogt/imgg/imgg_platform.py
new file mode 100644
index 000000000..c7c41f398
--- /dev/null
+++ b/pipelex/cogt/imgg/imgg_platform.py
@@ -0,0 +1,5 @@
+from enum import StrEnum
+
+
+class ImggPlatform(StrEnum):
+ FAL_AI = "fal-ai"
diff --git a/pipelex/cogt/imgg/imgg_prompt.py b/pipelex/cogt/imgg/imgg_prompt.py
new file mode 100644
index 000000000..a0efa972b
--- /dev/null
+++ b/pipelex/cogt/imgg/imgg_prompt.py
@@ -0,0 +1,33 @@
+from typing import Optional
+
+from pydantic import BaseModel
+from typing_extensions import override
+
+from pipelex import log
+from pipelex.cogt.exceptions import ImggPromptError
+from pipelex.tools.misc.json_utils import json_str
+from pipelex.tools.runtime_manager import ProblemReaction, runtime_manager
+
+
+class ImggPrompt(BaseModel):
+ positive_text: Optional[str] = None
+
+ def validate_before_execution(self):
+ reaction = runtime_manager.problem_reactions.job
+ match reaction:
+ case ProblemReaction.NONE:
+ pass
+ case ProblemReaction.RAISE:
+ if self.positive_text is None:
+ raise ImggPromptError("Imgg prompt positive_text cannot be None (or can it?)")
+ if self.positive_text == "":
+ raise ImggPromptError("Imgg prompt positive_text must not be an empty string")
+ case ProblemReaction.LOG:
+ if self.positive_text is None:
+ log.warning("Imgg prompt positive_text is None, that's not good, or is it?")
+ if self.positive_text == "":
+ log.warning("Imgg prompt positive_text should not be an empty string")
+
+ @override
+ def __str__(self) -> str:
+ return json_str(self, title="imgg_prompt", is_spaced=True)
diff --git a/pipelex/cogt/imgg/imgg_worker_abstract.py b/pipelex/cogt/imgg/imgg_worker_abstract.py
new file mode 100644
index 000000000..65dc51c41
--- /dev/null
+++ b/pipelex/cogt/imgg/imgg_worker_abstract.py
@@ -0,0 +1,88 @@
+from abc import abstractmethod
+from functools import wraps
+from typing import Any, Callable, List, Optional, TypeVar, cast
+
+from typing_extensions import Awaitable, override
+
+from pipelex import log
+from pipelex.cogt.image.generated_image import GeneratedImage
+from pipelex.cogt.imgg.imgg_engine import ImggEngine
+from pipelex.cogt.imgg.imgg_job import ImggJob
+from pipelex.cogt.inference.inference_report_delegate import InferenceReportDelegate
+from pipelex.cogt.inference.inference_worker_abstract import InferenceWorkerAbstract
+from pipelex.mission.job_metadata import UnitJobId
+
+F = TypeVar("F", bound=Callable[..., Awaitable[Any]])
+
+
+def imgg_job_func(func: F) -> F:
+ @wraps(func)
+ async def wrapper(
+ self: Any,
+ imgg_job: ImggJob,
+ *args: Any,
+ **kwargs: Any,
+ ) -> Any:
+ log.debug(f"Working — {func.__name__} using:\n{self.imgg_engine.desc}")
+
+ # Verify that the job is valid
+ imgg_job.validate_before_execution()
+
+ # Verify feasibility
+ self.check_can_perform_job(imgg_job=imgg_job)
+ # TODO: check can generate object (where it will be appropriate)
+
+ # metadata
+ imgg_job.job_metadata.unit_job_id = UnitJobId.IMGG_TEXT_TO_IMAGE
+
+ # Prepare job
+ imgg_job.imgg_job_before_start(imgg_engine=self.imgg_engine)
+
+ # Execute job
+ result = await func(self, imgg_job, *args, **kwargs)
+
+ # Report job
+ imgg_job.imgg_job_after_complete()
+ if self.report_delegate:
+ self.report_delegate.report_inference_job(inference_job=imgg_job)
+
+ return result
+
+ return cast(F, wrapper)
+
+
+class ImggWorkerAbstract(InferenceWorkerAbstract):
+ def __init__(
+ self,
+ imgg_engine: ImggEngine,
+ report_delegate: Optional[InferenceReportDelegate] = None,
+ ):
+ InferenceWorkerAbstract.__init__(self, report_delegate=report_delegate)
+ self.imgg_engine = imgg_engine
+
+ #########################################################
+ # Instance methods
+ #########################################################
+
+ @property
+ @override
+ def desc(self) -> str:
+ return f"Img Worker using:\n{self.imgg_engine.desc}"
+
+ def check_can_perform_job(self, imgg_job: ImggJob):
+ pass
+
+ @abstractmethod
+ async def gen_image(
+ self,
+ imgg_job: ImggJob,
+ ) -> GeneratedImage:
+ pass
+
+ @abstractmethod
+ async def gen_image_list(
+ self,
+ imgg_job: ImggJob,
+ nb_images: int,
+ ) -> List[GeneratedImage]:
+ pass
diff --git a/pipelex/cogt/imgg/imgg_worker_factory.py b/pipelex/cogt/imgg/imgg_worker_factory.py
new file mode 100644
index 000000000..07fd57cb3
--- /dev/null
+++ b/pipelex/cogt/imgg/imgg_worker_factory.py
@@ -0,0 +1,53 @@
+from typing import Optional
+
+from pipelex.cogt.exceptions import CogtError, MissingDependencyError
+from pipelex.cogt.imgg.imgg_engine import ImggEngine
+from pipelex.cogt.imgg.imgg_platform import ImggPlatform
+from pipelex.cogt.imgg.imgg_worker_abstract import ImggWorkerAbstract
+from pipelex.cogt.inference.inference_report_delegate import InferenceReportDelegate
+from pipelex.cogt.plugin_manager import PluginHandle
+from pipelex.hub import get_plugin_manager, get_secret
+from pipelex.tools.secrets.secrets_errors import SecretNotFoundError
+
+
+class FalCredentialsError(CogtError):
+ pass
+
+
+class ImggWorkerFactory:
+ def make_imgg_worker(
+ self,
+ imgg_engine: ImggEngine,
+ report_delegate: Optional[InferenceReportDelegate] = None,
+ ) -> ImggWorkerAbstract:
+ imgg_sdk_handle = PluginHandle.get_for_imgg_engine(imgg_platform=imgg_engine.imgg_platform)
+ plugin_manager = get_plugin_manager()
+ imgg_worker: ImggWorkerAbstract
+ match imgg_engine.imgg_platform:
+ case ImggPlatform.FAL_AI:
+ try:
+ fal_api_key = get_secret(secret_id="FAL_API_KEY")
+ except SecretNotFoundError as exc:
+ raise FalCredentialsError("FAL_API_KEY not found") from exc
+
+ try:
+ from fal_client import AsyncClient as FalAsyncClient
+ except ImportError as exc:
+ raise MissingDependencyError(
+ "fal-client", "fal", "The fal-client SDK is required to use FAL models (generation of images)."
+ ) from exc
+
+ from pipelex.cogt.plugin.fal.fal_imgg_worker import FalImggWorker
+
+ imgg_sdk_instance = plugin_manager.get_imgg_sdk_instance(imgg_sdk_handle=imgg_sdk_handle) or plugin_manager.set_imgg_sdk_instance(
+ imgg_sdk_handle=imgg_sdk_handle,
+ imgg_sdk_instance=FalAsyncClient(key=fal_api_key),
+ )
+
+ imgg_worker = FalImggWorker(
+ sdk_instance=imgg_sdk_instance,
+ imgg_engine=imgg_engine,
+ report_delegate=report_delegate,
+ )
+
+ return imgg_worker
diff --git a/pipelex/cogt/inference/__init__.py b/pipelex/cogt/inference/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/pipelex/cogt/inference/__init__.py
@@ -0,0 +1 @@
+
diff --git a/pipelex/cogt/inference/cost_registry.py b/pipelex/cogt/inference/cost_registry.py
new file mode 100644
index 000000000..4e024fa10
--- /dev/null
+++ b/pipelex/cogt/inference/cost_registry.py
@@ -0,0 +1,173 @@
+from typing import Any, Dict, List, Optional
+
+import pandas as pd
+from pydantic import Field, RootModel
+from rich import box
+from rich.console import Console
+from rich.table import Table
+
+from pipelex import log
+from pipelex.cogt.exceptions import CostRegistryError
+from pipelex.cogt.llm.llm_report import LLMTokenCostReport, LLMTokenCostReportField, LLMTokensUsage, model_cost_per_token
+from pipelex.cogt.llm.token_category import TokenCategory
+
+CostRegistryRoot = List[LLMTokenCostReport]
+
+
+class CostRegistry(RootModel[CostRegistryRoot]):
+ root: CostRegistryRoot = Field(default_factory=list)
+
+ def to_dataframe(self) -> pd.DataFrame:
+ records: List[Dict[str, Any]] = []
+ for token_cost_report in self.root:
+ record_dict = token_cost_report.as_flat_dictionary()
+ records.append(record_dict)
+ df = pd.DataFrame(records)
+ return df
+
+ @classmethod
+ def generate_report(
+ cls,
+ mission_id: str,
+ llm_tokens_usages: List[LLMTokensUsage],
+ unit_scale: float,
+ cost_report_file_path: Optional[str] = None,
+ ):
+ if not llm_tokens_usages:
+ log.warning(f"No report to generate for mission '{mission_id}'")
+ return
+ cost_registry = CostRegistry()
+ for llm_tokens_usage in llm_tokens_usages:
+ cost_report = cls.complete_cost_report(llm_tokens_usage=llm_tokens_usage)
+ cost_registry.root.append(cost_report)
+
+ cost_registry_df = cost_registry.to_dataframe()
+
+ # Calculate total costs overall
+ total_nb_tokens_input_cached = cost_registry_df[LLMTokenCostReportField.NB_TOKENS_INPUT_CACHED].sum() # pyright: ignore[reportUnknownMemberType]
+ total_nb_tokens_input_non_cached = cost_registry_df[LLMTokenCostReportField.NB_TOKENS_INPUT_NON_CACHED].sum() # pyright: ignore[reportUnknownMemberType]
+ total_nb_tokens_input_joined = cost_registry_df[LLMTokenCostReportField.NB_TOKENS_INPUT_JOINED].sum() # pyright: ignore[reportUnknownMemberType]
+ total_nb_tokens_output = cost_registry_df[LLMTokenCostReportField.NB_TOKENS_OUTPUT].sum() # pyright: ignore[reportUnknownMemberType]
+ total_cost_input_cached = cost_registry_df[LLMTokenCostReportField.COST_INPUT_CACHED].sum() # pyright: ignore[reportUnknownMemberType]
+ total_cost_input_non_cached = cost_registry_df[LLMTokenCostReportField.COST_INPUT_NON_CACHED].sum() # pyright: ignore[reportUnknownMemberType]
+ total_cost_input_joined = cost_registry_df[LLMTokenCostReportField.COST_INPUT_JOINED].sum() # pyright: ignore[reportUnknownMemberType]
+ total_cost_output = cost_registry_df[LLMTokenCostReportField.COST_OUTPUT].sum() # pyright: ignore[reportUnknownMemberType]
+ total_cost = cls.compute_total_cost(
+ input_non_cached_cost=total_cost_input_non_cached,
+ input_cached_cost=total_cost_input_cached,
+ output_cost=total_cost_output,
+ )
+
+ # Calculate costs per LLM model
+ llm_group = cost_registry_df.groupby(LLMTokenCostReportField.LLM_NAME) # pyright: ignore[reportUnknownMemberType]
+ agg_by_llm_name = llm_group.agg( # pyright: ignore[reportUnknownMemberType]
+ {
+ LLMTokenCostReportField.NB_TOKENS_INPUT_CACHED: "sum",
+ LLMTokenCostReportField.NB_TOKENS_INPUT_NON_CACHED: "sum",
+ LLMTokenCostReportField.NB_TOKENS_INPUT_JOINED: "sum",
+ LLMTokenCostReportField.NB_TOKENS_OUTPUT: "sum",
+ LLMTokenCostReportField.COST_INPUT_CACHED: "sum",
+ LLMTokenCostReportField.COST_INPUT_NON_CACHED: "sum",
+ LLMTokenCostReportField.COST_INPUT_JOINED: "sum",
+ LLMTokenCostReportField.COST_OUTPUT: "sum",
+ }
+ ).reset_index()
+ if agg_by_llm_name is None or agg_by_llm_name.empty: # pyright: ignore[reportUnnecessaryComparison]
+ raise CostRegistryError("Empty report aggregation by LLM name")
+
+ console = Console()
+ title = "Costs by LLM model"
+ title += f" for mission '{mission_id}'"
+ table = Table(title=title, box=box.ROUNDED)
+
+ scale_str: str
+ if unit_scale == 1:
+ scale_str = ""
+ else:
+ scale_str = str(unit_scale)
+ # Add columns
+ table.add_column("Model", style="cyan")
+ table.add_column("Input Cached", justify="right", style="green")
+ table.add_column("Input Non Cached", justify="right", style="green")
+ table.add_column("Input Joined", justify="right", style="green")
+ table.add_column("Output", justify="right", style="green")
+ table.add_column(f"Input Cached Cost ({scale_str}$)", justify="right", style="yellow")
+ table.add_column(f"Input Non Cached Cost ({scale_str}$)", justify="right", style="yellow")
+ table.add_column(f"Input Joined Cost ({scale_str}$)", justify="right", style="yellow")
+ table.add_column(f"Output Cost ({scale_str}$)", justify="right", style="yellow")
+ table.add_column(f"Total Cost ({scale_str}$)", justify="right", style="bold yellow")
+
+ for _, row in agg_by_llm_name.iterrows(): # pyright: ignore[reportUnknownMemberType, reportUnknownVariableType]
+ llm_name = row[LLMTokenCostReportField.LLM_NAME] # pyright: ignore[reportUnknownVariableType]
+ row_total_cost = cls.compute_total_cost(
+ input_non_cached_cost=row[LLMTokenCostReportField.COST_INPUT_NON_CACHED], # pyright: ignore[reportUnknownArgumentType]
+ input_cached_cost=row[LLMTokenCostReportField.COST_INPUT_CACHED], # pyright: ignore[reportUnknownArgumentType]
+ output_cost=row[LLMTokenCostReportField.COST_OUTPUT], # pyright: ignore[reportUnknownArgumentType]
+ )
+ table.add_row(
+ llm_name, # pyright: ignore[reportUnknownArgumentType]
+ f"{row[LLMTokenCostReportField.NB_TOKENS_INPUT_CACHED]:,}", # pyright: ignore[reportUnknownVariableType]
+ f"{row[LLMTokenCostReportField.NB_TOKENS_INPUT_NON_CACHED]:,}", # pyright: ignore[reportUnknownVariableType]
+ f"{row[LLMTokenCostReportField.NB_TOKENS_INPUT_JOINED]:,}", # pyright: ignore[reportUnknownVariableType]
+ f"{row[LLMTokenCostReportField.NB_TOKENS_OUTPUT]:,}", # pyright: ignore[reportUnknownVariableType]
+ f"{row[LLMTokenCostReportField.COST_INPUT_CACHED] / unit_scale:.4f}", # pyright: ignore[reportUnknownVariableType]
+ f"{row[LLMTokenCostReportField.COST_INPUT_NON_CACHED] / unit_scale:.4f}", # pyright: ignore[reportUnknownVariableType]
+ f"{row[LLMTokenCostReportField.COST_INPUT_JOINED] / unit_scale:.4f}", # pyright: ignore[reportUnknownVariableType]
+ f"{row[LLMTokenCostReportField.COST_OUTPUT] / unit_scale:.4f}", # pyright: ignore[reportUnknownVariableType]
+ f"{row_total_cost / unit_scale:.4f}", # pyright: ignore[reportUnknownVariableType]
+ )
+
+ # add total row
+ footer_style = "bold"
+ table.add_row(
+ "Total",
+ f"{total_nb_tokens_input_cached:,}",
+ f"{total_nb_tokens_input_non_cached:,}",
+ f"{total_nb_tokens_input_joined:,}",
+ f"{total_nb_tokens_output:,}",
+ f"{total_cost_input_cached / unit_scale:.4f}",
+ f"{total_cost_input_non_cached / unit_scale:.4f}",
+ f"{total_cost_input_joined / unit_scale:.4f}",
+ f"{total_cost_output / unit_scale:.4f}",
+ f"{total_cost / unit_scale:.4f}",
+ style=footer_style,
+ end_section=True,
+ )
+
+ console.print(table)
+
+ if cost_report_file_path:
+ cost_registry_df.to_excel( # pyright: ignore[reportUnknownMemberType]
+ cost_report_file_path,
+ index=False,
+ )
+
+ @classmethod
+ def compute_total_cost(cls, input_non_cached_cost: float, input_cached_cost: float, output_cost: float) -> float:
+ return input_non_cached_cost + input_cached_cost + output_cost
+
+ @classmethod
+ def complete_cost_report(cls, llm_tokens_usage: LLMTokensUsage) -> LLMTokenCostReport:
+ cost_report = llm_tokens_usage.compute_cost_report()
+ # compute the input_non_cached tokens
+ if cost_report.nb_tokens_by_category.get(TokenCategory.INPUT_NON_CACHED) is not None:
+ raise CostRegistryError("TokenCategory.INPUT_NON_CACHED already exists in the cost report")
+ # we use pop to remove input tokens which will be replaced by "input joined"
+ nb_tokens_input_joined = cost_report.nb_tokens_by_category.pop(TokenCategory.INPUT, 0)
+ cost_report.costs_by_token_category.pop(TokenCategory.INPUT, None)
+
+ nb_tokens_input_cached = cost_report.nb_tokens_by_category.get(TokenCategory.INPUT_CACHED, 0)
+ nb_tokens_input_non_cached = nb_tokens_input_joined - nb_tokens_input_cached
+ cost_report.nb_tokens_by_category[TokenCategory.INPUT_JOINED] = nb_tokens_input_joined
+ cost_report.nb_tokens_by_category[TokenCategory.INPUT_NON_CACHED] = nb_tokens_input_non_cached
+ cost_report.nb_tokens_by_category[TokenCategory.INPUT_CACHED] = nb_tokens_input_cached
+
+ cost_report.costs_by_token_category[TokenCategory.INPUT_NON_CACHED] = nb_tokens_input_non_cached * model_cost_per_token(
+ llm_engine=llm_tokens_usage.llm_engine, token_type=TokenCategory.INPUT_NON_CACHED
+ )
+ costs_input_cached = cost_report.costs_by_token_category.get(TokenCategory.INPUT_CACHED, 0)
+ cost_report.costs_by_token_category[TokenCategory.INPUT_CACHED] = costs_input_cached
+ cost_report.costs_by_token_category[TokenCategory.INPUT_JOINED] = (
+ costs_input_cached + cost_report.costs_by_token_category[TokenCategory.INPUT_NON_CACHED]
+ )
+ return cost_report
diff --git a/pipelex/cogt/inference/inference_job_abstract.py b/pipelex/cogt/inference/inference_job_abstract.py
new file mode 100644
index 000000000..9b99655d8
--- /dev/null
+++ b/pipelex/cogt/inference/inference_job_abstract.py
@@ -0,0 +1,13 @@
+from abc import ABC, abstractmethod
+
+from pydantic import BaseModel
+
+from pipelex.mission.job_metadata import JobMetadata
+
+
+class InferenceJobAbstract(ABC, BaseModel):
+ job_metadata: JobMetadata
+
+ @abstractmethod
+ def validate_before_execution(self):
+ pass
diff --git a/pipelex/cogt/inference/inference_manager.py b/pipelex/cogt/inference/inference_manager.py
new file mode 100644
index 000000000..5d9cf63b0
--- /dev/null
+++ b/pipelex/cogt/inference/inference_manager.py
@@ -0,0 +1,172 @@
+from typing import Dict, Optional
+
+from typing_extensions import override
+
+from pipelex import log
+from pipelex.cogt.exceptions import InferenceManagerWorkerSetupError
+from pipelex.cogt.imgg.imgg_engine_factory import ImggEngineFactory
+from pipelex.cogt.imgg.imgg_worker_abstract import ImggWorkerAbstract
+from pipelex.cogt.imgg.imgg_worker_factory import ImggWorkerFactory
+from pipelex.cogt.inference.inference_manager_protocol import InferenceManagerProtocol
+from pipelex.cogt.llm.llm_models.llm_engine_blueprint import LLMEngineBlueprint
+from pipelex.cogt.llm.llm_models.llm_engine_factory import LLMEngineFactory
+from pipelex.cogt.llm.llm_worker_abstract import LLMWorkerAbstract
+from pipelex.cogt.llm.llm_worker_factory import LLMWorkerFactory
+from pipelex.cogt.ocr.ocr_engine_factory import OcrEngineFactory
+from pipelex.cogt.ocr.ocr_worker_abstract import OcrWorkerAbstract
+from pipelex.cogt.ocr.ocr_worker_factory import OcrWorkerFactory
+from pipelex.config import get_config
+from pipelex.hub import get_llm_deck, get_report_delegate
+
+
+class InferenceManager(InferenceManagerProtocol):
+ def __init__(self):
+ self.imgg_worker_factory = ImggWorkerFactory()
+ self.ocr_worker_factory = OcrWorkerFactory()
+ self.llm_workers: Dict[str, LLMWorkerAbstract] = {}
+ self.imgg_workers: Dict[str, ImggWorkerAbstract] = {}
+ self.ocr_workers: Dict[str, OcrWorkerAbstract] = {}
+
+ @override
+ def teardown(self):
+ self.imgg_worker_factory = ImggWorkerFactory()
+ self.ocr_worker_factory = OcrWorkerFactory()
+ self.llm_workers.clear()
+ self.imgg_workers.clear()
+ self.ocr_workers.clear()
+ log.verbose("InferenceManagerAsync reset")
+
+ def print_workers(self):
+ log.debug("LLM Workers:")
+ for handle, llm_worker in self.llm_workers.items():
+ log.debug(f" {handle}:")
+ log.debug(llm_worker.desc)
+ log.debug("Image Workers:")
+ for handle, imgg_worker_async in self.imgg_workers.items():
+ log.debug(f" {handle}:")
+ log.debug(imgg_worker_async.desc)
+ log.debug("OCR Workers:")
+ for handle, ocr_worker_async in self.ocr_workers.items():
+ log.debug(f" {handle}:")
+ log.debug(ocr_worker_async.desc)
+
+ ####################################################################################################
+ # Setup LLM Workers
+ ####################################################################################################
+
+ @override
+ def setup_llm_workers(self):
+ log.verbose("Setting up LLM Workers...")
+ llm_handle_to_llm_engine_blueprint = get_llm_deck().llm_handles
+ log.verbose(f"{len(llm_handle_to_llm_engine_blueprint)} LLM engine_cards found")
+ for llm_handle, llm_engine_blueprint in llm_handle_to_llm_engine_blueprint.items():
+ self._setup_one_llm_worker(llm_engine_blueprint=llm_engine_blueprint, llm_handle=llm_handle)
+ log.verbose(f"Setup LLM worker for '{llm_handle}' on {llm_engine_blueprint.llm_platform_choice}")
+ log.debug("Done setting up LLM Workers (async)")
+
+ def _setup_one_llm_worker(
+ self,
+ llm_engine_blueprint: LLMEngineBlueprint,
+ llm_handle: str,
+ ) -> LLMWorkerAbstract:
+ llm_engine = LLMEngineFactory.make_llm_engine(llm_engine_blueprint=llm_engine_blueprint)
+ llm_worker = LLMWorkerFactory.make_llm_worker(
+ llm_engine=llm_engine,
+ report_delegate=get_report_delegate(),
+ )
+ self.llm_workers[llm_handle] = llm_worker
+ return llm_worker
+
+ @override
+ def get_llm_worker(
+ self,
+ llm_handle: str,
+ specific_llm_engine_blueprint: Optional[LLMEngineBlueprint] = None,
+ ) -> LLMWorkerAbstract:
+ if llm_worker := self.llm_workers.get(llm_handle):
+ return llm_worker
+ if not get_config().cogt.inference_manager_config.is_auto_setup_preset_llm:
+ raise InferenceManagerWorkerSetupError(
+ f"No LLM worker for '{llm_handle}', set it up or enable cogt.inference_manager_config.is_auto_setup_preset_llm"
+ )
+
+ if not specific_llm_engine_blueprint:
+ specific_llm_engine_blueprint = get_llm_deck().get_llm_engine_blueprint(llm_handle=llm_handle)
+ llm_worker = self._setup_one_llm_worker(
+ llm_engine_blueprint=specific_llm_engine_blueprint,
+ llm_handle=llm_handle,
+ )
+
+ return llm_worker
+
+ ####################################################################################################
+ # Manage IMGG Workers
+ ####################################################################################################
+
+ @override
+ def setup_imgg_workers(self):
+ log.verbose("Setting up Imgg Workers...")
+ imgg_handles = get_config().cogt.imgg_config.imgg_handles
+ log.verbose(f"{len(imgg_handles)} Imgg handles found")
+ for imgg_handle in imgg_handles:
+ self._setup_one_imgg_worker(imgg_handle=imgg_handle)
+
+ log.debug("Done setting up Imgg Workers (async)")
+
+ def _setup_one_imgg_worker(self, imgg_handle: str) -> ImggWorkerAbstract:
+ imgg_engine = ImggEngineFactory.make_imgg_engine(imgg_handle=imgg_handle)
+ log.verbose(imgg_engine.desc, title=f"Setting up ImgEngine for '{imgg_handle}'")
+ imgg_worker = self.imgg_worker_factory.make_imgg_worker(
+ imgg_engine=imgg_engine,
+ report_delegate=get_report_delegate(),
+ )
+ self.imgg_workers[imgg_handle] = imgg_worker
+ return imgg_worker
+
+ @override
+ def get_imgg_worker(self, imgg_handle: str) -> ImggWorkerAbstract:
+ imgg_worker = self.imgg_workers.get(imgg_handle)
+ if imgg_worker is None:
+ if not get_config().cogt.inference_manager_config.is_auto_setup_preset_imgg:
+ raise InferenceManagerWorkerSetupError(
+ f"Found no Imgg worker for '{imgg_handle}', set it up or enable cogt.inference_manager_config.is_auto_setup_preset_imgg"
+ )
+
+ imgg_worker = self._setup_one_imgg_worker(imgg_handle=imgg_handle)
+ return imgg_worker
+
+ ####################################################################################################
+ # Manage OCR Workers
+ ####################################################################################################
+
+ @override
+ def setup_ocr_workers(self):
+ log.verbose("Setting up OCR Workers...")
+ ocr_handles = get_config().cogt.ocr_config.ocr_handles
+ log.verbose(f"{len(ocr_handles)} OCR handles found")
+ for ocr_handle in ocr_handles:
+ self._setup_one_ocr_worker(ocr_handle=ocr_handle)
+
+ log.debug("Done setting up OCR Workers (async)")
+
+ def _setup_one_ocr_worker(self, ocr_handle: str) -> OcrWorkerAbstract:
+ ocr_engine = OcrEngineFactory.make_ocr_engine(ocr_handle=ocr_handle)
+ log.verbose(ocr_engine.desc, title=f"Setting up OcrEngine for '{ocr_handle}'")
+ ocr_worker = self.ocr_worker_factory.make_ocr_worker(
+ ocr_engine=ocr_engine,
+ report_delegate=get_report_delegate(),
+ )
+ self.ocr_workers[ocr_handle] = ocr_worker
+ return ocr_worker
+
+ @override
+ def get_ocr_worker(self, ocr_handle: str) -> OcrWorkerAbstract:
+ ocr_worker = self.ocr_workers.get(ocr_handle)
+ if ocr_worker is None:
+ if not get_config().cogt.inference_manager_config.is_auto_setup_preset_ocr:
+ raise InferenceManagerWorkerSetupError(
+ f"Found no OCR worker for '{ocr_handle}', set it up or enable cogt.inference_manager_config.is_auto_setup_preset_ocr"
+ )
+
+ ocr_worker = self._setup_one_ocr_worker(ocr_handle=ocr_handle)
+ return ocr_worker
diff --git a/pipelex/cogt/inference/inference_manager_protocol.py b/pipelex/cogt/inference/inference_manager_protocol.py
new file mode 100644
index 000000000..a03631506
--- /dev/null
+++ b/pipelex/cogt/inference/inference_manager_protocol.py
@@ -0,0 +1,43 @@
+from typing import Optional, Protocol
+
+from pipelex.cogt.imgg.imgg_worker_abstract import ImggWorkerAbstract
+from pipelex.cogt.llm.llm_models.llm_engine_blueprint import LLMEngineBlueprint
+from pipelex.cogt.llm.llm_worker_abstract import LLMWorkerAbstract
+from pipelex.cogt.ocr.ocr_worker_abstract import OcrWorkerAbstract
+
+
+class InferenceManagerProtocol(Protocol):
+ """
+ This is the protocol for the inference manager.
+ Its point is only to avoid a circular import.
+ """
+
+ def teardown(self): ...
+
+ ####################################################################################################
+ # LLM Workers
+ ####################################################################################################
+
+ def setup_llm_workers(self): ...
+
+ def get_llm_worker(
+ self,
+ llm_handle: str,
+ specific_llm_engine_blueprint: Optional[LLMEngineBlueprint] = None,
+ ) -> LLMWorkerAbstract: ...
+
+ ####################################################################################################
+ # IMG Generation Workers
+ ####################################################################################################
+
+ def setup_imgg_workers(self): ...
+
+ def get_imgg_worker(self, imgg_handle: str) -> ImggWorkerAbstract: ...
+
+ ####################################################################################################
+ # OCR Workers
+ ####################################################################################################
+
+ def setup_ocr_workers(self): ...
+
+ def get_ocr_worker(self, ocr_handle: str) -> OcrWorkerAbstract: ...
diff --git a/pipelex/cogt/inference/inference_report_delegate.py b/pipelex/cogt/inference/inference_report_delegate.py
new file mode 100644
index 000000000..a69bbfbbd
--- /dev/null
+++ b/pipelex/cogt/inference/inference_report_delegate.py
@@ -0,0 +1,13 @@
+from typing import Optional, Protocol
+
+from pipelex.cogt.inference.inference_job_abstract import InferenceJobAbstract
+
+
+class InferenceReportDelegate(Protocol):
+ def open_registry(self, mission_id: str): ...
+
+ def report_inference_job(self, inference_job: InferenceJobAbstract): ...
+
+ def generate_report(self, mission_id: Optional[str] = None): ...
+
+ def close_registry(self, mission_id: str): ...
diff --git a/pipelex/cogt/inference/inference_report_manager.py b/pipelex/cogt/inference/inference_report_manager.py
new file mode 100644
index 000000000..8457c568f
--- /dev/null
+++ b/pipelex/cogt/inference/inference_report_manager.py
@@ -0,0 +1,115 @@
+from typing import Dict, List, Optional
+
+from pydantic import Field, RootModel
+from typing_extensions import override
+
+from pipelex import log
+from pipelex.cogt.config_cogt import CogtReportConfig
+from pipelex.cogt.exceptions import InferenceReportManagerError
+from pipelex.cogt.inference.cost_registry import CostRegistry
+from pipelex.cogt.inference.inference_job_abstract import InferenceJobAbstract
+from pipelex.cogt.inference.inference_report_delegate import InferenceReportDelegate
+from pipelex.cogt.llm.llm_job import LLMJob
+from pipelex.cogt.llm.llm_report import LLMTokenCostReport, LLMTokensUsage
+from pipelex.mission.mission_models import SpecialMissionId
+from pipelex.tools.misc.file_utils import ensure_path, get_incremental_file_path
+
+LLMUsageRegistryRoot = List[LLMTokensUsage]
+
+
+class UsageRegistry(RootModel[LLMUsageRegistryRoot]):
+ root: LLMUsageRegistryRoot = Field(default_factory=list)
+
+ def get_current_tokens_usage(self) -> LLMUsageRegistryRoot:
+ return self.root
+
+ def add_tokens_usage(self, llm_tokens_usage: LLMTokensUsage):
+ self.root.append(llm_tokens_usage)
+
+
+class InferenceReportManager(InferenceReportDelegate):
+ def __init__(self, report_config: CogtReportConfig):
+ self._usage_registries: Dict[str, UsageRegistry] = {}
+ self._report_config = report_config
+
+ ############################################################
+ # Manager lifecycle
+ ############################################################
+
+ def setup(self):
+ self._usage_registries.clear()
+ self._usage_registries[SpecialMissionId.UNTITLED] = UsageRegistry()
+
+ def teardown(self):
+ self._usage_registries.clear()
+
+ ############################################################
+ # Private methods
+ ############################################################
+
+ def _get_registry(self, mission_id: str) -> UsageRegistry:
+ if mission_id not in self._usage_registries:
+ raise InferenceReportManagerError(f"Registry for mission '{mission_id}' does not exist")
+ return self._usage_registries[mission_id]
+
+ def _report_llm_job(self, llm_job: LLMJob):
+ llm_tokens_usage = llm_job.job_report.llm_tokens_usage
+
+ if not llm_tokens_usage:
+ log.warning("LLM job has no llm_tokens_usage")
+ return
+
+ llm_token_cost_report: Optional[LLMTokenCostReport] = None
+
+ if self._report_config.is_log_costs_to_console:
+ llm_token_cost_report = CostRegistry.complete_cost_report(llm_tokens_usage=llm_tokens_usage)
+
+ mission_id = llm_job.job_metadata.mission_id
+ self._get_registry(mission_id).add_tokens_usage(llm_tokens_usage)
+
+ if self._report_config.is_log_costs_to_console:
+ log.verbose(llm_token_cost_report, title="Token Cost report")
+
+ ############################################################
+ # InferenceReportDelegate
+ ############################################################
+
+ @override
+ def open_registry(self, mission_id: str):
+ if mission_id in self._usage_registries:
+ raise InferenceReportManagerError(f"Registry for mission '{mission_id}' already exists")
+ self._usage_registries[mission_id] = UsageRegistry()
+
+ @override
+ def report_inference_job(self, inference_job: InferenceJobAbstract):
+ log.info(f"Inference job '{inference_job.job_metadata.unit_job_id}' completed in {inference_job.job_metadata.duration:.2f} seconds")
+ if not isinstance(inference_job, LLMJob):
+ # InferenceReportManager does not support reporting for other types of inference jobs yet
+ # TODO: add support for other types of inference jobs
+ return
+ llm_job: LLMJob = inference_job
+ self._report_llm_job(llm_job=llm_job)
+
+ @override
+ def generate_report(self, mission_id: Optional[str] = None):
+ mission_id = mission_id or SpecialMissionId.UNTITLED
+ cost_report_file_path: Optional[str] = None
+ if self._report_config.is_generate_cost_report_file_enabled:
+ ensure_path(self._report_config.cost_report_dir_path)
+ cost_report_file_path = get_incremental_file_path(
+ base_path=self._report_config.cost_report_dir_path,
+ base_name=self._report_config.cost_report_base_name,
+ extension=self._report_config.cost_report_extension,
+ )
+
+ registry = self._get_registry(mission_id)
+ CostRegistry.generate_report(
+ mission_id=mission_id,
+ llm_tokens_usages=registry.get_current_tokens_usage(),
+ unit_scale=self._report_config.cost_report_unit_scale,
+ cost_report_file_path=cost_report_file_path,
+ )
+
+ @override
+ def close_registry(self, mission_id: str):
+ self._usage_registries.pop(mission_id)
diff --git a/pipelex/cogt/inference/inference_worker_abstract.py b/pipelex/cogt/inference/inference_worker_abstract.py
new file mode 100644
index 000000000..4e2062c45
--- /dev/null
+++ b/pipelex/cogt/inference/inference_worker_abstract.py
@@ -0,0 +1,17 @@
+from abc import ABC, abstractmethod
+from typing import Optional
+
+from pipelex.cogt.inference.inference_report_delegate import InferenceReportDelegate
+
+
+class InferenceWorkerAbstract(ABC):
+ def __init__(
+ self,
+ report_delegate: Optional[InferenceReportDelegate] = None,
+ ):
+ self.report_delegate = report_delegate
+
+ @property
+ @abstractmethod
+ def desc(self) -> str:
+ pass
diff --git a/pipelex/cogt/llm/__init__.py b/pipelex/cogt/llm/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/pipelex/cogt/llm/__init__.py
@@ -0,0 +1 @@
+
diff --git a/pipelex/cogt/llm/llm_job.py b/pipelex/cogt/llm/llm_job.py
new file mode 100644
index 000000000..74cddce94
--- /dev/null
+++ b/pipelex/cogt/llm/llm_job.py
@@ -0,0 +1,41 @@
+from datetime import datetime
+
+from typing_extensions import override
+
+from pipelex.cogt.inference.inference_job_abstract import InferenceJobAbstract
+from pipelex.cogt.llm.llm_job_components import LLMJobConfig, LLMJobParams, LLMJobReport
+from pipelex.cogt.llm.llm_models.llm_engine import LLMEngine
+from pipelex.cogt.llm.llm_prompt import LLMPrompt
+from pipelex.cogt.llm.llm_report import LLMTokensUsage
+
+
+class LLMJob(InferenceJobAbstract):
+ llm_prompt: LLMPrompt
+ job_params: LLMJobParams
+ job_config: LLMJobConfig
+ job_report: LLMJobReport = LLMJobReport()
+
+ @property
+ def params_desc(self) -> str:
+ return f"temp={self.job_params.temperature}, max_tokens={self.job_params.max_tokens}"
+
+ @override
+ def validate_before_execution(self):
+ self.llm_prompt.validate_before_execution()
+
+ def llm_job_before_start(self, llm_engine: LLMEngine):
+ # Reset metadata
+ self.job_metadata.started_at = datetime.now()
+
+ # Reset outputs
+ self.job_report = LLMJobReport()
+
+ # Reset info
+ self.job_report.llm_tokens_usage = LLMTokensUsage(
+ job_metadata=self.job_metadata,
+ llm_engine=llm_engine,
+ nb_tokens_by_category={},
+ )
+
+ def llm_job_after_complete(self):
+ self.job_metadata.completed_at = datetime.now()
diff --git a/pipelex/cogt/llm/llm_job_components.py b/pipelex/cogt/llm/llm_job_components.py
new file mode 100644
index 000000000..9dfb1b062
--- /dev/null
+++ b/pipelex/cogt/llm/llm_job_components.py
@@ -0,0 +1,29 @@
+from typing import Optional
+
+from pydantic import BaseModel, Field
+
+from pipelex.cogt.llm.llm_report import LLMTokensUsage
+
+########################################################################
+### Inputs
+########################################################################
+
+
+class LLMJobParams(BaseModel):
+ temperature: float = Field(..., ge=0, le=1)
+ max_tokens: Optional[int] = Field(None, gt=0)
+ seed: Optional[int] = Field(None, ge=0)
+
+
+class LLMJobConfig(BaseModel):
+ is_streaming_enabled: bool
+ max_retries: int = Field(..., ge=1, le=10)
+
+
+########################################################################
+### Outputs
+########################################################################
+
+
+class LLMJobReport(BaseModel):
+ llm_tokens_usage: Optional[LLMTokensUsage] = None
diff --git a/pipelex/cogt/llm/llm_job_factory.py b/pipelex/cogt/llm/llm_job_factory.py
new file mode 100644
index 000000000..e6c9810ff
--- /dev/null
+++ b/pipelex/cogt/llm/llm_job_factory.py
@@ -0,0 +1,125 @@
+from typing import Any, Dict, List, Optional
+
+from pipelex import log
+from pipelex.cogt.image.prompt_image import PromptImage
+from pipelex.cogt.llm.llm_job import LLMJob
+from pipelex.cogt.llm.llm_job_components import LLMJobConfig, LLMJobParams
+from pipelex.cogt.llm.llm_prompt import LLMPrompt
+from pipelex.cogt.llm.llm_prompt_factory_abstract import LLMPromptFactoryAbstract
+from pipelex.cogt.llm.llm_prompt_template import LLMPromptTemplate
+from pipelex.config import get_config
+from pipelex.mission.job_metadata import JobCategory, JobMetadata
+
+
+class LLMJobFactory:
+ # straightforward: the prompt is provided
+ @classmethod
+ def make_llm_job(
+ cls,
+ llm_prompt: LLMPrompt,
+ llm_job_params: LLMJobParams,
+ llm_job_config: Optional[LLMJobConfig] = None,
+ job_metadata: Optional[JobMetadata] = None,
+ ) -> LLMJob:
+ config = get_config()
+ llm_config = config.cogt.llm_config
+ if job_metadata:
+ job_metadata.update(
+ JobMetadata(
+ job_category=JobCategory.LLM_JOB,
+ )
+ )
+ else:
+ job_metadata = JobMetadata(
+ top_job_id=f"LLMJob for {config.project_name}",
+ job_category=JobCategory.LLM_JOB,
+ )
+ job_params = llm_job_params
+ job_config = llm_job_config or llm_config.llm_job_config
+
+ return LLMJob(
+ job_metadata=job_metadata,
+ llm_prompt=llm_prompt,
+ job_params=job_params,
+ job_config=job_config,
+ )
+
+ # powerful: the prompt is generated by a prompt factory using prompt arguments
+ # but this one is using the generic llm_prompt_factory.make_llm_prompt_from_args()
+ @classmethod
+ async def make_llm_job_from_prompt_factory(
+ cls,
+ llm_prompt_factory: LLMPromptFactoryAbstract,
+ llm_prompt_arguments: Dict[str, Any],
+ llm_job_params: LLMJobParams,
+ llm_job_config: Optional[LLMJobConfig] = None,
+ job_metadata: Optional[JobMetadata] = None,
+ ) -> LLMJob:
+ print(f"llm_prompt_factory:\n{llm_prompt_factory.desc}")
+ log.debug(llm_prompt_arguments, title="llm_prompt_arguments")
+ llm_prompt = await llm_prompt_factory.make_llm_prompt_from_args(**llm_prompt_arguments)
+
+ return cls.make_llm_job(
+ job_metadata=job_metadata,
+ llm_prompt=llm_prompt,
+ llm_job_params=llm_job_params,
+ llm_job_config=llm_job_config,
+ )
+
+ # powerful: the prompt is generated by a prompt template using prompt arguments
+ @classmethod
+ async def make_llm_job_from_prompt_template(
+ cls,
+ llm_prompt_template: LLMPromptTemplate,
+ llm_prompt_arguments: Dict[str, Any],
+ llm_job_params: LLMJobParams,
+ llm_job_config: Optional[LLMJobConfig] = None,
+ job_metadata: Optional[JobMetadata] = None,
+ ) -> LLMJob:
+ log.debug(llm_prompt_arguments, title="llm_prompt_arguments")
+ llm_prompt = await llm_prompt_template.make_llm_prompt_from_args(**llm_prompt_arguments)
+
+ return cls.make_llm_job(
+ job_metadata=job_metadata,
+ llm_prompt=llm_prompt,
+ llm_job_params=llm_job_params,
+ llm_job_config=llm_job_config,
+ )
+
+ @classmethod
+ def make_llm_job_from_prompt_contents(
+ cls,
+ llm_job_params: LLMJobParams,
+ user_text: Optional[str] = None,
+ system_text: Optional[str] = None,
+ user_images: Optional[List[PromptImage]] = None,
+ llm_job_config: Optional[LLMJobConfig] = None,
+ job_metadata: Optional[JobMetadata] = None,
+ ) -> LLMJob:
+ config = get_config()
+ llm_config = config.cogt.llm_config
+ if job_metadata:
+ job_metadata.update(
+ JobMetadata(
+ job_category=JobCategory.LLM_JOB,
+ )
+ )
+ else:
+ job_metadata = JobMetadata(
+ top_job_id=f"LLMJob for {config.project_name}",
+ job_category=JobCategory.LLM_JOB,
+ )
+ llm_prompt = LLMPrompt(
+ system_text=system_text,
+ user_text=user_text,
+ user_images=user_images or [],
+ )
+ job_params = llm_job_params
+ job_config = llm_job_config or llm_config.llm_job_config
+
+ return LLMJob(
+ job_metadata=job_metadata,
+ llm_prompt=llm_prompt,
+ job_params=job_params,
+ job_config=job_config,
+ )
diff --git a/pipelex/cogt/llm/llm_job_func.py b/pipelex/cogt/llm/llm_job_func.py
new file mode 100644
index 000000000..aa4bbc53b
--- /dev/null
+++ b/pipelex/cogt/llm/llm_job_func.py
@@ -0,0 +1,75 @@
+from functools import wraps
+from typing import Any, Awaitable, Callable, TypeVar, cast
+
+from instructor.exceptions import InstructorRetryException
+
+from pipelex import log
+from pipelex.cogt.exceptions import LLMWorkerError
+from pipelex.cogt.llm.llm_job import LLMJob
+from pipelex.cogt.llm.llm_worker_abstract import LLMWorkerAbstract, LLMWorkerJobFuncName
+
+F = TypeVar("F", bound=Callable[..., Awaitable[Any]])
+
+
+def llm_job_func(func: F) -> F:
+ """
+ A decorator for asynchronous LLM job functions.
+
+ This decorator wraps an asynchronous function that performs an LLM job,
+ adding logging, integrity checks, feasibility checks, job preparation,
+ execution timing, and reporting.
+
+ Args:
+ func (F): The asynchronous function to be decorated.
+
+ Returns:
+ F: The wrapped asynchronous function.
+ """
+
+ @wraps(func)
+ async def wrapper(
+ self: LLMWorkerAbstract,
+ llm_job: LLMJob,
+ *args: Any,
+ **kwargs: Any,
+ ) -> Any:
+ func_name = LLMWorkerJobFuncName(func.__name__)
+ log.debug(f"LLM Working async job function: '{func_name}'")
+ log.verbose(f"\n{self.llm_engine.desc}")
+ log.verbose(llm_job.params_desc)
+
+ # Verify that the job is valid
+ llm_job.validate_before_execution()
+
+ # Verify feasibility
+ self.check_can_perform_job(llm_job=llm_job, func_name=func_name)
+
+ # TODO: Fix printing prompts that contain image bytes
+ # log.verbose(llm_job.llm_prompt.desc, title="llm_prompt")
+
+ # metadata
+ llm_job.job_metadata.unit_job_id = self.unit_job_id(func_name=func_name)
+
+ # Prepare job
+ llm_job.llm_job_before_start(llm_engine=self.llm_engine)
+
+ # Execute job
+ try:
+ result = await func(self, llm_job, *args, **kwargs)
+ except InstructorRetryException as exc:
+ raise LLMWorkerError(
+ f"LLM Worker error: Instructor failed after retry with llm '{self.llm_engine.tag}': {exc}\nLLMPrompt: {llm_job.llm_prompt.desc}"
+ ) from exc
+
+ # Cleanup result
+ if hasattr(result, "_raw_response"):
+ delattr(result, "_raw_response")
+
+ # Report job
+ llm_job.llm_job_after_complete()
+ if self.report_delegate:
+ self.report_delegate.report_inference_job(inference_job=llm_job)
+
+ return result
+
+ return cast(F, wrapper)
diff --git a/pipelex/cogt/llm/llm_models/__init__.py b/pipelex/cogt/llm/llm_models/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/pipelex/cogt/llm/llm_models/__init__.py
@@ -0,0 +1 @@
+
diff --git a/pipelex/cogt/llm/llm_models/llm_deck.py b/pipelex/cogt/llm/llm_models/llm_deck.py
new file mode 100644
index 000000000..d43ae1adb
--- /dev/null
+++ b/pipelex/cogt/llm/llm_models/llm_deck.py
@@ -0,0 +1,241 @@
+from typing import Dict, Optional, Self, Union
+
+from pydantic import field_validator, model_validator
+from typing_extensions import override
+
+from pipelex import log
+from pipelex.cogt.exceptions import LLMDeckValidatonError, LLMHandleNotFoundError, LLMPresetNotFoundError, LLMSettingsValidationError
+from pipelex.cogt.llm.llm_models.llm_deck_abstract import LLMDeckAbstract
+from pipelex.cogt.llm.llm_models.llm_engine_blueprint import LLMEngineBlueprint
+from pipelex.cogt.llm.llm_models.llm_family import LLMFamily
+from pipelex.cogt.llm.llm_models.llm_model import LLMModel
+from pipelex.cogt.llm.llm_models.llm_setting import LLMSetting, LLMSettingChoices, LLMSettingOrPresetId
+from pipelex.hub import get_llm_models_provider
+from pipelex.tools.config.models import ConfigModel
+from pipelex.tools.exceptions import ConfigValidationError
+
+LLM_PRESET_DISABLED = "disabled"
+
+
+class LLMDeck(LLMDeckAbstract, ConfigModel):
+ ############################################################
+ # LLMDeckAbstract overrides
+ ############################################################
+
+ @override
+ def check_llm_setting(self, llm_setting_or_preset_id: LLMSettingOrPresetId, is_disabled_allowed: bool = False):
+ if isinstance(llm_setting_or_preset_id, LLMSetting):
+ return
+ preset_id: str = llm_setting_or_preset_id
+ if preset_id in self.llm_presets:
+ return
+ if preset_id == LLM_PRESET_DISABLED and is_disabled_allowed:
+ return
+ raise LLMPresetNotFoundError(f"llm preset id '{preset_id}' not found in deck")
+
+ @override
+ def get_llm_engine_blueprint(self, llm_handle: str) -> LLMEngineBlueprint:
+ the_engine_blueprint = self.llm_handles.get(llm_handle)
+ if not the_engine_blueprint:
+ raise LLMHandleNotFoundError(f"LLM Engine blueprint for llm_handle '{llm_handle}' not found in deck's engine blueprints")
+ return the_engine_blueprint
+
+ @override
+ def get_llm_setting(self, llm_setting_or_preset_id: LLMSettingOrPresetId) -> LLMSetting:
+ the_llm_setting: LLMSetting
+ if isinstance(llm_setting_or_preset_id, str):
+ # it's a preset id
+ the_llm_preset = self.llm_presets.get(llm_setting_or_preset_id)
+ if not the_llm_preset:
+ raise LLMPresetNotFoundError(f"LLM preset '{llm_setting_or_preset_id}' not found in deck")
+ the_llm_setting = the_llm_preset
+ else:
+ # it's an explict setting
+ the_llm_setting = llm_setting_or_preset_id
+ return the_llm_setting
+
+ @override
+ def get_llm_setting_for_text(self, override: Optional[LLMSettingChoices] = None) -> LLMSetting:
+ llm_setting: LLMSettingOrPresetId
+ if replacement := self.llm_choice_overrides.for_text:
+ log.warning(f"General llm setting override for text, '{self.llm_choice_defaults.for_text}' -> '{replacement}'")
+ llm_setting = replacement
+ elif override and (provided_override_for_text := override.for_text):
+ llm_setting = provided_override_for_text
+ elif self.llm_choice_defaults.for_text is None:
+ raise ConfigValidationError("llm_choices.for_text cannot be None")
+ else:
+ llm_setting = self.llm_choice_defaults.for_text
+
+ return self.get_llm_setting(llm_setting_or_preset_id=llm_setting)
+
+ @override
+ def get_llm_setting_for_object(self, override: Optional[LLMSettingChoices] = None) -> LLMSetting:
+ log.debug(f"Getting LLM setting for object with provided_override: {override}")
+ llm_setting: LLMSettingOrPresetId
+ if replacement := self.llm_choice_overrides.for_object:
+ log.warning(f"General llm setting override for object, '{self.llm_choice_defaults.for_object}' -> '{replacement}'")
+ llm_setting = replacement
+ elif override and (provided_override_for_object := override.for_object):
+ llm_setting = provided_override_for_object
+ elif self.llm_choice_defaults.for_object is None:
+ raise ConfigValidationError("llm_choices.for_object cannot be None")
+ else:
+ llm_setting = self.llm_choice_defaults.for_object
+
+ return self.get_llm_setting(llm_setting_or_preset_id=llm_setting)
+
+ @override
+ def get_llm_setting_for_object_direct(self, override: Optional[LLMSettingChoices] = None) -> LLMSetting:
+ log.debug(f"Getting LLM preset for object direct with provided_override: {override}")
+ llm_setting: LLMSettingOrPresetId
+ if replacement := self.llm_choice_overrides.for_object_direct:
+ log.warning(f"General choice override for LLM preset for structured, '{self.llm_choice_defaults.for_object_direct}' -> '{replacement}'")
+ llm_setting = replacement
+ elif override and (provided_override_for_object_direct := override.for_object_direct):
+ llm_setting = provided_override_for_object_direct
+ elif self.llm_choice_defaults.for_object_direct is None:
+ raise ConfigValidationError("llm_choices.for_object_direct cannot be None")
+ else:
+ llm_setting = self.llm_choice_defaults.for_object_direct
+
+ return self.get_llm_setting(llm_setting_or_preset_id=llm_setting)
+
+ @override
+ def get_llm_setting_for_object_list(self, override: Optional[LLMSettingChoices] = None) -> LLMSetting:
+ llm_setting: LLMSettingOrPresetId
+ if replacement := self.llm_choice_overrides.for_object_list:
+ log.warning(f"General choice override for LLM preset for structured, '{self.llm_choice_defaults.for_object_list}' -> '{replacement}'")
+ llm_setting = replacement
+ elif override and (provided_override_for_object_list := override.for_object_list):
+ llm_setting = provided_override_for_object_list
+ elif self.llm_choice_defaults.for_object_list is None:
+ raise ConfigValidationError("llm_choices.for_object_list cannot be None")
+ else:
+ llm_setting = self.llm_choice_defaults.for_object_list
+
+ return self.get_llm_setting(llm_setting_or_preset_id=llm_setting)
+
+ @override
+ def get_llm_setting_for_object_list_direct(self, override: Optional[LLMSettingChoices] = None) -> LLMSetting:
+ llm_setting: LLMSettingOrPresetId
+ if override and (provided_override_for_object_list_direct := override.for_object_list_direct):
+ llm_setting = provided_override_for_object_list_direct
+ elif self.llm_choice_defaults.for_object_list_direct is None:
+ raise ConfigValidationError("llm_choices.for_object_list_direct cannot be None")
+ else:
+ llm_setting = self.llm_choice_defaults.for_object_list_direct
+
+ return self.get_llm_setting(llm_setting_or_preset_id=llm_setting)
+
+ @override
+ def find_llm_model(self, llm_handle: str) -> LLMModel:
+ llm_models_provider = get_llm_models_provider()
+ llm_engine_blueprint = self.llm_handles[llm_handle]
+ llm_model = llm_models_provider.get_llm_model(
+ llm_name=llm_engine_blueprint.llm_name,
+ llm_version=llm_engine_blueprint.llm_version,
+ llm_platform_choice=llm_engine_blueprint.llm_platform_choice,
+ )
+ return llm_model
+
+ @override
+ @classmethod
+ def final_validate(cls, deck: Self):
+ for llm_preset_id, llm_setting in deck.llm_presets.items():
+ llm_model = deck.find_llm_model(llm_handle=llm_setting.llm_handle)
+ try:
+ cls._validate_llm_setting(llm_setting=llm_setting, llm_model=llm_model)
+ except ConfigValidationError as exc:
+ raise LLMDeckValidatonError(f"LLM preset '{llm_preset_id}' is invalid: {exc}")
+
+ ############################################################
+ #### LLMDeck concrete validations
+ ############################################################
+
+ @classmethod
+ def _validate_llm_setting(cls, llm_setting: LLMSetting, llm_model: LLMModel):
+ if llm_model.max_tokens is not None and (llm_setting_max_tokens := llm_setting.max_tokens):
+ if llm_setting_max_tokens > llm_model.max_tokens:
+ raise LLMSettingsValidationError(
+ f"LLM setting '{llm_setting.llm_handle}' has a max_tokens of {llm_setting_max_tokens}, \
+ which is greater than the model's max_tokens of {llm_model.max_tokens}"
+ )
+ match llm_model.llm_family:
+ case LLMFamily.O_SERIES:
+ if llm_setting.temperature != 1:
+ raise LLMSettingsValidationError(
+ f"O-series LLMs like '{llm_setting.llm_handle}' must have a temperature of 1, not {llm_setting.temperature}"
+ )
+ case _:
+ pass
+
+ @field_validator("llm_handles", mode="before")
+ @classmethod
+ def validate_llm_handles(cls, value: Dict[str, Union[LLMEngineBlueprint, str]]) -> Dict[str, LLMEngineBlueprint]:
+ the_dict: Dict[str, LLMEngineBlueprint] = {}
+ for llm_handle, llm_engine_spec in value.items():
+ if isinstance(llm_engine_spec, str):
+ the_dict[llm_handle] = LLMEngineBlueprint(llm_name=llm_engine_spec)
+ elif isinstance(llm_engine_spec, dict):
+ the_dict[llm_handle] = LLMEngineBlueprint.model_validate(llm_engine_spec)
+ else:
+ raise ConfigValidationError(f"Invalid LLM engine blueprint for '{llm_handle}' is a {type(llm_engine_spec)}: {llm_engine_spec}")
+ return the_dict
+
+ @field_validator("llm_choice_defaults", mode="after")
+ @classmethod
+ def validate_llm_choice_defaults(cls, llm_choice_defaults: LLMSettingChoices) -> LLMSettingChoices:
+ if llm_choice_defaults.for_text is None:
+ raise ConfigValidationError("llm_choice_defaults.for_text cannot be None")
+ if llm_choice_defaults.for_object is None:
+ raise ConfigValidationError("llm_choice_defaults.for_object cannot be None")
+ if llm_choice_defaults.for_object_direct is None:
+ raise ConfigValidationError("llm_choice_defaults.for_object_direct cannot be None")
+ if llm_choice_defaults.for_object_list is None:
+ raise ConfigValidationError("llm_choice_defaults.for_object_list cannot be None")
+ if llm_choice_defaults.for_object_list_direct is None:
+ raise ConfigValidationError("llm_choice_defaults.for_object_list_direct cannot be None")
+ return llm_choice_defaults
+
+ @field_validator("llm_choice_overrides", mode="after")
+ @classmethod
+ def validate_llm_choice_overrides(cls, value: LLMSettingChoices) -> LLMSettingChoices:
+ if value.for_text == LLM_PRESET_DISABLED:
+ value.for_text = None
+ if value.for_object == LLM_PRESET_DISABLED:
+ value.for_object = None
+ if value.for_object_direct == LLM_PRESET_DISABLED:
+ value.for_object_direct = None
+ if value.for_object_list == LLM_PRESET_DISABLED:
+ value.for_object_list = None
+ if value.for_object_list_direct == LLM_PRESET_DISABLED:
+ value.for_object_list_direct = None
+ return value
+
+ def add_llm_handle_to_llm_engine_blueprint(self, llm_handle: str, llm_engine_default: str):
+ if llm_handle in self.llm_handles:
+ raise ConfigValidationError(f"LLM engine blueprint for '{llm_handle}' is already defined in llm_handle_to_llm_engine_blueprint")
+ # TODO: sort the defaults by llm family
+ self.llm_handles[llm_handle] = LLMEngineBlueprint(llm_name=llm_engine_default)
+
+ def validate_llm_presets(self) -> Self:
+ for llm_preset_id, llm_setting in self.llm_presets.items():
+ if llm_setting.llm_handle not in self.llm_handles:
+ raise LLMHandleNotFoundError(f"llm_handle '{llm_setting.llm_handle}' for llm_preset '{llm_preset_id}' not found in deck")
+ return self
+
+ @model_validator(mode="after")
+ def validate_llm_default_choices(self) -> Self:
+ self._validate_llm_choices(llm_choices=self.llm_choice_defaults)
+ return self
+
+ @model_validator(mode="after")
+ def validate_llm_setting_overrides(self) -> Self:
+ self._validate_llm_choices(llm_choices=self.llm_choice_overrides)
+ return self
+
+ def _validate_llm_choices(self, llm_choices: LLMSettingChoices):
+ for llm_setting in llm_choices.list_used_presets():
+ self.check_llm_setting(llm_setting_or_preset_id=llm_setting)
+ return
diff --git a/pipelex/cogt/llm/llm_models/llm_deck_abstract.py b/pipelex/cogt/llm/llm_models/llm_deck_abstract.py
new file mode 100644
index 000000000..fef6a418e
--- /dev/null
+++ b/pipelex/cogt/llm/llm_models/llm_deck_abstract.py
@@ -0,0 +1,62 @@
+from abc import ABC, abstractmethod
+from typing import Dict, Optional, Self
+
+from pydantic import Field
+
+from pipelex.cogt.llm.llm_models.llm_engine_blueprint import LLMEngineBlueprint
+from pipelex.cogt.llm.llm_models.llm_model import LLMModel
+from pipelex.cogt.llm.llm_models.llm_setting import LLMSetting, LLMSettingChoices, LLMSettingOrPresetId
+
+
+class LLMDeckAbstract(ABC):
+ llm_handles: Dict[str, LLMEngineBlueprint] = Field(default_factory=dict)
+ llm_presets: Dict[str, LLMSetting] = Field(default_factory=dict)
+ llm_choice_defaults: LLMSettingChoices
+ llm_choice_overrides: LLMSettingChoices = LLMSettingChoices(
+ for_text=None,
+ for_object=None,
+ for_object_direct=None,
+ for_object_list=None,
+ for_object_list_direct=None,
+ )
+
+ @abstractmethod
+ def check_llm_setting(self, llm_setting_or_preset_id: LLMSettingOrPresetId, is_disabled_allowed: bool = False):
+ pass
+
+ @abstractmethod
+ def get_llm_engine_blueprint(self, llm_handle: str) -> LLMEngineBlueprint:
+ pass
+
+ @abstractmethod
+ def get_llm_setting(self, llm_setting_or_preset_id: LLMSettingOrPresetId) -> LLMSetting:
+ pass
+
+ @abstractmethod
+ def get_llm_setting_for_text(self, override: Optional[LLMSettingChoices] = None) -> LLMSetting:
+ pass
+
+ @abstractmethod
+ def get_llm_setting_for_object(self, override: Optional[LLMSettingChoices] = None) -> LLMSetting:
+ pass
+
+ @abstractmethod
+ def get_llm_setting_for_object_direct(self, override: Optional[LLMSettingChoices] = None) -> LLMSetting:
+ pass
+
+ @abstractmethod
+ def get_llm_setting_for_object_list(self, override: Optional[LLMSettingChoices] = None) -> LLMSetting:
+ pass
+
+ @abstractmethod
+ def get_llm_setting_for_object_list_direct(self, override: Optional[LLMSettingChoices] = None) -> LLMSetting:
+ pass
+
+ @abstractmethod
+ def find_llm_model(self, llm_handle: str) -> LLMModel:
+ pass
+
+ @classmethod
+ @abstractmethod
+ def final_validate(cls, deck: Self):
+ pass
diff --git a/pipelex/cogt/llm/llm_models/llm_deck_check.py b/pipelex/cogt/llm/llm_models/llm_deck_check.py
new file mode 100644
index 000000000..e8889f06a
--- /dev/null
+++ b/pipelex/cogt/llm/llm_models/llm_deck_check.py
@@ -0,0 +1,12 @@
+from pipelex.cogt.exceptions import LLMPresetNotFoundError
+from pipelex.cogt.llm.llm_models.llm_setting import LLMSetting, LLMSettingOrPresetId
+from pipelex.hub import get_llm_deck
+
+
+def check_llm_setting_with_deck(llm_setting_or_preset_id: LLMSettingOrPresetId, is_disabled_allowed: bool = False):
+ if isinstance(llm_setting_or_preset_id, LLMSetting):
+ return
+ preset_id: str = llm_setting_or_preset_id
+ if preset_id in get_llm_deck().llm_presets:
+ return
+ raise LLMPresetNotFoundError(f"llm preset id '{preset_id}' not found in deck")
diff --git a/pipelex/cogt/llm/llm_models/llm_engine.py b/pipelex/cogt/llm/llm_models/llm_engine.py
new file mode 100644
index 000000000..92be8cf9b
--- /dev/null
+++ b/pipelex/cogt/llm/llm_models/llm_engine.py
@@ -0,0 +1,38 @@
+from pydantic import BaseModel, model_validator
+from typing_extensions import Self
+
+from pipelex.cogt.exceptions import LLMModelPlatformError
+from pipelex.cogt.llm.llm_models.llm_model import LLMModel
+from pipelex.cogt.llm.llm_models.llm_platform import LLMPlatform
+
+
+class LLMEngine(BaseModel):
+ llm_platform: LLMPlatform
+ llm_model: LLMModel
+
+ @model_validator(mode="after")
+ def validate_llm_platform(self) -> Self:
+ if self.llm_platform not in self.llm_model.platform_llm_id:
+ raise LLMModelPlatformError(
+ f"Missing id for {self.llm_model.name_and_version} on platform '{self.llm_platform}', provided ids: {self.llm_model.platform_llm_id}"
+ )
+ return self
+
+ @property
+ def llm_id(self) -> str:
+ return self.llm_model.platform_llm_id[self.llm_platform]
+
+ @property
+ def desc(self) -> str:
+ return f"""llm name: '{self.llm_model.llm_name}':
+version: '{self.llm_model.version}'
+platform: '{self.llm_platform}'
+platform llm id: '{self.llm_id}'"""
+
+ @property
+ def tag(self) -> str:
+ return f"{self.llm_platform} - {self.llm_model.llm_name} - {self.llm_model.version}"
+
+ @property
+ def is_gen_object_supported(self) -> bool:
+ return self.llm_model.is_gen_object_supported and self.llm_platform.is_gen_object_supported
diff --git a/pipelex/cogt/llm/llm_models/llm_engine_blueprint.py b/pipelex/cogt/llm/llm_models/llm_engine_blueprint.py
new file mode 100644
index 000000000..84c747d51
--- /dev/null
+++ b/pipelex/cogt/llm/llm_models/llm_engine_blueprint.py
@@ -0,0 +1,18 @@
+from pydantic import field_validator
+
+from pipelex.cogt.llm.llm_models.llm_model import LATEST_VERSION_NAME
+from pipelex.cogt.llm.llm_models.llm_platform import DEFAULT_PLATFORM_INDICATOR, LLMPlatform, LLMPlatformChoice
+from pipelex.tools.config.models import ConfigModel
+
+
+class LLMEngineBlueprint(ConfigModel):
+ llm_name: str
+ llm_version: str = LATEST_VERSION_NAME
+ llm_platform_choice: LLMPlatformChoice = "default"
+
+ @field_validator("llm_platform_choice", mode="before")
+ def validate_llm_platform_choice(cls, value: str) -> LLMPlatformChoice:
+ if value == DEFAULT_PLATFORM_INDICATOR:
+ # Make it a literal "default"
+ return "default"
+ return LLMPlatform(value)
diff --git a/pipelex/cogt/llm/llm_models/llm_engine_factory.py b/pipelex/cogt/llm/llm_models/llm_engine_factory.py
new file mode 100644
index 000000000..08c12f524
--- /dev/null
+++ b/pipelex/cogt/llm/llm_models/llm_engine_factory.py
@@ -0,0 +1,39 @@
+from pipelex.cogt.llm.llm_models.llm_engine import LLMEngine
+from pipelex.cogt.llm.llm_models.llm_engine_blueprint import LLMEngineBlueprint
+from pipelex.cogt.llm.llm_models.llm_platform import DEFAULT_PLATFORM_INDICATOR, LLMPlatform
+from pipelex.config import get_config
+from pipelex.hub import get_llm_models_provider
+
+
+class LLMEngineFactory:
+ @classmethod
+ def make_llm_engine(
+ cls,
+ llm_engine_blueprint: LLMEngineBlueprint,
+ ) -> LLMEngine:
+ """
+ Create an instance of LLMEngine based on the parameters provided through the LLMEngineCard.
+
+ Args:
+ llm_engine_blueprint: LLMEngineCard
+
+ """
+ llm_platform_choice = llm_engine_blueprint.llm_platform_choice
+ llm_model = get_llm_models_provider().get_llm_model(
+ llm_name=llm_engine_blueprint.llm_name,
+ llm_version=llm_engine_blueprint.llm_version,
+ llm_platform_choice=llm_platform_choice,
+ )
+
+ llm_platform: LLMPlatform
+ if isinstance(llm_platform_choice, LLMPlatform):
+ llm_platform = llm_platform_choice
+ else:
+ assert llm_platform_choice == DEFAULT_PLATFORM_INDICATOR
+ llm_config = get_config().cogt.llm_config
+ llm_platform = llm_config.get_preferred_platform(llm_name=llm_engine_blueprint.llm_name) or llm_model.default_platform
+
+ return LLMEngine(
+ llm_platform=llm_platform,
+ llm_model=llm_model,
+ )
diff --git a/pipelex/cogt/llm/llm_models/llm_family.py b/pipelex/cogt/llm/llm_models/llm_family.py
new file mode 100644
index 000000000..d6a3f0faa
--- /dev/null
+++ b/pipelex/cogt/llm/llm_models/llm_family.py
@@ -0,0 +1,134 @@
+from enum import StrEnum
+
+from pipelex.cogt.llm.llm_models.llm_platform import LLMPlatform
+from pipelex.cogt.llm.llm_models.llm_prompting_target import LLMPromptingTarget
+
+
+class LLMCreator(StrEnum):
+ AMAZON = "Amazon"
+ ANTHROPIC = "Anthropic"
+ DEEPSEEK = "DeepSeek"
+ GOOGLE = "Google"
+ OPENAI = "OpenAI"
+ META = "Meta"
+ MISTRAL = "Mistral"
+ PERPLEXITY = "Perplexity"
+
+ @property
+ def prompting_target(self) -> LLMPromptingTarget:
+ match self:
+ case LLMCreator.OPENAI:
+ return LLMPromptingTarget.OPENAI
+ case LLMCreator.ANTHROPIC:
+ return LLMPromptingTarget.ANTHROPIC
+ case LLMCreator.MISTRAL:
+ return LLMPromptingTarget.MISTRAL
+ case LLMCreator.GOOGLE:
+ return LLMPromptingTarget.GEMINI
+ case LLMCreator.AMAZON | LLMCreator.PERPLEXITY | LLMCreator.META | LLMCreator.DEEPSEEK:
+ return LLMPromptingTarget.OPENAI
+
+ @property
+ def console_color(self) -> str:
+ match self:
+ case LLMCreator.OPENAI:
+ return LLMPlatform.OPENAI.console_color
+ case LLMCreator.ANTHROPIC:
+ return LLMPlatform.ANTHROPIC.console_color
+ case LLMCreator.MISTRAL:
+ return LLMPlatform.MISTRAL.console_color
+ case LLMCreator.META:
+ return "dodger_blue2"
+ case LLMCreator.GOOGLE:
+ return "blue"
+ case LLMCreator.AMAZON:
+ return "orange"
+ case LLMCreator.PERPLEXITY:
+ return "purple"
+ case LLMCreator.DEEPSEEK:
+ return "red"
+
+
+class LLMFamily(StrEnum):
+ GPT_4 = "gpt-4"
+ GPT_3_5 = "gpt-3.5"
+ GPT_3 = "gpt-3"
+ GPT_4_5 = "gpt-4.5"
+ GPT_4_1 = "gpt-4.1"
+ GPT_4O = "gpt-4o"
+ O_SERIES = "o"
+ CLAUDE_3 = "claude-3"
+ CLAUDE_3_5 = "claude-3.5"
+ CLAUDE_3_7 = "claude-3.7"
+ CLAUDE_2 = "claude-2"
+ CLAUDE_INSTANT = "claude-instant"
+ MISTRAL_7B = "mistral-7b"
+ MISTRAL_8X7B = "mistral-8x7b"
+ MISTRAL_LARGE = "mistral-large"
+ MISTRAL_SMALL = "mistral-small"
+ MISTRAL_CODESTRAL = "mistral-codestral"
+ MINISTRAL = "ministral"
+ PIXTRAL = "pixtral"
+ LLAMA_3 = "llama-3"
+ LLAMA_3_1 = "llama-3.1"
+ GEMINI = "gemini"
+ BEDROCK_MISTRAL_LARGE = "bedrock-mistral-large"
+ BEDROCK_ANTHROPIC_CLAUDE = "bedrock-anthropic-claude"
+ BEDROCK_META_LLAMA_3 = "bedrock-meta-llama-3"
+ BEDROCK_AMAZON_NOVA = "bedrock-amazon-nova"
+
+ PERPLEXITY_SEARCH = "perplexity-search"
+ PERPLEXITY_RESEARCH = "perplexity-research"
+ PERPLEXITY_REASONING = "perplexity-reasoning"
+ PERPLEXITY_DEEPSEEK = "perplexity-deepseek"
+
+ CUSTOM_LLAMA_4 = "custom-llama-4"
+ CUSTOM_GEMMA_3 = "custom-gemma-3"
+
+ @property
+ def creator(self) -> LLMCreator:
+ match self:
+ case (
+ LLMFamily.GPT_4
+ | LLMFamily.GPT_3_5
+ | LLMFamily.GPT_3
+ | LLMFamily.O_SERIES
+ | LLMFamily.GPT_4_5
+ | LLMFamily.GPT_4_1
+ | LLMFamily.GPT_4O
+ ):
+ return LLMCreator.OPENAI
+ case LLMFamily.CLAUDE_3 | LLMFamily.CLAUDE_3_5 | LLMFamily.CLAUDE_2 | LLMFamily.CLAUDE_INSTANT | LLMFamily.CLAUDE_3_7:
+ return LLMCreator.ANTHROPIC
+ case LLMFamily.BEDROCK_ANTHROPIC_CLAUDE:
+ return LLMCreator.ANTHROPIC
+ case (
+ LLMFamily.MISTRAL_7B
+ | LLMFamily.MISTRAL_8X7B
+ | LLMFamily.MISTRAL_LARGE
+ | LLMFamily.MISTRAL_SMALL
+ | LLMFamily.MISTRAL_CODESTRAL
+ | LLMFamily.MINISTRAL
+ | LLMFamily.PIXTRAL
+ ):
+ return LLMCreator.MISTRAL
+ case LLMFamily.BEDROCK_MISTRAL_LARGE:
+ return LLMCreator.MISTRAL
+ case LLMFamily.LLAMA_3 | LLMFamily.LLAMA_3_1:
+ return LLMCreator.META
+ case LLMFamily.BEDROCK_META_LLAMA_3:
+ return LLMCreator.META
+ case LLMFamily.GEMINI:
+ return LLMCreator.GOOGLE
+ case LLMFamily.BEDROCK_AMAZON_NOVA:
+ return LLMCreator.AMAZON
+ case LLMFamily.PERPLEXITY_SEARCH | LLMFamily.PERPLEXITY_REASONING | LLMFamily.PERPLEXITY_RESEARCH:
+ return LLMCreator.PERPLEXITY
+ case LLMFamily.PERPLEXITY_DEEPSEEK:
+ return LLMCreator.DEEPSEEK
+ case LLMFamily.CUSTOM_LLAMA_4 | LLMFamily.CUSTOM_GEMMA_3:
+ return LLMCreator.META
+
+ @property
+ def prompting_target(self) -> LLMPromptingTarget:
+ return self.creator.prompting_target
diff --git a/pipelex/cogt/llm/llm_models/llm_model.py b/pipelex/cogt/llm/llm_models/llm_model.py
new file mode 100644
index 000000000..a8f843e29
--- /dev/null
+++ b/pipelex/cogt/llm/llm_models/llm_model.py
@@ -0,0 +1,54 @@
+from typing import Dict, Optional, Set
+
+from pydantic import BaseModel, Field, model_validator
+from typing_extensions import Self
+
+from pipelex.cogt.exceptions import LLMModelDefinitionError
+from pipelex.cogt.llm.llm_models.llm_family import LLMFamily
+from pipelex.cogt.llm.llm_models.llm_platform import LLMPlatform
+from pipelex.cogt.llm.token_category import TokenCostsByCategoryDict
+
+LATEST_VERSION_NAME = "latest"
+DISABLED_PLATFORM_NAME = "disabled"
+
+
+class LLMModel(BaseModel):
+ default_platform: LLMPlatform
+ llm_family: LLMFamily
+ llm_name: str
+ version: str
+ is_gen_object_supported: bool
+ is_vision_supported: bool = False
+ cost_per_million_tokens_usd: Optional[TokenCostsByCategoryDict] = None
+ platform_llm_id: Dict[LLMPlatform, str] = Field(..., min_length=1)
+ max_tokens: Optional[int] = None
+
+ max_prompt_images: Optional[int] = Field(None, ge=0)
+
+ @model_validator(mode="after")
+ def check_vision_and_nb_images(self) -> Self:
+ if self.is_vision_supported and self.max_prompt_images and self.max_prompt_images < 1:
+ raise LLMModelDefinitionError("If vision is True, max_prompt_images must be >= 1 or not set")
+ if not self.is_vision_supported and self.max_prompt_images and self.max_prompt_images > 0:
+ raise LLMModelDefinitionError("If vision is False, max_prompt_images must be 0 or not set")
+ return self
+
+ @property
+ def name_and_version(self) -> str:
+ return f"{self.llm_name}:{self.version}"
+
+ @property
+ def name_and_version_and_platform(self) -> str:
+ return f"{self.llm_name}:{self.version}:{self.default_platform}"
+
+ @property
+ def is_system_prompt_supported(self) -> bool:
+ return self.llm_family != LLMFamily.O_SERIES or self.llm_name == "o1"
+
+ @property
+ def supported_platforms(self) -> Set[LLMPlatform]:
+ return set(self.platform_llm_id.keys())
+
+ @property
+ def enabled_platforms(self) -> Set[LLMPlatform]:
+ return set([key for key, value in self.platform_llm_id.items() if value != DISABLED_PLATFORM_NAME])
diff --git a/pipelex/cogt/llm/llm_models/llm_model_library.py b/pipelex/cogt/llm/llm_models/llm_model_library.py
new file mode 100644
index 000000000..9b77916e1
--- /dev/null
+++ b/pipelex/cogt/llm/llm_models/llm_model_library.py
@@ -0,0 +1,124 @@
+import os
+from typing import Any, Dict, List
+
+from pydantic import Field, RootModel
+from typing_extensions import override
+
+from pipelex import log
+from pipelex.cogt.exceptions import LLMModelPlatformError, LLMModelProviderError
+from pipelex.cogt.llm.llm_models.llm_model import LATEST_VERSION_NAME, LLMModel
+from pipelex.cogt.llm.llm_models.llm_model_provider_abstract import LLMModelProviderAbstract
+from pipelex.cogt.llm.llm_models.llm_platform import DEFAULT_PLATFORM_INDICATOR, LLMPlatform, LLMPlatformChoice
+from pipelex.libraries.library_config import LibraryConfig
+from pipelex.tools.exceptions import ToolException
+from pipelex.tools.misc.toml_utils import load_toml_from_path
+
+# Some types to clarify what dictionaries we're loading from the TOML files
+LLMModelDict = Dict[str, Any]
+LLMModelVersion = str
+LLMModelGroup = Dict[LLMModelVersion, LLMModelDict]
+LLMName = str
+LLMModelFamilyGroups = Dict[LLMName, LLMModelGroup]
+LLMFamilyName = str
+LLMModelLibraryDict = Dict[LLMFamilyName, LLMModelFamilyGroups]
+
+
+class LLMModelLibraryError(ToolException):
+ pass
+
+
+LLMModelLibraryRoot = List[LLMModel]
+
+
+class LLMModelLibrary(LLMModelProviderAbstract, RootModel[LLMModelLibraryRoot]):
+ root: LLMModelLibraryRoot = Field(default_factory=list)
+
+ @override
+ def setup(self):
+ llm_model_library_dict = self.load_llm_model_library_dict()
+ for llm_family, llm_family_groups in llm_model_library_dict.items():
+ for llm_group_name, llm_group in llm_family_groups.items():
+ for version, llm_model_dict in llm_group.items():
+ complete_llm_model_dict = {
+ **llm_model_dict,
+ "llm_family": llm_family,
+ "llm_name": llm_group_name,
+ "version": version,
+ }
+ if "default_platform" not in llm_model_dict:
+ complete_llm_model_dict["default_platform"] = list(llm_model_dict["platform_llm_id"].keys())[0]
+ llm_model = LLMModel.model_validate(complete_llm_model_dict)
+ self.root.append(llm_model)
+
+ log.info(f"Loaded {len(self.root)} llm models")
+
+ @override
+ def teardown(self):
+ self.root = []
+
+ @property
+ @override
+ def desc(self) -> str:
+ return "TOML-based llm model provider with models in memory"
+
+ @classmethod
+ def load_llm_model_library_dict(cls) -> LLMModelLibraryDict:
+ libraries_path = LibraryConfig.exported_llm_integrations_path
+ llm_library: LLMModelLibraryDict = {}
+ for library_file_name in sorted(os.listdir(libraries_path)):
+ library_path = os.path.join(libraries_path, library_file_name)
+ llm_families: LLMModelLibraryDict = load_toml_from_path(library_path)
+ llm_library.update(llm_families)
+ return llm_library
+
+ @override
+ def get_all_llm_models(self) -> List[LLMModel]:
+ return self.root
+
+ @override
+ def get_llm_model(
+ self,
+ llm_name: str,
+ llm_version: str,
+ llm_platform_choice: LLMPlatformChoice,
+ ) -> LLMModel:
+ if llm_version == LATEST_VERSION_NAME:
+ return self._get_llm_model_latest_version(llm_name=llm_name, llm_platform_choice=llm_platform_choice)
+
+ found_llm_models = [llm_model for llm_model in self.root if llm_model.llm_name == llm_name and llm_model.version == llm_version]
+ if not found_llm_models:
+ raise LLMModelProviderError(f"Model '{llm_name}' version '{llm_version}' not found")
+ if len(found_llm_models) > 1:
+ raise LLMModelProviderError(f"Model '{llm_name}' version '{llm_version}' has multiple instances in the library")
+ llm_model = found_llm_models[0]
+
+ if isinstance(llm_platform_choice, LLMPlatform):
+ llm_platform: LLMPlatform = llm_platform_choice
+ if llm_platform not in llm_model.platform_llm_id:
+ raise LLMModelPlatformError(f"Missing llm id for LLM model {llm_model.name_and_version}'s chosen platform='{llm_platform}'")
+ return llm_model
+
+ def _get_llm_model_latest_version(
+ self,
+ llm_name: str,
+ llm_platform_choice: LLMPlatformChoice,
+ ) -> LLMModel:
+ found_llm_models = [llm_model for llm_model in self.root if llm_model.llm_name == llm_name]
+ if not found_llm_models:
+ raise LLMModelProviderError(f"Could not find model named '{llm_name}'")
+ elif len(found_llm_models) == 1:
+ # only one so it is the latest we've got
+ llm_model = found_llm_models[0]
+ elif chosen_model := next((model for model in found_llm_models if model.version == LATEST_VERSION_NAME), None):
+ # we've got a version named 'latest' so we use it
+ llm_model = chosen_model
+ elif isinstance(llm_platform_choice, LLMPlatform):
+ llm_platform: LLMPlatform = llm_platform_choice
+ llm_models_with_platform = [model for model in found_llm_models if llm_platform in model.platform_llm_id]
+ if not llm_models_with_platform:
+ raise LLMModelProviderError(f"Model '{llm_name}' has no version for platform '{llm_platform}'")
+ llm_model = max(llm_models_with_platform, key=lambda m: m.version)
+ else:
+ assert llm_platform_choice == DEFAULT_PLATFORM_INDICATOR
+ llm_model = max(found_llm_models, key=lambda m: m.version)
+ return llm_model
diff --git a/pipelex/cogt/llm/llm_models/llm_model_provider_abstract.py b/pipelex/cogt/llm/llm_models/llm_model_provider_abstract.py
new file mode 100644
index 000000000..33c4d152f
--- /dev/null
+++ b/pipelex/cogt/llm/llm_models/llm_model_provider_abstract.py
@@ -0,0 +1,33 @@
+from abc import ABC, abstractmethod
+from typing import List
+
+from pipelex.cogt.llm.llm_models.llm_model import LLMModel
+from pipelex.cogt.llm.llm_models.llm_platform import LLMPlatformChoice
+
+
+class LLMModelProviderAbstract(ABC):
+ @property
+ @abstractmethod
+ def desc(self) -> str:
+ pass
+
+ @abstractmethod
+ def get_all_llm_models(self) -> List[LLMModel]:
+ pass
+
+ @abstractmethod
+ def get_llm_model(
+ self,
+ llm_name: str,
+ llm_version: str,
+ llm_platform_choice: LLMPlatformChoice,
+ ) -> LLMModel:
+ pass
+
+ @abstractmethod
+ def setup(self):
+ pass
+
+ @abstractmethod
+ def teardown(self):
+ pass
diff --git a/pipelex/cogt/llm/llm_models/llm_platform.py b/pipelex/cogt/llm/llm_models/llm_platform.py
new file mode 100644
index 000000000..2d2b9ffe8
--- /dev/null
+++ b/pipelex/cogt/llm/llm_models/llm_platform.py
@@ -0,0 +1,79 @@
+from enum import StrEnum
+from typing import Literal, Union
+
+DEFAULT_PLATFORM_INDICATOR = "default"
+
+
+class LLMPlatform(StrEnum):
+ # Naming scheme:
+ # single name => it's the name of the platform and we use the standard sdk
+ # double name => <PROVIDER>_<SDK> => we use this sdk with this provider
+ # TODO: make this separation more "automatic"
+ ANTHROPIC = "anthropic"
+ AZURE_OPENAI = "azure_openai"
+ BEDROCK = "bedrock"
+ BEDROCK_ANTHROPIC = "bedrock_anthropic"
+ MISTRAL = "mistral"
+ OPENAI = "openai"
+ PERPLEXITY = "perplexity"
+ VERTEXAI_OPENAI = "vertexai_openai"
+ CUSTOM_OPENAI = "custom_openai"
+
+ @staticmethod
+ def list_openai_related() -> list["LLMPlatform"]:
+ return [
+ LLMPlatform.OPENAI,
+ LLMPlatform.AZURE_OPENAI,
+ LLMPlatform.VERTEXAI_OPENAI,
+ LLMPlatform.PERPLEXITY,
+ ]
+
+ @staticmethod
+ def list_anthropic_related() -> list["LLMPlatform"]:
+ return [LLMPlatform.ANTHROPIC, LLMPlatform.BEDROCK_ANTHROPIC]
+
+ @property
+ def is_openai_related(self) -> bool:
+ return self in LLMPlatform.list_openai_related()
+
+ @property
+ def is_gen_object_supported(self) -> bool:
+ match self:
+ case (
+ LLMPlatform.OPENAI
+ | LLMPlatform.AZURE_OPENAI
+ | LLMPlatform.VERTEXAI_OPENAI
+ | LLMPlatform.PERPLEXITY
+ | LLMPlatform.ANTHROPIC
+ | LLMPlatform.MISTRAL
+ | LLMPlatform.BEDROCK_ANTHROPIC
+ | LLMPlatform.CUSTOM_OPENAI
+ ):
+ return True
+ case LLMPlatform.BEDROCK:
+ return False
+
+ @property
+ def console_color(self) -> str:
+ match self:
+ case LLMPlatform.OPENAI:
+ return "deep_pink1"
+ case LLMPlatform.AZURE_OPENAI:
+ return "turquoise2"
+ case LLMPlatform.ANTHROPIC:
+ return "dark_orange"
+ case LLMPlatform.MISTRAL:
+ return "gold3"
+ case LLMPlatform.BEDROCK:
+ return "medium_purple1"
+ case LLMPlatform.BEDROCK_ANTHROPIC:
+ return "spring_green2"
+ case LLMPlatform.PERPLEXITY:
+ return "gray"
+ case LLMPlatform.VERTEXAI_OPENAI:
+ return "deep_sky_blue"
+ case LLMPlatform.CUSTOM_OPENAI:
+ return "white"
+
+
+LLMPlatformChoice = Union[LLMPlatform, Literal["default"]]
diff --git a/pipelex/cogt/llm/llm_models/llm_prompting_target.py b/pipelex/cogt/llm/llm_models/llm_prompting_target.py
new file mode 100644
index 000000000..7e3b44cea
--- /dev/null
+++ b/pipelex/cogt/llm/llm_models/llm_prompting_target.py
@@ -0,0 +1,8 @@
+from enum import StrEnum
+
+
+class LLMPromptingTarget(StrEnum):
+ OPENAI = "openai"
+ ANTHROPIC = "anthropic"
+ MISTRAL = "mistral"
+ GEMINI = "gemini"
diff --git a/pipelex/cogt/llm/llm_models/llm_setting.py b/pipelex/cogt/llm/llm_models/llm_setting.py
new file mode 100644
index 000000000..fe75b8890
--- /dev/null
+++ b/pipelex/cogt/llm/llm_models/llm_setting.py
@@ -0,0 +1,86 @@
+from typing import Literal, Optional, Self, Set, Union
+
+from pydantic import Field, field_validator, model_validator
+
+from pipelex.cogt.exceptions import LLMSettingsValidationError
+from pipelex.cogt.llm.llm_job_components import LLMJobParams
+from pipelex.cogt.llm.llm_models.llm_prompting_target import LLMPromptingTarget
+from pipelex.tools.config.models import ConfigModel
+from pipelex.tools.exceptions import ConfigValidationError
+
+
+class LLMSetting(ConfigModel):
+ llm_handle: str
+ temperature: float = Field(..., ge=0, le=1)
+ max_tokens: Optional[int] = None
+ prompting_target: Optional[LLMPromptingTarget] = Field(default=None, strict=False)
+
+ @field_validator("max_tokens", mode="before")
+ @classmethod
+ def validate_max_tokens(cls, value: Union[int, Literal["auto"], None]) -> Optional[int]:
+ if value is None:
+ return None
+ elif isinstance(value, str) and value == "auto":
+ return None
+ elif isinstance(value, int): # pyright: ignore[reportUnnecessaryIsInstance]
+ return value
+ else:
+ raise ConfigValidationError(f'Invalid max_tokens shoubd be an int or "auto" but it is a {type(value)}: {value}')
+
+ @model_validator(mode="after")
+ def validate_temperature(self) -> Self:
+ if self.llm_handle.startswith("gemini") and self.temperature > 1:
+ error_msg = f"Gemini LLMs such as '{self.llm_handle}' support temperatures up to 2 but we normalize between 0 and 1, \
+ so you can't set a temperature of {self.temperature}"
+ raise LLMSettingsValidationError(error_msg)
+ return self
+
+ def make_llm_job_params(self) -> LLMJobParams:
+ return LLMJobParams(
+ temperature=self.temperature,
+ max_tokens=self.max_tokens,
+ seed=None,
+ )
+
+
+LLMSettingOrPresetId = Union[LLMSetting, str]
+
+
+class LLMSettingChoices(ConfigModel):
+ for_text: Optional[LLMSettingOrPresetId]
+ for_object: Optional[LLMSettingOrPresetId]
+ for_object_direct: Optional[LLMSettingOrPresetId]
+ for_object_list: Optional[LLMSettingOrPresetId]
+ for_object_list_direct: Optional[LLMSettingOrPresetId]
+
+ def list_used_presets(self) -> Set[str]:
+ return set(
+ [
+ setting
+ for setting in [
+ self.for_text,
+ self.for_object,
+ self.for_object_direct,
+ self.for_object_list,
+ self.for_object_list_direct,
+ ]
+ if isinstance(setting, str)
+ ]
+ )
+
+ @classmethod
+ def make_completed_with_defaults(
+ cls,
+ for_text: Optional[LLMSettingOrPresetId] = None,
+ for_object: Optional[LLMSettingOrPresetId] = None,
+ for_object_direct: Optional[LLMSettingOrPresetId] = None,
+ for_object_list: Optional[LLMSettingOrPresetId] = None,
+ for_object_list_direct: Optional[LLMSettingOrPresetId] = None,
+ ) -> Self:
+ return cls(
+ for_text=for_text,
+ for_object=for_object,
+ for_object_direct=for_object_direct,
+ for_object_list=for_object_list,
+ for_object_list_direct=for_object_list_direct,
+ )
diff --git a/pipelex/cogt/llm/llm_prompt.py b/pipelex/cogt/llm/llm_prompt.py
new file mode 100644
index 000000000..a0c701df3
--- /dev/null
+++ b/pipelex/cogt/llm/llm_prompt.py
@@ -0,0 +1,66 @@
+from typing import List, Optional
+
+from pydantic import BaseModel
+from typing_extensions import override
+
+from pipelex import log
+from pipelex.cogt.exceptions import LLMPromptError
+from pipelex.cogt.image.prompt_image import PromptImage
+from pipelex.tools.misc.string_utils import is_none_or_has_text, is_not_none_and_has_text
+from pipelex.tools.runtime_manager import ProblemReaction, runtime_manager
+
+
+class LLMPrompt(BaseModel):
+ system_text: Optional[str] = None
+ user_text: Optional[str] = None
+ user_images: List[PromptImage] = []
+
+ def validate_before_execution(self):
+ reaction = runtime_manager.problem_reactions.job
+ match reaction:
+ case ProblemReaction.NONE:
+ pass
+ case ProblemReaction.RAISE:
+ if not is_none_or_has_text(text=self.system_text):
+ if self.system_text == "":
+ log.warning(f"system_text should be None or contain text. system_text = '{self.system_text}'")
+ else:
+ raise LLMPromptError("system_text should be None or contain text")
+ if not is_not_none_and_has_text(text=self.user_text):
+ raise LLMPromptError("user_text should contain text")
+ case ProblemReaction.LOG:
+ if not is_none_or_has_text(text=self.system_text):
+ if self.system_text == "":
+ log.warning(f"system_text should be None or contain text. system_text = '{self.system_text}'")
+ else:
+ log.error(f"Prompt template system_text should be None or contain text. system_text = '{self.system_text}'")
+ if not is_not_none_and_has_text(text=self.user_text):
+ log.error("user_text should contain text")
+
+ @override
+ def __str__(self) -> str:
+ # return json_str(self, title="llm_prompt", is_spaced=True)
+ return self.desc
+ # return "test"
+
+ @property
+ def desc(self) -> str:
+ description = "LLM Prompt:"
+ if self.system_text:
+ description += f"""
+system_text:
+{self.system_text}
+"""
+ if self.user_text:
+ description += f"""
+user_text:
+{self.user_text}
+"""
+ if self.user_images:
+ user_images_desc: str = "\n".join([f" {image}" for image in self.user_images])
+
+ description += f"""
+user_images:
+{user_images_desc}
+"""
+ return description
diff --git a/pipelex/cogt/llm/llm_prompt_factory_abstract.py b/pipelex/cogt/llm/llm_prompt_factory_abstract.py
new file mode 100644
index 000000000..1a30544a7
--- /dev/null
+++ b/pipelex/cogt/llm/llm_prompt_factory_abstract.py
@@ -0,0 +1,28 @@
+from abc import ABC, abstractmethod
+from typing import Any
+
+from pydantic import BaseModel
+
+from pipelex.cogt.llm.llm_prompt import LLMPrompt
+
+
+def make_empty_prompt() -> LLMPrompt:
+ return LLMPrompt(
+ system_text=None,
+ user_text=None,
+ user_images=[],
+ )
+
+
+class LLMPromptFactoryAbstract(ABC, BaseModel):
+ @abstractmethod
+ async def make_llm_prompt_from_args(
+ self,
+ **prompt_arguments: Any,
+ ) -> LLMPrompt:
+ pass
+
+ @property
+ @abstractmethod
+ def desc(self) -> str:
+ pass
diff --git a/pipelex/cogt/llm/llm_prompt_template.py b/pipelex/cogt/llm/llm_prompt_template.py
new file mode 100644
index 000000000..6f8bdcd17
--- /dev/null
+++ b/pipelex/cogt/llm/llm_prompt_template.py
@@ -0,0 +1,165 @@
+from typing import Any, List, Optional
+
+from typing_extensions import override
+
+from pipelex import log
+from pipelex.cogt.exceptions import LLMPromptFactoryError, LLMPromptTemplateInputsError
+from pipelex.cogt.image.prompt_image import PromptImage
+from pipelex.cogt.llm.llm_prompt import LLMPrompt
+from pipelex.cogt.llm.llm_prompt_factory_abstract import LLMPromptFactoryAbstract, make_empty_prompt
+from pipelex.cogt.llm.llm_prompt_template_inputs import LLMPromptTemplateInputs
+from pipelex.config import get_config
+from pipelex.hub import get_template
+from pipelex.tools.misc.string_utils import is_none_or_has_text
+from pipelex.tools.templating.template_provider_abstract import TemplateProviderAbstract
+
+
+class LLMPromptTemplate(LLMPromptFactoryAbstract):
+ proto_prompt: LLMPrompt = make_empty_prompt()
+ base_template_inputs: LLMPromptTemplateInputs = LLMPromptTemplateInputs()
+
+ # fields kept for reference and debugging only (they have no effect)
+ source_system_template_name: Optional[str] = None
+ source_user_template_name: Optional[str] = None
+
+ @property
+ @override
+ def desc(self) -> str:
+ return f"{LLMPromptTemplate.__name__} based on proto prompt: {self.proto_prompt} and base inputs: {self.base_template_inputs}"
+
+ @override
+ async def make_llm_prompt_from_args(
+ self,
+ **prompt_arguments: Any,
+ ) -> LLMPrompt:
+ return self.synchro_make_llm_prompt_from_args(**prompt_arguments)
+
+ def synchro_make_llm_prompt_from_args(
+ self,
+ **prompt_arguments: Any,
+ ) -> LLMPrompt:
+ arguments_dict = prompt_arguments.copy()
+
+ # pop the base fields and then use the templating method
+ system_text: Optional[str] = arguments_dict.pop("system_text", None)
+ user_text: Optional[str] = arguments_dict.pop("user_text", None)
+
+ # user_images is Optional here: None means the template is not altering the user_images field
+ user_images: Optional[List[PromptImage]] = None
+ if "user_images" in arguments_dict:
+ user_images = arguments_dict.pop("user_images")
+ elif "user_image" in arguments_dict:
+ user_images = [arguments_dict.pop("user_image")]
+ is_user_images_append: Optional[bool] = arguments_dict.pop("is_user_images_append", None)
+
+ return self.make_llm_prompt(
+ system_text=system_text,
+ user_text=user_text,
+ user_images=user_images,
+ is_user_images_append=is_user_images_append,
+ template_inputs=LLMPromptTemplateInputs(root=arguments_dict),
+ )
+
+ def make_llm_prompt(
+ self,
+ system_text: Optional[str] = None,
+ user_text: Optional[str] = None,
+ user_images: Optional[List[PromptImage]] = None,
+ is_user_images_append: Optional[bool] = None,
+ template_inputs: Optional[LLMPromptTemplateInputs] = None,
+ ) -> LLMPrompt:
+ log.verbose("_make_llm_prompt called for LLMPromptTemplate")
+ if not is_none_or_has_text(system_text):
+ if system_text == "":
+ log.warning(f"Prompt template system_text should be None or contain text. system_text = '{system_text}'")
+ else:
+ raise LLMPromptTemplateInputsError(f"Prompt template system_text should be None or contain text. system_text = '{system_text}'")
+ if not is_none_or_has_text(user_text):
+ raise LLMPromptTemplateInputsError(f"Prompt template user_text should be None or contain text. system_text = '{user_text}'")
+
+ all_template_inputs = self.base_template_inputs.complemented_by(additional_template_inputs=template_inputs)
+
+ # input variables can override prompt texts
+
+ llm_prompt = self.proto_prompt.model_copy()
+ if system_text:
+ llm_prompt.system_text = system_text
+ if user_text:
+ llm_prompt.user_text = user_text
+ if user_images:
+ if is_user_images_append:
+ llm_prompt.user_images.extend(user_images)
+ else:
+ llm_prompt.user_images = user_images
+
+ # input variables can be applied to prompt texts used as templates
+ if llm_prompt.system_text:
+ try:
+ llm_prompt.system_text = llm_prompt.system_text.format(**all_template_inputs.root)
+ except KeyError as exc:
+ error_msg = f"Could not apply inputs to system_text. KeyError = {exc}. system_text = '{llm_prompt.system_text}'"
+ if template_name := self.source_system_template_name:
+ error_msg = f"Error using template named '{template_name}': {error_msg}.\n\n Available inputs: {all_template_inputs.list_keys()}"
+ log.error(error_msg)
+ raise LLMPromptFactoryError(message=error_msg) from exc
+ if llm_prompt.user_text:
+ try:
+ llm_prompt.user_text = llm_prompt.user_text.format(**all_template_inputs.root)
+ except KeyError as exc:
+ error_msg = f"Could not apply inputs to user_text. KeyError = {exc}. user_text = '{llm_prompt.user_text}'"
+ if template_name := self.source_user_template_name:
+ error_msg = f"Error using template named '{template_name}': {error_msg}.\n\n Available inputs: {all_template_inputs.list_keys()}"
+ log.error(error_msg)
+ raise LLMPromptFactoryError(message=error_msg) from exc
+
+ return llm_prompt
+
+ # factories of LLMPromptTemplate (which is a factory of LLMPrompt)
+ @classmethod
+ def from_template_name(
+ cls,
+ template_provider: TemplateProviderAbstract,
+ system_text: Optional[str] = None,
+ user_text: Optional[str] = None,
+ user_images: Optional[List[PromptImage]] = None,
+ system_template_name: Optional[str] = None,
+ user_template_name: Optional[str] = None,
+ ) -> "LLMPromptTemplate":
+ proto_prompt: LLMPrompt = LLMPrompt(
+ system_text=system_text,
+ user_text=user_text,
+ user_images=user_images or [],
+ )
+ if user_template_name:
+ proto_prompt.user_text = template_provider.get_template(user_template_name)
+ if system_template_name:
+ proto_prompt.system_text = template_provider.get_template(system_template_name)
+ return cls(
+ proto_prompt=proto_prompt,
+ source_system_template_name=system_template_name,
+ source_user_template_name=user_template_name,
+ )
+
+ # factories of LLMPromptTemplate (which is a factory of LLMPrompt)
+ @classmethod
+ def from_template_contents(
+ cls,
+ system_text: Optional[str] = None,
+ user_text: Optional[str] = None,
+ user_images: Optional[List[PromptImage]] = None,
+ ) -> "LLMPromptTemplate":
+ proto_prompt = LLMPrompt(
+ user_text=user_text,
+ system_text=system_text,
+ user_images=user_images or [],
+ )
+ return cls(proto_prompt=proto_prompt)
+
+ @classmethod
+ def for_structure_from_preliminary_text(cls) -> "LLMPromptTemplate":
+ generic_template_names = get_config().pipelex.generic_template_names
+ proto_prompt = LLMPrompt(
+ system_text=get_template(generic_template_names.structure_from_preliminary_text_system),
+ user_text=get_template(generic_template_names.structure_from_preliminary_text_user),
+ )
+ return cls(proto_prompt=proto_prompt)
diff --git a/pipelex/cogt/llm/llm_prompt_template_inputs.py b/pipelex/cogt/llm/llm_prompt_template_inputs.py
new file mode 100644
index 000000000..835a1c951
--- /dev/null
+++ b/pipelex/cogt/llm/llm_prompt_template_inputs.py
@@ -0,0 +1,61 @@
+from typing import Any, Dict, ItemsView, List, Optional
+
+from pydantic import ConfigDict, Field, RootModel, model_validator
+from typing_extensions import Self, override
+
+from pipelex import log
+from pipelex.cogt.exceptions import LLMPromptTemplateInputsError
+from pipelex.tools.misc.json_utils import json_str
+from pipelex.tools.misc.string_utils import can_inject_text
+from pipelex.tools.runtime_manager import ProblemReaction, runtime_manager
+
+LLMPromptTemplateInputsDict = Dict[str, Any]
+
+
+class LLMPromptTemplateInputs(RootModel[LLMPromptTemplateInputsDict]):
+ root: LLMPromptTemplateInputsDict = Field(default_factory=dict)
+
+ model_config = ConfigDict(validate_assignment=True)
+
+ @model_validator(mode="after")
+ def validate_template_inputs(self) -> Self:
+ if not self.root:
+ # It's important to exit this func before calling get_config() because empty template inputs
+ # are created during imports (before Pipelex is fully initialized)
+ return self
+ template_inputs_reaction = runtime_manager.problem_reactions.template_inputs
+ if template_inputs_reaction == ProblemReaction.NONE:
+ return self
+ for var_name, value in self.root.items():
+ if not can_inject_text(value):
+ error_msg = f"Template input '{var_name}' cannot inject text"
+ if template_inputs_reaction == ProblemReaction.RAISE:
+ raise LLMPromptTemplateInputsError(message=error_msg)
+ log.error(error_msg)
+ return self
+
+ def items(self) -> ItemsView[str, Any]:
+ return self.root.items()
+
+ def list_keys(self) -> List[str]:
+ return list(self.root.keys())
+
+ def complemented_by(self, additional_template_inputs: Optional["LLMPromptTemplateInputs"]) -> "LLMPromptTemplateInputs":
+ all_template_inputs = self.root.copy()
+ if additional_template_inputs:
+ all_template_inputs.update(additional_template_inputs.root)
+ return LLMPromptTemplateInputs(root=all_template_inputs)
+
+ def complemented_by_dict(self, additional_inputs_dict: Optional[LLMPromptTemplateInputsDict]) -> "LLMPromptTemplateInputs":
+ all_template_inputs = self.root.copy()
+ if additional_inputs_dict:
+ all_template_inputs.update(additional_inputs_dict)
+ return LLMPromptTemplateInputs(root=all_template_inputs)
+
+ @override
+ def __str__(self) -> str:
+ return json_str(self.root, title="llm_prompt_template_inputs", is_spaced=True)
+
+ @staticmethod
+ def from_args(**template_inputs: Any) -> "LLMPromptTemplateInputs":
+ return LLMPromptTemplateInputs(root=template_inputs)
diff --git a/pipelex/cogt/llm/llm_report.py b/pipelex/cogt/llm/llm_report.py
new file mode 100644
index 000000000..d6cccecba
--- /dev/null
+++ b/pipelex/cogt/llm/llm_report.py
@@ -0,0 +1,119 @@
+from enum import StrEnum
+from typing import Any, Dict
+
+from pydantic import BaseModel
+
+from pipelex import log
+from pipelex.cogt.llm.llm_models.llm_engine import LLMEngine
+from pipelex.cogt.llm.llm_models.llm_family import LLMFamily
+from pipelex.cogt.llm.llm_models.llm_platform import LLMPlatform
+from pipelex.cogt.llm.token_category import NbTokensByCategoryDict, TokenCategory, TokenCostsByCategoryDict
+from pipelex.mission.job_metadata import JobMetadata
+
+
+class LLMTokenCostReportField(StrEnum):
+ LLM_NAME = "llm_name"
+ LLM_PLATFORM = "llm_platform"
+ LLM_FAMILY = "llm_family"
+ VERSION = "version"
+ PLATFORM_LLM_ID = "platform_llm_id"
+ NB_TOKENS_INPUT = "nb_tokens_input"
+ NB_TOKENS_INPUT_CACHED = "nb_tokens_input_cached"
+ NB_TOKENS_INPUT_NON_CACHED = "nb_tokens_input_non_cached"
+ NB_TOKENS_INPUT_JOINED = "nb_tokens_input_joined" # joined = cached + non-cached
+ NB_TOKENS_OUTPUT = "nb_tokens_output"
+ COST_INPUT_CACHED = "cost_input_cached"
+ COST_INPUT_NON_CACHED = "cost_input_non_cached"
+ COST_INPUT_JOINED = "cost_input_joined" # joined = cached + non-cached
+ COST_OUTPUT = "cost_output"
+
+ @staticmethod
+ def report_field_for_nb_tokens_by_category(token_category: TokenCategory) -> str:
+ return f"nb_tokens_{token_category}"
+
+ @staticmethod
+ def report_field_for_cost_by_category(token_category: TokenCategory) -> str:
+ return f"cost_{token_category}"
+
+
+class LLMTokenCostReport(BaseModel):
+ job_metadata: JobMetadata
+ llm_name: str
+ llm_platform: LLMPlatform
+ llm_family: LLMFamily
+ version: str
+ platform_llm_id: str
+
+ nb_tokens_by_category: NbTokensByCategoryDict
+ costs_by_token_category: TokenCostsByCategoryDict
+
+ def as_flat_dictionary(self) -> Dict[str, Any]:
+ the_dict: Dict[str, Any] = {}
+ dict_for_job_metadata = self.job_metadata.model_dump(serialize_as_any=True)
+ the_dict.update(dict_for_job_metadata)
+ dict_for_llm: Dict[str, Any] = {
+ LLMTokenCostReportField.LLM_NAME: self.llm_name,
+ LLMTokenCostReportField.LLM_PLATFORM: self.llm_platform,
+ LLMTokenCostReportField.LLM_FAMILY: self.llm_family,
+ LLMTokenCostReportField.VERSION: self.version,
+ LLMTokenCostReportField.PLATFORM_LLM_ID: self.platform_llm_id,
+ }
+ the_dict.update(dict_for_llm)
+ dict_for_nb_tokens = {
+ LLMTokenCostReportField.report_field_for_nb_tokens_by_category(token_category): nb_tokens
+ for token_category, nb_tokens in self.nb_tokens_by_category.items()
+ }
+ the_dict.update(dict_for_nb_tokens)
+ dict_for_costs = {
+ LLMTokenCostReportField.report_field_for_cost_by_category(token_category): cost
+ for token_category, cost in self.costs_by_token_category.items()
+ }
+ the_dict.update(dict_for_costs)
+ return the_dict
+
+
+def model_cost_per_token(llm_engine: LLMEngine, token_type: TokenCategory) -> float:
+ # cost_per_million_tokens_usd should be missing only for models that we run on our own GPUs
+ if not llm_engine.llm_model.cost_per_million_tokens_usd:
+ log.warning(f"cost_per_million_tokens_usd is not set for model {llm_engine.llm_model.name_and_version}")
+ return 0.0
+ # all token types are not used for all models
+ if token_type == TokenCategory.INPUT_CACHED:
+ if cost_per_million_tokens := llm_engine.llm_model.cost_per_million_tokens_usd.get(TokenCategory.INPUT_CACHED):
+ return cost_per_million_tokens / 1000000
+ elif cost_per_million_tokens := llm_engine.llm_model.cost_per_million_tokens_usd.get(TokenCategory.INPUT):
+ # according to openai docs, cached input tokens are discounted 50%
+ return 0.5 * cost_per_million_tokens / 1000000
+ else:
+ model = llm_engine.llm_model.name_and_version
+ log.warning(f"cost is not set for model {model} neither for {TokenCategory.INPUT} nor {TokenCategory.INPUT_CACHED}")
+ return 0.0
+ elif token_type == TokenCategory.INPUT_NON_CACHED:
+ return model_cost_per_token(llm_engine=llm_engine, token_type=TokenCategory.INPUT)
+ elif cost_per_million_tokens := llm_engine.llm_model.cost_per_million_tokens_usd.get(token_type):
+ return cost_per_million_tokens / 1000000
+ else:
+ return 0.0
+
+
+class LLMTokensUsage(BaseModel):
+ job_metadata: JobMetadata
+ llm_engine: LLMEngine
+ nb_tokens_by_category: NbTokensByCategoryDict
+
+ def compute_cost_report(self) -> LLMTokenCostReport:
+ costs_by_token_category: TokenCostsByCategoryDict = {
+ token_type: (model_cost_per_token(llm_engine=self.llm_engine, token_type=token_type) * nb_tokens)
+ for token_type, nb_tokens in self.nb_tokens_by_category.items()
+ }
+ token_cost_report = LLMTokenCostReport(
+ job_metadata=self.job_metadata,
+ llm_name=self.llm_engine.llm_model.llm_name,
+ llm_platform=self.llm_engine.llm_platform,
+ llm_family=self.llm_engine.llm_model.llm_family,
+ version=self.llm_engine.llm_model.version,
+ platform_llm_id=self.llm_engine.llm_id,
+ nb_tokens_by_category=self.nb_tokens_by_category,
+ costs_by_token_category=costs_by_token_category,
+ )
+ return token_cost_report
diff --git a/pipelex/cogt/llm/llm_worker_abstract.py b/pipelex/cogt/llm/llm_worker_abstract.py
new file mode 100644
index 000000000..91fcc1e71
--- /dev/null
+++ b/pipelex/cogt/llm/llm_worker_abstract.py
@@ -0,0 +1,87 @@
+from abc import ABC, abstractmethod
+from enum import StrEnum
+from typing import Optional, Type
+
+from typing_extensions import override
+
+from pipelex.cogt.exceptions import LLMCapabilityError
+from pipelex.cogt.inference.inference_report_delegate import InferenceReportDelegate
+from pipelex.cogt.inference.inference_worker_abstract import InferenceWorkerAbstract
+from pipelex.cogt.llm.llm_job import LLMJob
+from pipelex.cogt.llm.llm_models.llm_engine import LLMEngine
+from pipelex.cogt.llm.structured_output import StructureMethod
+from pipelex.mission.job_metadata import UnitJobId
+from pipelex.tools.typing.pydantic_utils import BaseModelTypeVar
+
+
+class LLMWorkerJobFuncName(StrEnum):
+ GEN_TEXT = "gen_text"
+ GEN_OBJECT = "gen_object"
+
+
+class LLMWorkerAbstract(InferenceWorkerAbstract, ABC):
+ def __init__(
+ self,
+ llm_engine: LLMEngine,
+ structure_method: Optional[StructureMethod],
+ report_delegate: Optional[InferenceReportDelegate] = None,
+ ):
+ """
+ Initialize the LLMWorker.
+
+ Args:
+ llm_engine (LLMEngine): The LLM engine to be used by the worker.
+ structure_method (Optional[StructureMethod]): The structure method to be used by the worker.
+ report_delegate (Optional[InferenceReportDelegate]): An optional report delegate for reporting unit jobs.
+ """
+ InferenceWorkerAbstract.__init__(self, report_delegate=report_delegate)
+ self.llm_engine = llm_engine
+ self.structure_method = structure_method
+
+ #########################################################
+ # Instance methods
+ #########################################################
+
+ @property
+ @override
+ def desc(self) -> str:
+ return f"LLM Worker using:\n{self.llm_engine.desc}"
+
+ def unit_job_id(self, func_name: LLMWorkerJobFuncName) -> UnitJobId:
+ match func_name:
+ case LLMWorkerJobFuncName.GEN_TEXT:
+ return UnitJobId.LLM_GEN_TEXT
+ case LLMWorkerJobFuncName.GEN_OBJECT:
+ return UnitJobId.LLM_GEN_OBJECT
+
+ def check_can_perform_job(self, llm_job: LLMJob, func_name: LLMWorkerJobFuncName):
+ match func_name:
+ case LLMWorkerJobFuncName.GEN_TEXT:
+ pass
+ case LLMWorkerJobFuncName.GEN_OBJECT:
+ if not self.llm_engine.is_gen_object_supported:
+ raise LLMCapabilityError(f"LLM Engine '{self.llm_engine.tag}' does not support object generation.")
+
+ if llm_job.llm_prompt.user_images:
+ if not self.llm_engine.llm_model.is_vision_supported:
+ raise LLMCapabilityError(f"LLM Engine '{self.llm_engine.tag}' does not support vision.")
+
+ nb_images = len(llm_job.llm_prompt.user_images)
+ max_prompt_images = self.llm_engine.llm_model.max_prompt_images or 5000
+ if nb_images > max_prompt_images:
+ raise LLMCapabilityError(f"LLM Engine '{self.llm_engine.tag}' does not accept that many images: {nb_images}.")
+
+ @abstractmethod
+ async def gen_text(
+ self,
+ llm_job: LLMJob,
+ ) -> str:
+ pass
+
+ @abstractmethod
+ async def gen_object(
+ self,
+ llm_job: LLMJob,
+ schema: Type[BaseModelTypeVar],
+ ) -> BaseModelTypeVar:
+ pass
diff --git a/pipelex/cogt/llm/llm_worker_factory.py b/pipelex/cogt/llm/llm_worker_factory.py
new file mode 100644
index 000000000..3b282d792
--- /dev/null
+++ b/pipelex/cogt/llm/llm_worker_factory.py
@@ -0,0 +1,153 @@
+from typing import Optional
+
+from pipelex.cogt.exceptions import MissingDependencyError
+from pipelex.cogt.inference.inference_report_delegate import InferenceReportDelegate
+from pipelex.cogt.llm.llm_models.llm_engine import LLMEngine
+from pipelex.cogt.llm.llm_models.llm_platform import LLMPlatform
+from pipelex.cogt.llm.llm_worker_abstract import LLMWorkerAbstract
+from pipelex.cogt.llm.structured_output import StructureMethod
+from pipelex.cogt.plugin_manager import PluginHandle
+from pipelex.config import get_config
+from pipelex.hub import get_plugin_manager
+
+
+class LLMWorkerFactory:
+ @staticmethod
+ def make_llm_worker(
+ llm_engine: LLMEngine,
+ report_delegate: Optional[InferenceReportDelegate] = None,
+ ) -> LLMWorkerAbstract:
+ llm_sdk_handle = PluginHandle.get_for_llm_platform(llm_platform=llm_engine.llm_platform)
+ plugin_manager = get_plugin_manager()
+ llm_worker: LLMWorkerAbstract
+ match llm_engine.llm_platform:
+ case LLMPlatform.OPENAI | LLMPlatform.AZURE_OPENAI | LLMPlatform.PERPLEXITY:
+ from pipelex.cogt.plugin.openai.openai_factory import OpenAIFactory
+
+ structure_method: Optional[StructureMethod] = None
+ if get_config().cogt.llm_config.instructor_config.is_openai_structured_output_enabled:
+ structure_method = StructureMethod.INSTRUCTOR_OPENAI_STRUCTURED
+
+ from pipelex.cogt.plugin.openai.openai_llm_worker import OpenAILLMWorker
+
+ llm_sdk_instance = plugin_manager.get_llm_sdk_instance(llm_sdk_handle=llm_sdk_handle) or plugin_manager.set_llm_sdk_instance(
+ llm_sdk_handle=llm_sdk_handle,
+ llm_sdk_instance=OpenAIFactory.make_openai_client(llm_platform=llm_engine.llm_platform),
+ )
+
+ llm_worker = OpenAILLMWorker(
+ sdk_instance=llm_sdk_instance,
+ llm_engine=llm_engine,
+ structure_method=structure_method,
+ report_delegate=report_delegate,
+ )
+ case LLMPlatform.VERTEXAI_OPENAI:
+ try:
+ import google.auth # noqa: F401
+ except ImportError as exc:
+ raise MissingDependencyError("google-auth-oauthlib", "google", "This dependency is required to connect to google.") from exc
+
+ from pipelex.cogt.plugin.openai.openai_factory import OpenAIFactory
+ from pipelex.cogt.plugin.openai.openai_llm_worker import OpenAILLMWorker
+
+ llm_sdk_instance = plugin_manager.get_llm_sdk_instance(llm_sdk_handle=llm_sdk_handle) or plugin_manager.set_llm_sdk_instance(
+ llm_sdk_handle=llm_sdk_handle,
+ llm_sdk_instance=OpenAIFactory.make_openai_client(llm_platform=llm_engine.llm_platform),
+ )
+
+ llm_worker = OpenAILLMWorker(
+ sdk_instance=llm_sdk_instance,
+ llm_engine=llm_engine,
+ structure_method=StructureMethod.INSTRUCTOR_VERTEX_JSON,
+ report_delegate=report_delegate,
+ )
+ case LLMPlatform.CUSTOM_OPENAI:
+ from pipelex.cogt.plugin.openai.openai_factory import OpenAIFactory
+ from pipelex.cogt.plugin.openai.openai_llm_worker import OpenAILLMWorker
+
+ llm_sdk_instance = plugin_manager.get_llm_sdk_instance(llm_sdk_handle=llm_sdk_handle) or plugin_manager.set_llm_sdk_instance(
+ llm_sdk_handle=llm_sdk_handle,
+ llm_sdk_instance=OpenAIFactory.make_openai_client(llm_platform=llm_engine.llm_platform),
+ )
+
+ llm_worker = OpenAILLMWorker(
+ sdk_instance=llm_sdk_instance,
+ llm_engine=llm_engine,
+ structure_method=StructureMethod.INSTRUCTOR_OPENAI_STRUCTURED,
+ report_delegate=report_delegate,
+ )
+ case LLMPlatform.ANTHROPIC | LLMPlatform.BEDROCK_ANTHROPIC:
+ try:
+ import anthropic # noqa: F401
+ except ImportError as exc:
+ raise MissingDependencyError(
+ "anthropic",
+ "anthropic",
+ "The anthropic SDK is required to use Anthropic models via the anthropic client. \
+ However, you can use Anthropic models through bedrock directly by using the 'bedrock-anthropic-claude' llm family.\
+ (eg: bedrock-anthropic-claude)",
+ ) from exc
+
+ from pipelex.cogt.plugin.anthropic.anthropic_factory import AnthropicFactory
+ from pipelex.cogt.plugin.anthropic.anthropic_llm_worker import AnthropicLLMWorker
+
+ llm_sdk_instance = plugin_manager.get_llm_sdk_instance(llm_sdk_handle=llm_sdk_handle) or plugin_manager.set_llm_sdk_instance(
+ llm_sdk_handle=llm_sdk_handle,
+ llm_sdk_instance=AnthropicFactory.make_anthropic_client(llm_platform=llm_engine.llm_platform),
+ )
+
+ llm_worker = AnthropicLLMWorker(
+ sdk_instance=llm_sdk_instance,
+ llm_engine=llm_engine,
+ structure_method=StructureMethod.INSTRUCTOR_ANTHROPIC_TOOLS,
+ report_delegate=report_delegate,
+ )
+ case LLMPlatform.MISTRAL:
+ try:
+ import mistralai # noqa: F401
+ except ImportError as exc:
+ raise MissingDependencyError(
+ "mistralai",
+ "mistral",
+ "The mistralai SDK is required to use Mistral models through the mistralai client. \
+ However, you can use Mistral models through bedrock directly by using the 'bedrock-mistral' llm family. \
+ (eg: bedrock-mistral-large)",
+ ) from exc
+
+ from pipelex.cogt.plugin.mistral.mistral_factory import MistralFactory
+ from pipelex.cogt.plugin.mistral.mistral_llm_worker import MistralLLMWorker
+
+ llm_sdk_instance = plugin_manager.get_llm_sdk_instance(llm_sdk_handle=llm_sdk_handle) or plugin_manager.set_llm_sdk_instance(
+ llm_sdk_handle=llm_sdk_handle,
+ llm_sdk_instance=MistralFactory.make_mistral_client(),
+ )
+
+ llm_worker = MistralLLMWorker(
+ sdk_instance=llm_sdk_instance,
+ llm_engine=llm_engine,
+ structure_method=StructureMethod.INSTRUCTOR_MISTRAL_TOOLS,
+ report_delegate=report_delegate,
+ )
+ case LLMPlatform.BEDROCK:
+ try:
+ import aioboto3 # noqa: F401
+ import boto3 # noqa: F401
+ except ImportError as exc:
+ raise MissingDependencyError(
+ "boto3,aioboto3", "bedrock", "The boto3 and aioboto3 SDKs are required to use Bedrock models."
+ ) from exc
+
+ from pipelex.cogt.plugin.bedrock.bedrock_factory import BedrockFactory
+ from pipelex.cogt.plugin.bedrock.bedrock_llm_worker import BedrockLLMWorker
+
+ llm_sdk_instance = plugin_manager.get_llm_sdk_instance(llm_sdk_handle=llm_sdk_handle) or plugin_manager.set_llm_sdk_instance(
+ llm_sdk_handle=llm_sdk_handle,
+ llm_sdk_instance=BedrockFactory.make_bedrock_client(),
+ )
+
+ llm_worker = BedrockLLMWorker(
+ sdk_instance=llm_sdk_instance,
+ llm_engine=llm_engine,
+ report_delegate=report_delegate,
+ )
+ return llm_worker
diff --git a/pipelex/cogt/llm/structured_output.py b/pipelex/cogt/llm/structured_output.py
new file mode 100644
index 000000000..224e069ed
--- /dev/null
+++ b/pipelex/cogt/llm/structured_output.py
@@ -0,0 +1,21 @@
+from enum import StrEnum
+
+from instructor.mode import Mode as InstructorMode
+
+
+class StructureMethod(StrEnum):
+ INSTRUCTOR_OPENAI_STRUCTURED = "openai_structured"
+ INSTRUCTOR_ANTHROPIC_TOOLS = "anthropic_tools"
+ INSTRUCTOR_MISTRAL_TOOLS = "mistral_tools"
+ INSTRUCTOR_VERTEX_JSON = "vertex_json"
+
+ def as_instructor_mode(self) -> InstructorMode:
+ match self:
+ case StructureMethod.INSTRUCTOR_OPENAI_STRUCTURED:
+ return InstructorMode.TOOLS_STRICT
+ case StructureMethod.INSTRUCTOR_ANTHROPIC_TOOLS:
+ return InstructorMode.ANTHROPIC_TOOLS
+ case StructureMethod.INSTRUCTOR_MISTRAL_TOOLS:
+ return InstructorMode.MISTRAL_TOOLS
+ case StructureMethod.INSTRUCTOR_VERTEX_JSON:
+ return InstructorMode.JSON
diff --git a/pipelex/cogt/llm/token_category.py b/pipelex/cogt/llm/token_category.py
new file mode 100644
index 000000000..3fd52f0c2
--- /dev/null
+++ b/pipelex/cogt/llm/token_category.py
@@ -0,0 +1,19 @@
+from enum import StrEnum
+from typing import Dict
+
+
+class TokenCategory(StrEnum):
+ INPUT = "input"
+ INPUT_CACHED = "input_cached"
+ INPUT_NON_CACHED = "input_non_cached"
+ INPUT_JOINED = "input_joined" # joined = cached + non-cached
+ INPUT_AUDIO = "input_audio"
+ OUTPUT = "output"
+ OUTPUT_AUDIO = "output_audio"
+ OUTPUT_REASONING = "output_reasoning"
+ OUTPUT_ACCEPTED_PREDICTION = "output_accepted_prediction"
+ OUTPUT_REJECTED_PREDICTION = "output_rejected_prediction"
+
+
+NbTokensByCategoryDict = Dict[TokenCategory, int]
+TokenCostsByCategoryDict = Dict[TokenCategory, float]
diff --git a/pipelex/cogt/ocr/__init__.py b/pipelex/cogt/ocr/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/pipelex/cogt/ocr/__init__.py
@@ -0,0 +1 @@
+
diff --git a/pipelex/cogt/ocr/ocr_engine.py b/pipelex/cogt/ocr/ocr_engine.py
new file mode 100644
index 000000000..a57b19475
--- /dev/null
+++ b/pipelex/cogt/ocr/ocr_engine.py
@@ -0,0 +1,12 @@
+from pydantic import BaseModel
+
+from pipelex.cogt.ocr.ocr_platform import OcrPlatform
+
+
+class OcrEngine(BaseModel):
+ ocr_platform: OcrPlatform
+ ocr_model_name: str
+
+ @property
+ def desc(self) -> str:
+ return f"Ocr Engine {self.ocr_platform}/{self.ocr_model_name}"
diff --git a/pipelex/cogt/ocr/ocr_engine_factory.py b/pipelex/cogt/ocr/ocr_engine_factory.py
new file mode 100644
index 000000000..ce30a5206
--- /dev/null
+++ b/pipelex/cogt/ocr/ocr_engine_factory.py
@@ -0,0 +1,27 @@
+from pipelex.cogt.exceptions import CogtError
+from pipelex.cogt.ocr.ocr_engine import OcrEngine
+from pipelex.cogt.ocr.ocr_platform import OcrPlatform
+
+
+class OcrEngineFactoryError(CogtError):
+ pass
+
+
+class OcrEngineFactory:
+ @classmethod
+ def make_ocr_engine(
+ cls,
+ ocr_handle: str,
+ ) -> OcrEngine:
+ parts = ocr_handle.split("/")
+ if len(parts) != 2:
+ raise OcrEngineFactoryError(f"Invalid Ocr handle: {ocr_handle}")
+
+ try:
+ ocr_platform = OcrPlatform(parts[0])
+ except ValueError:
+ raise OcrEngineFactoryError(f"Invalid Ocr platform: {parts[0]}")
+
+ ocr_model_name = parts[1]
+
+ return OcrEngine(ocr_platform=ocr_platform, ocr_model_name=ocr_model_name)
diff --git a/pipelex/cogt/ocr/ocr_handle.py b/pipelex/cogt/ocr/ocr_handle.py
new file mode 100644
index 000000000..798650933
--- /dev/null
+++ b/pipelex/cogt/ocr/ocr_handle.py
@@ -0,0 +1,5 @@
+from enum import StrEnum
+
+
+class OcrHandle(StrEnum):
+ MISTRAL_OCR = "mistral/mistral-ocr-latest"
diff --git a/pipelex/cogt/ocr/ocr_input.py b/pipelex/cogt/ocr/ocr_input.py
new file mode 100644
index 000000000..d03e9645f
--- /dev/null
+++ b/pipelex/cogt/ocr/ocr_input.py
@@ -0,0 +1,21 @@
+from typing import Optional, Self
+
+from pydantic import BaseModel, model_validator
+
+from pipelex.cogt.exceptions import CogtError
+from pipelex.tools.typing.validation_utils import has_exactly_one_among_attributes_from_list
+
+
+class OcrInputError(CogtError):
+ pass
+
+
+class OcrInput(BaseModel):
+ image_uri: Optional[str] = None
+ pdf_uri: Optional[str] = None
+
+ @model_validator(mode="after")
+ def validate_at_exactly_one_input(self) -> Self:
+ if not has_exactly_one_among_attributes_from_list(self, attributes_list=["image_uri", "pdf_uri"]):
+ raise OcrInputError("Exactly one of 'image_uri' or 'pdf_uri' must be provided")
+ return self
diff --git a/pipelex/cogt/ocr/ocr_job.py b/pipelex/cogt/ocr/ocr_job.py
new file mode 100644
index 000000000..12f6bdaf9
--- /dev/null
+++ b/pipelex/cogt/ocr/ocr_job.py
@@ -0,0 +1,29 @@
+from datetime import datetime
+
+from typing_extensions import override
+
+from pipelex.cogt.inference.inference_job_abstract import InferenceJobAbstract
+from pipelex.cogt.ocr.ocr_engine import OcrEngine
+from pipelex.cogt.ocr.ocr_input import OcrInput
+from pipelex.cogt.ocr.ocr_job_components import OcrJobConfig, OcrJobParams, OcrJobReport
+
+
+class OcrJob(InferenceJobAbstract):
+ ocr_input: OcrInput
+ job_params: OcrJobParams
+ job_config: OcrJobConfig
+ job_report: OcrJobReport = OcrJobReport()
+
+ @override
+ def validate_before_execution(self):
+ pass
+
+ def ocr_job_before_start(self, ocr_engine: OcrEngine):
+ # Reset metadata
+ self.job_metadata.started_at = datetime.now()
+
+ # Reset outputs
+ self.job_report = OcrJobReport()
+
+ def ocr_job_after_complete(self):
+ self.job_metadata.completed_at = datetime.now()
diff --git a/pipelex/cogt/ocr/ocr_job_components.py b/pipelex/cogt/ocr/ocr_job_components.py
new file mode 100644
index 000000000..7a06cfdd3
--- /dev/null
+++ b/pipelex/cogt/ocr/ocr_job_components.py
@@ -0,0 +1,32 @@
+from pydantic import BaseModel
+
+from pipelex.tools.config.models import ConfigModel
+
+
+class OcrJobParams(BaseModel):
+ should_include_images: bool
+ should_caption_images: bool
+ should_include_page_views: bool
+ page_views_dpi: int
+
+ @classmethod
+ def make_default_ocr_job_params(cls) -> "OcrJobParams":
+ return OcrJobParams(
+ should_caption_images=False,
+ should_include_page_views=False,
+ should_include_images=True,
+ page_views_dpi=300,
+ )
+
+
+class OcrJobConfig(ConfigModel):
+ pass
+
+
+########################################################################
+### Outputs
+########################################################################
+
+
+class OcrJobReport(ConfigModel):
+ pass
diff --git a/pipelex/cogt/ocr/ocr_job_factory.py b/pipelex/cogt/ocr/ocr_job_factory.py
new file mode 100644
index 000000000..b6c2e4ce5
--- /dev/null
+++ b/pipelex/cogt/ocr/ocr_job_factory.py
@@ -0,0 +1,36 @@
+from typing import Optional
+
+from pipelex.cogt.ocr.ocr_input import OcrInput
+from pipelex.cogt.ocr.ocr_job import OcrJob
+from pipelex.cogt.ocr.ocr_job_components import OcrJobConfig, OcrJobParams, OcrJobReport
+from pipelex.config import get_config
+from pipelex.mission.job_metadata import JobCategory, JobMetadata
+
+
+class OcrJobFactory:
+ @classmethod
+ def make_ocr_job(
+ cls,
+ ocr_input: OcrInput,
+ ocr_job_params: Optional[OcrJobParams] = None,
+ ocr_job_config: Optional[OcrJobConfig] = None,
+ job_metadata: Optional[JobMetadata] = None,
+ ) -> OcrJob:
+ config = get_config()
+ # TODO: manahge the param default sthrough the config
+ # ocr_config = get_config().cogt.ocr_config
+ job_metadata = job_metadata or JobMetadata(
+ top_job_id=f"OCRJob for {config.project_name}",
+ job_category=JobCategory.OCR_JOB,
+ )
+ job_params = ocr_job_params or OcrJobParams.make_default_ocr_job_params()
+ job_config = ocr_job_config or OcrJobConfig()
+ job_report = OcrJobReport()
+
+ return OcrJob(
+ job_metadata=job_metadata,
+ ocr_input=ocr_input,
+ job_params=job_params,
+ job_config=job_config,
+ job_report=job_report,
+ )
diff --git a/pipelex/cogt/ocr/ocr_output.py b/pipelex/cogt/ocr/ocr_output.py
new file mode 100644
index 000000000..d3d038551
--- /dev/null
+++ b/pipelex/cogt/ocr/ocr_output.py
@@ -0,0 +1,62 @@
+from typing import Dict, List, Optional
+
+from pydantic import Field
+
+from pipelex import log
+from pipelex.tools.misc.base_64_utils import save_base64_to_binary_file
+from pipelex.tools.misc.file_utils import ensure_directory_exists, save_text_to_path
+from pipelex.tools.typing.pydantic_utils import CustomBaseModel
+
+
+class ExtractedImage(CustomBaseModel):
+ image_id: str
+ base_64: Optional[str] = None
+ caption: Optional[str] = None
+
+ def save_to_directory(self, directory: str):
+ ensure_directory_exists(directory)
+ log.debug(f"Saving image to directory: {directory}")
+ if base_64 := self.base_64:
+ filename = self.image_id
+ file_path = f"{directory}/{filename}"
+ save_base64_to_binary_file(b64=base_64, file_path=file_path)
+
+
+class ExtractedImageFromPage(ExtractedImage):
+ top_left_x: Optional[int] = None
+ top_left_y: Optional[int] = None
+ bottom_right_x: Optional[int] = None
+ bottom_right_y: Optional[int] = None
+
+
+class Page(CustomBaseModel):
+ text: Optional[str] = None
+ extracted_images: List[ExtractedImageFromPage] = Field(default_factory=list)
+ page_view: Optional[ExtractedImageFromPage] = None
+
+ def save_to_directory(self, directory: str, page_text_file_name: str):
+ ensure_directory_exists(directory)
+ log.debug(f"Saving page to directory: {directory}")
+ if text := self.text:
+ filename = page_text_file_name
+ save_text_to_path(text=text, path=f"{directory}/{filename}")
+ for image in self.extracted_images:
+ image.save_to_directory(directory=directory)
+ if page_view := self.page_view:
+ page_view.save_to_directory(directory=directory)
+
+
+class OcrOutput(CustomBaseModel):
+ pages: Dict[int, Page]
+
+ @property
+ def concatenated_text(self) -> str:
+ return "\n".join([page.text for page in self.pages.values() if page.text])
+
+ def save_to_directory(self, directory: str, page_text_file_name: str):
+ ensure_directory_exists(directory)
+ full_text = self.concatenated_text
+ save_text_to_path(text=full_text, path=f"{directory}/full_text.txt")
+ for page_number, page in self.pages.items():
+ directory_for_page = f"{directory}/page_{page_number}"
+ page.save_to_directory(directory=directory_for_page, page_text_file_name=page_text_file_name)
diff --git a/pipelex/cogt/ocr/ocr_platform.py b/pipelex/cogt/ocr/ocr_platform.py
new file mode 100644
index 000000000..983a05c8c
--- /dev/null
+++ b/pipelex/cogt/ocr/ocr_platform.py
@@ -0,0 +1,5 @@
+from enum import StrEnum
+
+
+class OcrPlatform(StrEnum):
+ MISTRAL = "mistral"
diff --git a/pipelex/cogt/ocr/ocr_worker_abstract.py b/pipelex/cogt/ocr/ocr_worker_abstract.py
new file mode 100644
index 000000000..982520cd1
--- /dev/null
+++ b/pipelex/cogt/ocr/ocr_worker_abstract.py
@@ -0,0 +1,80 @@
+from abc import abstractmethod
+from functools import wraps
+from typing import Any, Callable, Optional, TypeVar, cast
+
+from typing_extensions import Awaitable, override
+
+from pipelex import log
+from pipelex.cogt.inference.inference_report_delegate import InferenceReportDelegate
+from pipelex.cogt.inference.inference_worker_abstract import InferenceWorkerAbstract
+from pipelex.cogt.ocr.ocr_engine import OcrEngine
+from pipelex.cogt.ocr.ocr_job import OcrJob
+from pipelex.cogt.ocr.ocr_output import OcrOutput
+from pipelex.mission.job_metadata import UnitJobId
+
+F = TypeVar("F", bound=Callable[..., Awaitable[Any]])
+
+
+def ocr_job_func(func: F) -> F:
+ @wraps(func)
+ async def wrapper(
+ self: Any,
+ ocr_job: OcrJob,
+ *args: Any,
+ **kwargs: Any,
+ ) -> Any:
+ log.debug(f"Working — {func.__name__} using:\n{self.ocr_engine.desc}")
+
+ # Verify that the job is valid
+ ocr_job.validate_before_execution()
+
+ # Verify feasibility
+ self.check_can_perform_job(ocr_job=ocr_job)
+ # TODO: check can generate object (where it will be appropriate)
+
+ # metadata
+ ocr_job.job_metadata.unit_job_id = UnitJobId.OCR_EXTRACT_PAGES
+
+ # Prepare job
+ ocr_job.ocr_job_before_start(ocr_engine=self.ocr_engine)
+
+ # Execute job
+ result = await func(self, ocr_job, *args, **kwargs)
+
+ # Report job
+ ocr_job.ocr_job_after_complete()
+ if self.report_delegate:
+ self.report_delegate.report_inference_job(inference_job=ocr_job)
+
+ return result
+
+ return cast(F, wrapper)
+
+
+class OcrWorkerAbstract(InferenceWorkerAbstract):
+ def __init__(
+ self,
+ ocr_engine: OcrEngine,
+ report_delegate: Optional[InferenceReportDelegate] = None,
+ ):
+ InferenceWorkerAbstract.__init__(self, report_delegate=report_delegate)
+ self.ocr_engine = ocr_engine
+
+ #########################################################
+ # Instance methods
+ #########################################################
+
+ @property
+ @override
+ def desc(self) -> str:
+ return f"Ocr Worker using:\n{self.ocr_engine.desc}"
+
+ def check_can_perform_job(self, ocr_job: OcrJob):
+ pass
+
+ @abstractmethod
+ async def ocr_extract_pages(
+ self,
+ ocr_job: OcrJob,
+ ) -> OcrOutput:
+ pass
diff --git a/pipelex/cogt/ocr/ocr_worker_factory.py b/pipelex/cogt/ocr/ocr_worker_factory.py
new file mode 100644
index 000000000..42ffa78c7
--- /dev/null
+++ b/pipelex/cogt/ocr/ocr_worker_factory.py
@@ -0,0 +1,46 @@
+from typing import Optional
+
+from pipelex.cogt.exceptions import MissingDependencyError
+from pipelex.cogt.inference.inference_report_delegate import InferenceReportDelegate
+from pipelex.cogt.ocr.ocr_engine import OcrEngine
+from pipelex.cogt.ocr.ocr_platform import OcrPlatform
+from pipelex.cogt.ocr.ocr_worker_abstract import OcrWorkerAbstract
+from pipelex.cogt.plugin_manager import PluginHandle
+from pipelex.hub import get_plugin_manager
+
+
+class OcrWorkerFactory:
+ def make_ocr_worker(
+ self,
+ ocr_engine: OcrEngine,
+ report_delegate: Optional[InferenceReportDelegate] = None,
+ ) -> OcrWorkerAbstract:
+ ocr_sdk_handle = PluginHandle.get_for_ocr_engine(ocr_platform=ocr_engine.ocr_platform)
+ plugin_manager = get_plugin_manager()
+ ocr_worker: OcrWorkerAbstract
+ match ocr_engine.ocr_platform:
+ case OcrPlatform.MISTRAL:
+ try:
+ import mistralai # noqa: F401
+ except ImportError as exc:
+ raise MissingDependencyError(
+ "mistralai",
+ "mistral",
+ "The mistralai SDK is required to use Mistral OCR models through the mistralai client.",
+ ) from exc
+
+ from pipelex.cogt.plugin.mistral.mistral_factory import MistralFactory
+ from pipelex.cogt.plugin.mistral.mistral_ocr_worker import MistralOcrWorker
+
+ ocr_sdk_instance = plugin_manager.get_ocr_sdk_instance(ocr_sdk_handle=ocr_sdk_handle) or plugin_manager.set_ocr_sdk_instance(
+ ocr_sdk_handle=ocr_sdk_handle,
+ ocr_sdk_instance=MistralFactory.make_mistral_client(),
+ )
+
+ ocr_worker = MistralOcrWorker(
+ sdk_instance=ocr_sdk_instance,
+ ocr_engine=ocr_engine,
+ report_delegate=report_delegate,
+ )
+
+ return ocr_worker
diff --git a/pipelex/cogt/plugin/__init__.py b/pipelex/cogt/plugin/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/pipelex/cogt/plugin/__init__.py
@@ -0,0 +1 @@
+
diff --git a/pipelex/cogt/plugin/anthropic/__init__.py b/pipelex/cogt/plugin/anthropic/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/pipelex/cogt/plugin/anthropic/__init__.py
@@ -0,0 +1 @@
+
diff --git a/pipelex/cogt/plugin/anthropic/anthropic_config.py b/pipelex/cogt/plugin/anthropic/anthropic_config.py
new file mode 100644
index 000000000..e9882b81c
--- /dev/null
+++ b/pipelex/cogt/plugin/anthropic/anthropic_config.py
@@ -0,0 +1,42 @@
+from enum import StrEnum
+
+from pydantic import Field
+
+from pipelex import log
+from pipelex.cogt.exceptions import CogtError
+from pipelex.tools.config.models import ConfigModel
+from pipelex.tools.environment import EnvVarNotFoundError, get_required_env
+from pipelex.tools.secrets.secrets_errors import SecretNotFoundError
+from pipelex.tools.secrets.secrets_provider_abstract import SecretsProviderAbstract
+
+
+class AnthropicCredentialsError(CogtError):
+ pass
+
+
+class AnthropicKeyMethod(StrEnum):
+ SECRET_PROVIDER = "secret_provider"
+ ENV = "env"
+
+
+class AnthropicConfig(ConfigModel):
+ api_key_method: AnthropicKeyMethod = Field(strict=False)
+ api_key_secret_name: str
+ api_key_env_var_name: str
+
+ def get_api_key(self, secrets_provider: SecretsProviderAbstract) -> str:
+ match self.api_key_method:
+ case AnthropicKeyMethod.ENV:
+ log.verbose("Getting Anthropic API key from environment.")
+ try:
+ key_from_env = get_required_env(self.api_key_env_var_name)
+ return key_from_env
+ except EnvVarNotFoundError as exc:
+ raise AnthropicCredentialsError(f"Error getting Anthropic API key from environment: {exc}") from exc
+ case AnthropicKeyMethod.SECRET_PROVIDER:
+ log.verbose("Getting Anthropic API key from secrets provider.")
+ try:
+ key_from_service_provider = secrets_provider.get_secret(secret_id=self.api_key_secret_name)
+ except SecretNotFoundError as exc:
+ raise AnthropicCredentialsError("Error getting Anthropic API key from secrets provider.") from exc
+ return key_from_service_provider
diff --git a/pipelex/cogt/plugin/anthropic/anthropic_factory.py b/pipelex/cogt/plugin/anthropic/anthropic_factory.py
new file mode 100644
index 000000000..968744c03
--- /dev/null
+++ b/pipelex/cogt/plugin/anthropic/anthropic_factory.py
@@ -0,0 +1,222 @@
+import asyncio
+from typing import List, Optional, Union
+
+from anthropic import AsyncAnthropic, AsyncAnthropicBedrock
+from anthropic.types import Usage
+from anthropic.types.image_block_param import ImageBlockParam
+from anthropic.types.message_param import MessageParam
+from anthropic.types.text_block_param import TextBlockParam
+from openai.types.chat import (
+ ChatCompletionMessageParam,
+ ChatCompletionSystemMessageParam,
+)
+
+from pipelex import log
+from pipelex.cogt.exceptions import CogtError
+from pipelex.cogt.image.prompt_image import (
+ PromptImage,
+ PromptImageBytes,
+ PromptImagePath,
+ PromptImageTypedBytes,
+ PromptImageTypedBytesOrUrl,
+ PromptImageUrl,
+)
+from pipelex.cogt.llm.llm_job import LLMJob
+from pipelex.cogt.llm.llm_models.llm_platform import LLMPlatform
+from pipelex.cogt.llm.token_category import NbTokensByCategoryDict, TokenCategory
+from pipelex.config import get_config
+from pipelex.hub import get_secrets_provider
+from pipelex.tools.misc.base_64_utils import (
+ load_binary_as_base64_async,
+)
+
+
+class AnthropicFactoryError(CogtError):
+ pass
+
+
+class AnthropicFactory:
+ @staticmethod
+ def make_anthropic_client(
+ llm_platform: LLMPlatform,
+ ) -> Union[AsyncAnthropic, AsyncAnthropicBedrock]:
+ # TODO: also support Anthropic with VertexAI
+ match llm_platform:
+ case LLMPlatform.ANTHROPIC:
+ anthropic_config = get_config().cogt.llm_config.anthropic_config
+ api_key = anthropic_config.get_api_key(secrets_provider=get_secrets_provider())
+ return AsyncAnthropic(api_key=api_key)
+ case LLMPlatform.BEDROCK_ANTHROPIC:
+ aws_config = get_config().pipelex.aws_config
+ aws_access_key_id, aws_secret_access_key, aws_region = aws_config.get_aws_access_keys()
+ return AsyncAnthropicBedrock(
+ aws_secret_key=aws_secret_access_key,
+ aws_access_key=aws_access_key_id,
+ aws_region=aws_region,
+ )
+ case _:
+ raise AnthropicFactoryError(f"Unsupported LLM platform for Anthropic sdk: '{llm_platform}'")
+
+ @classmethod
+ async def make_user_message(
+ cls,
+ llm_job: LLMJob,
+ ) -> MessageParam:
+ message: MessageParam
+ content: List[Union[TextBlockParam, ImageBlockParam]] = []
+
+ if llm_job.llm_prompt.user_text:
+ text_block_param: TextBlockParam = {
+ "type": "text",
+ "text": llm_job.llm_prompt.user_text,
+ }
+ content.append(text_block_param)
+ if llm_job.llm_prompt.user_images:
+ tasks_to_prep_images = [cls._prep_image_for_anthropic(prompt_image) for prompt_image in llm_job.llm_prompt.user_images]
+ prepped_user_images = await asyncio.gather(*tasks_to_prep_images)
+ # images_block_params: List[ImageBlockParam] = []
+ for prepped_image in prepped_user_images:
+ image_block_param: ImageBlockParam
+ if isinstance(prepped_image, PromptImageTypedBytes):
+ mime = prepped_image.file_type.mime
+ image_block_param = {
+ "type": "image",
+ "source": {
+ "type": "base64",
+ "media_type": mime, # type: ignore
+ "data": prepped_image.image_bytes.decode("utf-8"),
+ }, # type: ignore
+ }
+ elif isinstance(prepped_image, str): # pyright: ignore[reportUnnecessaryIsInstance]
+ url = prepped_image
+ image_block_param = {
+ "type": "image",
+ "source": {
+ "type": "url",
+ "url": url,
+ },
+ }
+ else:
+ raise AnthropicFactoryError(f"Unsupported PromptImageTypedBytesOrUrl type: '{type(prepped_image).__name__}'")
+ content.append(image_block_param)
+
+ message = {
+ "role": "user",
+ "content": content,
+ }
+
+ return message
+
+ # This creates a MessageParam disguised as a ChatCompletionMessageParam to please instructor type checking
+ @staticmethod
+ def openai_typed_user_message(
+ user_content_txt: str,
+ prepped_user_images: Optional[List[PromptImageTypedBytesOrUrl]] = None,
+ ) -> ChatCompletionMessageParam:
+ text_block_param: TextBlockParam = {"type": "text", "text": user_content_txt}
+ message: MessageParam
+ if prepped_user_images is not None:
+ log.debug(prepped_user_images)
+ images_block_params: List[ImageBlockParam] = []
+ for prepped_image in prepped_user_images:
+ image_block_param_in_loop: ImageBlockParam
+ if isinstance(prepped_image, PromptImageTypedBytes):
+ mime = prepped_image.file_type.mime
+ image_block_param_in_loop = {
+ "type": "image",
+ "source": {
+ "type": "base64",
+ "media_type": mime, # type: ignore
+ "data": prepped_image.image_bytes.decode("utf-8"),
+ }, # type: ignore
+ }
+ elif isinstance(prepped_image, str): # pyright: ignore[reportUnnecessaryIsInstance]
+ url = prepped_image
+ image_block_param_in_loop = {
+ "type": "image",
+ "source": {
+ "type": "url",
+ "url": url,
+ },
+ }
+ else:
+ raise AnthropicFactoryError(f"Unsupported PromptImageTypedBytesOrUrl type: '{type(prepped_image).__name__}'")
+ log.debug(image_block_param_in_loop)
+ images_block_params.append(image_block_param_in_loop)
+
+ content: List[Union[TextBlockParam, ImageBlockParam]] = images_block_params + [text_block_param]
+ message = {
+ "role": "user",
+ "content": content,
+ }
+
+ else:
+ message = {
+ "role": "user",
+ "content": [text_block_param],
+ }
+
+ return message # type: ignore
+
+ @classmethod
+ async def _prep_image_for_anthropic(
+ cls,
+ prompt_image: PromptImage,
+ ) -> PromptImageTypedBytesOrUrl:
+ typed_bytes_or_url: PromptImageTypedBytesOrUrl
+ if isinstance(prompt_image, PromptImageBytes):
+ typed_bytes_or_url = prompt_image.make_prompt_image_typed_bytes()
+ elif isinstance(prompt_image, PromptImageUrl):
+ typed_bytes_or_url = prompt_image.url
+ elif isinstance(prompt_image, PromptImagePath):
+ b64 = await load_binary_as_base64_async(prompt_image.file_path)
+ typed_bytes_or_url = PromptImageTypedBytes(image_bytes=b64, file_type=prompt_image.get_file_type())
+ else:
+ raise AnthropicFactoryError(f"Unsupported PromptImage type: '{type(prompt_image).__name__}'")
+ return typed_bytes_or_url
+
+ @classmethod
+ async def make_simple_messages(
+ cls,
+ llm_job: LLMJob,
+ ) -> List[ChatCompletionMessageParam]:
+ """
+ Makes a list of messages with a system message (if provided) and followed by a user message.
+ """
+ llm_prompt = llm_job.llm_prompt
+ messages: List[ChatCompletionMessageParam] = []
+ #### System message ####
+ if system_content := llm_prompt.system_text:
+ messages.append(ChatCompletionSystemMessageParam(role="system", content=system_content))
+
+ prepped_user_images: Optional[List[PromptImageTypedBytesOrUrl]]
+ if llm_prompt.user_images:
+ tasks_to_prep_images = [cls._prep_image_for_anthropic(prompt_image) for prompt_image in llm_prompt.user_images]
+ prepped_user_images = await asyncio.gather(*tasks_to_prep_images)
+ else:
+ prepped_user_images = None
+
+ #### Concatenation ####
+ messages.append(
+ AnthropicFactory.openai_typed_user_message(
+ user_content_txt=llm_prompt.user_text if llm_prompt.user_text else "",
+ prepped_user_images=prepped_user_images,
+ )
+ )
+ return messages
+
+ @staticmethod
+ def make_nb_tokens_by_category(usage: Usage) -> NbTokensByCategoryDict:
+ nb_tokens_by_category: NbTokensByCategoryDict = {
+ TokenCategory.INPUT: usage.input_tokens,
+ TokenCategory.OUTPUT: usage.output_tokens,
+ }
+ return nb_tokens_by_category
+
+ @staticmethod
+ def make_nb_tokens_by_category_from_nb(nb_input: int, nb_output: int) -> NbTokensByCategoryDict:
+ nb_tokens_by_category: NbTokensByCategoryDict = {
+ TokenCategory.INPUT: nb_input,
+ TokenCategory.OUTPUT: nb_output,
+ }
+ return nb_tokens_by_category
diff --git a/pipelex/cogt/plugin/anthropic/anthropic_llm_worker.py b/pipelex/cogt/plugin/anthropic/anthropic_llm_worker.py
new file mode 100644
index 000000000..32d0e2621
--- /dev/null
+++ b/pipelex/cogt/plugin/anthropic/anthropic_llm_worker.py
@@ -0,0 +1,108 @@
+from typing import Any, Optional, Type
+
+import instructor
+from anthropic import NOT_GIVEN, AsyncAnthropic, AsyncAnthropicBedrock
+from typing_extensions import override
+
+from pipelex import log
+from pipelex.cogt.inference.inference_report_delegate import InferenceReportDelegate
+from pipelex.cogt.llm.llm_job import LLMJob
+from pipelex.cogt.llm.llm_job_func import llm_job_func
+from pipelex.cogt.llm.llm_models.llm_engine import LLMEngine
+from pipelex.cogt.llm.llm_models.llm_platform import LLMPlatform
+from pipelex.cogt.llm.llm_worker_abstract import LLMWorkerAbstract
+from pipelex.cogt.llm.structured_output import StructureMethod
+from pipelex.cogt.plugin.anthropic.anthropic_factory import AnthropicFactory
+from pipelex.tools.typing.pydantic_utils import BaseModelTypeVar
+
+
+class AnthropicLLMWorker(LLMWorkerAbstract):
+ def __init__(
+ self,
+ sdk_instance: Any,
+ llm_engine: LLMEngine,
+ structure_method: Optional[StructureMethod] = None,
+ report_delegate: Optional[InferenceReportDelegate] = None,
+ ):
+ LLMWorkerAbstract.__init__(
+ self,
+ llm_engine=llm_engine,
+ structure_method=structure_method,
+ report_delegate=report_delegate,
+ )
+ if default_max_tokens := llm_engine.llm_model.max_tokens:
+ self.default_max_tokens = default_max_tokens
+ else:
+ raise ValueError("max_tokens is None, which is required for Anthropic models")
+
+ # Verify if the sdk_instance is compatible with the current LLM platform
+ if isinstance(sdk_instance, (AsyncAnthropic, AsyncAnthropicBedrock)):
+ if llm_engine.llm_platform == LLMPlatform.ANTHROPIC and not (isinstance(sdk_instance, AsyncAnthropic)):
+ raise ValueError(f"Provided sdk_instance does not match LLMEngine platform:{sdk_instance}")
+ elif llm_engine.llm_platform == LLMPlatform.BEDROCK_ANTHROPIC and not (isinstance(sdk_instance, AsyncAnthropicBedrock)):
+ raise ValueError(f"Provided sdk_instance does not match LLMEngine platform:{sdk_instance}")
+ else:
+ raise ValueError(f"Provided sdk_instance does not match LLMEngine platform:{sdk_instance}")
+
+ self.anthropic_async_client = sdk_instance
+ if structure_method:
+ instructor_mode = structure_method.as_instructor_mode()
+ log.debug(f"Anthropic structure mode: {structure_method} --> {instructor_mode}")
+ self.instructor_for_objects = instructor.from_anthropic(client=sdk_instance, mode=instructor_mode)
+ else:
+ self.instructor_for_objects = instructor.from_anthropic(client=sdk_instance)
+
+ #########################################################
+ # Instance methods
+ #########################################################
+
+ @override
+ @llm_job_func
+ async def gen_text(
+ self,
+ llm_job: LLMJob,
+ ) -> str:
+ message = await AnthropicFactory.make_user_message(llm_job=llm_job)
+ response = await self.anthropic_async_client.messages.create(
+ messages=[message],
+ system=llm_job.llm_prompt.system_text or NOT_GIVEN,
+ model=self.llm_engine.llm_id,
+ temperature=llm_job.job_params.temperature,
+ max_tokens=llm_job.job_params.max_tokens or self.default_max_tokens,
+ )
+
+ single_content_block = response.content[0]
+ if single_content_block.type != "text":
+ raise ValueError(f"Unexpected content block type: {single_content_block.type}")
+ full_reply_content = single_content_block.text
+
+ single_content_block = response.content[0]
+ if single_content_block.type != "text":
+ raise ValueError(f"Unexpected content block type: {single_content_block.type}")
+ full_reply_content = single_content_block.text
+
+ if (llm_tokens_usage := llm_job.job_report.llm_tokens_usage) and (usage := response.usage):
+ llm_tokens_usage.nb_tokens_by_category = AnthropicFactory.make_nb_tokens_by_category(usage=usage)
+
+ return full_reply_content
+
+ @override
+ @llm_job_func
+ async def gen_object(
+ self,
+ llm_job: LLMJob,
+ schema: Type[BaseModelTypeVar],
+ ) -> BaseModelTypeVar:
+ messages = await AnthropicFactory.make_simple_messages(llm_job=llm_job)
+ result_object, completion = await self.instructor_for_objects.chat.completions.create_with_completion(
+ messages=messages,
+ response_model=schema,
+ max_retries=llm_job.job_config.max_retries,
+ model=self.llm_engine.llm_id,
+ temperature=llm_job.job_params.temperature,
+ max_tokens=llm_job.job_params.max_tokens or self.default_max_tokens,
+ )
+ if (llm_tokens_usage := llm_job.job_report.llm_tokens_usage) and (usage := completion.usage):
+ llm_tokens_usage.nb_tokens_by_category = AnthropicFactory.make_nb_tokens_by_category(usage=usage)
+
+ return result_object
diff --git a/pipelex/cogt/plugin/anthropic/anthropic_llms.py b/pipelex/cogt/plugin/anthropic/anthropic_llms.py
new file mode 100644
index 000000000..b34883c0b
--- /dev/null
+++ b/pipelex/cogt/plugin/anthropic/anthropic_llms.py
@@ -0,0 +1,29 @@
+from typing import List
+
+from anthropic import AsyncAnthropic
+from anthropic.types import ModelInfo
+
+from pipelex.cogt.exceptions import LLMSDKError
+from pipelex.cogt.llm.llm_models.llm_platform import LLMPlatform
+from pipelex.cogt.plugin.anthropic.anthropic_factory import AnthropicFactory
+
+
+async def anthropic_list_anthropic_models(llm_platform: LLMPlatform) -> List[ModelInfo]:
+ """
+ List available Anthropic models.
+
+ Returns:
+ List[ModelInfo]: A list of Anthropic model information objects
+ """
+ anthropic_client = AnthropicFactory.make_anthropic_client(llm_platform=llm_platform)
+ if not hasattr(anthropic_client, "models"):
+ raise LLMSDKError(f"{type(anthropic_client).__name__} does not support listing models")
+ if not isinstance(anthropic_client, AsyncAnthropic):
+ raise LLMSDKError("We only support the standard Anthropic client for listing models")
+ models_response = await anthropic_client.models.list()
+ if not models_response:
+ raise ValueError("No models found")
+ models_list = models_response.data
+ if not models_list:
+ raise ValueError("No models found")
+ return sorted(models_list, key=lambda model: model.created_at)
diff --git a/pipelex/cogt/plugin/bedrock/__init__.py b/pipelex/cogt/plugin/bedrock/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/pipelex/cogt/plugin/bedrock/__init__.py
@@ -0,0 +1 @@
+
diff --git a/pipelex/cogt/plugin/bedrock/bedrock_client_aioboto3.py b/pipelex/cogt/plugin/bedrock/bedrock_client_aioboto3.py
new file mode 100644
index 000000000..9fe1d4237
--- /dev/null
+++ b/pipelex/cogt/plugin/bedrock/bedrock_client_aioboto3.py
@@ -0,0 +1,48 @@
+from typing import Any, Dict, Optional, Tuple, cast
+
+import aioboto3
+from types_aiobotocore_bedrock_runtime.type_defs import ConverseResponseTypeDef
+from typing_extensions import override
+
+from pipelex import log
+from pipelex.cogt.llm.token_category import NbTokensByCategoryDict, TokenCategory
+from pipelex.cogt.plugin.bedrock.bedrock_client_protocol import BedrockClientProtocol
+from pipelex.cogt.plugin.bedrock.bedrock_message import BedrockMessageDictList
+
+
+class BedrockClientAioboto3(BedrockClientProtocol):
+ def __init__(self, aws_region: str):
+ log.verbose(f"Init BedrockClientAioboto3 with region '{aws_region}'")
+ self.aws_region = aws_region
+ self.session = aioboto3.Session()
+
+ @override
+ async def chat(
+ self,
+ messages: BedrockMessageDictList,
+ system_text: Optional[str],
+ model: str,
+ temperature: float,
+ max_tokens: Optional[int] = None,
+ ) -> Tuple[str, NbTokensByCategoryDict]:
+ params: Dict[str, Any] = {
+ "modelId": model,
+ "messages": messages,
+ "inferenceConfig": {
+ "temperature": temperature,
+ "maxTokens": max_tokens,
+ },
+ }
+ if system_text:
+ params["system"] = [{"text": system_text}]
+
+ async with self.session.client("bedrock-runtime", region_name=self.aws_region) as aioboto3_session: # type: ignore
+ conversation_response: ConverseResponseTypeDef = await aioboto3_session.converse(**params)
+ resp_dict: Dict[str, Any] = cast(Dict[str, Any], conversation_response)
+ usage_dict: Dict[str, Any] = resp_dict["usage"]
+ nb_tokens_by_category: NbTokensByCategoryDict = {
+ TokenCategory.INPUT: usage_dict["inputTokens"],
+ TokenCategory.OUTPUT: usage_dict["outputTokens"],
+ }
+ response_text: str = resp_dict["output"]["message"]["content"][0]["text"]
+ return response_text, nb_tokens_by_category
diff --git a/pipelex/cogt/plugin/bedrock/bedrock_client_boto3.py b/pipelex/cogt/plugin/bedrock/bedrock_client_boto3.py
new file mode 100644
index 000000000..27d818adf
--- /dev/null
+++ b/pipelex/cogt/plugin/bedrock/bedrock_client_boto3.py
@@ -0,0 +1,47 @@
+import asyncio
+from typing import Any, Dict, Optional, Tuple
+
+import boto3
+from typing_extensions import override
+
+from pipelex import log
+from pipelex.cogt.llm.token_category import NbTokensByCategoryDict, TokenCategory
+from pipelex.cogt.plugin.bedrock.bedrock_client_protocol import BedrockClientProtocol
+from pipelex.cogt.plugin.bedrock.bedrock_message import BedrockMessageDictList
+
+
+class BedrockClientBoto3(BedrockClientProtocol):
+ def __init__(self, aws_region: str):
+ log.debug(f"Initializing BedrockClientBoto3 with region '{aws_region}'")
+ self.boto3_client = boto3.client(service_name="bedrock-runtime", region_name=aws_region) # pyright: ignore
+
+ @override
+ async def chat(
+ self,
+ messages: BedrockMessageDictList,
+ system_text: Optional[str],
+ model: str,
+ temperature: float,
+ max_tokens: Optional[int] = None,
+ ) -> Tuple[str, NbTokensByCategoryDict]:
+ params: Dict[str, Any] = {
+ "modelId": model,
+ "messages": messages,
+ "inferenceConfig": {
+ "temperature": temperature,
+ "maxTokens": max_tokens,
+ },
+ }
+ if system_text:
+ params["system"] = [{"text": system_text}]
+
+ loop: asyncio.AbstractEventLoop = asyncio.get_event_loop()
+ resp_dict: Dict[str, Any] = await loop.run_in_executor(None, lambda: self.boto3_client.converse(**params)) # pyright: ignore
+
+ usage_dict: Dict[str, Any] = resp_dict["usage"]
+ nb_tokens_by_category: NbTokensByCategoryDict = {
+ TokenCategory.INPUT: usage_dict["inputTokens"],
+ TokenCategory.OUTPUT: usage_dict["outputTokens"],
+ }
+ response_text: str = resp_dict["output"]["message"]["content"][0]["text"]
+ return response_text, nb_tokens_by_category
diff --git a/pipelex/cogt/plugin/bedrock/bedrock_client_protocol.py b/pipelex/cogt/plugin/bedrock/bedrock_client_protocol.py
new file mode 100644
index 000000000..f1f39c4d7
--- /dev/null
+++ b/pipelex/cogt/plugin/bedrock/bedrock_client_protocol.py
@@ -0,0 +1,16 @@
+from typing import Optional, Protocol, Tuple, runtime_checkable
+
+from pipelex.cogt.llm.token_category import NbTokensByCategoryDict
+from pipelex.cogt.plugin.bedrock.bedrock_message import BedrockMessageDictList
+
+
+@runtime_checkable
+class BedrockClientProtocol(Protocol):
+ async def chat(
+ self,
+ messages: BedrockMessageDictList,
+ system_text: Optional[str],
+ model: str,
+ temperature: float,
+ max_tokens: Optional[int] = None,
+ ) -> Tuple[str, NbTokensByCategoryDict]: ...
diff --git a/pipelex/cogt/plugin/bedrock/bedrock_config.py b/pipelex/cogt/plugin/bedrock/bedrock_config.py
new file mode 100644
index 000000000..3a268d769
--- /dev/null
+++ b/pipelex/cogt/plugin/bedrock/bedrock_config.py
@@ -0,0 +1,15 @@
+from enum import StrEnum
+
+from pydantic import Field
+
+from pipelex.tools.config.models import ConfigModel
+
+
+class BedrockClientMethod(StrEnum):
+ BOTO3 = "boto3"
+ AIBOTO3 = "aioboto3"
+
+
+class BedrockConfig(ConfigModel):
+ aws_region: str
+ client_method: BedrockClientMethod = Field(strict=False)
diff --git a/pipelex/cogt/plugin/bedrock/bedrock_factory.py b/pipelex/cogt/plugin/bedrock/bedrock_factory.py
new file mode 100644
index 000000000..3b9ddef6d
--- /dev/null
+++ b/pipelex/cogt/plugin/bedrock/bedrock_factory.py
@@ -0,0 +1,60 @@
+from pipelex import log
+from pipelex.cogt.exceptions import LLMCapabilityError, PromptImageFormatError
+from pipelex.cogt.image.prompt_image import PromptImageBytes
+from pipelex.cogt.llm.llm_job import LLMJob
+from pipelex.cogt.plugin.bedrock.bedrock_client_protocol import BedrockClientProtocol
+from pipelex.cogt.plugin.bedrock.bedrock_config import BedrockClientMethod
+from pipelex.cogt.plugin.bedrock.bedrock_message import BedrockContentItem, BedrockImage, BedrockMessage, BedrockSource, ImageFormat
+from pipelex.config import get_config
+
+
+class BedrockFactory:
+ #########################################################
+ # Client
+ #########################################################
+
+ @classmethod
+ def make_bedrock_client(cls) -> BedrockClientProtocol:
+ bedrock_config = get_config().cogt.llm_config.bedrock_config
+ aws_region = bedrock_config.aws_region
+ client_method = bedrock_config.client_method
+ bedrock_async_client: BedrockClientProtocol
+ log.verbose(f"Using '{client_method}' for BedrockClient")
+ match client_method:
+ case BedrockClientMethod.AIBOTO3:
+ from pipelex.cogt.plugin.bedrock.bedrock_client_aioboto3 import BedrockClientAioboto3
+
+ bedrock_async_client = BedrockClientAioboto3(aws_region=aws_region)
+ case BedrockClientMethod.BOTO3:
+ from pipelex.cogt.plugin.bedrock.bedrock_client_boto3 import BedrockClientBoto3
+
+ bedrock_async_client = BedrockClientBoto3(aws_region=aws_region)
+
+ return bedrock_async_client
+
+ #########################################################
+ # Message
+ #########################################################
+
+ @classmethod
+ def make_simple_message(cls, llm_job: LLMJob) -> BedrockMessage:
+ """
+ Makes a list of messages with a system message (if provided) and followed by a user message.
+ """
+ message = BedrockMessage(role="user", content=[])
+ if user_text := llm_job.llm_prompt.user_text:
+ message.content.append(BedrockContentItem(text=user_text))
+ if user_images := llm_job.llm_prompt.user_images:
+ raise LLMCapabilityError("BedrockFactory does not support images. Skipping images.")
+ for user_image in user_images:
+ if isinstance(user_image, PromptImageBytes):
+ image_bytes = user_image.image_bytes
+ image = BedrockImage(
+ format=ImageFormat.JPEG,
+ source=BedrockSource(bytes=image_bytes),
+ )
+ message.content.append(BedrockContentItem(image=image))
+ else:
+ raise PromptImageFormatError("Only PromptImageBytes is supported for BedrockFactory.")
+
+ return message
diff --git a/pipelex/cogt/plugin/bedrock/bedrock_llm_worker.py b/pipelex/cogt/plugin/bedrock/bedrock_llm_worker.py
new file mode 100644
index 000000000..3eee4eed8
--- /dev/null
+++ b/pipelex/cogt/plugin/bedrock/bedrock_llm_worker.py
@@ -0,0 +1,74 @@
+from typing import Any, Optional, Type
+
+from typing_extensions import override
+
+from pipelex import log
+from pipelex.cogt.exceptions import LLMCapabilityError, LLMEngineParameterError, SdkTypeError
+from pipelex.cogt.inference.inference_report_delegate import InferenceReportDelegate
+from pipelex.cogt.llm.llm_job import LLMJob
+from pipelex.cogt.llm.llm_job_func import llm_job_func
+from pipelex.cogt.llm.llm_models.llm_engine import LLMEngine
+from pipelex.cogt.llm.llm_worker_abstract import LLMWorkerAbstract
+from pipelex.cogt.llm.structured_output import StructureMethod
+from pipelex.cogt.plugin.bedrock.bedrock_client_protocol import BedrockClientProtocol
+from pipelex.cogt.plugin.bedrock.bedrock_factory import BedrockFactory
+from pipelex.tools.typing.pydantic_utils import BaseModelTypeVar
+
+
+class BedrockLLMWorker(LLMWorkerAbstract):
+ def __init__(
+ self,
+ sdk_instance: Any,
+ llm_engine: LLMEngine,
+ structure_method: Optional[StructureMethod] = None,
+ report_delegate: Optional[InferenceReportDelegate] = None,
+ ):
+ LLMWorkerAbstract.__init__(
+ self,
+ llm_engine=llm_engine,
+ structure_method=structure_method,
+ report_delegate=report_delegate,
+ )
+
+ if not isinstance(sdk_instance, BedrockClientProtocol):
+ raise SdkTypeError(
+ f"Provided sdk_instance for {self.__class__.__name__} is not of type BedrockClientProtocol: it's a '{type(sdk_instance)}'"
+ )
+
+ if default_max_tokens := llm_engine.llm_model.max_tokens:
+ self.default_max_tokens = default_max_tokens
+ else:
+ raise LLMEngineParameterError(
+ f"No max_tokens provided for llm model '{llm_engine.llm_model}', but it must be provided for Bedrock models"
+ )
+ self.bedrock_client_for_text = sdk_instance
+
+ @override
+ @llm_job_func
+ async def gen_text(
+ self,
+ llm_job: LLMJob,
+ ) -> str:
+ message = BedrockFactory.make_simple_message(llm_job=llm_job)
+
+ log.debug(self.llm_engine.llm_id)
+
+ bedrock_response_text, nb_tokens_by_category = await self.bedrock_client_for_text.chat(
+ messages=message.to_dict_list(),
+ system_text=llm_job.llm_prompt.system_text,
+ model=self.llm_engine.llm_id,
+ temperature=llm_job.job_params.temperature,
+ max_tokens=llm_job.job_params.max_tokens or self.default_max_tokens,
+ )
+ if (llm_tokens_usage := llm_job.job_report.llm_tokens_usage) and nb_tokens_by_category:
+ llm_tokens_usage.nb_tokens_by_category = nb_tokens_by_category
+ return bedrock_response_text
+
+ @override
+ @llm_job_func
+ async def gen_object(
+ self,
+ llm_job: LLMJob,
+ schema: Type[BaseModelTypeVar],
+ ) -> BaseModelTypeVar:
+ raise LLMCapabilityError(f"It is not possible to generate objects with a {self.__class__.__name__}.")
diff --git a/pipelex/cogt/plugin/bedrock/bedrock_message.py b/pipelex/cogt/plugin/bedrock/bedrock_message.py
new file mode 100644
index 000000000..e9905e181
--- /dev/null
+++ b/pipelex/cogt/plugin/bedrock/bedrock_message.py
@@ -0,0 +1,121 @@
+from enum import StrEnum
+from typing import Any, Dict, List, Literal, Optional
+
+from pydantic import BaseModel
+
+# Commented stuff below corresponds to untested stuff because Vision models are not available on Bedrock yet
+
+# AWS docs:
+# https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/bedrock-runtime/client/converse.html
+
+
+class ImageFormat(StrEnum):
+ PNG = "png"
+ JPEG = "jpeg"
+ # GIF = "gif"
+ # WEBP = "webp"
+
+
+# class DocumentFormat(str, Enum):
+# PDF = "pdf"
+# CSV = "csv"
+# DOC = "doc"
+# DOCX = "docx"
+# XLS = "xls"
+# XLSX = "xlsx"
+# HTML = "html"
+# TXT = "txt"
+# MD = "md"
+
+
+# class VideoFormat(str, Enum):
+# MKV = "mkv"
+# MOV = "mov"
+# MP4 = "mp4"
+# WEBM = "webm"
+# FLV = "flv"
+# MPEG = "mpeg"
+# MPG = "mpg"
+# WMV = "wmv"
+# THREE_GP = "three_gp"
+
+
+# class BedrockS3Location(BaseModel):
+# uri: str
+# bucketOwner: str
+
+
+class BedrockSource(BaseModel):
+ bytes: bytes
+ # s3Location: Optional[BedrockS3Location] = None
+
+
+class BedrockImage(BaseModel):
+ format: ImageFormat
+ source: BedrockSource
+
+
+# class BedrockDocument(BaseModel):
+# format: DocumentFormat
+# name: str
+# source: BedrockSource
+
+
+# class BedrockVideo(BaseModel):
+# format: VideoFormat
+# source: BedrockSource
+
+
+# class BedrockToolUse(BaseModel):
+# toolUseId: str
+# name: str
+# input: Any
+
+
+# class BedrockToolResultContent(BaseModel):
+# json_content: Optional[Any] = None
+# text: Optional[str] = None
+# image: Optional[BedrockImage] = None
+# document: Optional[BedrockDocument] = None
+# video: Optional[BedrockVideo] = None
+
+
+# class BedrockToolResult(BaseModel):
+# toolUseId: str
+# content: List[BedrockToolResultContent]
+# status: Literal["success", "error"]
+
+
+# class GuardContentText(BaseModel):
+# text: str
+# qualifiers: List[Literal["grounding_source", "query", "guard_content"]]
+
+
+# class GuardContent(BaseModel):
+# text: Optional[GuardContentText] = None
+# image: Optional[BedrockImage] = None
+
+
+class BedrockContentItem(BaseModel):
+ text: Optional[str] = None
+ image: Optional[BedrockImage] = None
+ # document: Optional[BedrockDocument] = None
+ # video: Optional[BedrockVideo] = None
+ # toolUse: Optional[BedrockToolUse] = None
+ # toolResult: Optional[BedrockToolResult] = None
+ # guardContent: Optional[GuardContent] = None
+
+
+BedrockMessageDict = Dict[str, Any]
+BedrockMessageDictList = List[BedrockMessageDict]
+
+
+class BedrockMessage(BaseModel):
+ role: Literal["user", "assistant"]
+ content: List[BedrockContentItem]
+
+ def to_dict(self) -> BedrockMessageDict:
+ return self.model_dump(exclude_none=True)
+
+ def to_dict_list(self) -> BedrockMessageDictList:
+ return [self.to_dict()]
diff --git a/pipelex/cogt/plugin/fal/__init__.py b/pipelex/cogt/plugin/fal/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/pipelex/cogt/plugin/fal/__init__.py
@@ -0,0 +1 @@
+
diff --git a/pipelex/cogt/plugin/fal/fal_factory.py b/pipelex/cogt/plugin/fal/fal_factory.py
new file mode 100644
index 000000000..a89c276be
--- /dev/null
+++ b/pipelex/cogt/plugin/fal/fal_factory.py
@@ -0,0 +1,173 @@
+from typing import Any, Dict, List
+
+from pipelex import log
+from pipelex.cogt.exceptions import CogtError
+from pipelex.cogt.image.generated_image import GeneratedImage
+from pipelex.cogt.imgg.imgg_engine import ImggEngine
+from pipelex.cogt.imgg.imgg_handle import ImggHandle
+from pipelex.cogt.imgg.imgg_job import ImggJob
+from pipelex.cogt.imgg.imgg_job_components import AspectRatio, OutputFormat
+
+
+class FalFactoryTypeError(CogtError):
+ pass
+
+
+class FalParameterError(CogtError):
+ pass
+
+
+class FalFactory:
+ @staticmethod
+ def make_fal_application(imgg_engine: ImggEngine) -> str:
+ return f"{imgg_engine.imgg_platform}/{imgg_engine.imgg_model_name}"
+
+ @classmethod
+ def image_size_for_flux_1(cls, aspect_ratio: AspectRatio) -> str:
+ match aspect_ratio:
+ case AspectRatio.SQUARE:
+ return "square_hd"
+ case AspectRatio.LANDSCAPE_4_3:
+ return "landscape_4_3"
+ case AspectRatio.LANDSCAPE_16_9:
+ return "landscape_16_9"
+ case AspectRatio.LANDSCAPE_21_9:
+ return "landscape_21_9"
+ case AspectRatio.PORTRAIT_3_4:
+ return "portrait_4_3"
+ case AspectRatio.PORTRAIT_9_16:
+ return "portrait_16_9"
+ case AspectRatio.PORTRAIT_9_21:
+ return "portrait_21_9"
+
+ @classmethod
+ def aspect_ratio_for_flux_1_1_ultra(cls, aspect_ratio: AspectRatio) -> str:
+ match aspect_ratio:
+ case AspectRatio.SQUARE:
+ return "1:1"
+ case AspectRatio.LANDSCAPE_4_3:
+ return "4:3"
+ case AspectRatio.LANDSCAPE_16_9:
+ return "16:9"
+ case AspectRatio.LANDSCAPE_21_9:
+ return "21:9"
+ case AspectRatio.PORTRAIT_3_4:
+ return "3:4"
+ case AspectRatio.PORTRAIT_9_16:
+ return "9:16"
+ case AspectRatio.PORTRAIT_9_21:
+ return "9:21"
+
+ @classmethod
+ def output_format_for_flux(cls, output_format: OutputFormat) -> str:
+ match output_format:
+ case OutputFormat.PNG:
+ return "png"
+ case OutputFormat.JPG:
+ return "jpeg"
+ case OutputFormat.WEBP:
+ raise FalParameterError("Output format WebP is not supported for Flux")
+
+ @classmethod
+ def make_fal_arguments(
+ cls,
+ fal_application: str,
+ imgg_job: ImggJob,
+ nb_images: int,
+ ) -> Dict[str, Any]:
+ params = imgg_job.job_params
+ args_dict: Dict[str, Any]
+ match fal_application:
+ case ImggHandle.FLUX_1_PRO_LEGACY | ImggHandle.FLUX_1_1_PRO:
+ args_dict = {
+ "prompt": imgg_job.imgg_prompt.positive_text,
+ "image_size": cls.image_size_for_flux_1(params.aspect_ratio),
+ "num_inference_steps": params.nb_steps,
+ "guidance_scale": params.guidance_scale,
+ "num_images": nb_images,
+ "enable_safety_checker": params.is_safety_checker_enabled,
+ "safety_tolerance": params.safety_tolerance,
+ "seed": params.seed,
+ "output_format": cls.output_format_for_flux(params.output_format),
+ "sync_mode": imgg_job.job_config.is_sync_mode,
+ }
+ case ImggHandle.FLUX_1_1_ULTRA:
+ args_dict = {
+ "prompt": imgg_job.imgg_prompt.positive_text,
+ "aspect_ratio": cls.aspect_ratio_for_flux_1_1_ultra(params.aspect_ratio),
+ "num_images": nb_images,
+ "enable_safety_checker": params.is_safety_checker_enabled,
+ "safety_tolerance": params.safety_tolerance,
+ "raw": params.is_raw,
+ "seed": params.seed,
+ "output_format": cls.output_format_for_flux(params.output_format),
+ "sync_mode": imgg_job.job_config.is_sync_mode,
+ }
+ case ImggHandle.SDXL_LIGHTNING:
+ num_inference_steps = params.nb_steps
+ acceptable_steps = [1, 2, 4, 8]
+ if num_inference_steps not in acceptable_steps:
+ log.warning(f"Number of inference steps {num_inference_steps}' for SDXL Lightning must be one of {acceptable_steps}")
+ num_inference_steps = 8
+ args_dict = {
+ "prompt": imgg_job.imgg_prompt.positive_text,
+ "image_size": cls.image_size_for_flux_1(params.aspect_ratio),
+ "num_inference_steps": num_inference_steps,
+ "num_images": nb_images,
+ "seed": params.seed,
+ "output_format": cls.output_format_for_flux(params.output_format),
+ "sync_mode": imgg_job.job_config.is_sync_mode,
+ }
+ case _:
+ raise FalParameterError(f"Invalid fal application: '{fal_application}'")
+
+ return args_dict
+
+ @staticmethod
+ def make_generated_image(fal_result: Dict[str, Any]) -> GeneratedImage:
+ images = fal_result["images"]
+ fal_image_dict = images[0]
+ image_url = fal_image_dict["url"]
+ if not isinstance(image_url, str):
+ raise FalFactoryTypeError("Image url is not a string")
+ # TODO: if the url is actual image data, send it to cloud storage?
+
+ width = fal_image_dict["width"]
+ if not isinstance(width, int):
+ raise FalFactoryTypeError("Image width is not an integer")
+ height = fal_image_dict["height"]
+ if not isinstance(height, int):
+ raise FalFactoryTypeError("Image height is not an integer")
+
+ generated_image = GeneratedImage(
+ url=image_url,
+ width=width,
+ height=height,
+ )
+ return generated_image
+
+ @staticmethod
+ def make_generated_image_list(fal_result: Dict[str, Any]) -> List[GeneratedImage]:
+ fal_image_dicts = fal_result["images"]
+
+ generated_image_list: List[GeneratedImage] = []
+ for fal_image_dict in fal_image_dicts:
+ image_url = fal_image_dict["url"]
+ if not isinstance(image_url, str):
+ raise FalFactoryTypeError("Image url is not a string")
+
+ width = fal_image_dict["width"]
+ if not isinstance(width, int):
+ raise FalFactoryTypeError("Image width is not an integer")
+ height = fal_image_dict["height"]
+ if not isinstance(height, int):
+ raise FalFactoryTypeError("Image height is not an integer")
+
+ generated_image = GeneratedImage(
+ url=image_url,
+ width=width,
+ height=height,
+ )
+ generated_image_list.append(generated_image)
+
+ return generated_image_list
diff --git a/pipelex/cogt/plugin/fal/fal_imgg_worker.py b/pipelex/cogt/plugin/fal/fal_imgg_worker.py
new file mode 100644
index 000000000..2b863f4d3
--- /dev/null
+++ b/pipelex/cogt/plugin/fal/fal_imgg_worker.py
@@ -0,0 +1,94 @@
+from typing import Any, List, Optional
+
+from fal_client import AsyncClient, InProgress
+from typing_extensions import override
+
+from pipelex import log
+from pipelex.cogt.exceptions import SdkTypeError
+from pipelex.cogt.image.generated_image import GeneratedImage
+from pipelex.cogt.imgg.imgg_engine import ImggEngine
+from pipelex.cogt.imgg.imgg_job import ImggJob
+from pipelex.cogt.imgg.imgg_worker_abstract import ImggWorkerAbstract, imgg_job_func
+from pipelex.cogt.inference.inference_report_delegate import InferenceReportDelegate
+from pipelex.cogt.plugin.fal.fal_factory import FalFactory
+
+
+class FalImggWorker(ImggWorkerAbstract):
+ def __init__(
+ self,
+ sdk_instance: Any,
+ imgg_engine: ImggEngine,
+ report_delegate: Optional[InferenceReportDelegate] = None,
+ ):
+ super().__init__(imgg_engine=imgg_engine, report_delegate=report_delegate)
+
+ if not isinstance(sdk_instance, AsyncClient):
+ raise SdkTypeError(f"Provided Imgg sdk_instance is not of type fal_client.AsyncClient: it's a '{type(sdk_instance)}'")
+
+ self.fal_async_client = sdk_instance
+
+ @override
+ @imgg_job_func
+ async def gen_image(
+ self,
+ imgg_job: ImggJob,
+ ) -> GeneratedImage:
+ application = FalFactory.make_fal_application(imgg_engine=self.imgg_engine)
+ arguments = FalFactory.make_fal_arguments(
+ fal_application=application,
+ imgg_job=imgg_job,
+ nb_images=1,
+ )
+ log.verbose(arguments, title=f"Fal arguments, application={application}")
+ handler = await self.fal_async_client.submit(
+ application=application,
+ arguments=arguments,
+ )
+
+ log_index = 0
+ async for event in handler.iter_events(with_logs=True):
+ if isinstance(event, InProgress):
+ if not event.logs:
+ continue
+ new_logs = event.logs[log_index:]
+ for event_log in new_logs:
+ print(event_log["message"])
+ log_index = len(event.logs)
+
+ fal_result = await handler.get()
+ generated_image = FalFactory.make_generated_image(fal_result=fal_result)
+ log.verbose(generated_image, title="generated_image")
+ return generated_image
+
+ @override
+ @imgg_job_func
+ async def gen_image_list(
+ self,
+ imgg_job: ImggJob,
+ nb_images: int,
+ ) -> List[GeneratedImage]:
+ application = FalFactory.make_fal_application(imgg_engine=self.imgg_engine)
+ arguments = FalFactory.make_fal_arguments(
+ fal_application=application,
+ imgg_job=imgg_job,
+ nb_images=nb_images,
+ )
+ handler = await self.fal_async_client.submit(
+ application=application,
+ arguments=arguments,
+ )
+
+ log_index = 0
+ async for event in handler.iter_events(with_logs=True):
+ if isinstance(event, InProgress):
+ if not event.logs:
+ continue
+ new_fal_logs = event.logs[log_index:]
+ for fal_log in new_fal_logs:
+ log.debug(fal_log["message"], title="FAL Log")
+ log_index = len(event.logs)
+
+ fal_result = await handler.get()
+ generated_image_list = FalFactory.make_generated_image_list(fal_result=fal_result)
+ log.verbose(generated_image_list, title="generated_image_list")
+ return generated_image_list
diff --git a/pipelex/cogt/plugin/mistral/__init__.py b/pipelex/cogt/plugin/mistral/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/pipelex/cogt/plugin/mistral/__init__.py
@@ -0,0 +1 @@
+
diff --git a/pipelex/cogt/plugin/mistral/mistral_config.py b/pipelex/cogt/plugin/mistral/mistral_config.py
new file mode 100644
index 000000000..84df9b29f
--- /dev/null
+++ b/pipelex/cogt/plugin/mistral/mistral_config.py
@@ -0,0 +1,18 @@
+from pipelex.cogt.exceptions import CogtError
+from pipelex.tools.config.models import ConfigModel
+from pipelex.tools.secrets.secrets_errors import SecretNotFoundError
+from pipelex.tools.secrets.secrets_provider_abstract import SecretsProviderAbstract
+
+
+class MistralCredentialsError(CogtError):
+ pass
+
+
+class MistralConfig(ConfigModel):
+ api_key_secret_name: str
+
+ def api_key(self, secrets_provider: SecretsProviderAbstract) -> str:
+ try:
+ return secrets_provider.get_secret(secret_id=self.api_key_secret_name)
+ except SecretNotFoundError as exc:
+ raise MistralCredentialsError("Error getting Mistral API key from secrets provider.") from exc
diff --git a/pipelex/cogt/plugin/mistral/mistral_factory.py b/pipelex/cogt/plugin/mistral/mistral_factory.py
new file mode 100644
index 000000000..8bf0e706a
--- /dev/null
+++ b/pipelex/cogt/plugin/mistral/mistral_factory.py
@@ -0,0 +1,155 @@
+from typing import Dict, List
+
+from mistralai import Mistral, OCRImageObject, OCRResponse
+from mistralai.models import (
+ ContentChunk,
+ ImageURLChunk,
+ Messages,
+ SystemMessage,
+ TextChunk,
+ UsageInfo,
+ UserMessage,
+)
+from openai.types.chat import (
+ ChatCompletionContentPartImageParam,
+ ChatCompletionContentPartParam,
+ ChatCompletionContentPartTextParam,
+ ChatCompletionMessageParam,
+ ChatCompletionSystemMessageParam,
+ ChatCompletionUserMessageParam,
+)
+
+from pipelex.cogt.exceptions import PromptImageFormatError
+from pipelex.cogt.image.prompt_image import PromptImage, PromptImageBytes, PromptImagePath, PromptImageUrl
+from pipelex.cogt.llm.llm_job import LLMJob
+from pipelex.cogt.llm.token_category import NbTokensByCategoryDict, TokenCategory
+from pipelex.cogt.ocr.ocr_output import ExtractedImageFromPage, OcrOutput, Page
+from pipelex.cogt.plugin.openai.openai_factory import OpenAIFactory
+from pipelex.config import get_config
+from pipelex.hub import get_secrets_provider
+from pipelex.tools.misc.base_64_utils import encode_to_base64, load_binary_as_base64
+
+
+class MistralFactory:
+ #########################################################
+ # Client
+ #########################################################
+
+ @classmethod
+ def make_mistral_client(cls) -> Mistral:
+ return Mistral(
+ api_key=get_config().cogt.llm_config.mistral_config.api_key(secrets_provider=get_secrets_provider()),
+ )
+
+ #########################################################
+ # Message
+ #########################################################
+
+ @classmethod
+ def make_simple_messages(cls, llm_job: LLMJob) -> List[Messages]:
+ """
+ Makes a list of messages with a system message (if provided) and followed by a user message.
+ """
+ messages: List[Messages] = []
+ user_content: List[ContentChunk] = []
+ if user_text := llm_job.llm_prompt.user_text:
+ user_content.append(TextChunk(text=user_text))
+ if user_images := llm_job.llm_prompt.user_images:
+ for user_image in user_images:
+ user_content.append(cls.make_mistral_image_url(user_image))
+ if user_content:
+ messages.append(UserMessage(content=user_content))
+
+ if system_text := llm_job.llm_prompt.system_text:
+ messages.append(SystemMessage(content=system_text))
+
+ return messages
+
+ @classmethod
+ def make_mistral_image_url(cls, prompt_image: PromptImage) -> ImageURLChunk:
+ if isinstance(prompt_image, PromptImageUrl):
+ return ImageURLChunk(image_url=prompt_image.url)
+ elif isinstance(prompt_image, PromptImagePath):
+ image_bytes = load_binary_as_base64(prompt_image.file_path).decode("utf-8")
+ # TODO: use actual image type
+ return ImageURLChunk(image_url=f"data:image/png;base64,{image_bytes}")
+ elif isinstance(prompt_image, PromptImageBytes):
+ image_bytes = encode_to_base64(prompt_image.b64_image_bytes).decode("utf-8")
+ # TODO: use actual image type
+ return ImageURLChunk(image_url=f"data:image/png;base64,{image_bytes}")
+ else:
+ raise PromptImageFormatError(f"prompt_image of type {type(prompt_image)} is not supported")
+
+ @classmethod
+ def make_simple_messages_openai_typed(
+ cls,
+ llm_job: LLMJob,
+ ) -> List[ChatCompletionMessageParam]:
+ """
+ Makes a list of messages with a system message (if provided) and followed by a user message.
+ """
+ llm_prompt = llm_job.llm_prompt
+ messages: List[ChatCompletionMessageParam] = []
+ user_contents: List[ChatCompletionContentPartParam] = []
+ if system_content := llm_prompt.system_text:
+ messages.append(ChatCompletionSystemMessageParam(role="system", content=system_content))
+ # TODO: confirm that we can prompt without user_contents, for instance if we have only images,
+ # otherwise consider using a default user_content
+ if user_prompt_text := llm_prompt.user_text:
+ user_part_text = ChatCompletionContentPartTextParam(text=user_prompt_text, type="text")
+ user_contents.append(user_part_text)
+
+ if user_images := llm_prompt.user_images:
+ for prompt_image in user_images:
+ openai_image_url = OpenAIFactory.make_openai_image_url(prompt_image=prompt_image)
+ image_param = ChatCompletionContentPartImageParam(image_url=openai_image_url, type="image_url")
+ user_contents.append(image_param)
+
+ messages.append(ChatCompletionUserMessageParam(role="user", content=user_contents))
+ return messages
+
+ @staticmethod
+ def make_nb_tokens_by_category(usage: UsageInfo) -> NbTokensByCategoryDict:
+ nb_tokens_by_category: NbTokensByCategoryDict = {
+ TokenCategory.INPUT: usage.prompt_tokens,
+ TokenCategory.OUTPUT: usage.completion_tokens,
+ }
+ return nb_tokens_by_category
+
+ @classmethod
+ async def make_ocr_output_from_mistral_response(
+ cls,
+ mistral_ocr_response: OCRResponse,
+ should_include_images: bool = False,
+ # export_dir: Optional[str] = None,
+ ) -> OcrOutput:
+ pages: Dict[int, Page] = {}
+ for ocr_response_page in mistral_ocr_response.pages:
+ page = Page(
+ text=ocr_response_page.markdown,
+ extracted_images=[],
+ )
+ if should_include_images:
+ for mistral_ocr_image_obj in ocr_response_page.images:
+ extracted_image = cls.make_extracted_image_from_page_from_mistral_ocr_image_obj(mistral_ocr_image_obj)
+ page.extracted_images.append(extracted_image)
+ pages[ocr_response_page.index] = page
+
+ return OcrOutput(
+ pages=pages,
+ )
+
+ @classmethod
+ def make_extracted_image_from_page_from_mistral_ocr_image_obj(
+ cls,
+ mistral_ocr_image_obj: OCRImageObject,
+ ) -> ExtractedImageFromPage:
+ extracted_image = ExtractedImageFromPage(
+ image_id=mistral_ocr_image_obj.id,
+ top_left_x=mistral_ocr_image_obj.top_left_x,
+ top_left_y=mistral_ocr_image_obj.top_left_y,
+ bottom_right_x=mistral_ocr_image_obj.bottom_right_x,
+ bottom_right_y=mistral_ocr_image_obj.bottom_right_y,
+ base_64=mistral_ocr_image_obj.image_base64 if mistral_ocr_image_obj.image_base64 else None,
+ )
+ return extracted_image
diff --git a/pipelex/cogt/plugin/mistral/mistral_llm_worker.py b/pipelex/cogt/plugin/mistral/mistral_llm_worker.py
new file mode 100644
index 000000000..b92886c3c
--- /dev/null
+++ b/pipelex/cogt/plugin/mistral/mistral_llm_worker.py
@@ -0,0 +1,91 @@
+from typing import Any, Optional, Type
+
+import instructor
+from mistralai import Mistral
+from mistralai.models import ChatCompletionResponse
+from typing_extensions import override
+
+from pipelex import log
+from pipelex.cogt.exceptions import LLMCompletionError, LLMEngineParameterError, SdkTypeError
+from pipelex.cogt.inference.inference_report_delegate import InferenceReportDelegate
+from pipelex.cogt.llm.llm_job import LLMJob
+from pipelex.cogt.llm.llm_job_func import llm_job_func
+from pipelex.cogt.llm.llm_models.llm_engine import LLMEngine
+from pipelex.cogt.llm.llm_worker_abstract import LLMWorkerAbstract
+from pipelex.cogt.llm.structured_output import StructureMethod
+from pipelex.cogt.plugin.mistral.mistral_factory import MistralFactory
+from pipelex.tools.typing.pydantic_utils import BaseModelTypeVar
+
+
+class MistralLLMWorker(LLMWorkerAbstract):
+ def __init__(
+ self,
+ sdk_instance: Any,
+ llm_engine: LLMEngine,
+ structure_method: Optional[StructureMethod] = None,
+ report_delegate: Optional[InferenceReportDelegate] = None,
+ ):
+ super().__init__(llm_engine=llm_engine, structure_method=structure_method, report_delegate=report_delegate)
+
+ if not isinstance(sdk_instance, Mistral):
+ raise SdkTypeError(f"Provided LLM sdk_instance for {self.__class__.__name__} is not of type Mistral: it's a '{type(sdk_instance)}'")
+
+ if default_max_tokens := llm_engine.llm_model.max_tokens:
+ self.default_max_tokens = default_max_tokens
+ else:
+ raise LLMEngineParameterError(
+ f"No max_tokens provided for llm model '{llm_engine.llm_model}', but it must be provided for Mistral models"
+ )
+ self.mistral_client_for_text: Mistral = sdk_instance
+
+ if structure_method:
+ instructor_mode = structure_method.as_instructor_mode()
+ log.debug(f"Mistral structure mode: {structure_method} --> {instructor_mode}")
+ self.instructor_for_objects = instructor.from_mistral(client=sdk_instance, mode=instructor_mode, use_async=True)
+ else:
+ self.instructor_for_objects = instructor.from_mistral(client=sdk_instance, use_async=True)
+
+ @override
+ @llm_job_func
+ async def gen_text(
+ self,
+ llm_job: LLMJob,
+ ) -> str:
+ messages = MistralFactory.make_simple_messages(llm_job=llm_job)
+ response: Optional[ChatCompletionResponse] = await self.mistral_client_for_text.chat.complete_async(
+ messages=messages,
+ model=self.llm_engine.llm_id,
+ temperature=llm_job.job_params.temperature,
+ max_tokens=llm_job.job_params.max_tokens or self.default_max_tokens,
+ )
+ if not response:
+ raise LLMCompletionError("Mistral response is None")
+ if not response.choices:
+ raise LLMCompletionError("Mistral response.choices is None")
+ mistral_response_content = response.choices[0].message.content
+ if not isinstance(mistral_response_content, str):
+ raise LLMCompletionError("Mistral response.choices[0].message.content is not a string")
+
+ if (llm_tokens_usage := llm_job.job_report.llm_tokens_usage) and (usage := response.usage):
+ llm_tokens_usage.nb_tokens_by_category = MistralFactory.make_nb_tokens_by_category(usage=usage)
+
+ return mistral_response_content
+
+ @override
+ @llm_job_func
+ async def gen_object(
+ self,
+ llm_job: LLMJob,
+ schema: Type[BaseModelTypeVar],
+ ) -> BaseModelTypeVar:
+ result_object, completion = await self.instructor_for_objects.chat.completions.create_with_completion(
+ response_model=schema,
+ messages=MistralFactory.make_simple_messages_openai_typed(llm_job=llm_job),
+ model=self.llm_engine.llm_id,
+ temperature=llm_job.job_params.temperature,
+ max_tokens=llm_job.job_params.max_tokens or self.default_max_tokens,
+ )
+ if (llm_tokens_usage := llm_job.job_report.llm_tokens_usage) and (usage := completion.usage):
+ llm_tokens_usage.nb_tokens_by_category = MistralFactory.make_nb_tokens_by_category(usage=usage)
+
+ return result_object
diff --git a/pipelex/cogt/plugin/mistral/mistral_llms.py b/pipelex/cogt/plugin/mistral/mistral_llms.py
new file mode 100644
index 000000000..9787e3c54
--- /dev/null
+++ b/pipelex/cogt/plugin/mistral/mistral_llms.py
@@ -0,0 +1,16 @@
+from typing import List
+
+from mistralai.models import Data
+
+from pipelex.cogt.plugin.mistral.mistral_factory import MistralFactory
+
+
+def list_mistral_models() -> List[Data]:
+ mistral_client = MistralFactory.make_mistral_client()
+ models_list_response = mistral_client.models.list()
+ if not models_list_response:
+ raise ValueError("No models found")
+ models_list = models_list_response.data
+ if not models_list:
+ raise ValueError("No models found")
+ return sorted(models_list, key=lambda model: model.id)
diff --git a/pipelex/cogt/plugin/mistral/mistral_ocr_worker.py b/pipelex/cogt/plugin/mistral/mistral_ocr_worker.py
new file mode 100644
index 000000000..5e84f8dc7
--- /dev/null
+++ b/pipelex/cogt/plugin/mistral/mistral_ocr_worker.py
@@ -0,0 +1,176 @@
+from typing import Any, Optional
+
+from mistralai import Mistral
+from typing_extensions import override
+
+from pipelex import log
+from pipelex.cogt.exceptions import OcrCapabilityError, SdkTypeError
+from pipelex.cogt.inference.inference_report_delegate import InferenceReportDelegate
+from pipelex.cogt.ocr.ocr_engine import OcrEngine
+from pipelex.cogt.ocr.ocr_input import OcrInputError
+from pipelex.cogt.ocr.ocr_job import OcrJob
+from pipelex.cogt.ocr.ocr_output import OcrOutput
+from pipelex.cogt.ocr.ocr_worker_abstract import OcrWorkerAbstract, ocr_job_func
+from pipelex.cogt.plugin.mistral.mistral_factory import MistralFactory
+from pipelex.cogt.plugin.mistral.mistral_utils import upload_file_for_ocr
+from pipelex.tools.misc.base_64_utils import load_binary_as_base64_async
+from pipelex.tools.misc.path_utils import clarify_path_or_url
+
+
+class MistralOcrWorker(OcrWorkerAbstract):
+ def __init__(
+ self,
+ sdk_instance: Any,
+ ocr_engine: OcrEngine,
+ report_delegate: Optional[InferenceReportDelegate] = None,
+ ):
+ super().__init__(ocr_engine=ocr_engine, report_delegate=report_delegate)
+
+ if not isinstance(sdk_instance, Mistral):
+ raise SdkTypeError(f"Provided OCR sdk_instance for {self.__class__.__name__} is not of type Mistral: it's a '{type(sdk_instance)}'")
+
+ self.mistral_client: Mistral = sdk_instance
+
+ @override
+ @ocr_job_func
+ async def ocr_extract_pages(
+ self,
+ ocr_job: OcrJob,
+ ) -> OcrOutput:
+ # TODO: report usage
+ if image_uri := ocr_job.ocr_input.image_uri:
+ ocr_output = await self.make_ocr_output_from_image(
+ image_uri=image_uri,
+ should_caption_image=ocr_job.job_params.should_caption_images,
+ )
+
+ elif pdf_uri := ocr_job.ocr_input.pdf_uri:
+ ocr_output = await self.make_ocr_output_from_pdf(
+ pdf_uri=pdf_uri,
+ should_include_images=ocr_job.job_params.should_include_images,
+ should_caption_images=ocr_job.job_params.should_caption_images,
+ should_include_page_views=ocr_job.job_params.should_include_page_views,
+ )
+ else:
+ raise OcrInputError("No image nor PDF URI provided in OcrJob")
+ return ocr_output
+
+ async def make_ocr_output_from_image(
+ self,
+ image_uri: str,
+ should_caption_image: bool = False,
+ ) -> OcrOutput:
+ if should_caption_image:
+ raise NotImplementedError("Captioning is not implemented for Mistral OCR.")
+ image_path, image_url = clarify_path_or_url(path_or_uri=image_uri)
+ if image_url:
+ return await self.extract_from_image_url(
+ image_url=image_url,
+ )
+ else:
+ assert image_path is not None # Type narrowing for mypy
+ return await self.extract_from_image_file(
+ image_path=image_path,
+ )
+
+ async def make_ocr_output_from_pdf(
+ self,
+ pdf_uri: str,
+ should_include_images: bool,
+ should_caption_images: bool,
+ should_include_page_views: bool,
+ ) -> OcrOutput:
+ if should_caption_images:
+ raise OcrCapabilityError("Captioning is not implemented for Mistral OCR.")
+ if should_include_page_views:
+ log.debug("Page views are not implemented for Mistral OCR.")
+ # TODO: use a model capability flag to check possibility before asking for it
+ # it it's asked and not available, raise
+ # the caller will be responsible to get the page views using other solution if needed
+ # raise OcrCapabilityError("Page views are not implemented for Mistral OCR.")
+ pdf_path, pdf_url = clarify_path_or_url(path_or_uri=pdf_uri) # pyright: ignore
+ ocr_output: OcrOutput
+ if pdf_url:
+ ocr_output = await self.extract_from_pdf_url(
+ pdf_url=pdf_url,
+ should_include_images=should_include_images,
+ )
+ else: # pdf_path must be provided based on validation
+ assert pdf_path is not None # Type narrowing for mypy
+ ocr_output = await self.extract_from_pdf_file(
+ pdf_path=pdf_path,
+ should_include_images=should_include_images,
+ )
+ return ocr_output
+
+ async def extract_from_image_url(
+ self,
+ image_url: str,
+ ) -> OcrOutput:
+ ocr_response = await self.mistral_client.ocr.process_async(
+ model=self.ocr_engine.ocr_model_name,
+ document={
+ "type": "image_url",
+ "image_url": image_url,
+ },
+ )
+ ocr_output = await MistralFactory.make_ocr_output_from_mistral_response(
+ mistral_ocr_response=ocr_response,
+ )
+ return ocr_output
+
+ async def extract_from_image_file(
+ self,
+ image_path: str,
+ ) -> OcrOutput:
+ b64 = await load_binary_as_base64_async(path=image_path)
+
+ # TODO: set proper image format
+ ocr_response = await self.mistral_client.ocr.process_async(
+ model=self.ocr_engine.ocr_model_name,
+ document={"type": "image_url", "image_url": f"data:image/jpeg;base64,{b64.decode('utf-8')}"},
+ )
+ ocr_output = await MistralFactory.make_ocr_output_from_mistral_response(
+ mistral_ocr_response=ocr_response,
+ )
+ return ocr_output
+
+ async def extract_from_pdf_url(
+ self,
+ pdf_url: str,
+ should_include_images: bool = False,
+ ) -> OcrOutput:
+ ocr_response = await self.mistral_client.ocr.process_async(
+ model=self.ocr_engine.ocr_model_name,
+ document={
+ "type": "document_url",
+ "document_url": pdf_url,
+ },
+ include_image_base64=should_include_images,
+ )
+
+ ocr_output = await MistralFactory.make_ocr_output_from_mistral_response(
+ mistral_ocr_response=ocr_response,
+ should_include_images=should_include_images,
+ )
+ return ocr_output
+
+ async def extract_from_pdf_file(
+ self,
+ pdf_path: str,
+ should_include_images: bool = False,
+ ) -> OcrOutput:
+ # Upload the file
+ uploaded_file_id = await upload_file_for_ocr(
+ mistral_client=self.mistral_client,
+ file_path=pdf_path,
+ )
+
+ # Get signed URL
+ signed_url = await self.mistral_client.files.get_signed_url_async(
+ file_id=uploaded_file_id,
+ )
+ return await self.extract_from_pdf_url(
+ pdf_url=signed_url.url,
+ should_include_images=should_include_images,
+ )
diff --git a/pipelex/cogt/plugin/mistral/mistral_utils.py b/pipelex/cogt/plugin/mistral/mistral_utils.py
new file mode 100644
index 000000000..fbbb43ffe
--- /dev/null
+++ b/pipelex/cogt/plugin/mistral/mistral_utils.py
@@ -0,0 +1,27 @@
+import os
+
+import aiofiles
+from mistralai import Mistral
+
+
+async def upload_file_for_ocr(
+ mistral_client: Mistral,
+ file_path: str,
+) -> str:
+ """
+ Upload a local file to Mistral.
+
+ Args:
+ pdf_path: Path to the local file to upload
+
+ Returns:
+ ID of the uploaded file
+ """
+ async with aiofiles.open(file_path, "rb") as file: # type: ignore[reportUnknownMemberType]
+ file_content = await file.read()
+
+ uploaded_file = await mistral_client.files.upload_async(
+ file={"file_name": os.path.basename(file_path), "content": file_content},
+ purpose="ocr",
+ )
+ return uploaded_file.id
diff --git a/pipelex/cogt/plugin/openai/__init__.py b/pipelex/cogt/plugin/openai/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/pipelex/cogt/plugin/openai/__init__.py
@@ -0,0 +1 @@
+
diff --git a/pipelex/cogt/plugin/openai/azure_openai_config.py b/pipelex/cogt/plugin/openai/azure_openai_config.py
new file mode 100644
index 000000000..74f5f0516
--- /dev/null
+++ b/pipelex/cogt/plugin/openai/azure_openai_config.py
@@ -0,0 +1,45 @@
+from enum import StrEnum
+
+from pydantic import Field
+
+from pipelex import log
+from pipelex.cogt.exceptions import CogtError
+from pipelex.tools.config.models import ConfigModel
+from pipelex.tools.environment import EnvVarNotFoundError, get_required_env
+from pipelex.tools.secrets.secrets_errors import SecretNotFoundError
+from pipelex.tools.secrets.secrets_provider_abstract import SecretsProviderAbstract
+
+
+class AzureOpenAICredentialsError(CogtError):
+ pass
+
+
+class AzureOpenAIKeyMethod(StrEnum):
+ SECRET_PROVIDER = "secret_provider"
+ ENV = "env"
+
+
+class AzureOpenAIConfig(ConfigModel):
+ api_endpoint: str
+ api_version: str
+ api_key_method: AzureOpenAIKeyMethod = Field(strict=False)
+ api_key_env_var_name: str
+ api_key_secret_name: str
+
+ def get_api_key(self, secrets_provider: SecretsProviderAbstract) -> str:
+ match self.api_key_method:
+ case AzureOpenAIKeyMethod.ENV:
+ log.debug("Using Azure OpenAI API key from environment.")
+ try:
+ key_from_env = get_required_env(self.api_key_env_var_name)
+ return key_from_env
+ except EnvVarNotFoundError as exc:
+ raise AzureOpenAICredentialsError(f"Error getting Azure OpenAI API key from environment: {exc}") from exc
+ case AzureOpenAIKeyMethod.SECRET_PROVIDER:
+ log.verbose("Using Azure OpenAI API key from secrets provider.")
+ # TODO: make it automatically select the right key for the right azure resource
+ try:
+ key_from_secrets_provider = secrets_provider.get_secret(secret_id=self.api_key_secret_name)
+ except SecretNotFoundError as exc:
+ raise AzureOpenAICredentialsError("Error getting Azure OpenAI API key from secrets provider.") from exc
+ return key_from_secrets_provider
diff --git a/pipelex/cogt/plugin/openai/custom_openai_config.py b/pipelex/cogt/plugin/openai/custom_openai_config.py
new file mode 100644
index 000000000..7f2c4393e
--- /dev/null
+++ b/pipelex/cogt/plugin/openai/custom_openai_config.py
@@ -0,0 +1,52 @@
+from typing import Optional
+
+from pipelex import log
+from pipelex.cogt.exceptions import CogtError
+from pipelex.tools.config.models import ConfigModel
+from pipelex.tools.environment import EnvVarNotFoundError, get_required_env
+from pipelex.tools.secrets.secrets_errors import SecretNotFoundError
+from pipelex.tools.secrets.secrets_provider_abstract import SecretsProviderAbstract
+
+
+class CustomOpenAICredentialsError(CogtError):
+ pass
+
+
+class CustomOpenAIConfig(ConfigModel):
+ """Configuration for custom OpenAI-compatible endpoints (e.g., Ollama, LM Studio, etc.)"""
+
+ base_url: str
+ api_key: Optional[str] = None
+ # Option to load API key from environment or secrets if needed
+ api_key_env_var_name: Optional[str] = None
+ api_key_secret_name: Optional[str] = None
+
+ def get_api_key(self, secrets_provider: Optional[SecretsProviderAbstract] = None) -> Optional[str]:
+ """Get API key if configured, otherwise return None for services that don't require authentication"""
+
+ # If api_key is directly set, use it
+ if self.api_key:
+ log.debug("Using Custom OpenAI API key from config.")
+ return self.api_key
+
+ # Try to get from environment variable if configured
+ if self.api_key_env_var_name:
+ log.debug("Using Custom OpenAI API key from environment.")
+ try:
+ key_from_env = get_required_env(self.api_key_env_var_name)
+ return key_from_env
+ except EnvVarNotFoundError as exc:
+ raise CustomOpenAICredentialsError(f"Error getting Custom OpenAI API key from environment: {exc}") from exc
+
+ # Try to get from secrets provider if configured
+ if self.api_key_secret_name and secrets_provider:
+ log.verbose("Using Custom OpenAI API key from secrets provider.")
+ try:
+ key_from_secrets_provider = secrets_provider.get_secret(secret_id=self.api_key_secret_name)
+ return key_from_secrets_provider
+ except SecretNotFoundError as exc:
+ raise CustomOpenAICredentialsError("Error getting Custom OpenAI API key from secrets provider.") from exc
+
+ # No API key configured - return None (for services that don't require auth)
+ log.debug("No Custom OpenAI API key configured - using None.")
+ return None
diff --git a/pipelex/cogt/plugin/openai/openai_config.py b/pipelex/cogt/plugin/openai/openai_config.py
new file mode 100644
index 000000000..cff8ece50
--- /dev/null
+++ b/pipelex/cogt/plugin/openai/openai_config.py
@@ -0,0 +1,42 @@
+from enum import StrEnum
+
+from pydantic import Field
+
+from pipelex import log
+from pipelex.cogt.exceptions import CogtError
+from pipelex.tools.config.models import ConfigModel
+from pipelex.tools.environment import EnvVarNotFoundError, get_required_env
+from pipelex.tools.secrets.secrets_errors import SecretNotFoundError
+from pipelex.tools.secrets.secrets_provider_abstract import SecretsProviderAbstract
+
+
+class OpenAICredentialsError(CogtError):
+ pass
+
+
+class OpenAIKeyMethod(StrEnum):
+ SECRET_PROVIDER = "secret_provider"
+ ENV = "env"
+
+
+class OpenAIOpenAIConfig(ConfigModel):
+ api_key_method: OpenAIKeyMethod = Field(strict=False)
+ api_key_secret_name: str
+ api_key_env_var_name: str
+
+ def get_api_key(self, secrets_provider: SecretsProviderAbstract) -> str:
+ match self.api_key_method:
+ case OpenAIKeyMethod.ENV:
+ log.debug("Using OpenAI API key from environment.")
+ try:
+ key_from_env = get_required_env(self.api_key_env_var_name)
+ return key_from_env
+ except EnvVarNotFoundError as exc:
+ raise OpenAICredentialsError(f"Error getting OpenAI API key from environment: {exc}") from exc
+ case OpenAIKeyMethod.SECRET_PROVIDER:
+ log.verbose("Using OpenAI API key from secrets provider.")
+ try:
+ key_from_service_provider = secrets_provider.get_secret(secret_id=self.api_key_secret_name)
+ except SecretNotFoundError as exc:
+ raise OpenAICredentialsError("Error getting OpenAI API key from secrets provider.") from exc
+ return key_from_service_provider
diff --git a/pipelex/cogt/plugin/openai/openai_errors.py b/pipelex/cogt/plugin/openai/openai_errors.py
new file mode 100644
index 000000000..43d440ec0
--- /dev/null
+++ b/pipelex/cogt/plugin/openai/openai_errors.py
@@ -0,0 +1,9 @@
+from pipelex.cogt.exceptions import CogtError
+
+
+class OpenAIWorkerError(CogtError):
+ pass
+
+
+class OpenAIWorkerModelNotFoundError(OpenAIWorkerError):
+ pass
diff --git a/pipelex/cogt/plugin/openai/openai_factory.py b/pipelex/cogt/plugin/openai/openai_factory.py
new file mode 100644
index 000000000..8c56ef004
--- /dev/null
+++ b/pipelex/cogt/plugin/openai/openai_factory.py
@@ -0,0 +1,173 @@
+from typing import Dict, List, Optional
+
+import openai
+from openai.types.chat import (
+ ChatCompletionContentPartImageParam,
+ ChatCompletionContentPartParam,
+ ChatCompletionContentPartTextParam,
+ ChatCompletionMessageParam,
+ ChatCompletionSystemMessageParam,
+ ChatCompletionUserMessageParam,
+)
+from openai.types.chat.chat_completion_content_part_image_param import ImageURL
+from openai.types.completion_usage import CompletionUsage
+
+from pipelex import log
+from pipelex.cogt.exceptions import CogtError
+from pipelex.cogt.image.prompt_image import PromptImage, PromptImageBytes, PromptImagePath, PromptImageUrl
+from pipelex.cogt.llm.llm_job import LLMJob
+from pipelex.cogt.llm.llm_models.llm_engine import LLMEngine
+from pipelex.cogt.llm.llm_models.llm_platform import LLMPlatform
+from pipelex.cogt.llm.token_category import NbTokensByCategoryDict, TokenCategory
+from pipelex.config import get_config
+from pipelex.hub import get_secrets_provider
+from pipelex.tools.misc.base_64_utils import load_binary_as_base64
+
+
+class OpenAIFactoryError(CogtError):
+ pass
+
+
+class OpenAIFactory:
+ @classmethod
+ def make_openai_client(cls, llm_platform: LLMPlatform) -> openai.AsyncClient:
+ the_client: openai.AsyncOpenAI
+ api_key: Optional[str] = None
+ match llm_platform:
+ case LLMPlatform.AZURE_OPENAI:
+ azure_openai_config = get_config().cogt.llm_config.azure_openai_config
+ api_key = azure_openai_config.get_api_key(secrets_provider=get_secrets_provider())
+ azure_endpoint = azure_openai_config.api_endpoint
+ api_version = azure_openai_config.api_version
+
+ log.verbose(f"Making AsyncAzureOpenAI client with endpoint: {azure_endpoint}, api_version: {api_version}")
+ the_client = openai.AsyncAzureOpenAI(
+ azure_endpoint=azure_endpoint,
+ api_key=api_key,
+ api_version=api_version,
+ )
+ case LLMPlatform.PERPLEXITY:
+ perplexity_config = get_config().cogt.llm_config.perplexity_config
+ api_key = perplexity_config.get_api_key(secrets_provider=get_secrets_provider())
+ endpoint = perplexity_config.api_endpoint
+
+ log.verbose(f"Making perplexity AsyncOpenAI client with endpoint: {endpoint}")
+ the_client = openai.AsyncOpenAI(
+ api_key=api_key,
+ base_url=endpoint,
+ )
+ case LLMPlatform.OPENAI:
+ openai_openai_config = get_config().cogt.llm_config.openai_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:
+ vertexai_config = get_config().cogt.llm_config.vertexai_config
+ project_id = vertexai_config.project_id
+ region = vertexai_config.region
+ api_key = vertexai_config.get_api_key()
+ endpoint = f"https://{region}-aiplatform.googleapis.com/v1beta1/projects/{project_id}/locations/{region}/endpoints/openapi"
+
+ log.verbose(f"Making vertex AsyncOpenAI client with endpoint: {endpoint}")
+ the_client = openai.AsyncOpenAI(
+ api_key=api_key,
+ base_url=endpoint,
+ )
+ case LLMPlatform.CUSTOM_OPENAI:
+ custom_openai_config = get_config().cogt.llm_config.custom_openai_config
+ api_key = custom_openai_config.get_api_key(secrets_provider=get_secrets_provider())
+ base_url = custom_openai_config.base_url
+
+ log.verbose(f"Making custom AsyncOpenAI client with base_url: {base_url}")
+ the_client = openai.AsyncOpenAI(
+ api_key=api_key,
+ base_url=base_url,
+ )
+ case LLMPlatform.ANTHROPIC | LLMPlatform.BEDROCK | LLMPlatform.BEDROCK_ANTHROPIC | LLMPlatform.MISTRAL:
+ raise OpenAIFactoryError(f"Platform '{llm_platform}' is not supported by this factory '{cls.__name__}'")
+
+ return the_client
+
+ @classmethod
+ def make_simple_messages(
+ cls,
+ llm_job: LLMJob,
+ llm_engine: LLMEngine,
+ ) -> List[ChatCompletionMessageParam]:
+ """
+ Makes a list of messages with a system message (if provided) and followed by a user message.
+ """
+ llm_prompt = llm_job.llm_prompt
+ messages: List[ChatCompletionMessageParam] = []
+ user_contents: List[ChatCompletionContentPartParam] = []
+ if llm_engine.llm_model.is_system_prompt_supported and (system_content := llm_prompt.system_text):
+ messages.append(ChatCompletionSystemMessageParam(role="system", content=system_content))
+ # TODO: confirm that we can prompt without user_contents, for instance if we have only images,
+ # otherwise consider using a default user_content
+ if user_prompt_text := llm_prompt.user_text:
+ user_part_text = ChatCompletionContentPartTextParam(text=user_prompt_text, type="text")
+ user_contents.append(user_part_text)
+ if llm_prompt.user_images:
+ for prompt_image in llm_prompt.user_images:
+ openai_image_url = cls.make_openai_image_url(prompt_image=prompt_image)
+ image_param = ChatCompletionContentPartImageParam(image_url=openai_image_url, type="image_url")
+ user_contents.append(image_param)
+
+ messages.append(ChatCompletionUserMessageParam(role="user", content=user_contents))
+ return messages
+
+ @classmethod
+ def make_openai_image_url(cls, prompt_image: PromptImage) -> ImageURL:
+ if isinstance(prompt_image, PromptImageUrl):
+ url = prompt_image.url
+ openai_image_url = ImageURL(url=url, detail="high")
+ elif isinstance(prompt_image, PromptImageBytes):
+ # TODO: manage image type
+ url_with_bytes: str = f"data:image/jpeg;base64,{prompt_image.b64_image_bytes.decode('utf-8')}"
+ openai_image_url = ImageURL(url=url_with_bytes, detail="high")
+ elif isinstance(prompt_image, PromptImagePath):
+ image_bytes = load_binary_as_base64(path=prompt_image.file_path)
+ return cls.make_openai_image_url(PromptImageBytes(b64_image_bytes=image_bytes))
+ else:
+ raise ValueError(f"prompt_image of type {type(prompt_image)} is not supported")
+ return openai_image_url
+
+ @staticmethod
+ def make_openai_error_info(exception: Exception) -> str:
+ error_mapping: Dict[type, str] = {
+ openai.BadRequestError: "OpenAI API request was invalid.",
+ openai.InternalServerError: "OpenAI is having trouble. Please try again later.",
+ openai.RateLimitError: "OpenAI API request exceeded rate limit.",
+ openai.AuthenticationError: "OpenAI API request was not authorized.",
+ openai.PermissionDeniedError: "OpenAI API request was not permitted.",
+ openai.NotFoundError: "Requested resource not found.",
+ openai.APITimeoutError: "OpenAI API request timed out.",
+ openai.APIConnectionError: "OpenAI API request failed to connect.",
+ openai.APIError: "OpenAI API returned an API Error.",
+ }
+ error_info = error_mapping.get(type(exception), "An unexpected error occurred with the OpenAI API.")
+ return error_info
+
+ # reference:
+ # https://help.openai.com/en/articles/5247780-using-logit-bias-to-define-token-probability
+ # https://platform.openai.com/tokenizer
+ @staticmethod
+ def make_logit_bias(nb_items: int, weight: int = 100) -> dict[str, int]:
+ logit_bias = {str(k): weight for k in range(15, 15 + nb_items + 1)}
+ log.debug(f"logit_bias: {logit_bias}")
+ return logit_bias
+
+ @staticmethod
+ def make_nb_tokens_by_category(usage: CompletionUsage) -> NbTokensByCategoryDict:
+ nb_tokens_by_category: NbTokensByCategoryDict = {
+ TokenCategory.INPUT: usage.prompt_tokens,
+ TokenCategory.OUTPUT: usage.completion_tokens,
+ }
+ if prompt_tokens_details := usage.prompt_tokens_details:
+ nb_tokens_by_category[TokenCategory.INPUT_AUDIO] = prompt_tokens_details.audio_tokens or 0
+ nb_tokens_by_category[TokenCategory.INPUT_CACHED] = prompt_tokens_details.cached_tokens or 0
+ if completion_tokens_details := usage.completion_tokens_details:
+ nb_tokens_by_category[TokenCategory.OUTPUT_AUDIO] = completion_tokens_details.audio_tokens or 0
+ nb_tokens_by_category[TokenCategory.OUTPUT_REASONING] = completion_tokens_details.reasoning_tokens or 0
+ nb_tokens_by_category[TokenCategory.OUTPUT_ACCEPTED_PREDICTION] = completion_tokens_details.accepted_prediction_tokens or 0
+ nb_tokens_by_category[TokenCategory.OUTPUT_REJECTED_PREDICTION] = completion_tokens_details.rejected_prediction_tokens or 0
+ return nb_tokens_by_category
diff --git a/pipelex/cogt/plugin/openai/openai_func.py b/pipelex/cogt/plugin/openai/openai_func.py
new file mode 100644
index 000000000..598dc0212
--- /dev/null
+++ b/pipelex/cogt/plugin/openai/openai_func.py
@@ -0,0 +1,59 @@
+import inspect
+from typing import Any, Callable, Dict, List, Tuple, Type
+
+from instructor import OpenAISchema, openai_schema
+from openai.types.chat import ChatCompletionMessage
+from pydantic import BaseModel, create_model
+
+
+def create_pydantic_model_from_function(func: Callable[..., Any]) -> Type[BaseModel]:
+ """
+ Creates a Pydantic BaseModel from a function's signature.
+
+ Parameters:
+ func (Callable): The function from which to derive the BaseModel.
+
+ Returns:
+ Type[BaseModel]: A dynamically created Pydantic BaseModel class.
+ """
+ sig = inspect.signature(func)
+ fields: Dict[str, Tuple[Type[Any], Any]] = {
+ name: (param.annotation, param.default if param.default is not inspect.Parameter.empty else ...) for name, param in sig.parameters.items()
+ }
+ model_name = func.__name__
+ return create_model(__model_name=model_name, **fields) # type: ignore
+
+
+def create_openai_schema_from_function(func: Callable[..., Any]) -> Dict[str, Any]:
+ """
+ Creates an OpenAI schema from a function.
+
+ Parameters:
+ func (Callable): The function from which to derive the OpenAI schema.
+
+ Returns:
+ Dict[str, Any]: The OpenAI schema as a dictionary.
+ """
+ model: Type[BaseModel] = create_pydantic_model_from_function(func)
+ the_openai_schema: OpenAISchema = openai_schema(model)
+ as_openai_schema: Dict[str, Any] = the_openai_schema.openai_schema
+
+ # replace description using first non-empty line of func.__doc__ description
+ if func.__doc__:
+ description = func.__doc__.strip().split("\n")[0]
+ else:
+ description = func.__name__
+ as_openai_schema["description"] = description
+ return as_openai_schema
+
+
+def list_openai_tools(openai_message: ChatCompletionMessage) -> List[str]:
+ if not openai_message.tool_calls:
+ return []
+ tools: List[str] = []
+ for tool_call in openai_message.tool_calls:
+ if tool_call.type == "function":
+ tools.append(tool_call.function.name)
+ else:
+ tools.append(tool_call.type)
+ return tools
diff --git a/pipelex/cogt/plugin/openai/openai_llm_worker.py b/pipelex/cogt/plugin/openai/openai_llm_worker.py
new file mode 100644
index 000000000..dc9d20ecc
--- /dev/null
+++ b/pipelex/cogt/plugin/openai/openai_llm_worker.py
@@ -0,0 +1,223 @@
+from typing import Any, Optional, Type
+
+import instructor
+import openai
+from openai import NOT_GIVEN, APIConnectionError, NotFoundError
+from openai.types.chat import ChatCompletionMessage
+from typing_extensions import override
+
+from pipelex import log
+from pipelex.cogt.exceptions import SdkTypeError
+from pipelex.cogt.inference.inference_report_delegate import InferenceReportDelegate
+from pipelex.cogt.llm.llm_job import LLMJob
+from pipelex.cogt.llm.llm_job_func import llm_job_func
+from pipelex.cogt.llm.llm_models.llm_engine import LLMEngine
+from pipelex.cogt.llm.llm_models.llm_family import LLMFamily
+from pipelex.cogt.llm.llm_worker_abstract import LLMWorkerAbstract
+from pipelex.cogt.llm.structured_output import StructureMethod
+from pipelex.cogt.plugin.openai.openai_errors import OpenAIWorkerError, OpenAIWorkerModelNotFoundError
+from pipelex.cogt.plugin.openai.openai_factory import OpenAIFactory
+from pipelex.tools.typing.pydantic_utils import BaseModelTypeVar
+
+
+class OpenAILLMWorker(LLMWorkerAbstract):
+ def __init__(
+ self,
+ sdk_instance: Any,
+ llm_engine: LLMEngine,
+ structure_method: Optional[StructureMethod],
+ report_delegate: Optional[InferenceReportDelegate] = None,
+ ):
+ super().__init__(llm_engine=llm_engine, structure_method=structure_method, report_delegate=report_delegate)
+
+ if not isinstance(sdk_instance, openai.AsyncOpenAI):
+ raise SdkTypeError(
+ f"Provided LLM sdk_instance for {self.__class__.__name__} is not of type openai.AsyncOpenAI: it's a '{type(sdk_instance)}'"
+ )
+
+ self.openai_client_for_text: openai.AsyncOpenAI = sdk_instance
+ if structure_method:
+ instructor_mode = structure_method.as_instructor_mode()
+ log.debug(f"OpenAI structure mode: {structure_method} --> {instructor_mode}")
+ self.instructor_for_objects = instructor.from_openai(client=sdk_instance, mode=instructor_mode)
+ else:
+ self.instructor_for_objects = instructor.from_openai(client=sdk_instance)
+
+ #########################################################
+
+ @override
+ @llm_job_func
+ async def gen_text(
+ self,
+ llm_job: LLMJob,
+ ) -> str:
+ messages = OpenAIFactory.make_simple_messages(
+ llm_job=llm_job,
+ llm_engine=self.llm_engine,
+ )
+
+ try:
+ match self.llm_engine.llm_model.llm_family:
+ case LLMFamily.O_SERIES:
+ # for o1 models, we must use temperature=1, and tokens limit is named max_completion_tokens
+ response = await self.openai_client_for_text.chat.completions.create(
+ model=self.llm_engine.llm_id,
+ temperature=1,
+ max_completion_tokens=llm_job.job_params.max_tokens or NOT_GIVEN,
+ seed=llm_job.job_params.seed,
+ messages=messages,
+ )
+ case LLMFamily.GEMINI:
+ # for gemini models, we multiply the temperature by 2 because the range is 0-2
+ response = await self.openai_client_for_text.chat.completions.create(
+ model=self.llm_engine.llm_id,
+ temperature=llm_job.job_params.temperature * 2,
+ max_tokens=llm_job.job_params.max_tokens or NOT_GIVEN,
+ seed=llm_job.job_params.seed,
+ messages=messages,
+ )
+ case (
+ LLMFamily.GPT_4
+ | LLMFamily.GPT_3_5
+ | LLMFamily.GPT_3
+ | LLMFamily.GPT_4_5
+ | LLMFamily.GPT_4_1
+ | LLMFamily.GPT_4O
+ | LLMFamily.CUSTOM_LLAMA_4
+ | LLMFamily.CUSTOM_GEMMA_3
+ ):
+ response = await self.openai_client_for_text.chat.completions.create(
+ model=self.llm_engine.llm_id,
+ temperature=llm_job.job_params.temperature,
+ max_tokens=llm_job.job_params.max_tokens or NOT_GIVEN,
+ seed=llm_job.job_params.seed,
+ messages=messages,
+ )
+ case (
+ LLMFamily.CLAUDE_3
+ | LLMFamily.CLAUDE_3_5
+ | LLMFamily.CLAUDE_3_7
+ | LLMFamily.CLAUDE_2
+ | LLMFamily.CLAUDE_INSTANT
+ | LLMFamily.MISTRAL_7B
+ | LLMFamily.MISTRAL_8X7B
+ | LLMFamily.MISTRAL_LARGE
+ | LLMFamily.MISTRAL_SMALL
+ | LLMFamily.MISTRAL_CODESTRAL
+ | LLMFamily.MINISTRAL
+ | LLMFamily.PIXTRAL
+ | LLMFamily.LLAMA_3
+ | LLMFamily.LLAMA_3_1
+ | LLMFamily.BEDROCK_MISTRAL_LARGE
+ | LLMFamily.BEDROCK_ANTHROPIC_CLAUDE
+ | LLMFamily.BEDROCK_META_LLAMA_3
+ | LLMFamily.BEDROCK_AMAZON_NOVA
+ | LLMFamily.PERPLEXITY_SEARCH
+ | LLMFamily.PERPLEXITY_RESEARCH
+ | LLMFamily.PERPLEXITY_REASONING
+ | LLMFamily.PERPLEXITY_DEEPSEEK
+ ):
+ raise OpenAIWorkerError(f"LLM family {self.llm_engine.llm_model.llm_family} is not supported by OpenAILLMWorker")
+ except NotFoundError as not_found_error:
+ raise OpenAIWorkerModelNotFoundError(
+ f"OpenAI model or deployment '{self.llm_engine.llm_id}' not found: {not_found_error}"
+ ) from not_found_error
+ except APIConnectionError as api_connection_error:
+ raise OpenAIWorkerError(f"OpenAI API connection error: {api_connection_error}") from api_connection_error
+
+ openai_message: ChatCompletionMessage = response.choices[0].message
+ response_text = openai_message.content
+ if response_text is None:
+ print("This helper does not support tools, if we don't get content, something is wrong.")
+ raise ValueError(f"OpenAI response message content is None: {response}")
+
+ if (llm_tokens_usage := llm_job.job_report.llm_tokens_usage) and (usage := response.usage):
+ llm_tokens_usage.nb_tokens_by_category = OpenAIFactory.make_nb_tokens_by_category(usage=usage)
+ return response_text
+
+ @override
+ @llm_job_func
+ async def gen_object(
+ self,
+ llm_job: LLMJob,
+ schema: Type[BaseModelTypeVar],
+ ) -> BaseModelTypeVar:
+ messages = OpenAIFactory.make_simple_messages(
+ llm_job=llm_job,
+ llm_engine=self.llm_engine,
+ )
+ try:
+ match self.llm_engine.llm_model.llm_family:
+ case LLMFamily.O_SERIES:
+ # for o1 models, we must use temperature=1, and tokens limit is named max_completion_tokens
+ result_object, completion = await self.instructor_for_objects.chat.completions.create_with_completion(
+ model=self.llm_engine.llm_id,
+ temperature=1,
+ max_completion_tokens=llm_job.job_params.max_tokens or NOT_GIVEN,
+ seed=llm_job.job_params.seed,
+ messages=messages,
+ response_model=schema,
+ max_retries=llm_job.job_config.max_retries,
+ )
+ case LLMFamily.GEMINI:
+ # for gemini models, we multiply the temperature by 2 because the range is 0-2
+ result_object, completion = await self.instructor_for_objects.chat.completions.create_with_completion(
+ model=self.llm_engine.llm_id,
+ temperature=llm_job.job_params.temperature * 2,
+ max_tokens=llm_job.job_params.max_tokens or NOT_GIVEN,
+ seed=llm_job.job_params.seed,
+ messages=messages,
+ response_model=schema,
+ max_retries=llm_job.job_config.max_retries,
+ )
+ case (
+ LLMFamily.GPT_4
+ | LLMFamily.GPT_3_5
+ | LLMFamily.GPT_3
+ | LLMFamily.GPT_4_5
+ | LLMFamily.GPT_4_1
+ | LLMFamily.GPT_4O
+ | LLMFamily.CUSTOM_LLAMA_4
+ | LLMFamily.CUSTOM_GEMMA_3
+ ):
+ result_object, completion = await self.instructor_for_objects.chat.completions.create_with_completion(
+ model=self.llm_engine.llm_id,
+ temperature=llm_job.job_params.temperature,
+ max_tokens=llm_job.job_params.max_tokens or NOT_GIVEN,
+ seed=llm_job.job_params.seed,
+ messages=messages,
+ response_model=schema,
+ max_retries=llm_job.job_config.max_retries,
+ )
+ case (
+ LLMFamily.CLAUDE_3
+ | LLMFamily.CLAUDE_3_5
+ | LLMFamily.CLAUDE_3_7
+ | LLMFamily.CLAUDE_2
+ | LLMFamily.CLAUDE_INSTANT
+ | LLMFamily.MISTRAL_7B
+ | LLMFamily.MISTRAL_8X7B
+ | LLMFamily.MISTRAL_LARGE
+ | LLMFamily.MISTRAL_SMALL
+ | LLMFamily.MISTRAL_CODESTRAL
+ | LLMFamily.MINISTRAL
+ | LLMFamily.PIXTRAL
+ | LLMFamily.LLAMA_3
+ | LLMFamily.LLAMA_3_1
+ | LLMFamily.BEDROCK_MISTRAL_LARGE
+ | LLMFamily.BEDROCK_ANTHROPIC_CLAUDE
+ | LLMFamily.BEDROCK_META_LLAMA_3
+ | LLMFamily.BEDROCK_AMAZON_NOVA
+ | LLMFamily.PERPLEXITY_SEARCH
+ | LLMFamily.PERPLEXITY_RESEARCH
+ | LLMFamily.PERPLEXITY_REASONING
+ | LLMFamily.PERPLEXITY_DEEPSEEK
+ ):
+ raise OpenAIWorkerError(f"LLM family {self.llm_engine.llm_model.llm_family} is not supported by OpenAILLMWorker")
+ except NotFoundError as exc:
+ raise OpenAIWorkerError(f"OpenAI model or deployment '{self.llm_engine.llm_id}' not found: {exc}") from exc
+
+ if (llm_tokens_usage := llm_job.job_report.llm_tokens_usage) and (usage := completion.usage):
+ llm_tokens_usage.nb_tokens_by_category = OpenAIFactory.make_nb_tokens_by_category(usage=usage)
+
+ return result_object
diff --git a/pipelex/cogt/plugin/openai/openai_llms.py b/pipelex/cogt/plugin/openai/openai_llms.py
new file mode 100644
index 000000000..805854ec0
--- /dev/null
+++ b/pipelex/cogt/plugin/openai/openai_llms.py
@@ -0,0 +1,21 @@
+from typing import List
+
+from openai.types import Model
+
+from pipelex.cogt.exceptions import LLMSDKError
+from pipelex.cogt.llm.llm_models.llm_platform import LLMPlatform
+from pipelex.cogt.plugin.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:
+ raise LLMSDKError(f"Platform '{llm_platform}' does not support listing models with OpenAI SDK")
+ case _:
+ pass
+
+ models = await openai_client_async.models.list()
+ data = models.data
+ sorted_data = sorted(data, key=lambda x: x.id)
+ return sorted_data
diff --git a/pipelex/cogt/plugin/openai/perplexity_config.py b/pipelex/cogt/plugin/openai/perplexity_config.py
new file mode 100644
index 000000000..b52430afc
--- /dev/null
+++ b/pipelex/cogt/plugin/openai/perplexity_config.py
@@ -0,0 +1,43 @@
+from enum import StrEnum
+
+from pydantic import Field
+
+from pipelex import log
+from pipelex.cogt.exceptions import CogtError
+from pipelex.tools.config.models import ConfigModel
+from pipelex.tools.environment import EnvVarNotFoundError, get_required_env
+from pipelex.tools.secrets.secrets_errors import SecretNotFoundError
+from pipelex.tools.secrets.secrets_provider_abstract import SecretsProviderAbstract
+
+
+class PerplexityCredentialsError(CogtError):
+ pass
+
+
+class PerplexityKeyMethod(StrEnum):
+ SECRET_PROVIDER = "secret_provider"
+ ENV = "env"
+
+
+class PerplexityConfig(ConfigModel):
+ api_endpoint: str
+ api_key_method: PerplexityKeyMethod = Field(strict=False)
+ api_key_env_var_name: str
+ api_key_secret_name: str
+
+ def get_api_key(self, secrets_provider: SecretsProviderAbstract) -> str:
+ match self.api_key_method:
+ case PerplexityKeyMethod.ENV:
+ log.debug("Using Perplexity API key from environment.")
+ try:
+ key_from_env = get_required_env(self.api_key_env_var_name)
+ return key_from_env
+ except EnvVarNotFoundError as exc:
+ raise PerplexityCredentialsError(f"Error getting Azure OpenAI API key from environment: {exc}") from exc
+ case PerplexityKeyMethod.SECRET_PROVIDER:
+ log.verbose("Using Perplexity API key from secrets provider.")
+ try:
+ key_from_secrets_provider = secrets_provider.get_secret(secret_id=self.api_key_secret_name)
+ except SecretNotFoundError as exc:
+ raise PerplexityCredentialsError("Error getting Perplexity API key from secrets provider.") from exc
+ return key_from_secrets_provider
diff --git a/pipelex/cogt/plugin/openai/vertexai_config.py b/pipelex/cogt/plugin/openai/vertexai_config.py
new file mode 100644
index 000000000..061e8315e
--- /dev/null
+++ b/pipelex/cogt/plugin/openai/vertexai_config.py
@@ -0,0 +1,53 @@
+from enum import StrEnum
+from typing import Any, Dict
+
+from pipelex.cogt.exceptions import CogtError, MissingDependencyError
+from pipelex.tools.config.models import ConfigModel
+from pipelex.tools.environment import EnvVarNotFoundError, get_required_env
+from pipelex.tools.misc.json_utils import load_json_dict_from_path
+
+
+class VertexAICredentialsError(CogtError):
+ pass
+
+
+class VertexAIKeyMethod(StrEnum):
+ SECRET_PROVIDER = "secret_provider"
+ ENV = "env"
+
+
+class VertexAIConfig(ConfigModel):
+ project_id: str
+ region: str
+
+ def get_api_key(self) -> str:
+ try:
+ from google.auth.transport.requests import Request
+ from google.oauth2.service_account import Credentials
+ except ImportError as exc:
+ raise MissingDependencyError(
+ "google-auth-oauthlib",
+ "google",
+ "The google-auth-oauthlib SDK is required to use Google connection. \
+ You can install it with 'pip install pipelex[google]', or use this model via another provider \
+ (such as Azure OpenAI, OpenAI, anthropic or bedrock).",
+ ) from exc
+
+ try:
+ gcp_credentials_file_path = get_required_env("GCP_CREDENTIALS_FILE_PATH")
+ except EnvVarNotFoundError as exc:
+ raise VertexAICredentialsError("GCP_CREDENTIALS_FILE_PATH environment variable not found") from exc
+
+ try:
+ credentials_dict: Dict[str, Any] = load_json_dict_from_path(path=gcp_credentials_file_path)
+ except FileNotFoundError as exc:
+ raise VertexAICredentialsError(f"File not found: {gcp_credentials_file_path}") from exc
+
+ credentials = Credentials.from_service_account_info( # pyright: ignore[reportUnknownMemberType]
+ credentials_dict, scopes=["https://www.googleapis.com/auth/cloud-platform"]
+ )
+ auth_req = Request()
+ credentials.refresh(auth_req) # pyright: ignore[reportUnknownMemberType]
+ if not isinstance(credentials.token, str): # pyright: ignore[reportUnknownMemberType]
+ raise VertexAICredentialsError("Token is not a string")
+ return credentials.token
diff --git a/pipelex/cogt/plugin_manager.py b/pipelex/cogt/plugin_manager.py
new file mode 100644
index 000000000..55e530bc2
--- /dev/null
+++ b/pipelex/cogt/plugin_manager.py
@@ -0,0 +1,86 @@
+from enum import StrEnum
+from typing import Any, Dict, Optional
+
+from pydantic import Field, RootModel
+
+from pipelex.cogt.imgg.imgg_platform import ImggPlatform
+from pipelex.cogt.llm.llm_models.llm_platform import LLMPlatform
+from pipelex.cogt.ocr.ocr_platform import OcrPlatform
+
+
+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"
+ CUSTOM_OPENAI_ASYNC = "custom_openai_async"
+ FAL_ASYNC = "fal_async"
+
+ @staticmethod
+ def get_for_llm_platform(llm_platform: LLMPlatform) -> "PluginHandle":
+ match llm_platform:
+ case LLMPlatform.OPENAI:
+ return PluginHandle.OPENAI_ASYNC
+ case LLMPlatform.AZURE_OPENAI:
+ return PluginHandle.AZURE_OPENAI_ASYNC
+ case LLMPlatform.ANTHROPIC:
+ return PluginHandle.ANTHROPIC_ASYNC
+ case LLMPlatform.MISTRAL:
+ return PluginHandle.MISTRAL_ASYNC
+ case LLMPlatform.BEDROCK:
+ return PluginHandle.BEDROCK_ASYNC
+ case LLMPlatform.BEDROCK_ANTHROPIC:
+ return PluginHandle.BEDROCK_ANTHROPIC_ASYNC
+ case LLMPlatform.PERPLEXITY:
+ return PluginHandle.PERPLEXITY_ASYNC
+ case LLMPlatform.VERTEXAI_OPENAI:
+ return PluginHandle.VERTEXAI_OPENAI_ASYNC
+ case LLMPlatform.CUSTOM_OPENAI:
+ return PluginHandle.CUSTOM_OPENAI_ASYNC
+
+ @staticmethod
+ def get_for_ocr_engine(ocr_platform: OcrPlatform) -> "PluginHandle":
+ match ocr_platform:
+ case OcrPlatform.MISTRAL:
+ return PluginHandle.MISTRAL_ASYNC
+
+ @staticmethod
+ def get_for_imgg_engine(imgg_platform: ImggPlatform) -> "PluginHandle":
+ match imgg_platform:
+ case ImggPlatform.FAL_AI:
+ return PluginHandle.FAL_ASYNC
+
+
+PluginManagerRoot = Dict[str, Any]
+
+
+class PluginManager(RootModel[PluginManagerRoot]):
+ root: PluginManagerRoot = Field(default_factory=dict)
+
+ def reset(self):
+ self.root.clear()
+
+ def get_llm_sdk_instance(self, llm_sdk_handle: PluginHandle) -> Optional[Any]:
+ return self.root.get(llm_sdk_handle)
+
+ def set_llm_sdk_instance(self, llm_sdk_handle: PluginHandle, llm_sdk_instance: Any) -> Any:
+ self.root[llm_sdk_handle] = llm_sdk_instance
+ return llm_sdk_instance
+
+ def get_ocr_sdk_instance(self, ocr_sdk_handle: PluginHandle) -> Optional[Any]:
+ return self.root.get(ocr_sdk_handle)
+
+ def set_ocr_sdk_instance(self, ocr_sdk_handle: PluginHandle, ocr_sdk_instance: Any) -> Any:
+ self.root[ocr_sdk_handle] = ocr_sdk_instance
+ return ocr_sdk_instance
+
+ def get_imgg_sdk_instance(self, imgg_sdk_handle: PluginHandle) -> Optional[Any]:
+ return self.root.get(imgg_sdk_handle)
+
+ def set_imgg_sdk_instance(self, imgg_sdk_handle: PluginHandle, imgg_sdk_instance: Any) -> Any:
+ self.root[imgg_sdk_handle] = imgg_sdk_instance
+ return imgg_sdk_instance
diff --git a/pipelex/config.py b/pipelex/config.py
new file mode 100644
index 000000000..a873a63d5
--- /dev/null
+++ b/pipelex/config.py
@@ -0,0 +1,75 @@
+from typing import Dict, List, Optional
+
+import shortuuid
+
+from pipelex.cogt.config_cogt import Cogt
+from pipelex.cogt.llm.llm_models.llm_prompting_target import LLMPromptingTarget
+from pipelex.exceptions import PipelexError
+from pipelex.hub import get_required_config
+from pipelex.libraries.library_config import LibraryConfig
+from pipelex.mission.track.tracker_config import TrackerConfig
+from pipelex.tools.aws.aws_config import AwsConfig
+from pipelex.tools.config.models import ConfigModel, ConfigRoot
+from pipelex.tools.log.log_config import LogConfig
+from pipelex.tools.templating.templating_models import PromptingStyle
+
+
+class PipelexConfigError(PipelexError):
+ pass
+
+
+class PipeRunConfig(ConfigModel):
+ pipe_stack_limit: int
+
+
+class GenericTemplateNames(ConfigModel):
+ structure_from_preliminary_text_user: str
+ structure_from_preliminary_text_system: str
+
+
+class StructureConfig(ConfigModel):
+ is_default_text_then_structure: bool
+
+
+class PromptingConfig(ConfigModel):
+ default_prompting_style: PromptingStyle
+ prompting_styles: Dict[str, PromptingStyle]
+
+ def get_prompting_style(self, prompting_target: Optional[LLMPromptingTarget] = None) -> Optional[PromptingStyle]:
+ if prompting_target:
+ return self.prompting_styles.get(prompting_target, self.default_prompting_style)
+ else:
+ return None
+
+
+class FeatureConfig(ConfigModel):
+ is_mission_tracking_enabled: bool
+ is_activity_tracking_enabled: bool
+
+
+class Pipelex(ConfigModel):
+ extra_env_files: List[str]
+ feature_config: FeatureConfig
+ log_config: LogConfig
+ aws_config: AwsConfig
+
+ library_config: LibraryConfig
+ generic_template_names: GenericTemplateNames
+ tracker_config: TrackerConfig
+ structure_config: StructureConfig
+ prompting_config: PromptingConfig
+
+ pipe_run_config: PipeRunConfig
+
+
+class PipelexConfig(ConfigRoot):
+ session_id: str = shortuuid.uuid()
+ cogt: Cogt
+ pipelex: Pipelex
+
+
+def get_config() -> PipelexConfig:
+ singleton_config = get_required_config()
+ if not isinstance(singleton_config, PipelexConfig):
+ raise RuntimeError(f"Expected {PipelexConfig}, but got {type(singleton_config)}")
+ return singleton_config
diff --git a/pipelex/core/__init__.py b/pipelex/core/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/pipelex/core/__init__.py
@@ -0,0 +1 @@
+
diff --git a/pipelex/core/concept.py b/pipelex/core/concept.py
new file mode 100644
index 000000000..dd26a2122
--- /dev/null
+++ b/pipelex/core/concept.py
@@ -0,0 +1,111 @@
+import re
+from typing import List, Self, Tuple
+
+from kajson.class_registry import class_registry
+from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator
+
+from pipelex import log
+from pipelex.core.stuff_content import StuffContent
+from pipelex.exceptions import ConceptCodeError, ConceptDomainError, ConceptError, StructureClassError
+from pipelex.tools.misc.string_utils import pascal_case_to_sentence
+
+
+class Concept(BaseModel):
+ model_config = ConfigDict(extra="ignore", strict=True)
+
+ code: str
+ domain: str
+ structure_class_name: str
+ definition: str
+ refines: List[str] = Field(default_factory=list)
+
+ @model_validator(mode="after")
+ def validate_code_domain(self) -> Self:
+ if not Concept.concept_str_contains_domain(self.code):
+ raise ConceptCodeError(f"Code must contain a dot (.) for concept with code '{self.code}' and domain '{self.domain}'")
+
+ domain, code = Concept.extract_domain_and_concept_from_definition(concept_code=self.code)
+ if domain != self.domain:
+ raise ConceptDomainError(
+ f"Left part of code must match the domain field for concept with \
+ code '{self.code}' and domain '{self.domain}': {domain} != {self.domain}"
+ )
+
+ self.validate_domain_syntax(domain, self.code, self.domain)
+ self.validate_concept_code_syntax(code, self.code, self.domain)
+
+ return self
+
+ @classmethod
+ def validate_domain_syntax(cls, domain: str, code: str, domain_field: str) -> None:
+ if not re.match(r"^[a-z][a-z0-9_]*$", domain):
+ raise ConceptDomainError(
+ f"Domain must be snake_case (lowercase letters, numbers, and underscores only) \
+ for concept with code '{code}' and domain '{domain_field}': {domain}"
+ )
+
+ @classmethod
+ def validate_concept_code_syntax(cls, code: str, concept_code: str, domain_field: str) -> None:
+ if not re.match(r"^[A-Z][a-zA-Z0-9]*$", code):
+ raise ConceptCodeError(
+ f"Code must be PascalCase (letters and numbers only, starting with uppercase) \
+ for concept with code '{concept_code}' and domain '{domain_field}': {code}"
+ )
+
+ @field_validator("refines")
+ @classmethod
+ def validate_refines(cls, value: List[str]) -> List[str]:
+ for code in value:
+ if not cls.concept_str_contains_domain(code):
+ raise ConceptCodeError(f"Each inherited code must contain a dot (.), got: {code}")
+
+ domain, code = Concept.extract_domain_and_concept_from_definition(concept_code=code)
+ cls.validate_concept_code_syntax(code=code, concept_code=code, domain_field=code)
+ cls.validate_domain_syntax(domain=domain, code=code, domain_field=code)
+ return value
+
+ @field_validator("structure_class_name")
+ @classmethod
+ def validate_structure_class_name(cls, value: str) -> str:
+ if not cls.is_valid_structure_class(structure_class_name=value):
+ raise StructureClassError(f"Could not validate concept because structure_class_name '{value}' is not in class registry. ")
+ return value
+
+ @classmethod
+ def is_valid_structure_class(cls, structure_class_name: str) -> bool:
+ if class_registry.has_subclass(name=structure_class_name, base_class=StuffContent):
+ return True
+ else:
+ if class_registry.has_class(name=structure_class_name):
+ log.warning(f"Concept class '{structure_class_name}' is registered but it's not a subclass of StuffContent")
+ return False
+
+ @classmethod
+ def extract_domain_and_concept_from_definition(cls, concept_code: str) -> Tuple[str, str]:
+ if "." in concept_code:
+ domain, concept = concept_code.split(".")
+ return domain, concept
+ raise ConceptError(f"No extraction of domain and concept from concept code '{concept_code}'")
+
+ @classmethod
+ def extract_concept_name_from_str(cls, concept_str: str) -> str:
+ _, concept = cls.extract_domain_and_concept_from_definition(concept_code=concept_str)
+ return concept
+
+ @classmethod
+ def extract_domain_from_str(cls, concept_str: str) -> str:
+ domain, _ = cls.extract_domain_and_concept_from_definition(concept_code=concept_str)
+ return domain
+
+ @classmethod
+ def concept_str_contains_domain(cls, concept_str: str) -> bool:
+ """Check if the concept code contains a domain and is in the form <domain>.<concept_code>"""
+ return "." in concept_str and len(concept_str.split(".")) == 2
+
+ @classmethod
+ def sentence_from_concept_code(cls, concept_code: str) -> str:
+ return pascal_case_to_sentence(name=concept_code)
+
+ @property
+ def node_name(self) -> str:
+ return self.code
diff --git a/pipelex/core/concept_factory.py b/pipelex/core/concept_factory.py
new file mode 100644
index 000000000..80f130647
--- /dev/null
+++ b/pipelex/core/concept_factory.py
@@ -0,0 +1,142 @@
+from inspect import getsource
+from typing import Any, Dict, List, Optional, Type
+
+from kajson.class_registry import class_registry
+from pydantic import BaseModel, ConfigDict, Field, ValidationError
+
+from pipelex.core.concept import Concept
+from pipelex.core.stuff_content import TextContent
+from pipelex.exceptions import ConceptFactoryError, StructureClassError
+
+
+class ConceptBlueprint(BaseModel):
+ model_config = ConfigDict(extra="forbid")
+
+ definition: str
+ structure: Optional[str] = None
+ refines: List[str] = Field(default_factory=list)
+ domain: Optional[str] = None
+
+
+class ConceptFactory:
+ @classmethod
+ def make_refines(cls, domain: str, refines: List[str]) -> List[str]:
+ new_refines: List[str] = []
+ for ref in refines:
+ if not Concept.concept_str_contains_domain(ref):
+ ref = ConceptFactory.make_concept_code(domain=domain, code=ref)
+ new_refines.append(ref)
+ return new_refines
+
+ @classmethod
+ def make_concept_code(cls, domain: str, code: str) -> str:
+ if "." in code:
+ return code
+ return f"{domain}.{code}"
+
+ @classmethod
+ def make_from_details_dict_if_possible(
+ cls,
+ domain: str,
+ code: str,
+ details_dict: Dict[str, Any],
+ ) -> Optional[Concept]:
+ if concept_definition := details_dict.pop("Concept", None):
+ details_dict["definition"] = concept_definition
+ details_dict["refines"] = ConceptFactory.make_refines(domain=domain, refines=details_dict.pop("refines", []))
+ concept_blueprint = ConceptBlueprint.model_validate(details_dict)
+ the_concept = ConceptFactory.make_concept_from_blueprint(domain=domain, code=code, concept_blueprint=concept_blueprint)
+ return the_concept
+ elif "definition" in details_dict:
+ # legacy format
+ details_dict["domain"] = domain
+ details_dict["refines"] = ConceptFactory.make_refines(domain=domain, refines=details_dict.pop("refines", []))
+ details_dict["code"] = ConceptFactory.make_concept_code(domain, code)
+ try:
+ the_concept = Concept.model_validate(details_dict)
+ except ValidationError as e:
+ raise ConceptFactoryError(f"Error validating concept: {e}") from e
+ return the_concept
+ else:
+ return None
+
+ @classmethod
+ def make_from_details_dict(
+ cls,
+ domain_code: str,
+ code: str,
+ details_dict: Dict[str, Any],
+ ) -> Concept:
+ concept_definition = details_dict.pop("Concept", None)
+ if not concept_definition:
+ raise ConceptFactoryError(f"Concept '{code}' in domain '{domain_code}' has no definition")
+ details_dict["definition"] = concept_definition
+ details_dict["domain"] = domain_code
+ details_dict["refines"] = ConceptFactory.make_refines(domain=domain_code, refines=details_dict.pop("refines", []))
+ concept_blueprint = ConceptBlueprint.model_validate(details_dict)
+ the_concept = ConceptFactory.make_concept_from_blueprint(domain=domain_code, code=code, concept_blueprint=concept_blueprint)
+ return the_concept
+
+ @classmethod
+ def make_concept_from_definition(
+ cls,
+ domain_code: str,
+ code: str,
+ definition: str,
+ ) -> Concept:
+ structure_class_name: str
+ if Concept.is_valid_structure_class(structure_class_name=code):
+ # structure is set implicitly, by the concept's code
+ structure_class_name = code
+ else:
+ structure_class_name = TextContent.__name__
+ # TODO: why use a dict to create a concept? it makes no sense
+ # TODO: don't wall make_concept_code from the factory, the code received here must already be a valid concept code
+ concept_dict = {
+ "domain": domain_code,
+ "code": ConceptFactory.make_concept_code(domain_code, code),
+ "definition": definition,
+ "structure_class_name": structure_class_name,
+ }
+ try:
+ the_concept = Concept.model_validate(concept_dict)
+ except ValidationError as e:
+ raise ConceptFactoryError(f"Error validating concept: {e}") from e
+ return the_concept
+
+ @classmethod
+ def make_concept_from_blueprint(
+ cls,
+ domain: str,
+ code: str,
+ concept_blueprint: ConceptBlueprint,
+ ) -> Concept:
+ structure_class_name: str
+ if structure := concept_blueprint.structure:
+ # structure is set explicitly
+ if not Concept.is_valid_structure_class(structure_class_name=structure):
+ raise StructureClassError(
+ f"Structure class '{structure}' set for concept '{code}' in domain '{domain}' is not a registered subclass of StuffContent"
+ )
+ structure_class_name = structure
+ elif Concept.is_valid_structure_class(structure_class_name=code):
+ # structure is set implicitly, by the concept's code
+ structure_class_name = code
+ else:
+ structure_class_name = TextContent.__name__
+
+ return Concept(
+ code=ConceptFactory.make_concept_code(domain, code),
+ domain=domain,
+ definition=concept_blueprint.definition,
+ structure_class_name=structure_class_name,
+ refines=concept_blueprint.refines,
+ )
+
+ @classmethod
+ def get_concept_class_source_code(cls, concept_name: str, base_class: Type[Any]) -> str:
+ if not class_registry.has_class(concept_name):
+ raise RuntimeError(f"Class '{concept_name}' not found in registry")
+
+ cls = class_registry.get_required_subclass(name=concept_name, base_class=base_class)
+ return getsource(cls)
diff --git a/pipelex/core/concept_library.py b/pipelex/core/concept_library.py
new file mode 100644
index 000000000..e4a69ef14
--- /dev/null
+++ b/pipelex/core/concept_library.py
@@ -0,0 +1,125 @@
+from typing import Dict, List, Optional
+
+from pydantic import Field, RootModel
+from typing_extensions import override
+
+from pipelex import log
+from pipelex.core.concept import Concept
+from pipelex.core.concept_factory import ConceptFactory
+from pipelex.core.concept_provider_abstract import ConceptProviderAbstract
+from pipelex.exceptions import ConceptLibraryConceptNotFoundError, ConceptLibraryError
+
+ConceptLibraryRoot = Dict[str, Concept]
+
+
+class ConceptLibrary(RootModel[ConceptLibraryRoot], ConceptProviderAbstract):
+ root: ConceptLibraryRoot = Field(default_factory=dict)
+
+ def validate_with_libraries(self):
+ for concept in self.root.values():
+ for domain_concept_code in concept.refines:
+ if "." in domain_concept_code:
+ domain, concept_code = Concept.extract_domain_and_concept_from_definition(concept_code=domain_concept_code)
+
+ found_concept = self.root.get(f"{domain}.{concept_code}", None)
+ if not found_concept:
+ raise ConceptLibraryError(
+ f"Concept '{concept.code}' refines '{domain_concept_code}' but no concept \
+ with the code '{concept_code}' and domain '{domain}' exists"
+ )
+ else:
+ current_domain = concept.domain
+ found_concept = self.root.get(f"{current_domain}.{domain_concept_code}", None)
+ if not found_concept:
+ raise ConceptLibraryError(
+ f"Concept '{concept.code}' refines '{domain_concept_code}' but no concept \
+ with the code '{domain_concept_code}' and domain '{current_domain}' exists"
+ )
+ if found_concept.domain != current_domain:
+ raise ConceptLibraryError(
+ f"Concept '{concept.code}' refines '{domain_concept_code}' but the concept \
+ exists in domain '{found_concept.domain}' and not in the same domain '{current_domain}'"
+ )
+
+ self.get_required_concept(concept_code=domain_concept_code)
+
+ def reset(self):
+ self.root = {}
+
+ @override
+ def is_concept_implicit(self, concept_code: str) -> bool:
+ concept_names = self._list_concept_names()
+ is_implicit = concept_code not in concept_names
+ if is_implicit:
+ log.debug(f"Concept '{concept_code}' is implicit")
+ return is_implicit
+
+ @override
+ def list_concepts(self) -> List[Concept]:
+ return list(self.root.values())
+
+ def _list_concept_names(self) -> List[str]:
+ return [Concept.extract_domain_and_concept_from_definition(c.code)[1] for c in self.list_concepts()]
+
+ @override
+ def list_concepts_by_domain(self, domain: str) -> List[Concept]:
+ return [concept for key, concept in self.root.items() if key.startswith(f"{domain}.")]
+
+ def add_new_concept(self, concept: Concept):
+ name = concept.code
+ if name in self.root:
+ raise ConceptLibraryError(f"Concept '{name}' already exists in the library")
+ self.root[name] = concept
+
+ def add_concepts(self, concepts: List[Concept]):
+ for concept in concepts:
+ self.add_new_concept(concept=concept)
+
+ @override
+ def is_compatible(self, tested_concept: Concept, wanted_concept: Concept) -> bool:
+ if tested_concept.code == wanted_concept.code:
+ return True
+ for inherited_concept_code in tested_concept.refines:
+ inherited_concept = self.get_required_concept(concept_code=inherited_concept_code)
+ if self.is_compatible(inherited_concept, wanted_concept):
+ return True
+ return False
+
+ @override
+ def is_compatible_by_concept_code(self, tested_concept_code: str, wanted_concept_code: str) -> bool:
+ tested_concept = self.get_required_concept(concept_code=tested_concept_code)
+ wanted_concept = self.get_required_concept(concept_code=wanted_concept_code)
+ if tested_concept.code == wanted_concept.code:
+ return True
+ for inherited_concept_code in tested_concept.refines:
+ if self.is_compatible_by_concept_code(inherited_concept_code, wanted_concept_code):
+ return True
+ return False
+
+ @override
+ def get_concept(self, concept_code: str) -> Optional[Concept]:
+ return self.root.get(concept_code, None)
+
+ @override
+ def get_required_concept(self, concept_code: str) -> Concept:
+ the_concept = self.get_concept(concept_code=concept_code)
+ if not the_concept:
+ if self.is_concept_implicit(concept_code=concept_code):
+ # The implicit concept is obviously coming with a domain (the one it is used in)
+ # TODO: replace this with a concept factory method make_implicit_concept
+ return ConceptFactory.make_concept_from_definition(
+ domain_code="implicit",
+ code=Concept.extract_domain_and_concept_from_definition(concept_code=concept_code)[1],
+ definition=concept_code,
+ )
+ else:
+ raise ConceptLibraryConceptNotFoundError(f"Concept code was not found and is not implicit: '{concept_code}'")
+ return the_concept
+
+ @override
+ def get_concepts_dict(self) -> Dict[str, Concept]:
+ return self.root
+
+ @override
+ def teardown(self) -> None:
+ self.root = {}
diff --git a/pipelex/core/concept_native.py b/pipelex/core/concept_native.py
new file mode 100644
index 000000000..0a8780df0
--- /dev/null
+++ b/pipelex/core/concept_native.py
@@ -0,0 +1,92 @@
+from enum import Enum, StrEnum
+from typing import List
+
+from pipelex.core.concept import Concept
+from pipelex.core.concept_factory import ConceptFactory
+from pipelex.core.domain import SpecialDomain
+
+
+class NativeConceptClass(StrEnum):
+ DYNAMIC = "DynamicContent"
+ TEXT = "TextContent"
+ IMAGE = "ImageContent"
+ PDF = "PDFContent"
+ TEXT_AND_IMAGES = "TextAndImagesContent"
+ NUMBER = "NumberContent"
+ LLM_PROMPT = "LLMPromptContent"
+ PAGE = "PageContent"
+
+
+# Exceptionally, we use an Enum here (and not our usual StrEnum) to avoid confusion with
+# the concept_code with must have the form "native.ConceptName"
+class NativeConcept(Enum):
+ DYNAMIC = "Dynamic"
+ TEXT = "Text"
+ IMAGE = "Image"
+ PDF = "PDF"
+ TEXT_AND_IMAGES = "TextAndImages"
+ NUMBER = "Number"
+ LLM_PROMPT = "LlmPrompt"
+ PAGE = "Page"
+
+ @classmethod
+ def names(cls) -> List[str]:
+ return [code.value for code in cls]
+
+ @property
+ def code(self) -> str:
+ return ConceptFactory.make_concept_code(SpecialDomain.NATIVE, self.value)
+
+ @property
+ def content_class_name(self) -> NativeConceptClass:
+ match self:
+ case NativeConcept.TEXT:
+ return NativeConceptClass.TEXT
+ case NativeConcept.IMAGE:
+ return NativeConceptClass.IMAGE
+ case NativeConcept.PDF:
+ return NativeConceptClass.PDF
+ case NativeConcept.TEXT_AND_IMAGES:
+ return NativeConceptClass.TEXT_AND_IMAGES
+ case NativeConcept.NUMBER:
+ return NativeConceptClass.NUMBER
+ case NativeConcept.LLM_PROMPT:
+ return NativeConceptClass.LLM_PROMPT
+ case NativeConcept.DYNAMIC:
+ return NativeConceptClass.DYNAMIC
+ case NativeConcept.PAGE:
+ return NativeConceptClass.PAGE
+
+ def make_concept(self) -> Concept:
+ definition: str
+ match self:
+ case NativeConcept.TEXT:
+ definition = "A text"
+ case NativeConcept.IMAGE:
+ definition = "An image"
+ case NativeConcept.PDF:
+ definition = "A PDF"
+ case NativeConcept.TEXT_AND_IMAGES:
+ definition = "A text and an image"
+ case NativeConcept.NUMBER:
+ definition = "A number"
+ case NativeConcept.LLM_PROMPT:
+ definition = "A prompt for an LLM"
+ case NativeConcept.DYNAMIC:
+ definition = "A dynamic concept"
+ case NativeConcept.PAGE:
+ definition = "The content of a page of a document, comprising text and linked images as well as an optional page view image"
+
+ return Concept(
+ code=self.code,
+ domain=SpecialDomain.NATIVE,
+ definition=definition,
+ structure_class_name=self.content_class_name,
+ )
+
+ @classmethod
+ def all_concepts(cls) -> List[Concept]:
+ concepts: List[Concept] = []
+ for code in cls:
+ concepts.append(code.make_concept())
+ return concepts
diff --git a/pipelex/core/concept_provider_abstract.py b/pipelex/core/concept_provider_abstract.py
new file mode 100644
index 000000000..adf8a30f9
--- /dev/null
+++ b/pipelex/core/concept_provider_abstract.py
@@ -0,0 +1,44 @@
+from abc import ABC, abstractmethod
+from typing import ClassVar, Dict, List, Optional
+
+from pipelex.core.concept import Concept
+
+
+class ConceptProviderAbstract(ABC):
+ _instance: ClassVar[Optional["ConceptProviderAbstract"]] = None
+
+ @abstractmethod
+ def get_concept(self, concept_code: str) -> Optional[Concept]:
+ pass
+
+ @abstractmethod
+ def list_concepts_by_domain(self, domain: str) -> List[Concept]:
+ pass
+
+ @abstractmethod
+ def list_concepts(self) -> List[Concept]:
+ pass
+
+ @abstractmethod
+ def is_concept_implicit(self, concept_code: str) -> bool:
+ pass
+
+ @abstractmethod
+ def get_required_concept(self, concept_code: str) -> Concept:
+ pass
+
+ @abstractmethod
+ def get_concepts_dict(self) -> Dict[str, Concept]:
+ pass
+
+ @abstractmethod
+ def is_compatible(self, tested_concept: Concept, wanted_concept: Concept) -> bool:
+ pass
+
+ @abstractmethod
+ def is_compatible_by_concept_code(self, tested_concept_code: str, wanted_concept_code: str) -> bool:
+ pass
+
+ @abstractmethod
+ def teardown(self) -> None:
+ pass
diff --git a/pipelex/core/domain.py b/pipelex/core/domain.py
new file mode 100644
index 000000000..18dcba2b3
--- /dev/null
+++ b/pipelex/core/domain.py
@@ -0,0 +1,26 @@
+from enum import StrEnum
+from typing import Optional, Self
+
+from pydantic import BaseModel
+from typing_extensions import override
+
+
+class SpecialDomain(StrEnum):
+ IMPLICIT = "implicit"
+ NATIVE = "native"
+
+
+class Domain(BaseModel):
+ code: str
+ definition: str
+ system_prompt: Optional[str] = None
+ system_prompt_to_structure: Optional[str] = None
+ prompt_template_to_structure: Optional[str] = None
+
+ @override
+ def __str__(self):
+ return self.code
+
+ @classmethod
+ def make_default(cls) -> Self:
+ return cls(code=SpecialDomain.NATIVE, definition="")
diff --git a/pipelex/core/domain_library.py b/pipelex/core/domain_library.py
new file mode 100644
index 000000000..8225ec972
--- /dev/null
+++ b/pipelex/core/domain_library.py
@@ -0,0 +1,74 @@
+from typing import Dict, List, Optional
+
+from pydantic import Field, RootModel
+from typing_extensions import override
+
+from pipelex import log
+from pipelex.core.domain import Domain
+from pipelex.core.domain_provider_abstract import DomainProviderAbstract
+from pipelex.exceptions import DomainLibraryError
+from pipelex.tools.misc.file_utils import save_text_to_path
+
+DomainLibraryRoot = Dict[str, Domain]
+
+
+class DomainLibrary(RootModel[DomainLibraryRoot], DomainProviderAbstract):
+ root: DomainLibraryRoot = Field(default_factory=dict)
+
+ def validate_with_libraries(self):
+ pass
+
+ def reset(self):
+ self.root = {}
+
+ def add_new_domain(self, domain: Domain):
+ domain_code = domain.code
+ if domain_code in self.root:
+ raise DomainLibraryError(f"Domain '{domain_code}' already exists in the library")
+ self.root[domain_code] = domain
+
+ def print_all(self):
+ log.dev("-" * 80)
+ log.dev("DomainLibrary")
+ log.dev("-" * 80)
+ for domain_code, domain in self.root.items():
+ log.dev(f"• {domain_code}:")
+ log.dev(f" - definition: {domain.definition}")
+ if system_prompt := domain.system_prompt:
+ log.dev(f" - system_prompt: {system_prompt}")
+
+ def _export_as_text_listing(self) -> str:
+ exported_lines: List[str] = []
+ for domain_code, domain in self.root.items():
+ exported_lines.append(f" • {domain_code}: {domain.definition}")
+ return "\n".join(exported_lines)
+
+ def export_listing_to_path(self, export_path: str):
+ log.dev("-" * 80)
+ log.dev(f"Exporting DomainLibrary to {export_path}")
+ log.dev("-" * 80)
+ exported_string = self._export_as_text_listing()
+ save_text_to_path(exported_string, export_path)
+
+ @override
+ def get_domain(self, domain_code: str) -> Optional[Domain]:
+ return self.root.get(domain_code)
+
+ @override
+ def get_required_domain(self, domain_code: str) -> Domain:
+ the_domain = self.get_domain(domain_code=domain_code)
+ if not the_domain:
+ raise DomainLibraryError(f"Domain '{domain_code}' not found. Check for typos and make sure it is declared in a pipeline library.")
+ return the_domain
+
+ @override
+ def get_domains(self) -> List[Domain]:
+ return list(self.root.values())
+
+ @override
+ def get_domains_dict(self) -> Dict[str, Domain]:
+ return self.root
+
+ @override
+ def teardown(self) -> None:
+ self.root = {}
diff --git a/pipelex/core/domain_provider_abstract.py b/pipelex/core/domain_provider_abstract.py
new file mode 100644
index 000000000..62c7267ad
--- /dev/null
+++ b/pipelex/core/domain_provider_abstract.py
@@ -0,0 +1,28 @@
+from abc import ABC, abstractmethod
+from typing import ClassVar, Dict, List, Optional
+
+from pipelex.core.domain import Domain
+
+
+class DomainProviderAbstract(ABC):
+ _instance: ClassVar[Optional["DomainProviderAbstract"]] = None
+
+ @abstractmethod
+ def get_domain(self, domain_code: str) -> Optional[Domain]:
+ pass
+
+ @abstractmethod
+ def get_required_domain(self, domain_code: str) -> Domain:
+ pass
+
+ @abstractmethod
+ def get_domains(self) -> List[Domain]:
+ pass
+
+ @abstractmethod
+ def get_domains_dict(self) -> Dict[str, Domain]:
+ pass
+
+ @abstractmethod
+ def teardown(self) -> None:
+ pass
diff --git a/pipelex/core/pipe_abstract.py b/pipelex/core/pipe_abstract.py
new file mode 100644
index 000000000..51a01e9e2
--- /dev/null
+++ b/pipelex/core/pipe_abstract.py
@@ -0,0 +1,71 @@
+from abc import ABC, abstractmethod
+from typing import Optional, Set, Type
+
+from pydantic import BaseModel, ConfigDict
+
+from pipelex.core.pipe_output import PipeOutput
+from pipelex.core.pipe_run_params import PipeRunParams
+from pipelex.core.working_memory import WorkingMemory
+from pipelex.exceptions import PipeStackOverflowError
+from pipelex.mission.job_metadata import JobMetadata
+
+
+class PipeAbstract(ABC, BaseModel):
+ model_config = ConfigDict(strict=True, extra="forbid")
+
+ code: str
+ domain: str
+
+ definition: Optional[str] = None
+ input_concept_code: Optional[str] = None
+ output_concept_code: str
+
+ @property
+ def class_name(self) -> str:
+ return self.__class__.__name__
+
+ def validate_with_libraries(self):
+ pass
+
+ # Dependencies
+
+ def pipe_dependencies(self) -> Set[str]:
+ return set()
+
+ def concept_dependencies(self) -> Set[str]:
+ required_concepts = set([self.output_concept_code])
+ if self.input_concept_code:
+ required_concepts.add(self.input_concept_code)
+ return required_concepts
+
+ # Required variables
+
+ @property
+ def required_input_concept_code(self) -> str:
+ if self.input_concept_code is None:
+ raise RuntimeError("input_concept_code is required")
+ return self.input_concept_code
+
+ def required_variables(self) -> Set[str]:
+ return set()
+
+ # Run pipe
+
+ @abstractmethod
+ async def run_pipe(
+ self,
+ job_metadata: JobMetadata,
+ working_memory: WorkingMemory,
+ pipe_run_params: PipeRunParams,
+ output_name: Optional[str] = None,
+ ) -> PipeOutput:
+ pass
+
+ def monitor_pipe_stack(self, pipe_run_params: PipeRunParams):
+ pipe_stack = pipe_run_params.pipe_stack
+ limit = pipe_run_params.pipe_stack_limit
+ if len(pipe_stack) > limit:
+ raise PipeStackOverflowError(f"Exceeded pipe stack limit of {limit}. You can raise that limit in the config. Stack:\n{pipe_stack}")
+
+
+PipeAbstractType = Type[PipeAbstract]
diff --git a/pipelex/core/pipe_blueprint.py b/pipelex/core/pipe_blueprint.py
new file mode 100644
index 000000000..3e000242a
--- /dev/null
+++ b/pipelex/core/pipe_blueprint.py
@@ -0,0 +1,67 @@
+from typing import Any, Dict, Optional, Protocol, TypeVar
+
+from pydantic import ConfigDict, field_validator, model_validator
+from typing_extensions import Self, runtime_checkable
+
+from pipelex.core.concept_native import NativeConcept
+from pipelex.core.pipe_abstract import PipeAbstract
+from pipelex.core.stuff_content import StructuredContent
+
+
+class PipeBlueprint(StructuredContent):
+ model_config = ConfigDict(extra="forbid")
+
+ definition: Optional[str] = None
+ input: Optional[str] = None
+ output: str
+ domain: str
+
+ @model_validator(mode="after")
+ def add_domain_prefix(self) -> Self:
+ if self.input and "." not in self.input:
+ self.input = f"{self.domain}.{self.input}"
+ if self.output and "." not in self.output:
+ self.output = f"{self.domain}.{self.output}"
+ return self
+
+ @classmethod
+ def _add_native_prefix_if_needed(cls, value: str) -> str:
+ if value in NativeConcept.names():
+ return f"native.{value}"
+ return value
+
+ @field_validator("input")
+ @classmethod
+ def validate_input(cls, value: Optional[str]) -> Optional[str]:
+ if value:
+ return cls._add_native_prefix_if_needed(value)
+ return value
+
+ @field_validator("output")
+ @classmethod
+ def validate_output(cls, value: str) -> str:
+ return cls._add_native_prefix_if_needed(value)
+
+
+PipeBlueprintType = TypeVar("PipeBlueprintType", bound="PipeBlueprint", contravariant=True)
+
+PipeType = TypeVar("PipeType", bound="PipeAbstract", covariant=True)
+
+
+@runtime_checkable
+class PipeSpecificFactoryProtocol(Protocol[PipeBlueprintType, PipeType]):
+ @classmethod
+ def make_pipe_from_blueprint(
+ cls,
+ domain_code: str,
+ pipe_code: str,
+ pipe_blueprint: PipeBlueprintType,
+ ) -> PipeType: ...
+
+ @classmethod
+ def make_pipe_from_details_dict(
+ cls,
+ domain_code: str,
+ pipe_code: str,
+ details_dict: Dict[str, Any],
+ ) -> PipeType: ...
diff --git a/pipelex/core/pipe_library.py b/pipelex/core/pipe_library.py
new file mode 100644
index 000000000..63c2cc31a
--- /dev/null
+++ b/pipelex/core/pipe_library.py
@@ -0,0 +1,67 @@
+from typing import Dict, List, Optional
+
+from pydantic import Field, RootModel
+from typing_extensions import override
+
+from pipelex.core.pipe_abstract import PipeAbstract
+from pipelex.core.pipe_provider_abstract import PipeProviderAbstract
+from pipelex.exceptions import ConceptError, ConceptLibraryConceptNotFoundError, PipeLibraryError, PipeLibraryPipeNotFoundError
+from pipelex.hub import get_concept_provider
+
+PipeLibraryRoot = Dict[str, PipeAbstract]
+
+
+class PipeLibrary(RootModel[PipeLibraryRoot], PipeProviderAbstract):
+ root: PipeLibraryRoot = Field(default_factory=dict)
+
+ def validate_with_libraries(self):
+ concept_provider = get_concept_provider()
+ for pipe in self.root.values():
+ try:
+ for concept_code in pipe.concept_dependencies():
+ try:
+ concept_provider.get_required_concept(concept_code=concept_code)
+ except ConceptError as concept_error:
+ raise PipeLibraryError(
+ f"Error validating pipe '{pipe.code}' dependency concept '{concept_code}' because of: {concept_error}"
+ ) from concept_error
+ for pipe_code in pipe.pipe_dependencies():
+ self.get_required_pipe(pipe_code=pipe_code)
+ pipe.validate_with_libraries()
+ except (ConceptLibraryConceptNotFoundError, PipeLibraryPipeNotFoundError) as not_found_error:
+ raise PipeLibraryError(f"Missing dependency for pipe '{pipe.code}': {not_found_error}") from not_found_error
+
+ def add_new_pipe(self, pipe: PipeAbstract):
+ name = pipe.code
+ if pipe.input_concept_code and "." not in pipe.input_concept_code:
+ pipe.input_concept_code = f"{pipe.domain}.{pipe.input_concept_code}"
+ if pipe.output_concept_code and "." not in pipe.output_concept_code:
+ pipe.output_concept_code = f"{pipe.domain}.{pipe.output_concept_code}"
+ if name in self.root:
+ raise PipeLibraryError(f"Pipe '{name}' already exists in the library")
+ self.root[pipe.code] = pipe
+
+ @override
+ def get_optional_pipe(self, pipe_code: str) -> Optional[PipeAbstract]:
+ return self.root.get(pipe_code)
+
+ @override
+ def get_required_pipe(self, pipe_code: str) -> PipeAbstract:
+ the_pipe = self.get_optional_pipe(pipe_code=pipe_code)
+ if not the_pipe:
+ raise PipeLibraryPipeNotFoundError(
+ f"Pipe '{pipe_code}' not found. Check for typos and make sure it is declared in a library listed in the config."
+ )
+ return the_pipe
+
+ @override
+ def get_pipes(self) -> List[PipeAbstract]:
+ return list(self.root.values())
+
+ @override
+ def get_pipes_dict(self) -> Dict[str, PipeAbstract]:
+ return self.root
+
+ @override
+ def teardown(self) -> None:
+ self.root = {}
diff --git a/pipelex/core/pipe_output.py b/pipelex/core/pipe_output.py
new file mode 100644
index 000000000..daac4bb2a
--- /dev/null
+++ b/pipelex/core/pipe_output.py
@@ -0,0 +1,78 @@
+from typing import List, Type, TypeVar
+
+from pydantic import BaseModel, Field
+
+from pipelex.core.stuff import Stuff
+from pipelex.core.stuff_content import (
+ HtmlContent,
+ ImageContent,
+ ListContent,
+ MermaidContent,
+ NumberContent,
+ StuffContentType,
+ TextAndImagesContent,
+ TextContent,
+)
+from pipelex.core.working_memory import WorkingMemory
+
+
+class PipeOutput(BaseModel):
+ working_memory: WorkingMemory = Field(default_factory=WorkingMemory)
+
+ @property
+ def main_stuff(self) -> Stuff:
+ return self.working_memory.get_main_stuff()
+
+ def main_stuff_as_list(self, item_type: Type[StuffContentType]) -> ListContent[StuffContentType]:
+ """
+ Get main stuff content as ListContent with items of type StuffContentType.
+ If the items are of possibly various types, use item_type=StuffContent.
+ """
+ return self.working_memory.main_stuff_as_list(item_type=item_type)
+
+ def main_stuff_as_items(self, item_type: Type[StuffContentType]) -> List[StuffContentType]:
+ """
+ Get main stuff content as ListContent with items of type StuffContentType.
+ Return the actual items
+ """
+ return self.working_memory.main_stuff_as_list(item_type=item_type).items
+
+ def main_stuff_as(self, content_type: Type[StuffContentType]) -> StuffContentType:
+ """
+ Get main stuff content as StuffContentType.
+ If the items are of possibly various types, use item_type=StuffContent.
+ """
+ return self.working_memory.main_stuff_as(content_type=content_type)
+
+ @property
+ def main_stuff_as_text(self) -> TextContent:
+ """Get main stuff content as TextContent if applicable."""
+ return self.working_memory.main_stuff_as_text
+
+ @property
+ def main_stuff_as_image(self) -> ImageContent:
+ """Get main stuff content as ImageContent if applicable."""
+ return self.working_memory.main_stuff_as_image
+
+ @property
+ def main_stuff_as_text_and_image(self) -> TextAndImagesContent:
+ """Get main stuff content as TextAndImageContent if applicable."""
+ return self.working_memory.main_stuff_as_text_and_image
+
+ @property
+ def main_stuff_as_number(self) -> NumberContent:
+ """Get main stuff content as NumberContent if applicable."""
+ return self.working_memory.main_stuff_as_number
+
+ @property
+ def main_stuff_as_html(self) -> HtmlContent:
+ """Get main stuff content as HtmlContent if applicable."""
+ return self.working_memory.main_stuff_as_html
+
+ @property
+ def main_stuff_as_mermaid(self) -> MermaidContent:
+ """Get main stuff content as MermaidContent if applicable."""
+ return self.working_memory.main_stuff_as_mermaid
+
+
+PipeOutputType = TypeVar("PipeOutputType", bound=PipeOutput)
diff --git a/pipelex/core/pipe_provider_abstract.py b/pipelex/core/pipe_provider_abstract.py
new file mode 100644
index 000000000..c24214148
--- /dev/null
+++ b/pipelex/core/pipe_provider_abstract.py
@@ -0,0 +1,28 @@
+from abc import ABC, abstractmethod
+from typing import ClassVar, Dict, List, Optional
+
+from pipelex.core.pipe_abstract import PipeAbstract
+
+
+class PipeProviderAbstract(ABC):
+ _instance: ClassVar[Optional["PipeProviderAbstract"]] = None
+
+ @abstractmethod
+ def get_required_pipe(self, pipe_code: str) -> PipeAbstract:
+ pass
+
+ @abstractmethod
+ def get_optional_pipe(self, pipe_code: str) -> Optional[PipeAbstract]:
+ pass
+
+ @abstractmethod
+ def get_pipes(self) -> List[PipeAbstract]:
+ pass
+
+ @abstractmethod
+ def get_pipes_dict(self) -> Dict[str, PipeAbstract]:
+ pass
+
+ @abstractmethod
+ def teardown(self) -> None:
+ pass
diff --git a/pipelex/core/pipe_run_params.py b/pipelex/core/pipe_run_params.py
new file mode 100644
index 000000000..1c5089747
--- /dev/null
+++ b/pipelex/core/pipe_run_params.py
@@ -0,0 +1,163 @@
+from enum import StrEnum
+from typing import Any, Dict, List, Optional, Self, Tuple, Union
+
+from pydantic import BaseModel, Field, field_validator
+
+from pipelex import log
+from pipelex.core.working_memory import BATCH_ITEM_STUFF_NAME, MAIN_STUFF_NAME
+
+
+class PipeRunParamKey(StrEnum):
+ DYNAMIC_OUTPUT_CONCEPT = "_dynamic_output_concept"
+ NB_OUTPUT = "_nb_output"
+
+
+PipeOutputMultiplicity = Union[bool, int]
+
+
+def make_output_multiplicity(nb_output: Optional[int], multiple_output: Optional[bool]) -> Optional[PipeOutputMultiplicity]:
+ output_multiplicity: Optional[PipeOutputMultiplicity]
+ if nb_output:
+ output_multiplicity = nb_output
+ elif multiple_output:
+ output_multiplicity = True
+ else:
+ output_multiplicity = None
+ return output_multiplicity
+
+
+def output_multiplicity_to_apply(
+ output_multiplicity_base: Optional[PipeOutputMultiplicity],
+ output_multiplicity_override: Optional[PipeOutputMultiplicity],
+) -> Tuple[Optional[PipeOutputMultiplicity], bool, Optional[int]]:
+ """
+ Interpret / unwrap the output multiplicity override and return the appropriate values.
+ """
+ log.debug(f"output_multiplicity_base = {output_multiplicity_base}")
+ log.debug(f"output_multiplicity_override = {output_multiplicity_override}")
+ if output_multiplicity_override is None:
+ log.debug("output_multiplicity_override is None")
+ if isinstance(output_multiplicity_base, bool):
+ log.debug("output_multiplicity_base is bool")
+ return output_multiplicity_base, output_multiplicity_base, None
+ elif isinstance(output_multiplicity_base, int):
+ log.debug("output_multiplicity_base is int")
+ return output_multiplicity_base, True, output_multiplicity_base
+ else:
+ log.debug("output_multiplicity_base is not bool")
+ return output_multiplicity_base, False, output_multiplicity_base
+ elif isinstance(output_multiplicity_override, bool):
+ log.debug("output_multiplicity_override is bool")
+ if output_multiplicity_override:
+ log.debug("output_multiplicity_override is True")
+ if isinstance(output_multiplicity_base, bool):
+ log.debug("output_multiplicity_base is bool")
+ # base is also bool, we disregard it
+ return True, True, None
+ else:
+ log.debug("output_multiplicity_base is not bool")
+ # base is an int, we use it
+ return output_multiplicity_base, True, output_multiplicity_base
+ else:
+ log.debug("output_multiplicity_override is False")
+ # override is False, we refuse multiplicity
+ return False, False, None
+ else:
+ log.debug("output_multiplicity_override is int")
+ # override is an int, we use it
+ return output_multiplicity_override, True, output_multiplicity_override
+
+
+class BatchParams(BaseModel):
+ input_list_stuff_name: str
+ input_item_stuff_name: str
+
+ @classmethod
+ def make_optional_batch_params(
+ cls,
+ input_list_name: Union[bool, str],
+ input_item_name: Optional[str] = None,
+ ) -> Optional["BatchParams"]:
+ the_batch_params: Optional[BatchParams] = None
+ if input_list_name or input_item_name:
+ input_list_stuff_name: str
+ if isinstance(input_list_name, str):
+ input_list_stuff_name = input_list_name
+ else:
+ input_list_stuff_name = MAIN_STUFF_NAME
+ input_item_stuff_name = input_item_name or BATCH_ITEM_STUFF_NAME
+ the_batch_params = BatchParams(
+ input_list_stuff_name=input_list_stuff_name,
+ input_item_stuff_name=input_item_stuff_name,
+ )
+ return the_batch_params
+
+ @classmethod
+ def make_default(cls) -> "BatchParams":
+ return BatchParams(
+ input_list_stuff_name=MAIN_STUFF_NAME,
+ input_item_stuff_name=BATCH_ITEM_STUFF_NAME,
+ )
+
+
+class PipeRunParams(BaseModel):
+ final_stuff_code: Optional[str] = None
+ output_multiplicity: Optional[PipeOutputMultiplicity] = None
+ dynamic_output_concept_code: Optional[str] = None
+ batch_params: Optional[BatchParams] = None
+ params: Dict[str, Any] = Field(default_factory=dict)
+
+ pipe_stack_limit: int
+ pipe_stack: List[str] = Field(default_factory=list)
+ pipe_layers: List[str] = Field(default_factory=list)
+
+ @field_validator("params")
+ @classmethod
+ def validate_param_keys(cls, v: Dict[str, Any]) -> Dict[str, Any]:
+ for key in v:
+ if not key.startswith("_"):
+ raise ValueError(f"Parameter key '{key}' must start with an underscore '_'")
+ return v
+
+ @classmethod
+ def copy_by_injecting_multiplicity(
+ cls,
+ pipe_run_params: Self,
+ applied_output_multiplicity: Optional[PipeOutputMultiplicity],
+ ) -> Self:
+ """
+ Copy the run params the nb_output into the params, and remove the attribute.
+ This is useful to make a single prompt with multiple outputs.
+ """
+ new_run_params = pipe_run_params.model_copy()
+
+ # inject the nb_output into the params, and remove the attribute
+ if isinstance(applied_output_multiplicity, bool):
+ new_run_params.output_multiplicity = applied_output_multiplicity
+ elif isinstance(applied_output_multiplicity, int):
+ new_run_params.output_multiplicity = False
+ new_run_params.params[PipeRunParamKey.NB_OUTPUT] = applied_output_multiplicity
+ return new_run_params
+
+ @property
+ def is_multiple_output_required(self) -> bool:
+ return isinstance(self.output_multiplicity, int) and self.output_multiplicity > 1 # pyright: ignore[reportUnnecessaryIsInstance]
+
+ def push_pipe_to_stack(self, pipe_code: str) -> None:
+ self.pipe_stack.append(pipe_code)
+
+ def pop_pipe_from_stack(self, pipe_code: str) -> None:
+ popped_pipe_code = self.pipe_stack.pop()
+ if popped_pipe_code != pipe_code:
+ # raise PipeRunError(f"Pipe code '{pipe_code}' was not the last pipe in the stack, it was '{popped_pipe_code}'")
+ log.error(f"Pipe code '{pipe_code}' was not the last pipe in the stack, it was '{popped_pipe_code}'")
+ # TODO: investigate how this can happen, maybe due to a shared object between branches of PipeBatch or PipeParallel
+ # (which should be copied instead)
+
+ def push_pipe_layer(self, pipe_code: str) -> None:
+ if self.pipe_layers and self.pipe_layers[-1] == pipe_code:
+ return
+ self.pipe_layers.append(pipe_code)
+
+ def pop_pipe_code(self) -> str:
+ return self.pipe_layers.pop()
diff --git a/pipelex/core/pipe_run_params_factory.py b/pipelex/core/pipe_run_params_factory.py
new file mode 100644
index 000000000..351976bca
--- /dev/null
+++ b/pipelex/core/pipe_run_params_factory.py
@@ -0,0 +1,24 @@
+from typing import Any, Dict, Optional
+
+from pipelex.config import get_config
+from pipelex.core.pipe_run_params import BatchParams, PipeOutputMultiplicity, PipeRunParams
+
+
+class PipeRunParamsFactory:
+ @classmethod
+ def make_run_params(
+ cls,
+ pipe_stack_limit: Optional[int] = None,
+ output_multiplicity: Optional[PipeOutputMultiplicity] = None,
+ dynamic_output_concept_code: Optional[str] = None,
+ batch_params: Optional[BatchParams] = None,
+ params: Optional[Dict[str, Any]] = None,
+ ) -> PipeRunParams:
+ pipe_stack_limit = pipe_stack_limit or get_config().pipelex.pipe_run_config.pipe_stack_limit
+ return PipeRunParams(
+ pipe_stack_limit=pipe_stack_limit,
+ output_multiplicity=output_multiplicity,
+ dynamic_output_concept_code=dynamic_output_concept_code,
+ batch_params=batch_params,
+ params=params or {},
+ )
diff --git a/pipelex/core/registry_models.py b/pipelex/core/registry_models.py
new file mode 100644
index 000000000..3f400ac52
--- /dev/null
+++ b/pipelex/core/registry_models.py
@@ -0,0 +1,93 @@
+from typing import Any, ClassVar, List
+
+from pipelex.core.pipe_abstract import PipeAbstractType
+from pipelex.core.pipe_blueprint import PipeSpecificFactoryProtocol
+from pipelex.core.stuff import Stuff
+from pipelex.core.stuff_content import (
+ DynamicContent,
+ HtmlContent,
+ ImageContent,
+ ListContent,
+ LLMPromptContent,
+ NumberContent,
+ PageContent,
+ PDFContent,
+ StructuredContent,
+ StuffContent,
+ TextAndImagesContent,
+ TextContent,
+)
+from pipelex.pipe_controllers.pipe_batch import PipeBatch
+from pipelex.pipe_controllers.pipe_batch_factory import PipeBatchFactory
+from pipelex.pipe_controllers.pipe_condition import PipeCondition
+from pipelex.pipe_controllers.pipe_condition_factory import PipeConditionFactory
+from pipelex.pipe_controllers.pipe_parallel import PipeParallel
+from pipelex.pipe_controllers.pipe_parallel_factory import PipeParallelFactory
+from pipelex.pipe_controllers.pipe_sequence import PipeSequence
+from pipelex.pipe_controllers.pipe_sequence_factory import PipeSequenceFactory
+from pipelex.pipe_operators.pipe_func import PipeFunc
+from pipelex.pipe_operators.pipe_func_factory import PipeFuncFactory
+from pipelex.pipe_operators.pipe_img_gen import PipeImgGen
+from pipelex.pipe_operators.pipe_img_gen_factory import PipeImgGenFactory
+from pipelex.pipe_operators.pipe_jinja2 import PipeJinja2
+from pipelex.pipe_operators.pipe_jinja2_factory import PipeJinja2Factory
+from pipelex.pipe_operators.pipe_llm import PipeLLM
+from pipelex.pipe_operators.pipe_llm_factory import PipeLLMFactory
+from pipelex.pipe_operators.pipe_llm_prompt import PipeLLMPrompt
+from pipelex.pipe_operators.pipe_ocr import PipeOcr
+from pipelex.pipe_operators.pipe_ocr_factory import PipeOcrFactory
+from pipelex.tools.registry_models import ModelType, RegistryModels
+
+
+class PipelexRegistryModels(RegistryModels):
+ FIELD_EXTRACTION: ClassVar[List[ModelType]] = []
+
+ PIPE_OPERATORS: ClassVar[List[PipeAbstractType]] = [
+ PipeFunc,
+ PipeImgGen,
+ PipeJinja2,
+ PipeLLM,
+ PipeLLMPrompt,
+ PipeOcr,
+ ]
+
+ PIPE_OPERATORS_FACTORY: ClassVar[List[PipeSpecificFactoryProtocol[Any, Any]]] = [
+ PipeFuncFactory,
+ PipeImgGenFactory,
+ PipeJinja2Factory,
+ PipeLLMFactory,
+ PipeOcrFactory,
+ ]
+
+ PIPE_CONTROLLERS: ClassVar[List[PipeAbstractType]] = [
+ PipeBatch,
+ PipeCondition,
+ PipeParallel,
+ PipeSequence,
+ ]
+
+ PIPE_CONTROLLERS_FACTORY: ClassVar[List[PipeSpecificFactoryProtocol[Any, Any]]] = [
+ PipeBatchFactory,
+ PipeConditionFactory,
+ PipeParallelFactory,
+ PipeSequenceFactory,
+ ]
+
+ STUFF: ClassVar[List[ModelType]] = [
+ TextContent,
+ NumberContent,
+ ImageContent,
+ LLMPromptContent,
+ Stuff,
+ StuffContent,
+ HtmlContent,
+ ListContent,
+ StructuredContent,
+ PDFContent,
+ TextAndImagesContent,
+ PageContent,
+ ]
+
+ EXPERIMENTAL: ClassVar[List[ModelType]] = [
+ DynamicContent,
+ ]
diff --git a/pipelex/core/stuff.py b/pipelex/core/stuff.py
new file mode 100644
index 000000000..ae6b3b9c1
--- /dev/null
+++ b/pipelex/core/stuff.py
@@ -0,0 +1,176 @@
+from typing import Any, Dict, Optional, Type, Union
+
+from pydantic import BaseModel, ConfigDict, Field
+from typing_extensions import override
+
+from pipelex import log
+from pipelex.core.concept import Concept
+from pipelex.core.stuff_artefact import StuffArtefact
+from pipelex.core.stuff_content import (
+ HtmlContent,
+ ImageContent,
+ ListContent,
+ MermaidContent,
+ NumberContent,
+ PDFContent,
+ StuffContent,
+ StuffContentType,
+ TextAndImagesContent,
+ TextContent,
+)
+from pipelex.exceptions import StuffError
+from pipelex.tools.misc.string_utils import pascal_case_to_snake_case
+
+
+class StuffCreationRecord(BaseModel):
+ pass
+
+
+class Stuff(BaseModel):
+ model_config = ConfigDict(extra="ignore", strict=True)
+
+ stuff_code: str
+ pipelex_session_id: Optional[str] = Field(default=None)
+ creation_record: Optional[StuffCreationRecord] = None
+ stuff_name: Optional[str] = None
+ concept_code: str
+ content: StuffContent
+
+ def make_artefact(self) -> StuffArtefact:
+ artefact_dict: Dict[str, Any] = self.content.model_dump(serialize_as_any=True)
+
+ def set_artefact_field(key: str, value: Optional[Union[str, StuffContent]]):
+ if value is None:
+ return
+ if key in artefact_dict:
+ stuff_name = self.stuff_name or f"unnamed using concept code {self.concept_code}"
+ raise StuffError(
+ f"Cannot create stuff artefact for stuff {stuff_name} because reserved field {key} already exists in the stuff content"
+ )
+ artefact_dict[key] = value
+
+ set_artefact_field("stuff_name", self.stuff_name)
+ set_artefact_field("content_class", self.content.__class__.__name__)
+ set_artefact_field("concept_code", self.concept_code)
+ set_artefact_field("stuff_code", self.stuff_code)
+ set_artefact_field("content", self.content)
+ return StuffArtefact(artefact_dict)
+
+ @classmethod
+ def make_stuff_name(cls, concept_str: str) -> str:
+ if Concept.concept_str_contains_domain(concept_str):
+ return pascal_case_to_snake_case(Concept.extract_concept_name_from_str(concept_str=concept_str))
+ else:
+ log.error(f"Generating stuff name for Concept str '{concept_str}' which does not contain a domain")
+ return pascal_case_to_snake_case(name=concept_str)
+
+ @property
+ def title(self) -> str:
+ name_from_concept = Stuff.make_stuff_name(concept_str=self.concept_code)
+ concept_display = Concept.sentence_from_concept_code(concept_code=self.concept_code)
+ if self.is_list:
+ return f"List of [{concept_display}]"
+ elif self.stuff_name:
+ if self.stuff_name == name_from_concept:
+ return concept_display
+ else:
+ return f"{self.stuff_name} (a {concept_display})"
+ else:
+ return concept_display
+
+ @property
+ def short_desc(self) -> str:
+ return f"""{self.pipelex_session_id}/{self.stuff_code}:
+{self.concept_code} — {type(self.content).__name__}:
+{self.content.short_desc}"""
+
+ @override
+ def __str__(self) -> str:
+ return f"{self.title}\n{self.content.rendered_plain()}"
+
+ @property
+ def is_list(self) -> bool:
+ return isinstance(self.content, ListContent)
+
+ @property
+ def is_image(self) -> bool:
+ return isinstance(self.content, ImageContent)
+
+ @property
+ def is_pdf(self) -> bool:
+ return isinstance(self.content, PDFContent)
+
+ @property
+ def is_text(self) -> bool:
+ return isinstance(self.content, TextContent)
+
+ @property
+ def is_number(self) -> bool:
+ return isinstance(self.content, NumberContent)
+
+ def content_as(self, content_type: Type[StuffContentType]) -> StuffContentType:
+ """Get content with proper typing if it's of the expected type."""
+ if not isinstance(self.content, content_type):
+ raise TypeError(f"Content is of type '{type(self.content)}', instead of the expected '{content_type}'")
+ return self.content
+
+ def as_list_content(self) -> ListContent: # pyright: ignore[reportMissingTypeArgument, reportUnknownParameterType]
+ """Get content as ListContent with items of any type."""
+ return self.content_as(content_type=ListContent) # pyright: ignore[reportUnknownVariableType]
+
+ def as_list_of_fixed_content_type(self, item_type: Type[StuffContentType]) -> ListContent[StuffContentType]:
+ """
+ Get content as ListContent with items of type T.
+
+ Args:
+ item_type: The expected type of items in the list.
+
+ Returns:
+ A typed ListContent[StuffContentType] with proper type information
+
+ Raises:
+ TypeError: If content is not ListContent or items don't match expected type
+ """
+ list_content: ListContent[StuffContentType] = self.content_as(content_type=ListContent)
+
+ # Validate all items are of the expected type
+ for i, item in enumerate(list_content.items):
+ if not isinstance(item, item_type):
+ raise TypeError(f"Item {i} in list is of type {type(item)}, not {item_type}")
+
+ return list_content
+
+ @property
+ def as_text(self) -> TextContent:
+ """Get content as TextContent if applicable."""
+ return self.content_as(TextContent)
+
+ @property
+ def as_image(self) -> ImageContent:
+ """Get content as ImageContent if applicable."""
+ return self.content_as(ImageContent)
+
+ @property
+ def as_pdf(self) -> PDFContent:
+ """Get content as PDFContent if applicable."""
+ return self.content_as(PDFContent)
+
+ @property
+ def as_text_and_image(self) -> TextAndImagesContent:
+ """Get content as TextAndImageContent if applicable."""
+ return self.content_as(TextAndImagesContent)
+
+ @property
+ def as_number(self) -> NumberContent:
+ """Get content as NumberContent if applicable."""
+ return self.content_as(NumberContent)
+
+ @property
+ def as_html(self) -> HtmlContent:
+ """Get content as HtmlContent if applicable."""
+ return self.content_as(HtmlContent)
+
+ @property
+ def as_mermaid(self) -> MermaidContent:
+ """Get content as MermaidContent if applicable."""
+ return self.content_as(MermaidContent)
diff --git a/pipelex/core/stuff_artefact.py b/pipelex/core/stuff_artefact.py
new file mode 100644
index 000000000..c457ca3a2
--- /dev/null
+++ b/pipelex/core/stuff_artefact.py
@@ -0,0 +1,61 @@
+from typing import Any, Dict, Optional, Tuple
+
+from jinja2.runtime import Context
+from pydantic import RootModel
+from typing_extensions import override
+
+from pipelex.core.stuff_content import StuffContent
+from pipelex.exceptions import StuffArtefactError
+from pipelex.tools.templating.jinja2_models import Jinja2TaggableAbstract
+from pipelex.tools.templating.jinja2_rendering import Jinja2ContextKey
+from pipelex.tools.templating.templating_models import TextFormat
+
+
+class StuffArtefact(RootModel[Dict[str, Any]], Jinja2TaggableAbstract):
+ """A flattened representation of Stuff and its content as a dictionary.
+
+ This RootModel implementation allows for subscript access to the underlying dictionary
+ while maintaining type safety. It's particularly useful for injecting into jinja2 templates
+ as a context variable.
+
+ Note that in jinja2, subscripts to access the dict values are compatible with the dot notation
+ e.g. {{ variable.field_name }} is equivalent to {{ variable['field_name'] }}
+ """
+
+ def __getitem__(self, key: str) -> Any:
+ return self.root[key]
+
+ def __setitem__(self, key: str, value: Any) -> None:
+ self.root[key] = value
+
+ def get(self, key: str, default: Any = None) -> Any:
+ return self.root.get(key, default)
+
+ def __contains__(self, key: str) -> bool:
+ return key in self.root
+
+ def keys(self):
+ return self.root.keys()
+
+ def values(self):
+ return self.root.values()
+
+ def items(self):
+ return self.root.items()
+
+ def rendered_str(self, text_format: TextFormat) -> str:
+ content = self.root["content"]
+ if not isinstance(content, StuffContent):
+ raise StuffArtefactError(f"StuffArtefact has no StuffContent, content: {self}")
+ rendered_str = content.rendered_str(text_format=text_format)
+ return rendered_str
+
+ @override
+ def render_tagged_for_jinja2(self, context: Context, tag_name: Optional[str] = None) -> Tuple[Any, Optional[str]]:
+ # TODO: factorize the text formatting with the jinja2 "text_format" filter
+ text_format = context.get(Jinja2ContextKey.TEXT_FORMAT, default=TextFormat.PLAIN)
+ rendered_str = self.rendered_str(text_format=text_format)
+
+ tag_name = tag_name or self.get("stuff_name")
+
+ return rendered_str, tag_name
diff --git a/pipelex/core/stuff_content.py b/pipelex/core/stuff_content.py
new file mode 100644
index 000000000..219363925
--- /dev/null
+++ b/pipelex/core/stuff_content.py
@@ -0,0 +1,524 @@
+import base64
+import json
+from abc import ABC, abstractmethod
+from io import BytesIO
+from typing import Any, Dict, Generic, List, Optional, Self, Type, TypeVar, Union
+
+import markdown
+from json2html import json2html
+from kajson import kajson
+from PIL import Image
+from pydantic import BaseModel
+from typing_extensions import override
+from yattag import Doc
+
+from pipelex.cogt.llm.llm_prompt import LLMPrompt
+from pipelex.cogt.ocr.ocr_output import ExtractedImage
+from pipelex.tools.misc.base_64_utils import save_base64_to_binary_file
+from pipelex.tools.misc.file_utils import ensure_directory_exists, get_incremental_file_path, save_text_to_path
+from pipelex.tools.misc.filetype_utils import detect_file_type_from_base64
+from pipelex.tools.misc.markdown_utils import convert_to_markdown
+from pipelex.tools.misc.path_utils import InterpretedPathOrUrl, interpret_path_or_url
+from pipelex.tools.templating.templating_models import TextFormat
+from pipelex.tools.typing.pydantic_utils import CustomBaseModel, clean_model_to_dict
+
+ObjectContentType = TypeVar("ObjectContentType", bound=BaseModel)
+StuffContentType = TypeVar("StuffContentType", bound="StuffContent")
+
+# TODO: split in separate files
+
+
+class StuffContent(ABC, CustomBaseModel):
+ @property
+ def short_desc(self) -> str:
+ return f"some {self.__class__.__name__}"
+
+ def smart_dump(self) -> Union[str, Dict[str, Any], List[str], List[Dict[str, Any]]]:
+ return self.model_dump(serialize_as_any=True)
+
+ @override
+ def __str__(self) -> str:
+ return self.rendered_plain()
+
+ def rendered_str(self, text_format: TextFormat = TextFormat.PLAIN) -> str:
+ match text_format:
+ case TextFormat.PLAIN:
+ return self.rendered_plain()
+ case TextFormat.HTML:
+ return self.rendered_html()
+ case TextFormat.MARKDOWN:
+ return self.rendered_markdown()
+ case TextFormat.JSON:
+ return self.rendered_json()
+ case TextFormat.SPREADSHEET:
+ return self.render_spreadsheet()
+
+ def rendered_plain(self) -> str:
+ return self.rendered_markdown()
+
+ @abstractmethod
+ def rendered_html(self) -> str:
+ pass
+
+ @abstractmethod
+ def rendered_markdown(self, level: int = 1, is_pretty: bool = False) -> str:
+ pass
+
+ def render_spreadsheet(self) -> str:
+ return self.rendered_plain()
+
+ def rendered_json(self) -> str:
+ return kajson.dumps(self.smart_dump(), indent=4)
+
+
+class StuffContentInitableFromStr(StuffContent):
+ @classmethod
+ @abstractmethod
+ def make_from_str(cls, str_value: str) -> "StuffContentInitableFromStr":
+ pass
+
+
+class TextContent(StuffContentInitableFromStr):
+ text: str
+
+ @override
+ def smart_dump(self) -> Union[str, Dict[str, Any], List[str], List[Dict[str, Any]]]:
+ return self.text
+
+ @property
+ @override
+ def short_desc(self) -> str:
+ return f"some text ({len(self.text)} chars)"
+
+ @classmethod
+ @override
+ def make_from_str(cls, str_value: str) -> "TextContent":
+ return TextContent(text=str_value)
+
+ @override
+ def __str__(self) -> str:
+ return self.text
+
+ @override
+ def rendered_plain(self) -> str:
+ return self.text
+
+ @override
+ def rendered_html(self) -> str:
+ # Convert a markdown string to HTML and return HTML as a Unicode string.
+ html = markdown.markdown(self.text)
+ return html
+
+ @override
+ def rendered_markdown(self, level: int = 1, is_pretty: bool = False) -> str:
+ return self.text
+
+ @override
+ def rendered_json(self) -> str:
+ return json.dumps({"text": self.text})
+
+ def save_to_directory(self, directory: str):
+ ensure_directory_exists(directory)
+ filename = "text_content.txt"
+ save_text_to_path(text=self.text, path=f"{directory}/{filename}")
+
+
+class DynamicContent(StuffContent):
+ @property
+ @override
+ def short_desc(self) -> str:
+ return "some dynamic concept"
+
+ @override
+ def rendered_html(self) -> str:
+ return str(self.smart_dump())
+
+ @override
+ def rendered_markdown(self, level: int = 1, is_pretty: bool = False) -> str:
+ return str(self.smart_dump())
+
+
+class NumberContent(StuffContentInitableFromStr):
+ number: Union[int, float]
+
+ @override
+ def smart_dump(self) -> Union[str, Dict[str, Any], List[str], List[Dict[str, Any]]]:
+ return str(self.number)
+
+ @property
+ @override
+ def short_desc(self) -> str:
+ return f"some number ({self.number})"
+
+ @classmethod
+ @override
+ def make_from_str(cls, str_value: str) -> "NumberContent":
+ try:
+ int_value = int(str_value)
+ return NumberContent(number=int_value)
+ except ValueError:
+ float_value = float(str_value)
+ return NumberContent(number=float_value)
+
+ @override
+ def __str__(self) -> str:
+ return str(self.number)
+
+ @override
+ def rendered_plain(self) -> str:
+ return str(self.number)
+
+ @override
+ def rendered_html(self) -> str:
+ return str(self.number)
+
+ @override
+ def rendered_markdown(self, level: int = 1, is_pretty: bool = False) -> str:
+ return str(self.number)
+
+ @override
+ def rendered_json(self) -> str:
+ return json.dumps({"number": self.number})
+
+
+class ImageContent(StuffContentInitableFromStr):
+ url: str
+ source_prompt: Optional[str] = None
+ caption: Optional[str] = None
+ base_64: Optional[str] = None
+
+ @property
+ @override
+ def short_desc(self) -> str:
+ url_desc = interpret_path_or_url(path_or_uri=self.url).desc
+ return f"{url_desc} or an image"
+
+ @classmethod
+ @override
+ def make_from_str(cls, str_value: str) -> "ImageContent":
+ return ImageContent(url=str_value)
+
+ @override
+ def rendered_plain(self) -> str:
+ return self.url
+
+ @override
+ def rendered_html(self) -> str:
+ doc = Doc()
+ doc.stag("img", src=self.url, klass="msg-img")
+
+ return doc.getvalue()
+
+ @override
+ def rendered_markdown(self, level: int = 1, is_pretty: bool = False) -> str:
+ return f"![{self.url}]({self.url})"
+
+ @override
+ def rendered_json(self) -> str:
+ return json.dumps({"image_url": self.url, "source_prompt": self.source_prompt})
+
+ @classmethod
+ def make_from_extracted_image(cls, extracted_image: ExtractedImage) -> Self:
+ return cls(
+ url=extracted_image.image_id,
+ base_64=extracted_image.base_64,
+ caption=extracted_image.caption,
+ )
+
+ @classmethod
+ def make_from_image(cls, image: Image.Image) -> Self:
+ buffer = BytesIO()
+ image.save(buffer, format="PNG")
+ base_64 = base64.b64encode(buffer.getvalue()).decode("utf-8")
+ return cls(
+ url=f"data:image/png;base64,{base_64}",
+ base_64=base_64,
+ )
+
+ def save_to_directory(self, directory: str, base_name: Optional[str] = None, extension: Optional[str] = None):
+ ensure_directory_exists(directory)
+ base_name = base_name or "img"
+ if base_64 := self.base_64:
+ if not extension:
+ match interpret_path_or_url(path_or_uri=self.url):
+ case InterpretedPathOrUrl.FILE_NAME:
+ parts = self.url.rsplit(".", 1)
+ base_name = parts[0]
+ extension = parts[1]
+ case _:
+ file_type = detect_file_type_from_base64(b64=base_64)
+ base_name = base_name or "img"
+ extension = file_type.extension
+ file_path = get_incremental_file_path(
+ base_path=directory,
+ base_name=base_name,
+ extension=extension,
+ avoid_suffix_if_possible=True,
+ )
+ save_base64_to_binary_file(b64=base_64, file_path=file_path)
+
+ if caption := self.caption:
+ caption_file_path = get_incremental_file_path(
+ base_path=directory,
+ base_name=f"{base_name}_caption",
+ extension="txt",
+ avoid_suffix_if_possible=True,
+ )
+ save_text_to_path(text=caption, path=caption_file_path)
+ if source_prompt := self.source_prompt:
+ source_prompt_file_path = get_incremental_file_path(
+ base_path=directory,
+ base_name=f"{base_name}_source_prompt",
+ extension="txt",
+ avoid_suffix_if_possible=True,
+ )
+ save_text_to_path(text=source_prompt, path=source_prompt_file_path)
+
+
+class PDFContent(StuffContentInitableFromStr):
+ url: str
+
+ @property
+ @override
+ def short_desc(self) -> str:
+ url_desc = interpret_path_or_url(path_or_uri=self.url).desc
+ return f"{url_desc} of a PDF document"
+
+ @classmethod
+ @override
+ def make_from_str(cls, str_value: str) -> "PDFContent":
+ return PDFContent(url=str_value)
+
+ @override
+ def rendered_plain(self) -> str:
+ return self.url
+
+ @override
+ def rendered_html(self) -> str:
+ doc = Doc()
+ doc.stag("a", href=self.url, klass="msg-pdf")
+ doc.text(self.url)
+
+ return doc.getvalue()
+
+ @override
+ def rendered_markdown(self, level: int = 1, is_pretty: bool = False) -> str:
+ return f"[{self.url}]({self.url})"
+
+
+class HtmlContent(StuffContent):
+ inner_html: str
+ css_class: str
+
+ @property
+ @override
+ def short_desc(self) -> str:
+ return f"some html ({len(self.inner_html)} chars)"
+
+ @override
+ def __str__(self) -> str:
+ return self.rendered_html()
+
+ @override
+ def rendered_plain(self) -> str:
+ return self.inner_html
+
+ @override
+ def rendered_html(self) -> str:
+ doc, tag, text = Doc().tagtext()
+ with tag("div", klass=self.css_class):
+ text(self.inner_html)
+ return doc.getvalue()
+
+ @override
+ def rendered_markdown(self, level: int = 1, is_pretty: bool = False) -> str:
+ return self.inner_html
+
+ @override
+ def rendered_json(self) -> str:
+ return json.dumps({"html": self.inner_html, "css_class": self.css_class})
+
+
+class MermaidContent(StuffContent):
+ mermaid_code: str
+ mermaid_url: str
+
+ @property
+ @override
+ def short_desc(self) -> str:
+ return f"some mermaid code ({len(self.mermaid_code)} chars)"
+
+ @override
+ def __str__(self) -> str:
+ return self.mermaid_code
+
+ @override
+ def rendered_plain(self) -> str:
+ return self.mermaid_code
+
+ @override
+ def rendered_html(self) -> str:
+ doc, tag, text = Doc().tagtext()
+ with tag("div", klass="mermaid"):
+ text(self.mermaid_code)
+ return doc.getvalue()
+
+ @override
+ def rendered_markdown(self, level: int = 1, is_pretty: bool = False) -> str:
+ return self.mermaid_code
+
+ @override
+ def rendered_json(self) -> str:
+ return json.dumps({"mermaid": self.mermaid_code})
+
+
+class StructuredContent(StuffContent):
+ @property
+ @override
+ def short_desc(self) -> str:
+ return f"some structured content of class {self.__class__.__name__}"
+
+ @override
+ def smart_dump(self):
+ return self.model_dump(serialize_as_any=True)
+
+ @override
+ def rendered_html(self) -> str:
+ dict_dump = clean_model_to_dict(obj=self)
+
+ html: str = json2html.convert( # pyright: ignore[reportAssignmentType]
+ json=dict_dump, # pyright: ignore[reportArgumentType]
+ clubbing=True,
+ table_attributes="",
+ )
+ return html
+
+ @override
+ def rendered_markdown(self, level: int = 1, is_pretty: bool = False) -> str:
+ dict_dump = clean_model_to_dict(obj=self)
+ return convert_to_markdown(data=dict_dump, level=level, is_pretty=is_pretty)
+
+
+class LLMPromptContent(StructuredContent, LLMPrompt):
+ pass
+
+
+class ListContent(StuffContent, Generic[StuffContentType]):
+ items: List[StuffContentType]
+
+ @property
+ def nb_items(self) -> int:
+ return len(self.items)
+
+ def get_items(self, item_type: Type[StuffContent]) -> List[StuffContent]:
+ return [item for item in self.items if isinstance(item, item_type)]
+
+ @property
+ @override
+ def short_desc(self) -> str:
+ nb_items = len(self.items)
+ if nb_items == 0:
+ return "empty list"
+ elif nb_items == 1:
+ return f"list of 1 {self.items[0].__class__.__name__}"
+ else:
+ item_classes: List[str] = [item.__class__.__name__ for item in self.items]
+ item_classes_set = set(item_classes)
+ nb_classes = len(item_classes_set)
+ if nb_classes == 1:
+ return f"list of {len(self.items)} {item_classes[0]}s"
+ elif nb_items == nb_classes:
+ return f"list of {len(self.items)} items of different types"
+ else:
+ return f"list of {len(self.items)} items of {nb_classes} different types"
+
+ @property
+ def _single_class_name(self) -> Optional[str]:
+ item_classes: List[str] = [item.__class__.__name__ for item in self.items]
+ item_classes_set = set(item_classes)
+ nb_classes = len(item_classes_set)
+ if nb_classes == 1:
+ return item_classes[0]
+ else:
+ return None
+
+ @override
+ def model_dump(self, *args: Any, **kwargs: Any):
+ obj_dict = super().model_dump(*args, **kwargs)
+ obj_dict["items"] = [item.model_dump(*args, **kwargs) for item in self.items]
+ return obj_dict
+
+ @override
+ def rendered_plain(self) -> str:
+ return self.rendered_markdown()
+
+ @override
+ def rendered_html(self) -> str:
+ list_dump = [item.smart_dump() for item in self.items]
+
+ html: str = json2html.convert( # pyright: ignore[reportAssignmentType]
+ json=list_dump, # pyright: ignore[reportArgumentType]
+ clubbing=True,
+ table_attributes="",
+ )
+ return html
+
+ @override
+ def rendered_markdown(self, level: int = 1, is_pretty: bool = False) -> str:
+ rendered = ""
+ if self._single_class_name == "TextContent":
+ for item in self.items:
+ rendered += f" • {item}\n"
+ else:
+ for item_index, item in enumerate(self.items):
+ rendered += f"\n • item #{item_index + 1}:\n\n"
+ rendered += item.rendered_str(text_format=TextFormat.MARKDOWN)
+ rendered += "\n"
+ return rendered
+
+
+class TextAndImagesContent(StuffContent):
+ text: Optional[TextContent]
+ images: Optional[List[ImageContent]]
+
+ @property
+ @override
+ def short_desc(self) -> str:
+ text_count = 1 if self.text else 0
+ image_count = len(self.images) if self.images else 0
+ return f"text and image content ({text_count} text, {image_count} images)"
+
+ @override
+ def rendered_markdown(self, level: int = 1, is_pretty: bool = False) -> str:
+ if self.text:
+ rendered = self.text.rendered_markdown(level=level, is_pretty=is_pretty)
+ else:
+ rendered = ""
+ return rendered
+
+ @override
+ def rendered_html(self) -> str:
+ if self.text:
+ rendered = self.text.rendered_html()
+ else:
+ rendered = ""
+ return rendered
+
+ def save_to_directory(self, directory: str):
+ ensure_directory_exists(directory)
+ if text_content := self.text:
+ text_content.save_to_directory(directory=directory)
+ if images := self.images:
+ for image_content in images:
+ image_content.save_to_directory(directory=directory)
+
+
+class PageContent(StructuredContent):
+ text_and_images: TextAndImagesContent
+ page_view: Optional[ImageContent] = None
+
+ def save_to_directory(self, directory: str):
+ ensure_directory_exists(directory)
+ self.text_and_images.save_to_directory(directory=directory)
+ if page_view := self.page_view:
+ page_view.save_to_directory(directory=directory, base_name="page_view")
diff --git a/pipelex/core/stuff_factory.py b/pipelex/core/stuff_factory.py
new file mode 100644
index 000000000..a64b2e8bb
--- /dev/null
+++ b/pipelex/core/stuff_factory.py
@@ -0,0 +1,157 @@
+from typing import Any, Dict, List, Optional, Tuple
+
+import shortuuid
+from kajson.class_registry import class_registry
+from pydantic import BaseModel, Field
+
+from pipelex.config import get_config
+from pipelex.core.concept import Concept
+from pipelex.core.concept_native import NativeConcept
+from pipelex.core.stuff import Stuff, StuffCreationRecord
+from pipelex.core.stuff_content import StuffContent, StuffContentInitableFromStr
+from pipelex.exceptions import PipelexError
+from pipelex.hub import get_required_concept
+
+
+class StuffFactoryError(PipelexError):
+ pass
+
+
+class StuffBlueprint(BaseModel):
+ name: str
+ concept_code: str = Field(alias="concept")
+ value: str
+
+
+class StuffFactory:
+ @classmethod
+ def make_stuff_name(cls, concept_str: str) -> str:
+ return Stuff.make_stuff_name(concept_str=concept_str)
+
+ @classmethod
+ def make_stuff(
+ cls,
+ concept_code: str,
+ content: StuffContent,
+ name: Optional[str] = None,
+ code: Optional[str] = None,
+ creation_record: Optional[StuffCreationRecord] = None,
+ pipelex_session_id: Optional[str] = None,
+ ) -> Stuff:
+ if not Concept.concept_str_contains_domain(concept_str=concept_code):
+ raise StuffFactoryError(f"Concept '{concept_code}' does not contain a domain")
+ if not name:
+ name = cls.make_stuff_name(concept_code)
+ return Stuff(
+ concept_code=concept_code,
+ content=content,
+ stuff_name=name,
+ stuff_code=code or shortuuid.uuid()[:5],
+ creation_record=creation_record,
+ pipelex_session_id=pipelex_session_id or get_config().session_id,
+ )
+
+ @classmethod
+ def make_stuff_using_concept(
+ cls,
+ concept: Concept,
+ content: StuffContent,
+ name: Optional[str] = None,
+ code: Optional[str] = None,
+ creation_record: Optional[StuffCreationRecord] = None,
+ pipelex_session_id: Optional[str] = None,
+ ) -> Stuff:
+ if not name:
+ name = cls.make_stuff_name(concept_str=concept.code)
+ return Stuff(
+ concept_code=concept.code,
+ content=content,
+ stuff_name=name,
+ stuff_code=code or shortuuid.uuid()[:5],
+ creation_record=creation_record,
+ pipelex_session_id=pipelex_session_id or get_config().session_id,
+ )
+
+ @classmethod
+ def make_from_blueprint_dict(cls, blueprint_dict: Dict[str, Any]) -> "Stuff":
+ blueprint = StuffBlueprint.model_validate(obj=blueprint_dict)
+ return cls.make_from_blueprint(blueprint=blueprint)
+
+ @classmethod
+ def make_from_blueprint_str(cls, blueprint_str: str) -> "Stuff":
+ blueprint = StuffBlueprint.model_validate_json(json_data=blueprint_str)
+ return cls.make_from_blueprint(blueprint=blueprint)
+
+ @classmethod
+ def make_from_blueprint(cls, blueprint: StuffBlueprint) -> "Stuff":
+ the_stuff = cls.make_from_str(
+ concept_code=blueprint.concept_code,
+ str_value=blueprint.value,
+ name=blueprint.name,
+ pipelex_session_id="blueprint",
+ )
+ return the_stuff
+
+ @classmethod
+ def make_from_str(
+ cls,
+ concept_code: str,
+ str_value: str,
+ name: Optional[str] = None,
+ pipelex_session_id: Optional[str] = None,
+ ) -> Stuff:
+ if not Concept.concept_str_contains_domain(concept_code):
+ raise StuffFactoryError(f"Concept '{concept_code}' does not contain a domain")
+ the_concept = get_required_concept(concept_code=concept_code)
+ the_subclass_name = the_concept.structure_class_name
+ the_subclass = class_registry.get_class(name=the_subclass_name) or eval(the_subclass_name)
+ if not issubclass(the_subclass, StuffContentInitableFromStr):
+ raise StuffFactoryError(f"Concept '{concept_code}', subclass '{the_subclass}' is not InitableFromStr")
+ stuff_content: StuffContent = the_subclass.make_from_str(str_value)
+
+ if not name:
+ name = cls.make_stuff_name(concept_code)
+
+ return Stuff(
+ concept_code=concept_code,
+ content=stuff_content,
+ stuff_name=name,
+ stuff_code=shortuuid.uuid()[:5],
+ creation_record=None,
+ pipelex_session_id=pipelex_session_id or get_config().session_id,
+ )
+
+ @classmethod
+ def make_multiple_text_from_str(cls, str_text_dict: Dict[str, str]) -> List[Stuff]:
+ """
+ Make multiple stuffs from a dictionary of strings.
+ It is implied that each string value should be associated with a native.Text concept.
+ """
+ return [cls.make_from_str(concept_code=NativeConcept.TEXT.code, str_value=str_value, name=name) for name, str_value in str_text_dict.items()]
+
+ @classmethod
+ def make_multiple_stuff_from_str(cls, str_stuff_and_concepts_dict: Dict[str, Tuple[str, str]]) -> List[Stuff]:
+ """
+ Make multiple stuffs from a dictionary of strings.
+ It is implied that each string value should be associated with a native.Text concept.
+ """
+ result: List[Stuff] = []
+ for name, (concept_code, str_value) in str_stuff_and_concepts_dict.items():
+ stuff = cls.make_from_str(concept_code=concept_code, str_value=str_value, name=name)
+ result.append(stuff)
+ return result
+
+ @classmethod
+ def combine_stuffs(cls, concept_code: str, stuff_contents: Dict[str, StuffContent], name: Optional[str] = None) -> Stuff:
+ """
+ Combine a dictionary of stuffs into a single stuff.
+ """
+ the_concept = get_required_concept(concept_code=concept_code)
+ the_subclass_name = the_concept.structure_class_name
+ the_subclass = class_registry.get_required_subclass(name=the_subclass_name, base_class=StuffContent)
+ the_stuff_content = the_subclass.model_validate(obj=stuff_contents)
+ return cls.make_stuff(
+ concept_code=concept_code,
+ content=the_stuff_content,
+ name=name,
+ )
diff --git a/pipelex/core/working_memory.py b/pipelex/core/working_memory.py
new file mode 100644
index 000000000..f1a8467cf
--- /dev/null
+++ b/pipelex/core/working_memory.py
@@ -0,0 +1,348 @@
+from operator import attrgetter
+from typing import Any, Dict, List, Optional, Self, Set, Type, TypeVar
+
+from pydantic import BaseModel, Field, model_validator
+
+from pipelex import log, pretty_print
+from pipelex.core.concept_native import NativeConcept
+from pipelex.core.stuff import Stuff
+from pipelex.core.stuff_artefact import StuffArtefact
+from pipelex.core.stuff_content import (
+ HtmlContent,
+ ImageContent,
+ ListContent,
+ MermaidContent,
+ NumberContent,
+ PDFContent,
+ StuffContent,
+ StuffContentType,
+ TextAndImagesContent,
+ TextContent,
+)
+from pipelex.exceptions import WorkingMemoryError, WorkingMemoryNotFoundError, WorkingMemoryStuffNotFoundError, WorkingMemoryTypeError
+from pipelex.tools.misc.json_utils import save_as_json_to_path
+
+MAIN_STUFF_NAME = "main_stuff"
+BATCH_ITEM_STUFF_NAME = "_batch_item"
+
+StuffDict = Dict[str, Stuff]
+StuffArtefactDict = Dict[str, StuffArtefact]
+
+# Create a generic type variable
+T = TypeVar("T")
+
+
+class WorkingMemory(BaseModel):
+ root: StuffDict = Field(default_factory=dict)
+ aliases: Dict[str, str] = Field(default_factory=dict)
+
+ @model_validator(mode="after")
+ def validate_stuff_names(self) -> Self:
+ for key, stuff in self.root.items():
+ if key.startswith("_") and not key == BATCH_ITEM_STUFF_NAME:
+ log.warning(f"Stuff key '{key}' starts with '_', which is reserved for params")
+
+ if not stuff.stuff_name:
+ self.root[key].stuff_name = key
+ elif key != MAIN_STUFF_NAME and stuff.stuff_name != key:
+ log.warning(f"Stuff name '{stuff.stuff_name}' does not match the key '{key}'")
+ elif stuff.stuff_name.startswith("_") and stuff.stuff_name != BATCH_ITEM_STUFF_NAME:
+ log.warning(f"Stuff name '{stuff.stuff_name}' starts with '_', which is reserved for params")
+
+ return self
+
+ def pretty_print_summary(self):
+ for stuff in self.root.values():
+ content = stuff.content.rendered_plain()
+ if len(content) > 300:
+ content = content[:300] + "..."
+ pretty_print(content, title=f"{stuff.stuff_name} ({stuff.concept_code})")
+
+ def make_deep_copy(self) -> Self:
+ return self.model_copy(deep=True)
+
+ def generate_full_stuff_dict(self) -> StuffDict:
+ full_stuff_dict: StuffDict = self.root.copy()
+ full_stuff_dict.update({alias: self.root[target] for alias, target in self.aliases.items()})
+ return full_stuff_dict
+
+ def generate_stuff_artefact_dict(self) -> StuffArtefactDict:
+ artefact_dict: StuffArtefactDict = {}
+ for name, stuff in self.root.items():
+ artefact_dict[name] = stuff.make_artefact()
+ for alias, target in self.aliases.items():
+ artefact_dict[alias] = artefact_dict[target]
+ return artefact_dict
+
+ def get_optional_stuff(self, name: str) -> Optional[Stuff]:
+ if named_stuff := self.root.get(name):
+ return named_stuff
+ if alias := self.aliases.get(name):
+ return self.root.get(alias)
+ return None
+
+ def get_optional_main_stuff(self) -> Optional[Stuff]:
+ return self.get_optional_stuff(name=MAIN_STUFF_NAME)
+
+ # TODO: all calls to get_stuff should catch WorkingMemoryStuffNotFoundError in order to indicate what pipe is missing a required stuff
+ def get_stuff(self, name: str) -> Stuff:
+ if named_stuff := self.root.get(name):
+ return named_stuff
+ if alias := self.aliases.get(name):
+ stuff = self.root.get(alias)
+ if stuff is None:
+ raise WorkingMemoryStuffNotFoundError(f"Alias '{alias}' points to a non-existent stuff '{name}'")
+ return stuff
+ raise WorkingMemoryStuffNotFoundError(f"Stuff '{name}' not found in working memory, valid keys are: {self.list_keys()}")
+
+ def get_stuff_attribute(self, name: str, wanted_type: Optional[Type[Any]] = None) -> Any:
+ if "." in name:
+ parts = name.split(".", 1) # Split only at the first dot
+ base_name = parts[0]
+ attr_path_str = parts[1] # Keep the rest as a dot-separated string
+
+ base_stuff = self.get_stuff(base_name)
+
+ try:
+ stuff_content = attrgetter(attr_path_str)(base_stuff.content)
+ except AttributeError as exc:
+ raise WorkingMemoryNotFoundError(f"Stuff attribute not found in attribute path '{name}': {exc}") from exc
+
+ if wanted_type is not None and not isinstance(stuff_content, wanted_type):
+ raise WorkingMemoryTypeError(f"Content at '{name}' is of type {type(stuff_content).__name__}, it should be {wanted_type.__name__}")
+
+ return stuff_content
+ else:
+ content = self.get_stuff(name).content
+
+ if wanted_type is not None and not isinstance(content, wanted_type):
+ raise WorkingMemoryTypeError(f"Content of '{name}' is of type {type(content).__name__}, it should be {wanted_type.__name__}")
+
+ return content
+
+ def get_stuffs(self, names: Set[str]) -> List[Stuff]:
+ the_stuffs: List[Stuff] = []
+ for name in names:
+ the_stuffs.append(self.get_stuff(name=name))
+ return the_stuffs
+
+ def get_stuff_by_stuff_code(self, stuff_code: str) -> Stuff:
+ matching_stuffs: List[Stuff] = []
+ for stuff in self.root.values():
+ if stuff.concept_code == stuff_code:
+ matching_stuffs.append(stuff)
+ if len(matching_stuffs) == 0:
+ raise WorkingMemoryError(f"Stuff code '{stuff_code}' not found in working memory")
+ elif len(matching_stuffs) > 1:
+ raise WorkingMemoryError(f"Stuff code '{stuff_code}' is used by multiple stuffs: {matching_stuffs}")
+ return matching_stuffs[0]
+
+ def is_stuff_code_used(self, stuff_code: str) -> bool:
+ for stuff in self.root.values():
+ if stuff.concept_code == stuff_code:
+ return True
+ return False
+
+ def get_main_stuff(self) -> Stuff:
+ return self.get_stuff(name=MAIN_STUFF_NAME)
+
+ def remove_stuff(self, name: str):
+ self.root.pop(name, None)
+
+ def remove_main_stuff(self):
+ if MAIN_STUFF_NAME in self.root:
+ del self.root[MAIN_STUFF_NAME]
+
+ def set_stuff(self, name: str, stuff: Stuff):
+ self.root[name] = stuff
+
+ def add_new_stuff(self, name: str, stuff: Stuff, aliases: Optional[List[str]] = None):
+ log.debug(f"Adding new stuff '{name}' to WorkingMemory with aliases: {aliases}")
+ if self.is_stuff_code_used(stuff_code=stuff.stuff_code):
+ raise WorkingMemoryError(f"Stuff code '{stuff.stuff_code}' is already used by another stuff")
+ if name in self.root or name in self.aliases:
+ existing_stuff = self.get_stuff(name=name)
+ if existing_stuff == stuff:
+ log.warning(f"Key '{name}' already exists in WorkingMemory with the same stuff")
+ return
+ else:
+ log.warning(f"Key '{name}' already exists in WorkingMemory and will be replaced by something different")
+ log.verbose(f"Existing stuff: {existing_stuff}")
+ log.verbose(f"New stuff: {stuff}")
+
+ # it's a new stuff
+ self.set_stuff(name=name, stuff=stuff)
+ if aliases:
+ for alias in aliases:
+ self.set_alias(alias, name)
+
+ def set_new_main_stuff(self, stuff: Stuff, name: Optional[str] = None):
+ if name:
+ self.remove_main_stuff()
+ self.add_new_stuff(name=name, stuff=stuff, aliases=[MAIN_STUFF_NAME])
+ log.verbose(f"Setting new main stuff {name}: {stuff.concept_code} = '{stuff.short_desc}'")
+ log.verbose(stuff.content.rendered_plain())
+ else:
+ self.remove_alias_to_main_stuff()
+ self.set_stuff(name=MAIN_STUFF_NAME, stuff=stuff)
+ log.verbose(f"Setting new main stuff (unnamed): {stuff.concept_code} = '{stuff.short_desc}'")
+
+ def set_alias(self, alias: str, target: str) -> None:
+ """Add an alias pointing to a target name."""
+ if alias == target:
+ raise WorkingMemoryError(f"Cannot create alias '{alias}' pointing to itself")
+ if target not in self.root:
+ raise WorkingMemoryError(f"Cannot create alias to non-existent target '{target}'")
+ log.debug(f"Setting alias '{alias}' pointing to target '{target}'")
+ self.aliases[alias] = target
+
+ def add_alias(self, alias: str, target: str) -> None:
+ """Add an alias pointing to a target name."""
+ if alias in self.root:
+ raise WorkingMemoryError(f"Cannot add alias '{alias}' as it already exists")
+ self.set_alias(alias=alias, target=target)
+ log.debug(f"Added alias '{alias}' pointing to target '{target}'")
+
+ def remove_alias(self, alias: str) -> None:
+ """Remove an alias if it exists."""
+ if alias in self.aliases:
+ del self.aliases[alias]
+
+ def remove_alias_to_main_stuff(self) -> None:
+ """Remove the alias pointing to the main stuff if it exists."""
+ self.remove_alias(alias=MAIN_STUFF_NAME)
+
+ def get_aliases_for(self, target: str) -> List[str]:
+ """Get all aliases pointing to a target name."""
+ return [alias for alias, t in self.aliases.items() if t == target]
+
+ def list_keys(self) -> List[str]:
+ return list(self.root.keys()) + list(self.aliases.keys())
+
+ ################################################################################################
+ # Export methods
+ ################################################################################################
+
+ def content_dict(self) -> Dict[str, StuffContent]:
+ result = {name: stuff.content for name, stuff in self.root.items()}
+ # Include aliased content
+ result.update({alias: self.root[target].content for alias, target in self.aliases.items()})
+ return result
+
+ def pretty_print(self):
+ for name, stuff in self.root.items():
+ pretty_print(stuff.content.rendered_plain(), title=f"{name}: {stuff.concept_code}")
+
+ def update_from_strings_from_dict(self, context_dict: Dict[str, Any]) -> "WorkingMemory":
+ update_stuff_dict: StuffDict = {}
+ for name, str_content in context_dict.items():
+ if not isinstance(str_content, str):
+ continue
+ stuff_content: StuffContent
+ if str_content.startswith("http"):
+ if ".png" in str_content or ".jpg" in str_content or ".jpeg" in str_content:
+ stuff_content = ImageContent(url=str_content)
+ else:
+ log.warning(f"Skipping unknown URL content: {str_content}")
+ continue
+ else:
+ stuff_content = TextContent(text=str_content)
+ update_stuff_dict[name] = Stuff(
+ stuff_name=name,
+ stuff_code="",
+ concept_code=NativeConcept.TEXT.code,
+ content=stuff_content,
+ )
+ self.root.update(update_stuff_dict)
+ return self
+
+ def save_to_memory_file(self, memory_file_path: str):
+ save_as_json_to_path(self.model_dump(serialize_as_any=True), memory_file_path)
+
+ ################################################################################################
+ # Stuff accessors
+ ################################################################################################
+
+ def get_stuff_as(self, name: str, content_type: Type[StuffContentType]) -> StuffContentType:
+ """Get stuff content as StuffContentType."""
+ return self.get_stuff(name=name).content_as(content_type=content_type)
+
+ def get_stuff_as_list(self, name: str, item_type: Type[StuffContentType]) -> ListContent[StuffContentType]:
+ """
+ Get stuff content as ListContent with items of type StuffContentType.
+ If the items are of possibly various types, use item_type=StuffContent.
+ """
+ return self.get_stuff(name=name).as_list_of_fixed_content_type(item_type=item_type)
+
+ def get_stuff_as_text(self, name: str) -> TextContent:
+ """Get stuff content as TextContent if applicable."""
+ return self.get_stuff(name=name).as_text
+
+ def get_stuff_as_image(self, name: str) -> ImageContent:
+ """Get stuff content as ImageContent if applicable."""
+ return self.get_stuff(name=name).as_image
+
+ def get_stuff_as_text_and_image(self, name: str) -> TextAndImagesContent:
+ """Get stuff content as TextAndImageContent if applicable."""
+ return self.get_stuff(name=name).as_text_and_image
+
+ def get_stuff_as_pdf(self, name: str) -> PDFContent:
+ """Get stuff content as PDFContent if applicable."""
+ return self.get_stuff(name=name).as_pdf
+
+ def get_stuff_as_number(self, name: str) -> NumberContent:
+ """Get stuff content as NumberContent if applicable."""
+ return self.get_stuff(name=name).as_number
+
+ def get_stuff_as_html(self, name: str) -> HtmlContent:
+ """Get stuff content as HtmlContent if applicable."""
+ return self.get_stuff(name=name).as_html
+
+ def get_stuff_as_mermaid(self, name: str) -> MermaidContent:
+ """Get stuff content as MermaidContent if applicable."""
+ return self.get_stuff(name=name).as_mermaid
+
+ ################################################################################################
+ # Main stuff accessors
+ ################################################################################################
+
+ def main_stuff_as(self, content_type: Type[StuffContentType]) -> StuffContentType:
+ """Get main stuff content as StuffContentType."""
+ return self.get_stuff_as(name=MAIN_STUFF_NAME, content_type=content_type)
+
+ def main_stuff_as_list(self, item_type: Type[StuffContentType]) -> ListContent[StuffContentType]:
+ """
+ Get main stuff content as ListContent with items of type StuffContentType.
+ If the items are of possibly various types, use item_type=StuffContent.
+ """
+ return self.get_stuff_as_list(name=MAIN_STUFF_NAME, item_type=item_type)
+
+ @property
+ def main_stuff_as_text(self) -> TextContent:
+ """Get main stuff content as TextContent if applicable."""
+ return self.get_stuff_as_text(name=MAIN_STUFF_NAME)
+
+ @property
+ def main_stuff_as_image(self) -> ImageContent:
+ """Get main stuff content as ImageContent if applicable."""
+ return self.get_stuff_as_image(name=MAIN_STUFF_NAME)
+
+ @property
+ def main_stuff_as_text_and_image(self) -> TextAndImagesContent:
+ """Get main stuff content as TextAndImageContent if applicable."""
+ return self.get_stuff_as_text_and_image(name=MAIN_STUFF_NAME)
+
+ @property
+ def main_stuff_as_number(self) -> NumberContent:
+ """Get main stuff content as NumberContent if applicable."""
+ return self.get_stuff_as_number(name=MAIN_STUFF_NAME)
+
+ @property
+ def main_stuff_as_html(self) -> HtmlContent:
+ """Get main stuff content as HtmlContent if applicable."""
+ return self.get_stuff_as_html(name=MAIN_STUFF_NAME)
+
+ @property
+ def main_stuff_as_mermaid(self) -> MermaidContent:
+ """Get main stuff content as MermaidContent if applicable."""
+ return self.get_stuff_as_mermaid(name=MAIN_STUFF_NAME)
diff --git a/pipelex/core/working_memory_factory.py b/pipelex/core/working_memory_factory.py
new file mode 100644
index 000000000..e3b8d87e3
--- /dev/null
+++ b/pipelex/core/working_memory_factory.py
@@ -0,0 +1,122 @@
+from typing import Any, Dict, List, Optional
+
+from pydantic import BaseModel
+
+from pipelex.core.concept_native import NativeConcept
+from pipelex.core.stuff import Stuff
+from pipelex.core.stuff_content import ImageContent, PDFContent, TextContent
+from pipelex.core.stuff_factory import StuffBlueprint, StuffFactory
+from pipelex.core.working_memory import MAIN_STUFF_NAME, StuffDict, WorkingMemory
+from pipelex.exceptions import WorkingMemoryError
+from pipelex.tools.misc.json_utils import load_json_dict_from_path
+
+
+class WorkingMemoryFactory(BaseModel):
+ @classmethod
+ def make_from_text(
+ cls,
+ text: str,
+ concept_code: str = NativeConcept.TEXT.code,
+ name: Optional[str] = "text",
+ ) -> WorkingMemory:
+ stuff = StuffFactory.make_stuff(
+ concept_code=concept_code,
+ content=TextContent(text=text),
+ name=name,
+ )
+ return cls.make_from_single_stuff(stuff=stuff)
+
+ @classmethod
+ def make_from_image(
+ cls,
+ image_url: str,
+ concept_code: str = NativeConcept.IMAGE.code,
+ name: Optional[str] = "image",
+ ) -> WorkingMemory:
+ stuff = StuffFactory.make_stuff(
+ concept_code=concept_code,
+ content=ImageContent(url=image_url),
+ name=name,
+ )
+ return cls.make_from_single_stuff(stuff=stuff)
+
+ @classmethod
+ def make_from_pdf(
+ cls,
+ pdf_url: str,
+ concept_code: str = NativeConcept.PDF.code,
+ name: Optional[str] = "pdf",
+ ) -> WorkingMemory:
+ stuff = StuffFactory.make_stuff(
+ concept_code=concept_code,
+ content=PDFContent(url=pdf_url),
+ name=name,
+ )
+ return cls.make_from_single_stuff(stuff=stuff)
+
+ @classmethod
+ def make_from_stuff_and_name(cls, stuff: Stuff, name: str) -> WorkingMemory:
+ stuff_dict: StuffDict = {name: stuff}
+ aliases: Dict[str, str] = {MAIN_STUFF_NAME: name}
+ return WorkingMemory(root=stuff_dict, aliases=aliases)
+
+ @classmethod
+ def make_from_single_blueprint(cls, blueprint: StuffBlueprint) -> WorkingMemory:
+ stuff = StuffFactory.make_from_blueprint(blueprint=blueprint)
+ return cls.make_from_single_stuff(stuff=stuff)
+
+ @classmethod
+ def make_from_single_stuff(cls, stuff: Stuff) -> WorkingMemory:
+ name = stuff.stuff_name
+ if not name:
+ raise WorkingMemoryError(f"Cannot make_from_single_stuff because stuff has no name: {stuff}")
+ return cls.make_from_stuff_and_name(stuff=stuff, name=name)
+
+ @classmethod
+ def make_from_multiple_stuffs(
+ cls,
+ stuff_list: List[Stuff],
+ main_name: Optional[str] = None,
+ is_ignore_unnamed: bool = False,
+ ) -> WorkingMemory:
+ stuff_dict: StuffDict = {}
+ for stuff in stuff_list:
+ name = stuff.stuff_name
+ if not name:
+ if is_ignore_unnamed:
+ continue
+ else:
+ raise WorkingMemoryError(f"Stuff {stuff} has no name")
+ stuff_dict[name] = stuff
+ aliases: Dict[str, str] = {}
+ if stuff_dict:
+ if main_name:
+ aliases[MAIN_STUFF_NAME] = main_name
+ else:
+ aliases[MAIN_STUFF_NAME] = list(stuff_dict.keys())[0]
+ return WorkingMemory(root=stuff_dict, aliases=aliases)
+
+ @classmethod
+ def make_from_strings_from_dict(cls, input_dict: Dict[str, Any]) -> WorkingMemory:
+ stuff_dict: StuffDict = {}
+ for name, content in input_dict.items():
+ if not isinstance(content, str):
+ continue
+ text_content = TextContent(text=content)
+ stuff_dict[name] = Stuff(
+ stuff_name=name,
+ stuff_code="",
+ concept_code=NativeConcept.TEXT.code,
+ content=text_content,
+ )
+ return WorkingMemory(root=stuff_dict)
+
+ @classmethod
+ def make_empty(cls) -> WorkingMemory:
+ return WorkingMemory(root={})
+
+ @classmethod
+ def make_from_memory_file(cls, memory_file_path: str) -> WorkingMemory:
+ working_memory_dict = load_json_dict_from_path(memory_file_path)
+ working_memory = WorkingMemory.model_validate(working_memory_dict)
+ return working_memory
diff --git a/pipelex/exceptions.py b/pipelex/exceptions.py
new file mode 100644
index 000000000..3b7dae1f7
--- /dev/null
+++ b/pipelex/exceptions.py
@@ -0,0 +1,163 @@
+from pipelex.tools.exceptions import RootException
+
+
+class PipelexError(RootException):
+ pass
+
+
+class PipelexConfigError(PipelexError):
+ pass
+
+
+class PipelexSetupError(PipelexError):
+ pass
+
+
+class ClientAuthenticationError(PipelexError):
+ pass
+
+
+class DomainDefinitionError(PipelexError):
+ pass
+
+
+class DomainLibraryError(PipelexError):
+ pass
+
+
+class ConceptLibraryError(PipelexError):
+ pass
+
+
+class ConceptLibraryConceptNotFoundError(PipelexError):
+ pass
+
+
+class ConceptFactoryError(PipelexError):
+ pass
+
+
+class PipeLibraryError(PipelexError):
+ pass
+
+
+class PipeLibraryPipeNotFoundError(PipelexError):
+ pass
+
+
+class PipeFactoryError(PipelexError):
+ pass
+
+
+class LibraryError(PipelexError):
+ pass
+
+
+class LibraryParsingError(PipelexError):
+ pass
+
+
+class PipeDefinitionError(PipelexError):
+ pass
+
+
+class WorkingMemoryError(PipelexError):
+ pass
+
+
+class WorkingMemoryTypeError(WorkingMemoryError):
+ pass
+
+
+class WorkingMemoryNotFoundError(WorkingMemoryError):
+ pass
+
+
+class WorkingMemoryStuffNotFoundError(WorkingMemoryNotFoundError):
+ pass
+
+
+class StuffError(PipelexError):
+ pass
+
+
+class PipeExecutionError(PipelexError):
+ pass
+
+
+class PipeRunError(PipeExecutionError):
+ pass
+
+
+class PipeStackOverflowError(PipeExecutionError):
+ pass
+
+
+class PipeConditionError(PipelexError):
+ pass
+
+
+class StructureClassError(PipelexError):
+ pass
+
+
+class PipeRunParamsError(PipelexError):
+ pass
+
+
+class PipeBatchError(PipelexError):
+ """Base class for all PipeBatch-related errors."""
+
+ pass
+
+
+class PipeBatchRecursionError(PipeBatchError):
+ """Raised when a PipeBatch attempts to run itself recursively."""
+
+ pass
+
+
+class PipeBatchInputError(PipeBatchError):
+ """Raised when the input to a PipeBatch is not a ListContent or is invalid."""
+
+ pass
+
+
+class PipeBatchOutputError(PipeBatchError):
+ """Raised when there's an error with the output structure of a PipeBatch operation."""
+
+ pass
+
+
+class PipeBatchBranchError(PipeBatchError):
+ """Raised when there's an error with a branch pipe execution in PipeBatch."""
+
+ pass
+
+
+class JobHistoryError(PipelexError):
+ pass
+
+
+class PipeInputError(PipelexError):
+ pass
+
+
+class StuffArtefactError(PipelexError):
+ pass
+
+
+class ConceptError(Exception):
+ pass
+
+
+class ConceptCodeError(ConceptError):
+ pass
+
+
+class ConceptDomainError(ConceptError):
+ pass
+
+
+class MissionManagerNotFoundError(PipelexError):
+ pass
diff --git a/pipelex/hub.py b/pipelex/hub.py
new file mode 100644
index 000000000..015d8e6e0
--- /dev/null
+++ b/pipelex/hub.py
@@ -0,0 +1,426 @@
+from collections import defaultdict
+from typing import ClassVar, Dict, List, Optional, Type
+
+from pipelex import log
+from pipelex.cogt.content_generation.content_generator_protocol import ContentGeneratorProtocol
+from pipelex.cogt.imgg.imgg_worker_abstract import ImggWorkerAbstract
+from pipelex.cogt.inference.inference_manager_protocol import InferenceManagerProtocol
+from pipelex.cogt.inference.inference_report_delegate import InferenceReportDelegate
+from pipelex.cogt.llm.llm_models.llm_deck_abstract import LLMDeckAbstract
+from pipelex.cogt.llm.llm_models.llm_engine_blueprint import LLMEngineBlueprint
+from pipelex.cogt.llm.llm_models.llm_model_provider_abstract import LLMModelProviderAbstract
+from pipelex.cogt.llm.llm_worker_abstract import LLMWorkerAbstract
+from pipelex.cogt.ocr.ocr_worker_abstract import OcrWorkerAbstract
+from pipelex.cogt.plugin_manager import PluginManager
+from pipelex.core.concept import Concept
+from pipelex.core.concept_provider_abstract import ConceptProviderAbstract
+from pipelex.core.domain import Domain
+from pipelex.core.domain_provider_abstract import DomainProviderAbstract
+from pipelex.core.pipe_abstract import PipeAbstract
+from pipelex.core.pipe_provider_abstract import PipeProviderAbstract
+from pipelex.mission.activity.activity_manager_protocol import ActivityManagerProtocol
+from pipelex.mission.mission import Mission
+from pipelex.mission.mission_manager_abstract import MissionManagerAbstract
+from pipelex.mission.track.mission_tracker_protocol import MissionTrackerProtocol
+from pipelex.pipe_works.pipe_router_protocol import PipeRouterProtocol
+from pipelex.tools.config.manager import config_manager
+from pipelex.tools.config.models import ConfigRoot
+from pipelex.tools.secrets.secrets_provider_abstract import SecretsProviderAbstract
+from pipelex.tools.templating.template_provider_abstract import TemplateProviderAbstract
+
+
+class PipelexHub:
+ """
+ PipelexHub serves as a central dependency manager to break cyclic imports between components.
+ It provides access to core providers and factories through a singleton instance,
+ allowing components to retrieve dependencies based on protocols without direct imports that could create cycles.
+ """
+
+ _instance: ClassVar[Optional["PipelexHub"]] = None
+
+ def __init__(self):
+ # tools
+ self._config: Optional[ConfigRoot] = None
+ self._secrets_provider: Optional[SecretsProviderAbstract] = None
+ self._template_provider: Optional[TemplateProviderAbstract] = None
+ # cogt
+ self._llm_models_provider: Optional[LLMModelProviderAbstract] = None
+ self._llm_deck_provider: Optional[LLMDeckAbstract] = None
+ self._plugin_manager: Optional[PluginManager] = None
+ self._inference_manager: InferenceManagerProtocol
+ self._report_delegate: InferenceReportDelegate
+ self._content_generator: Optional[ContentGeneratorProtocol] = None
+
+ # pipelex
+ self._domain_provider: Optional[DomainProviderAbstract] = None
+ self._concept_provider: Optional[ConceptProviderAbstract] = None
+ self._pipe_provider: Optional[PipeProviderAbstract] = None
+ self._pipe_router: Optional[PipeRouterProtocol] = None
+
+ # mission
+ self._mission_tracker: Optional[MissionTrackerProtocol] = None
+ self._mission_manager: Optional[MissionManagerAbstract] = None
+ self._activity_manager: Optional[ActivityManagerProtocol] = None
+
+ ############################################################
+ # Class methods for singleton management
+ ############################################################
+
+ @classmethod
+ def get_instance(cls) -> "PipelexHub":
+ if cls._instance is None:
+ raise RuntimeError("PipelexHub is not initialized")
+ return cls._instance
+
+ @classmethod
+ def set_instance(cls, pipelex_hub: "PipelexHub") -> None:
+ cls._instance = pipelex_hub
+
+ ############################################################
+ # Setters
+ ############################################################
+
+ # tools
+
+ def setup_config(self, config_cls: Type[ConfigRoot]):
+ """
+ Set the global configuration instance.
+
+ # Args:
+ # config (Config): The configuration instance to set.
+ """
+ config = config_manager.load_config()
+ config["project_name"] = config_manager.get_project_name()
+ self.set_config(config=config_cls.model_validate(config))
+
+ def set_config(self, config: ConfigRoot):
+ if self._config is not None:
+ log.warning(f"set_config() got called but {self._config.project_name} config has already been set")
+ return
+ self._config = config
+
+ def reset_config(self) -> None:
+ """
+ Reset the global configuration instance and the config manager.
+ """
+ self._config = None
+ log.reset()
+
+ def set_secrets_provider(self, secrets_provider: SecretsProviderAbstract):
+ self._secrets_provider = secrets_provider
+
+ def set_template_provider(self, template_provider: TemplateProviderAbstract):
+ self._template_provider = template_provider
+
+ # cogt
+
+ def set_llm_models_provider(self, llm_models_provider: LLMModelProviderAbstract):
+ self._llm_models_provider = llm_models_provider
+
+ def set_llm_deck_provider(self, llm_deck_provider: LLMDeckAbstract):
+ self._llm_deck_provider = llm_deck_provider
+
+ def set_plugin_manager(self, plugin_manager: PluginManager):
+ self._plugin_manager = plugin_manager
+
+ def set_inference_manager(self, inference_manager: InferenceManagerProtocol):
+ self._inference_manager = inference_manager
+
+ def set_report_delegate(self, report_delegate: InferenceReportDelegate):
+ self._report_delegate = report_delegate
+
+ def set_content_generator(self, content_generator: ContentGeneratorProtocol):
+ self._content_generator = content_generator
+
+ # pipelex
+
+ def set_domain_provider(self, domain_provider: DomainProviderAbstract):
+ self._domain_provider = domain_provider
+
+ def set_concept_provider(self, concept_provider: ConceptProviderAbstract):
+ self._concept_provider = concept_provider
+
+ def set_pipe_provider(self, pipe_provider: PipeProviderAbstract):
+ self._pipe_provider = pipe_provider
+
+ def set_pipe_router(self, pipe_router: PipeRouterProtocol):
+ self._pipe_router = pipe_router
+
+ def set_mission_tracker(self, mission_tracker: MissionTrackerProtocol):
+ self._mission_tracker = mission_tracker
+
+ def set_mission_manager(self, mission_manager: MissionManagerAbstract):
+ self._mission_manager = mission_manager
+
+ def set_activity_manager(self, activity_manager: ActivityManagerProtocol):
+ self._activity_manager = activity_manager
+
+ ############################################################
+ # Getters
+ ############################################################
+
+ # tools
+
+ def get_required_config(self) -> ConfigRoot:
+ """
+ Get the current configuration instance as an instance of a particular subclass of ConfigRoot. This should be used only from pipelex.tools.
+ when getting the config from other projects, use their own project.get_config() method to get the Config
+ with the proper subclass which is required for proper type checking.
+
+ Returns:
+ Config: The current configuration instance.
+
+ Raises:
+ RuntimeError: If the configuration has not been set.
+ """
+ if self._config is None:
+ raise RuntimeError("Config instance is not set. You must initialize Pipelex first.")
+ return self._config
+
+ def get_required_secrets_provider(self) -> SecretsProviderAbstract:
+ if self._secrets_provider is None:
+ raise RuntimeError("Secrets provider is not set. You must initialize Pipelex first.")
+ return self._secrets_provider
+
+ def get_required_template_provider(self) -> TemplateProviderAbstract:
+ if self._template_provider is None:
+ raise RuntimeError("Template provider is not set. You must initialize Pipelex first.")
+ return self._template_provider
+
+ # cogt
+
+ def get_required_llm_models_provider(self) -> LLMModelProviderAbstract:
+ if self._llm_models_provider is None:
+ raise RuntimeError("LLMModelProvider is not initialized")
+ return self._llm_models_provider
+
+ def get_optional_llm_models_provider(self) -> Optional[LLMModelProviderAbstract]:
+ return self._llm_models_provider
+
+ def get_required_llm_deck(self) -> LLMDeckAbstract:
+ if self._llm_deck_provider is None:
+ raise RuntimeError("LLMDeck is not initialized")
+ return self._llm_deck_provider
+
+ def get_plugin_manager(self) -> PluginManager:
+ if self._plugin_manager is None:
+ raise RuntimeError("SdkManager is not initialized")
+ return self._plugin_manager
+
+ def get_inference_manager(self) -> InferenceManagerProtocol:
+ return self._inference_manager
+
+ def get_report_delegate(self) -> InferenceReportDelegate:
+ return self._report_delegate
+
+ def get_required_content_generator(self) -> ContentGeneratorProtocol:
+ if self._content_generator is None:
+ raise RuntimeError("ContentGenerator is not initialized")
+ return self._content_generator
+
+ # pipelex
+
+ def get_required_domain_provider(self) -> DomainProviderAbstract:
+ if self._domain_provider is None:
+ raise RuntimeError("DomainProvider is not initialized")
+ return self._domain_provider
+
+ def get_optional_domain_provider(self) -> Optional[DomainProviderAbstract]:
+ return self._domain_provider
+
+ def get_required_concept_provider(self) -> ConceptProviderAbstract:
+ if self._concept_provider is None:
+ raise RuntimeError("ConceptProvider is not initialized")
+ return self._concept_provider
+
+ def get_optional_concept_provider(self) -> Optional[ConceptProviderAbstract]:
+ return self._concept_provider
+
+ def get_required_pipe_provider(self) -> PipeProviderAbstract:
+ if self._pipe_provider is None:
+ raise RuntimeError("PipeProvider is not initialized")
+ return self._pipe_provider
+
+ def get_required_pipe_router(self) -> PipeRouterProtocol:
+ if self._pipe_router is None:
+ raise RuntimeError("PipeRouter is not initialized")
+ return self._pipe_router
+
+ def get_mission_tracker(self) -> MissionTrackerProtocol:
+ if self._mission_tracker is None:
+ raise RuntimeError("MissionTracker is not initialized")
+ return self._mission_tracker
+
+ def get_required_mission_manager(self) -> MissionManagerAbstract:
+ if self._mission_manager is None:
+ raise RuntimeError("MissionManager is not initialized")
+ return self._mission_manager
+
+ def get_activity_manager(self) -> ActivityManagerProtocol:
+ if self._activity_manager is None:
+ raise RuntimeError("ActivityManager is not initialized")
+ return self._activity_manager
+
+
+# Shorthand functions for accessing the singleton
+
+
+def get_pipelex_hub() -> PipelexHub:
+ return PipelexHub.get_instance()
+
+
+def set_pipelex_hub(pipelex_hub: PipelexHub):
+ PipelexHub.set_instance(pipelex_hub)
+
+
+# root convenience functions
+
+# tools
+
+
+def get_required_config() -> ConfigRoot:
+ return get_pipelex_hub().get_required_config()
+
+
+def get_secrets_provider() -> SecretsProviderAbstract:
+ return get_pipelex_hub().get_required_secrets_provider()
+
+
+def get_template_provider() -> TemplateProviderAbstract:
+ return get_pipelex_hub().get_required_template_provider()
+
+
+def get_template(template_name: str) -> str:
+ return get_template_provider().get_template(template_name=template_name)
+
+
+# cogt
+
+
+def get_llm_models_provider() -> LLMModelProviderAbstract:
+ return get_pipelex_hub().get_required_llm_models_provider()
+
+
+def get_llm_deck() -> LLMDeckAbstract:
+ return get_pipelex_hub().get_required_llm_deck()
+
+
+def get_plugin_manager() -> PluginManager:
+ return get_pipelex_hub().get_plugin_manager()
+
+
+def get_inference_manager() -> InferenceManagerProtocol:
+ return get_pipelex_hub().get_inference_manager()
+
+
+def get_llm_worker(
+ llm_handle: str,
+ specific_llm_engine_blueprint: Optional[LLMEngineBlueprint] = None,
+) -> LLMWorkerAbstract:
+ return get_inference_manager().get_llm_worker(
+ llm_handle=llm_handle,
+ specific_llm_engine_blueprint=specific_llm_engine_blueprint,
+ )
+
+
+def get_imgg_worker(
+ imgg_handle: str,
+) -> ImggWorkerAbstract:
+ return get_inference_manager().get_imgg_worker(imgg_handle=imgg_handle)
+
+
+def get_ocr_worker(
+ ocr_handle: str,
+) -> OcrWorkerAbstract:
+ return get_inference_manager().get_ocr_worker(ocr_handle=ocr_handle)
+
+
+def get_report_delegate() -> InferenceReportDelegate:
+ return get_pipelex_hub().get_report_delegate()
+
+
+def get_content_generator() -> ContentGeneratorProtocol:
+ return get_pipelex_hub().get_required_content_generator()
+
+
+# pipelex
+
+
+def get_secret(secret_id: str) -> str:
+ return get_secrets_provider().get_secret(secret_id=secret_id)
+
+
+def get_domain_provider() -> DomainProviderAbstract:
+ return get_pipelex_hub().get_required_domain_provider()
+
+
+def get_domains(excluded_domains: Optional[List[str]] = None) -> List[Domain]:
+ domains = get_pipelex_hub().get_required_domain_provider().get_domains()
+ if excluded_domains:
+ domains = [domain for domain in domains if domain.code not in excluded_domains]
+ return domains
+
+
+def get_required_domain(domain_code: str) -> Domain:
+ return get_pipelex_hub().get_required_domain_provider().get_required_domain(domain_code=domain_code)
+
+
+def get_optional_domain(domain_code: str) -> Optional[Domain]:
+ if domain_provider := get_pipelex_hub().get_optional_domain_provider():
+ return domain_provider.get_domain(domain_code=domain_code)
+ else:
+ return None
+
+
+def get_pipe_provider() -> PipeProviderAbstract:
+ return get_pipelex_hub().get_required_pipe_provider()
+
+
+def get_pipes_by_domain(excluded_domains: Optional[List[str]] = None) -> Dict[str, List[str]]:
+ pipes = get_pipe_provider().get_pipes()
+ pipes_by_domain: Dict[str, List[str]] = defaultdict(list)
+ for pipe in pipes:
+ if excluded_domains and pipe.domain in excluded_domains:
+ continue
+ pipes_by_domain[pipe.domain].append(pipe.code)
+ return pipes_by_domain
+
+
+def get_required_pipe(pipe_code: str) -> PipeAbstract:
+ return get_pipelex_hub().get_required_pipe_provider().get_required_pipe(pipe_code=pipe_code)
+
+
+def get_optional_pipe(pipe_code: str) -> Optional[PipeAbstract]:
+ return get_pipelex_hub().get_required_pipe_provider().get_optional_pipe(pipe_code=pipe_code)
+
+
+def get_concept_provider() -> ConceptProviderAbstract:
+ return get_pipelex_hub().get_required_concept_provider()
+
+
+def get_optional_concept_provider() -> Optional[ConceptProviderAbstract]:
+ return get_pipelex_hub().get_optional_concept_provider()
+
+
+def get_required_concept(concept_code: str) -> Concept:
+ return get_pipelex_hub().get_required_concept_provider().get_required_concept(concept_code=concept_code)
+
+
+def get_pipe_router() -> PipeRouterProtocol:
+ return get_pipelex_hub().get_required_pipe_router()
+
+
+def get_mission_tracker() -> MissionTrackerProtocol:
+ return get_pipelex_hub().get_mission_tracker()
+
+
+def get_mission_manager() -> MissionManagerAbstract:
+ return get_pipelex_hub().get_required_mission_manager()
+
+
+def get_activity_manager() -> ActivityManagerProtocol:
+ return get_pipelex_hub().get_activity_manager()
+
+
+def get_mission(mission_id: str) -> Mission:
+ return get_mission_manager().get_mission(mission_id=mission_id)
diff --git a/pipelex/libraries/__init__.py b/pipelex/libraries/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/pipelex/libraries/__init__.py
@@ -0,0 +1 @@
+
diff --git a/pipelex/libraries/library_config.py b/pipelex/libraries/library_config.py
new file mode 100644
index 000000000..03736eaa2
--- /dev/null
+++ b/pipelex/libraries/library_config.py
@@ -0,0 +1,86 @@
+from typing import ClassVar, List
+
+from pipelex.tools.config.models import ConfigModel
+from pipelex.tools.misc.file_utils import copy_file_from_package, copy_folder_from_package, find_files_in_dir
+
+
+class LibraryConfig(ConfigModel):
+ # Class variables
+ package_name: ClassVar[str] = "pipelex"
+ internal_library_root: ClassVar[str] = "libraries"
+ exported_library_root: ClassVar[str] = "pipelex_libraries"
+ internal_base_pipelines_path: ClassVar[str] = f"{internal_library_root}/pipelines"
+ exported_pipelines_path: ClassVar[str] = f"{exported_library_root}/pipelines"
+ exported_base_pipelines_path: ClassVar[str] = f"{exported_library_root}/pipelines/base_library"
+ loaded_pipelines_path: ClassVar[str] = f"{exported_library_root}/pipelines"
+ test_pipelines_path: ClassVar[str] = "tests/test_pipelines"
+ internal_llm_integrations_path: ClassVar[str] = f"{internal_library_root}/llm_integrations"
+ exported_llm_integrations_path: ClassVar[str] = f"{exported_library_root}/llm_integrations"
+ internal_llm_deck_path: ClassVar[str] = f"{internal_library_root}/llm_deck"
+ exported_llm_deck_path: ClassVar[str] = f"{exported_library_root}/llm_deck"
+ internal_templates_path: ClassVar[str] = f"{internal_library_root}/templates"
+ exported_templates_path: ClassVar[str] = f"{exported_library_root}/templates"
+
+ @classmethod
+ def get_llm_deck_paths(cls) -> List[str]:
+ llm_deck_paths = [str(path) for path in find_files_in_dir(dir_path=cls.exported_llm_deck_path, pattern="*.toml", is_recursive=True)]
+ llm_deck_paths.sort()
+ return llm_deck_paths
+
+ @classmethod
+ def get_templates_paths(cls) -> List[str]:
+ return [str(path) for path in find_files_in_dir(dir_path=cls.exported_templates_path, pattern="*.toml", is_recursive=True)]
+
+ @classmethod
+ def export_libraries(cls, overwrite: bool = False) -> None:
+ """Duplicate pipelex libraries files in the client project, preserving directory structure."""
+ # pipelines
+ copy_folder_from_package(
+ package_name=cls.package_name,
+ folder_path_in_package=cls.internal_base_pipelines_path,
+ target_dir=cls.exported_base_pipelines_path,
+ overwrite=overwrite,
+ )
+ copy_file_from_package(
+ package_name=cls.package_name,
+ file_path_in_package=f"{cls.internal_library_root}/__init__.py",
+ target_path=f"{cls.exported_library_root}/__init__.py",
+ overwrite=overwrite,
+ )
+ copy_file_from_package(
+ package_name=cls.package_name,
+ file_path_in_package=f"{cls.internal_base_pipelines_path}/__init__.py",
+ target_path=f"{cls.exported_pipelines_path}/__init__.py",
+ overwrite=overwrite,
+ )
+ copy_file_from_package(
+ package_name=cls.package_name,
+ file_path_in_package=f"{cls.internal_base_pipelines_path}/__init__.py",
+ target_path=f"{cls.exported_base_pipelines_path}/__init__.py",
+ overwrite=overwrite,
+ )
+
+ # llm_integrations
+ copy_folder_from_package(
+ package_name=cls.package_name,
+ folder_path_in_package=cls.internal_llm_integrations_path,
+ target_dir=cls.exported_llm_integrations_path,
+ overwrite=overwrite,
+ )
+
+ # llm_deck
+ copy_folder_from_package(
+ package_name=cls.package_name,
+ folder_path_in_package=cls.internal_llm_deck_path,
+ target_dir=cls.exported_llm_deck_path,
+ overwrite=overwrite,
+ non_overwrite_files=["overrides.toml"],
+ )
+
+ # templates
+ copy_folder_from_package(
+ package_name=cls.package_name,
+ folder_path_in_package=cls.internal_templates_path,
+ target_dir=cls.exported_templates_path,
+ overwrite=overwrite,
+ )
diff --git a/pipelex/libraries/library_manager.py b/pipelex/libraries/library_manager.py
new file mode 100644
index 000000000..ff810bff3
--- /dev/null
+++ b/pipelex/libraries/library_manager.py
@@ -0,0 +1,267 @@
+from enum import StrEnum
+from pathlib import Path
+from typing import Any, ClassVar, Dict, List, Optional, Type
+
+from kajson.class_registry import class_registry
+from kajson.exceptions import ClassRegistryInheritanceError, ClassRegistryNotFoundError
+from pydantic import ValidationError
+
+from pipelex import log
+from pipelex.cogt.llm.llm_models.llm_deck import LLMDeck
+from pipelex.core.concept_factory import ConceptFactory
+from pipelex.core.concept_library import ConceptLibrary
+from pipelex.core.concept_native import NativeConcept
+from pipelex.core.domain import Domain
+from pipelex.core.domain_library import DomainLibrary
+from pipelex.core.pipe_abstract import PipeAbstract
+from pipelex.core.pipe_blueprint import PipeSpecificFactoryProtocol
+from pipelex.core.pipe_library import PipeLibrary
+from pipelex.exceptions import ConceptLibraryError, LibraryError, LibraryParsingError, PipeFactoryError, PipeLibraryError
+from pipelex.libraries.library_config import LibraryConfig
+from pipelex.tools.misc.file_utils import find_files_in_dir
+from pipelex.tools.misc.json_utils import deep_update
+from pipelex.tools.misc.toml_utils import load_toml_from_path
+from pipelex.tools.runtime_manager import runtime_manager
+from pipelex.tools.typing.pydantic_utils import format_pydantic_validation_error
+
+
+class LibraryComponent(StrEnum):
+ CONCEPT = "concept"
+ PIPE = "pipe"
+
+
+class LibraryManager:
+ allowed_root_attributes: ClassVar[List[str]] = [
+ "domain",
+ "definition",
+ "system_prompt",
+ "system_prompt_to_structure",
+ "prompt_template_to_structure",
+ ]
+
+ def __init__(self) -> None:
+ # TODO : avoid having an Option LLMDeck: regroup with model provider
+ self.llm_deck: Optional[LLMDeck] = None
+ self.domain_library = DomainLibrary()
+ self.concept_library = ConceptLibrary()
+ self.pipe_library = PipeLibrary()
+
+ def teardown(self) -> None:
+ self.llm_deck = None
+ self.pipe_library.teardown()
+ self.concept_library.teardown()
+ self.domain_library.teardown()
+
+ def load_libraries(self):
+ log.debug("LibraryManager loading separate libraries")
+
+ class_registry.register_classes_in_folder(
+ folder_path=LibraryConfig.loaded_pipelines_path,
+ )
+ library_paths = [LibraryConfig.loaded_pipelines_path]
+ if runtime_manager.is_unit_testing:
+ log.debug("Registering test pipeline structures for unit testing")
+ class_registry.register_classes_in_folder(
+ folder_path=LibraryConfig.test_pipelines_path,
+ )
+ library_paths += [LibraryConfig.test_pipelines_path]
+
+ native_concepts = NativeConcept.all_concepts()
+ self.concept_library.add_concepts(concepts=native_concepts)
+
+ self._load_combo_libraries(library_paths=library_paths)
+
+ def load_deck(self) -> LLMDeck:
+ llm_deck_paths = LibraryConfig.get_llm_deck_paths()
+ full_llm_deck_dict: Dict[str, Any] = {}
+
+ for llm_deck_path in llm_deck_paths:
+ llm_deck_dict = load_toml_from_path(path=llm_deck_path)
+ log.debug(f"Loaded LLM deck from {llm_deck_path}")
+ log.debug(llm_deck_dict)
+ deep_update(full_llm_deck_dict, llm_deck_dict)
+
+ self.llm_deck = LLMDeck.model_validate(full_llm_deck_dict)
+ return self.llm_deck
+
+ def _load_combo_libraries(self, library_paths: List[str]):
+ log.debug("LibraryManager loading combo libraries")
+ # Find all .toml files in the directories and their subdirectories
+ toml_file_paths: List[Path] = []
+
+ for libraries_path in library_paths:
+ # Use the existing utility function specifically for TOML files
+ found_file_paths = find_files_in_dir(
+ dir_path=libraries_path,
+ pattern="*.toml",
+ is_recursive=True,
+ )
+ if not found_file_paths:
+ log.warning(f"No TOML files found in library path: {libraries_path}")
+ toml_file_paths.extend(found_file_paths)
+
+ # First pass: load all domains
+ for toml_path in toml_file_paths:
+ library_dict = load_toml_from_path(path=str(toml_path))
+ library_name = toml_path.stem
+ domain_code = library_dict.get("domain")
+ if domain_code is None:
+ raise LibraryParsingError(f"Library '{library_name}' has no domain set")
+ domain_definition = library_dict.get("definition")
+ if domain_definition is None:
+ # we skip the domain without definition, it must be defined one and only one time in the domain library
+ continue
+ system_prompt = library_dict.get("system_prompt")
+ system_prompt_to_structure = library_dict.get("system_prompt_to_structure")
+ prompt_template_to_structure = library_dict.get("prompt_template_to_structure")
+ domain = Domain(
+ code=domain_code,
+ definition=domain_definition,
+ system_prompt=system_prompt,
+ system_prompt_to_structure=system_prompt_to_structure,
+ prompt_template_to_structure=prompt_template_to_structure,
+ )
+ self.domain_library.add_new_domain(domain=domain)
+
+ # Second pass: load all concepts
+ for toml_path in toml_file_paths:
+ nb_concepts_before = len(self.concept_library.root)
+ library_dict = load_toml_from_path(path=str(toml_path))
+ library_name = toml_path.stem
+ try:
+ self._load_library_dict(library_name=library_name, library_dict=library_dict, component_type=LibraryComponent.CONCEPT)
+ except LibraryParsingError as exc:
+ raise LibraryError(f"Error parsing library '{library_name}' at '{toml_path}': {exc}") from exc
+ nb_concepts_loaded = len(self.concept_library.root) - nb_concepts_before
+ log.verbose(f"Loaded {nb_concepts_loaded} concepts from '{toml_path.name}'")
+
+ # Third pass: load all pipes
+ for toml_path in toml_file_paths:
+ nb_pipes_before = len(self.pipe_library.root)
+ library_dict = load_toml_from_path(path=str(toml_path))
+ library_name = toml_path.stem
+ self._load_library_dict(library_name=library_name, library_dict=library_dict, component_type=LibraryComponent.PIPE)
+ nb_pipes_loaded = len(self.pipe_library.root) - nb_pipes_before
+ log.verbose(f"Loaded {nb_pipes_loaded} pipes from '{toml_path.name}'")
+
+ def _load_library_dict(self, library_name: str, library_dict: Dict[str, Any], component_type: str):
+ if domain_code := library_dict.pop("domain", None):
+ if not self.domain_library.get_domain(domain_code=domain_code):
+ raise LibraryParsingError(
+ f"Domain '{domain_code}' is has not been defined in the domain libraryn make sure it has exactlyone definition"
+ )
+ # domain is set at the root of the library
+ self._load_library_components_from_recursive_dict(domain_code=domain_code, recursive_dict=library_dict, component_type=component_type)
+ else:
+ raise LibraryParsingError(f"Library '{library_name}' has no domain set")
+
+ def _load_library_components_from_recursive_dict(self, domain_code: str, recursive_dict: Dict[str, Any], component_type: str):
+ for key, obj in recursive_dict.items():
+ # root of domain
+ if not isinstance(obj, dict):
+ if not isinstance(obj, str):
+ raise LibraryError(f"Only a dict or a string is expected at the root of domain but '{domain_code}' got type '{type(obj)}'")
+ if key not in self.allowed_root_attributes:
+ raise LibraryParsingError(f"Domain '{domain_code}' has an unexpected root attribute '{key}'")
+ continue
+
+ # definitions within the domain
+ obj_dict: Dict[str, Any] = obj
+ if key == component_type:
+ try:
+ if key == LibraryComponent.CONCEPT:
+ self._load_concepts(domain_code=domain_code, obj_dict=obj_dict)
+ elif key == LibraryComponent.PIPE:
+ self._load_pipes(domain_code=domain_code, obj_dict=obj_dict)
+ else:
+ continue
+ except ValidationError as exc:
+ error_msg = format_pydantic_validation_error(exc)
+ error_class = ConceptLibraryError if component_type == LibraryComponent.CONCEPT else PipeLibraryError
+ raise error_class(f"Error loading a {component_type} from domain '{domain_code}' because of: {error_msg}") from exc
+ elif key not in [LibraryComponent.CONCEPT, LibraryComponent.PIPE]:
+ # Not a concept but a subdomain
+ self._load_library_components_from_recursive_dict(domain_code=domain_code, recursive_dict=obj_dict, component_type=component_type)
+ else:
+ # Skip keys that don't match our criteria
+ continue
+
+ def _load_concepts(self, domain_code: str, obj_dict: Dict[str, Any]):
+ for concept_code, concept_obj in obj_dict.items():
+ if isinstance(concept_obj, str):
+ # we only have a definition
+ concept_from_def = ConceptFactory.make_concept_from_definition(domain_code=domain_code, code=concept_code, definition=concept_obj)
+ self.concept_library.add_new_concept(concept=concept_from_def)
+ elif isinstance(concept_obj, dict):
+ # blueprint dict definition
+ concept_obj_dict: Dict[str, Any] = concept_obj
+ concept_from_dict = ConceptFactory.make_from_details_dict(domain_code=domain_code, code=concept_code, details_dict=concept_obj_dict)
+ self.concept_library.add_new_concept(concept=concept_from_dict)
+ else:
+ raise ConceptLibraryError(f"Unexpected type for concept_code '{concept_code}' in domain '{domain_code}': {type(concept_obj)}")
+
+ def _load_pipes(self, domain_code: str, obj_dict: Dict[str, Any]):
+ for pipe_code, pipe_obj in obj_dict.items():
+ if isinstance(pipe_obj, str):
+ # TODO: handle one-liner
+ pass
+ elif isinstance(pipe_obj, dict):
+ pipe_obj_dict: Dict[str, Any] = pipe_obj.copy()
+ pipe = LibraryManager.make_pipe_from_details_dict(
+ domain_code=domain_code,
+ pipe_code=pipe_code,
+ details_dict=pipe_obj_dict,
+ )
+ self.pipe_library.add_new_pipe(pipe=pipe)
+
+ def validate_libraries(self):
+ log.debug("LibraryManager validating libraries")
+ if self.llm_deck is None:
+ raise LibraryError("LLM deck is not loaded")
+ LLMDeck.final_validate(deck=self.llm_deck)
+ self.concept_library.validate_with_libraries()
+ self.pipe_library.validate_with_libraries()
+ self.domain_library.validate_with_libraries()
+
+ @classmethod
+ def make_pipe_from_details_dict(
+ cls,
+ domain_code: str,
+ pipe_code: str,
+ details_dict: Dict[str, Any],
+ ) -> PipeAbstract:
+ # first line in the details_dict is the pipe definition in the format:
+ # PipeClassName = "the pipe's definition in natural language"
+ pipe_definition: str
+ pipe_class_name: str
+ try:
+ pipe_class_name, pipe_definition = next(iter(details_dict.items()))
+ details_dict.pop(pipe_class_name)
+ except StopIteration as details_dict_empty_error:
+ raise PipeFactoryError(f"Pipe '{pipe_code}' could not be created because its blueprint is empty.") from details_dict_empty_error
+
+ # the factory class name for that specific type of Pipe is the pipe class name with "Factory" suffix
+ factory_class_name = f"{pipe_class_name}Factory"
+ try:
+ pipe_factory: Type[PipeSpecificFactoryProtocol[Any, Any]] = class_registry.get_required_subclass(
+ name=factory_class_name,
+ base_class=PipeSpecificFactoryProtocol,
+ )
+ except ClassRegistryNotFoundError as factory_not_found_error:
+ raise PipeFactoryError(
+ f"Pipe '{pipe_code}' couldn't be created: factory '{factory_class_name}' not found: {factory_not_found_error}"
+ ) from factory_not_found_error
+ except ClassRegistryInheritanceError as factory_inheritance_error:
+ raise PipeFactoryError(
+ f"Pipe '{pipe_code}' couldn't be created: factory '{factory_class_name}' is not a subclass of {type(PipeSpecificFactoryProtocol)}."
+ ) from factory_inheritance_error
+
+ details_dict["definition"] = pipe_definition
+ details_dict["domain"] = domain_code
+
+ pipe_from_blueprint: PipeAbstract = pipe_factory.make_pipe_from_details_dict(
+ domain_code=domain_code,
+ pipe_code=pipe_code,
+ details_dict=details_dict,
+ )
+ return pipe_from_blueprint
diff --git a/pipelex/libraries/llm_deck/base_llm_deck.toml b/pipelex/libraries/llm_deck/base_llm_deck.toml
new file mode 100644
index 000000000..7108705bb
--- /dev/null
+++ b/pipelex/libraries/llm_deck/base_llm_deck.toml
@@ -0,0 +1,75 @@
+
+
+####################################################################################################
+# LLM Deck base
+####################################################################################################
+
+# Match a llm_handle with a complete blueprint (llm_name, llm_version and llm_platform_choice).
+[llm_handles]
+gpt-4o-2024-08-06 = { llm_name = "gpt-4o", llm_version = "2024-08-06" }
+best-claude = "claude-3-7-sonnet"
+best-gemini = "gemini-2.5-pro"
+
+####################################################################################################
+# LLM Presets
+####################################################################################################
+
+[llm_presets]
+
+####################################################################################################
+# LLM Presets — General purpose
+
+cheap_llm_for_short_text = { llm_handle = "gpt-4o-mini", temperature = 0.5, max_tokens = 50 }
+cheap_llm_for_object = { llm_handle = "gpt-4o-mini", temperature = 0.5 }
+cheap_llm_to_structure = { llm_handle = "gpt-4o-mini", temperature = 0.1 }
+
+llm_for_testing_gen_text = { llm_handle = "gpt-4o-mini", temperature = 0.5 }
+llm_for_testing_gen_object = { llm_handle = "gpt-4o-mini", temperature = 0.5 }
+
+####################################################################################################
+# LLM Presets — Specific skills
+
+# Generation skills
+llm_for_factual_writing = { llm_handle = "gpt-4o", temperature = 0.1 }
+llm_for_creative_writing = { llm_handle = "best-claude", temperature = 0.9 }
+
+# Reasoning skills
+llm_to_reason_short = { llm_handle = "best-claude", temperature = 0.5, max_tokens = 500 }
+llm_to_reason = { llm_handle = "o4-mini", temperature = 1 }
+llm_to_reason_on_diagram = { llm_handle = "best-claude", temperature = 0.5 }
+
+# Search and answer skills
+llm_to_answer = { llm_handle = "best-claude", temperature = 0.1 }
+llm_to_retrieve = { llm_handle = "best-gemini", temperature = 0.1 }
+llm_for_enrichment = { llm_handle = "gpt-4o", temperature = 0.1 }
+llm_to_enrich = { llm_handle = "best-claude", temperature = 0.1 }
+llm_for_question_and_excerpt_reformulation = { llm_handle = "gpt-4o", temperature = 0.9 }
+
+# Engineering skills
+llm_to_engineer = { llm_handle = "best-claude", temperature = 0.5 }
+
+# Image skills
+llm_to_write_imgg_prompt = { llm_handle = "best-claude", temperature = 0.2 }
+llm_to_describe_img = { llm_handle = "best-claude", temperature = 0.5 }
+llm_to_design_fashion = { llm_handle = "best-claude", temperature = 0.7 }
+
+# Extraction skills
+llm_to_extract_diagram = { llm_handle = "best-claude", temperature = 0.5 }
+llm_to_extract_invoice = { llm_handle = "claude-3-7-sonnet", temperature = 0.1 }
+llm_to_extract_invoice_from_scan = { llm_handle = "best-claude", temperature = 0.5 }
+llm_to_extract_legal_terms = { llm_handle = "best-claude", temperature = 0.1 }
+llm_to_extract_tables = { llm_handle = "best-claude", temperature = 0.1 }
+
+# OCR skills
+llm_for_ocr = { llm_handle = "best-claude", temperature = 0.1 }
+
+####################################################################################################
+# LLM Choices
+####################################################################################################
+
+[llm_choice_defaults]
+for_text = "cheap_llm_for_short_text"
+for_object = "cheap_llm_for_object"
+for_object_direct = "cheap_llm_for_object"
+for_object_list = "cheap_llm_for_object"
+for_object_list_direct = "cheap_llm_for_object"
diff --git a/pipelex/libraries/llm_deck/overrides.toml b/pipelex/libraries/llm_deck/overrides.toml
new file mode 100644
index 000000000..8541de740
--- /dev/null
+++ b/pipelex/libraries/llm_deck/overrides.toml
@@ -0,0 +1,12 @@
+
+
+####################################################################################################
+# LLM Deck overrides
+####################################################################################################
+
+[llm_choice_overrides]
+for_text = "disabled"
+for_object = "disabled"
+for_object_direct = "disabled"
+for_object_list = "disabled"
+for_object_list_direct = "disabled"
diff --git a/pipelex/libraries/llm_integrations/anthropic.toml b/pipelex/libraries/llm_integrations/anthropic.toml
new file mode 100644
index 000000000..be9628903
--- /dev/null
+++ b/pipelex/libraries/llm_integrations/anthropic.toml
@@ -0,0 +1,44 @@
+
+
+[claude-3.claude-3-haiku.latest]
+max_tokens = 4096
+is_gen_object_supported = true
+is_vision_supported = true
+max_prompt_images = 100
+cost_per_million_tokens_usd = { input = 0.25, output = 1.25 }
+platform_llm_id = { anthropic = "claude-3-haiku-20240307" }
+
+[claude-3.claude-3-opus.latest]
+max_tokens = 4096
+is_gen_object_supported = true
+is_vision_supported = true
+max_prompt_images = 100
+cost_per_million_tokens_usd = { input = 15.0, output = 75.0 }
+platform_llm_id = { anthropic = "claude-3-opus-20240229" }
+
+["claude-3.5".claude-3-5-sonnet.latest]
+max_tokens = 8192
+is_gen_object_supported = true
+is_vision_supported = true
+max_prompt_images = 100
+cost_per_million_tokens_usd = { input = 3.0, output = 15.0 }
+platform_llm_id = { anthropic = "claude-3-5-sonnet-20240620", bedrock_anthropic = "us.anthropic.claude-3-5-sonnet-20240620-v1:0" }
+default_platform = "anthropic"
+
+["claude-3.5".claude-3-5-sonnet-v2.latest]
+max_tokens = 8192
+is_gen_object_supported = true
+is_vision_supported = true
+max_prompt_images = 100
+cost_per_million_tokens_usd = { input = 3.0, output = 15.0 }
+platform_llm_id = { anthropic = "claude-3-5-sonnet-20241022", bedrock_anthropic = "anthropic.claude-3-5-sonnet-20241022-v2:0" }
+default_platform = "anthropic"
+
+["claude-3.7".claude-3-7-sonnet.latest]
+max_tokens = 8192
+is_gen_object_supported = true
+is_vision_supported = true
+max_prompt_images = 100
+cost_per_million_tokens_usd = { input = 3.0, output = 15.0 }
+platform_llm_id = { anthropic = "claude-3-7-sonnet-20250219", bedrock_anthropic = "us.anthropic.claude-3-7-sonnet-20250219-v1:0" }
+default_platform = "anthropic"
diff --git a/pipelex/libraries/llm_integrations/bedrock.toml b/pipelex/libraries/llm_integrations/bedrock.toml
new file mode 100644
index 000000000..c61e77192
--- /dev/null
+++ b/pipelex/libraries/llm_integrations/bedrock.toml
@@ -0,0 +1,30 @@
+
+
+[bedrock-mistral-large.bedrock-mistral-large.latest]
+max_tokens = 8192
+is_gen_object_supported = false
+cost_per_million_tokens_usd = { input = 4.0, output = 12.0 }
+platform_llm_id = { bedrock = "mistral.mistral-large-2407-v1:0" }
+
+
+[bedrock-anthropic-claude.bedrock-claude-3-7-sonnet.latest]
+max_tokens = 8192
+is_gen_object_supported = false
+cost_per_million_tokens_usd = { input = 3.0, output = 15.0 }
+platform_llm_id = { bedrock = "us.anthropic.claude-3-7-sonnet-20250219-v1:0" }
+
+
+[bedrock-meta-llama-3.bedrock-meta-llama-3-3-70b-instruct.latest]
+max_tokens = 8192
+is_gen_object_supported = false
+# TODO: find out the actual cost per million tokens for llama3 on bedrock
+cost_per_million_tokens_usd = { input = 3.0, output = 15.0 }
+platform_llm_id = { bedrock = "us.meta.llama3-3-70b-instruct-v1:0" }
+
+
+[bedrock-amazon-nova.bedrock-nova-pro.latest]
+max_tokens = 5120
+is_gen_object_supported = false
+# TODO: find out the actual cost per million tokens for nova on bedrock
+cost_per_million_tokens_usd = { input = 3.0, output = 15.0 }
+platform_llm_id = { bedrock = "us.amazon.nova-pro-v1:0" }
diff --git a/pipelex/libraries/llm_integrations/custom.toml b/pipelex/libraries/llm_integrations/custom.toml
new file mode 100644
index 000000000..9e07a072c
--- /dev/null
+++ b/pipelex/libraries/llm_integrations/custom.toml
@@ -0,0 +1,15 @@
+
+
+[custom-gemma-3."gemma3:4b".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 = "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" }
diff --git a/pipelex/libraries/llm_integrations/mistral.toml b/pipelex/libraries/llm_integrations/mistral.toml
new file mode 100644
index 000000000..bcd797b3e
--- /dev/null
+++ b/pipelex/libraries/llm_integrations/mistral.toml
@@ -0,0 +1,69 @@
+
+
+[ministral.ministral-3b.latest]
+max_tokens = 131072
+is_gen_object_supported = true
+cost_per_million_tokens_usd = { input = 0.04, output = 0.04 }
+platform_llm_id = { mistral = "ministral-3b-latest" }
+
+[ministral.ministral-8b.latest]
+max_tokens = 131072
+is_gen_object_supported = true
+cost_per_million_tokens_usd = { input = 0.1, output = 0.1 }
+platform_llm_id = { mistral = "ministral-8b-latest" }
+
+[mistral-7b.mistral-7b."2312"]
+max_tokens = 32768
+is_gen_object_supported = true
+cost_per_million_tokens_usd = { input = 0.25, output = 0.25 }
+platform_llm_id = { mistral = "mistral-large-2402" }
+
+[mistral-8x7b.mistral-8x7b."2312"]
+max_tokens = 32768
+is_gen_object_supported = false
+cost_per_million_tokens_usd = { input = 0.7, output = 0.7 }
+platform_llm_id = { mistral = "open-mixtral-8x7b" }
+
+[mistral-codestral.mistral-codestral."2405"]
+max_tokens = 262144
+is_gen_object_supported = false
+cost_per_million_tokens_usd = { input = 1.0, output = 3.0 }
+platform_llm_id = { mistral = "codestral-2405" }
+
+[mistral-large.mistral-large."2402"]
+max_tokens = 32768
+is_gen_object_supported = true
+cost_per_million_tokens_usd = { input = 4.0, output = 12.0 }
+platform_llm_id = { mistral = "mistral-large-2402" }
+
+[mistral-large.mistral-large.latest]
+max_tokens = 131072
+is_gen_object_supported = true
+cost_per_million_tokens_usd = { input = 4.0, output = 12.0 }
+platform_llm_id = { mistral = "mistral-large-latest" }
+
+[mistral-small.mistral-small."2402"]
+max_tokens = 32768
+is_gen_object_supported = true
+cost_per_million_tokens_usd = { input = 1.0, output = 3.0 }
+platform_llm_id = { mistral = "mistral-small-2402" }
+
+[mistral-small.mistral-small.latest]
+max_tokens = 32768
+is_gen_object_supported = true
+cost_per_million_tokens_usd = { input = 1.0, output = 3.0 }
+platform_llm_id = { mistral = "mistral-small-latest" }
+
+[pixtral.pixtral-12b.latest]
+max_tokens = 131072
+is_gen_object_supported = true
+is_vision_supported = true
+cost_per_million_tokens_usd = { input = 0.15, output = 0.15 }
+platform_llm_id = { mistral = "pixtral-12b-latest" }
+
+[pixtral.pixtral-large.latest]
+max_tokens = 131072
+is_gen_object_supported = true
+is_vision_supported = true
+cost_per_million_tokens_usd = { input = 2.0, output = 6.0 }
+platform_llm_id = { mistral = "pixtral-large-latest" }
diff --git a/pipelex/libraries/llm_integrations/openai.toml b/pipelex/libraries/llm_integrations/openai.toml
new file mode 100644
index 000000000..748794a1a
--- /dev/null
+++ b/pipelex/libraries/llm_integrations/openai.toml
@@ -0,0 +1,140 @@
+
+
+["gpt-3.5"."gpt-3.5-turbo".latest]
+is_gen_object_supported = true
+cost_per_million_tokens_usd = { input = 0.5, output = 1.5 }
+platform_llm_id = { azure_openai = "gpt-35-turbo-16k", openai = "gpt-3.5-turbo-1106" }
+default_platform = "openai"
+
+[gpt-4.gpt-4.latest]
+is_gen_object_supported = false
+is_vision_supported = false
+cost_per_million_tokens_usd = { input = 30.0, output = 60.0 }
+platform_llm_id = { openai = "gpt-4" }
+
+[gpt-4.gpt-4-turbo.0125-preview]
+is_gen_object_supported = true
+is_vision_supported = false
+cost_per_million_tokens_usd = { input = 10.0, output = 30.0 }
+platform_llm_id = { openai = "gpt-4-0125-preview" }
+
+[gpt-4.gpt-4-turbo.1106-preview]
+is_gen_object_supported = true
+is_vision_supported = false
+cost_per_million_tokens_usd = { input = 10.0, output = 30.0 }
+platform_llm_id = { openai = "gpt-4-1106-preview" }
+
+[gpt-4.gpt-4-turbo."2024-04-09"]
+is_gen_object_supported = true
+is_vision_supported = false
+cost_per_million_tokens_usd = { input = 10.0, output = 30.0 }
+platform_llm_id = { azure_openai = "gpt-4-turbo", openai = "gpt-4-turbo-2024-04-09" }
+default_platform = "openai"
+
+[gpt-4.gpt-4-turbo.latest]
+is_gen_object_supported = true
+is_vision_supported = false
+cost_per_million_tokens_usd = { input = 10.0, output = 30.0 }
+platform_llm_id = { azure_openai = "gpt-4-turbo", openai = "gpt-4-turbo" }
+default_platform = "openai"
+
+[gpt-4o.gpt-4o."2024-05-13"]
+is_gen_object_supported = true
+is_vision_supported = true
+cost_per_million_tokens_usd = { input = 5.0, output = 15.0 }
+platform_llm_id = { azure_openai = "gpt-4o", openai = "gpt-4o-2024-05-13" }
+default_platform = "openai"
+
+[gpt-4.gpt-4o."2024-08-06"]
+is_gen_object_supported = true
+is_vision_supported = true
+cost_per_million_tokens_usd = { input = 2.5, output = 10.0 }
+platform_llm_id = { azure_openai = "gpt-4o-2024-08-06", openai = "gpt-4o-2024-08-06" }
+default_platform = "openai"
+
+[gpt-4.gpt-4o."2024-11-20"]
+is_gen_object_supported = true
+is_vision_supported = true
+cost_per_million_tokens_usd = { input = 2.5, output = 10.0 }
+platform_llm_id = { azure_openai = "gpt-4o-2024-11-20", openai = "gpt-4o-2024-11-20" }
+default_platform = "openai"
+
+[gpt-4o.gpt-4o.latest]
+is_gen_object_supported = true
+is_vision_supported = true
+cost_per_million_tokens_usd = { input = 2.5, output = 10.0 }
+platform_llm_id = { azure_openai = "gpt-4o-2024-11-20", openai = "gpt-4o" }
+default_platform = "openai"
+
+[gpt-4o.gpt-4o-mini."2024-07-18"]
+is_gen_object_supported = true
+is_vision_supported = true
+cost_per_million_tokens_usd = { input = 0.15, output = 0.6 }
+platform_llm_id = { azure_openai = "gpt-4o-mini", openai = "gpt-4o-mini-2024-07-18" }
+default_platform = "openai"
+
+[gpt-4o.gpt-4o-mini.latest]
+is_gen_object_supported = true
+is_vision_supported = true
+cost_per_million_tokens_usd = { input = 0.15, output = 0.6 }
+platform_llm_id = { azure_openai = "gpt-4o-mini", openai = "gpt-4o-mini" }
+default_platform = "openai"
+
+["gpt-4.5"."gpt-4.5-preview".latest]
+is_gen_object_supported = true
+is_vision_supported = true
+cost_per_million_tokens_usd = { input = 75, output = 150 }
+platform_llm_id = { openai = "gpt-4.5-preview" }
+
+["gpt-4.1"."gpt-4.1".latest]
+is_gen_object_supported = true
+is_vision_supported = true
+cost_per_million_tokens_usd = { input = 2, output = 8}
+platform_llm_id = { azure_openai = "gpt-4.1", openai = "gpt-4.1" }
+default_platform = "openai" # TODO: make it work with azure_openai by using automatically the right azure resource
+
+["gpt-4.1"."gpt-4.1-mini".latest]
+is_gen_object_supported = true
+is_vision_supported = true
+cost_per_million_tokens_usd = { input = 0.4, output = 1.6 }
+platform_llm_id = { azure_openai = "gpt-4.1-mini", openai = "gpt-4.1-mini" }
+default_platform = "openai" # TODO: make it work with azure_openai by using automatically the right azure resource
+
+["gpt-4.1"."gpt-4.1-nano".latest]
+is_gen_object_supported = true
+is_vision_supported = true
+cost_per_million_tokens_usd = { input = 0.1, output = 0.4 }
+platform_llm_id = { azure_openai = "gpt-4.1-nano", openai = "gpt-4.1-nano" }
+default_platform = "openai" # TODO: make it work with azure_openai by using automatically the right azure resource
+
+[o.o1-mini.latest]
+is_gen_object_supported = false
+is_vision_supported = false
+cost_per_million_tokens_usd = { input = 3.0, output = 12.0 }
+platform_llm_id = { openai = "o1-mini" }
+
+[o.o1.latest]
+is_gen_object_supported = true
+is_vision_supported = true
+cost_per_million_tokens_usd = { input = 15.0, output = 60.0 }
+platform_llm_id = { openai = "o1" }
+
+[o.o3-mini.latest]
+is_gen_object_supported = true
+cost_per_million_tokens_usd = { input = 1.1, output = 4.4 }
+# platform_llm_id = { openai = "o3-mini", azure_openai = "o3-mini" }
+platform_llm_id = { openai = "o3-mini"}
+default_platform = "openai" # TODO: make it work with azure_openai by using automatically the right azure resource
+
+[o.o3.latest]
+is_gen_object_supported = true
+is_vision_supported = true
+cost_per_million_tokens_usd = { input = 10.0, output = 40.0 }
+platform_llm_id = { openai = "o3" }
+
+[o.o4-mini.latest]
+is_gen_object_supported = true
+cost_per_million_tokens_usd = { input = 1.1, output = 4.4 }
+platform_llm_id = { openai = "o4-mini"}
+default_platform = "openai"
+
diff --git a/pipelex/libraries/llm_integrations/perplexity.toml b/pipelex/libraries/llm_integrations/perplexity.toml
new file mode 100644
index 000000000..a72dc5946
--- /dev/null
+++ b/pipelex/libraries/llm_integrations/perplexity.toml
@@ -0,0 +1,25 @@
+
+
+[perplexity-search.sonar-pro.latest]
+is_gen_object_supported = false
+platform_llm_id = { perplexity = "sonar-pro" }
+
+[perplexity-search.sonar.latest]
+is_gen_object_supported = false
+platform_llm_id = { perplexity = "sonar" }
+
+[perplexity-research.sonar-deep-research.latest]
+is_gen_object_supported = false
+platform_llm_id = { perplexity = "sonar-deep-research" }
+
+[perplexity-reasoning.sonar-reasoning-pro.latest]
+is_gen_object_supported = false
+platform_llm_id = { perplexity = "sonar-reasoning-pro" }
+
+[perplexity-reasoning.sonar-reasoning.latest]
+is_gen_object_supported = false
+platform_llm_id = { perplexity = "sonar-reasoning" }
+
+[perplexity-deepseek.perplexity-deepseek-r1.latest]
+is_gen_object_supported = false
+platform_llm_id = { perplexity = "r1-1776" }
diff --git a/pipelex/libraries/llm_integrations/vertexai.toml b/pipelex/libraries/llm_integrations/vertexai.toml
new file mode 100644
index 000000000..a90af6247
--- /dev/null
+++ b/pipelex/libraries/llm_integrations/vertexai.toml
@@ -0,0 +1,36 @@
+
+
+[gemini."gemini-1.5-flash".latest]
+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" }
+
+[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" }
+
+[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" }
+
+[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" }
+
+[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-04-17" }
diff --git a/pipelex/libraries/pipelines/__init__.py b/pipelex/libraries/pipelines/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/pipelex/libraries/pipelines/__init__.py
@@ -0,0 +1 @@
+
diff --git a/pipelex/libraries/pipelines/documents.toml b/pipelex/libraries/pipelines/documents.toml
new file mode 100644
index 000000000..8dbbef66c
--- /dev/null
+++ b/pipelex/libraries/pipelines/documents.toml
@@ -0,0 +1,18 @@
+
+
+domain = "documents"
+definition = "The domain of documents that can comprise pages, text, images, etc. in PDF or other formats"
+
+[concept]
+TextAndImagesContent = "A content that comprises text and images where the text can include local links to the images"
+PDF = "A PDF document"
+
+[pipe]
+
+[pipe.extract_page_contents_from_pdf]
+PipeOcr = "Extract page contents from a PDF document"
+input = "PDF"
+output = "PageContent"
+pdf = "pdf"
+page_images = true
+page_views = false
diff --git a/pipelex/libraries/pipelines/image_generation.toml b/pipelex/libraries/pipelines/image_generation.toml
new file mode 100644
index 000000000..7f7d34e9c
--- /dev/null
+++ b/pipelex/libraries/pipelines/image_generation.toml
@@ -0,0 +1,21 @@
+
+
+domain = "image_generation"
+definition = "Image generation"
+
+[concept]
+
+[pipe]
+
+[pipe.generate_image]
+PipeImgGen = "Generate AI image"
+input = "ImggPrompt"
+output = "Image"
+nb_steps = 2
+
+
+[pipe.generate_photo]
+PipeImgGen = "Generate AI image"
+input = "ImggPrompt"
+output = "images.Photo"
+nb_steps = 8
diff --git a/pipelex/libraries/pipelines/images.toml b/pipelex/libraries/pipelines/images.toml
new file mode 100644
index 000000000..77e5a98d8
--- /dev/null
+++ b/pipelex/libraries/pipelines/images.toml
@@ -0,0 +1,27 @@
+
+
+domain = "images"
+definition = "Generic image-related domain"
+
+[concept]
+ImggPrompt = "Prompt to generate an image"
+VisualDescription = "Visual description of something"
+SpecificImageAnalysis = "Specific analysis of an image"
+
+[concept.Photo]
+Concept = "Photo"
+structure = "ImageContent"
+refines = ["native.Image"]
+
+[pipe]
+
+[pipe.describe_image]
+PipeLLM = "Describe an image"
+input = "native.Image"
+output = "VisualDescription"
+system_prompt = "You are a very good observer."
+images = ["image"]
+llm = "llm_to_describe_img"
+prompt_template = """
+Describe the provided image in great detail.
+"""
diff --git a/pipelex/libraries/pipelines/questions.py b/pipelex/libraries/pipelines/questions.py
new file mode 100644
index 000000000..f66f584ca
--- /dev/null
+++ b/pipelex/libraries/pipelines/questions.py
@@ -0,0 +1,190 @@
+from datetime import datetime
+from enum import StrEnum
+from typing import Generic, List, Literal, Optional, TypeVar, Union
+
+from pydantic import Field, model_validator
+from typing_extensions import Self, override
+
+from pipelex import pretty_print
+from pipelex.core.stuff_content import StructuredContent
+
+
+class QuestionCategoryEnum(StrEnum):
+ NOT_A_QUESTION = "not_a_question"
+ TRICKY = "tricky"
+ STRAIGHTFORWARD = "straightforward"
+ OBVIOUS = "obvious"
+
+
+class QuestionCategory(StructuredContent):
+ category: QuestionCategoryEnum
+ explanation: str
+
+
+class QuestionAnalysis(StructuredContent):
+ explanation: str
+ trickiness_rating: int = Field(..., ge=1, le=100)
+ deceptiveness_rating: int = Field(..., ge=1, le=100)
+
+
+class QuestionWithExcerpt(StructuredContent):
+ question: str
+ excerpt: str
+
+
+class RawQuestionWithExcerpt(StructuredContent):
+ raw_question: str
+ raw_excerpt: str
+
+
+class AllowedTypes(StrEnum):
+ STRING = "str"
+ INTEGER = "int"
+ FLOAT = "float"
+ BOOLEAN = "bool"
+ LIST = "list"
+ DICT = "dict"
+ TUPLE = "tuple"
+ SET = "set"
+ DATE = "date"
+
+
+class TargetType(StructuredContent):
+ target_type: AllowedTypes
+ dimension: Optional[str] = None
+
+
+class ThoughtfulAnswer(StructuredContent):
+ the_trap: str
+ the_counter: str
+ the_lesson: str
+ the_answer: str
+
+ def pretty_print(self):
+ pretty_print(self.the_trap, title="The trap", border_style="bright_red")
+ pretty_print(self.the_counter, title="The counter", border_style="bright_yellow")
+ pretty_print(self.the_lesson, title="The lesson", border_style="blue")
+ pretty_print(self.the_answer, title="The answer", border_style="green")
+
+
+T = TypeVar("T")
+
+
+class BaseAnswer(StrEnum):
+ NOT_APPLICABLE = "Not applicable"
+ INDETERMINATE = "Indeterminate"
+
+
+# TODO: we should make this system easy to apply using a simple parameter on a chosen structure
+class SourcedAnswer(StructuredContent, Generic[T]):
+ """
+ This model represents an answer to a question given a excerpt of a text.
+ Add a short comment explaining how you determined the answer.
+
+ Make sure you return citations (taken from the text) in an array if you can answer the question.
+ Do not force a citation if you cannot answer the question.
+ """
+
+ answer: Union[T, Literal[BaseAnswer.NOT_APPLICABLE, BaseAnswer.INDETERMINATE]] = Field(description="The answer to the question")
+ short_comment: str = Field(..., description="A short comment explaining how you determined the answer.")
+ citations: Optional[List[str]] = Field(default=None, description="The array of citations that contains the answer.")
+
+ @property
+ def indeterminate(self) -> bool:
+ return self.answer == BaseAnswer.INDETERMINATE
+
+ @property
+ def not_applicable(self) -> bool:
+ return self.answer == BaseAnswer.NOT_APPLICABLE
+
+ @model_validator(mode="after")
+ def validate_answer(self) -> Self:
+ if not self.answer:
+ raise ValueError("Answer must be provided")
+
+ if not (self.indeterminate or self.answer) and not self.citations:
+ raise ValueError("Citations must be provided when answer is not 'Indeterminate'")
+
+ return self
+
+ @override
+ def render_spreadsheet(self) -> str:
+ return str(self.answer)
+
+
+C = TypeVar("C")
+
+
+class MultipleChoiceAnswer(SourcedAnswer[C], Generic[C]):
+ """A specialized answer type for multiple choice questions."""
+
+ choices: List[str] = Field(default_factory=list, description="The list of choices for the multiple choice question.")
+
+
+class YesNoChoices(StrEnum):
+ YES = "Yes"
+ NO = "No"
+
+
+class YesNo(MultipleChoiceAnswer[Literal[YesNoChoices.YES, YesNoChoices.NO]]):
+ """
+ Answer by yes or no or not applicable or indeterminate.
+ Make sure to extract the citation of the text that contains the arguments for providing the answer.
+ If the answer is not existing, do not force a citation.
+ """
+
+ choices: List[str] = Field(default=[choice.value for choice in YesNoChoices], description="Yes/No choices")
+
+
+class Date(SourcedAnswer[datetime]):
+ """
+ This model represents a date mentioned in a text.
+ """
+
+
+class BulletedList(SourcedAnswer[List[str]]):
+ """
+ Organize the information into a list of items, each item being a string, with a hyphen at the beginning of each item.
+ """
+
+
+class FreeText(SourcedAnswer[str]):
+ """
+ This model represents a free text.
+ The answer can be a free text without format constraints.
+ """
+
+
+class TimeUnit(StrEnum):
+ YEARS = "year(s)"
+ MONTHS = "month(s)"
+ DAYS = "day(s)"
+
+
+class Duration(SourcedAnswer[int]):
+ """
+ This model represents a duration. A duration is made of a value and a unit.
+ For instance, the duration "5 years" would be represented as "5 year(s)".
+ Add the unit to the asnwer: (years, months, days, hours, minutes, seconds)
+ """
+
+ unit: Optional[str] = Field(default=None, description="The unit of the duration: year(s), month(s), day(s), hour(s), minute(s), second(s)")
+
+
+class Numerical(SourcedAnswer[int]):
+ """
+ This model represents a number of items. Items can be of any kind.
+ """
+
+
+class TimeRange(SourcedAnswer[str]):
+ """
+ This model represents a time range. A time range is made of a start event and an end event.
+ For instance the time range "from 2025 to 2030" would be represented as "2025 to 2030".
+ """
+
+
+class Location(SourcedAnswer[str]):
+ """
+ This model represents the location geographically of something
+ """
diff --git a/pipelex/libraries/pipelines/questions.toml b/pipelex/libraries/pipelines/questions.toml
new file mode 100644
index 000000000..2249ac239
--- /dev/null
+++ b/pipelex/libraries/pipelines/questions.toml
@@ -0,0 +1,294 @@
+
+
+domain = "questions"
+definition = "Questions and answers"
+
+[concept]
+ProjectContext = "Context for a project"
+Color = "A color"
+TargetConcept = "The type of answer that we are looking for"
+TextSample = "A sample of text from a larger document"
+Date = "A date"
+Duration = "A duration"
+Numerical = "A number of something"
+Location = "A location"
+TimeRange = "A time range"
+BulletedList = "A bulleted list, each item being a string, with a hyphen at the beginning of each item"
+
+AnswerToAQuestion = "Answer to a question"
+Query = "Query to a retrieval system"
+AnswerToAQuestionWithExcerpt = "Answer to a question with excerpt"
+ThoughtfulAnswerConclusion = "Conclusion of a thoughtful answer"
+TargetFormat = "The most relevant format the answer should be in"
+FormattedAnswer = "Formatted answer"
+FormattedAnswerAndType = "Formatted answer and its appropriate type"
+AnswerFormat = "The most relevant format the answer should be in"
+FormatAnswerInstructions = "Instructions to answer the question in the most relevant format"
+RawQuestionWithExcerpt = "A raw question about a specific excerpt, before it's reformulated"
+QuestionWithExcerpt = "A question about a specific excerpt"
+QuestionAnalysis = "An analysis of a question, determining whether it's tricky"
+QuestionCategory = "A category to which a question belongs"
+TargetType = "The most relevant type the answer should be in"
+
+[concept.ThoughtfulAnswer]
+Concept = "A thoughtful answer to a question"
+structure = "ThoughtfulAnswer"
+refines = ["AnswerToAQuestion"]
+
+[concept.ThoughtfulAnswerStraightforward]
+Concept = "A thoughtful answer to a straightforward question"
+structure = "ThoughtfulAnswer"
+refines = ["ThoughtfulAnswer"]
+
+[concept.ThoughtfulAnswerTricky]
+Concept = "A thoughtful answer to a tricky question"
+structure = "ThoughtfulAnswer"
+refines = ["ThoughtfulAnswer"]
+
+
+[concept.Instructions]
+Concept = "Instructions to answer an enriched question"
+refines = ["ProjectContext"]
+
+[pipe]
+[pipe.analyse_question_tricky]
+PipeLLM = "Analyze a question to determine whether it's straightforward or tricky"
+input = "answer.Question"
+output = "QuestionAnalysis"
+llm = "llm_to_reason"
+prompt_template = """
+Here is a question for an LLM:
+{{ question|tag }}
+
+Do you think it's tricky, or maybe even a deceptive trap?
+Does it assume things that are not necessarily true?
+Does it suggest patterns that aren't applicable?
+
+Please explain what you think and then give a rating between 0 to 100 of trickiness and another rating between 0 to 100 of deceptiveness.
+If there's an obvious trap, state it without getting into details.
+"""
+
+[pipe.reformulate_question_with_excerpt]
+PipeLLM = "Reformulate a question with excerpt."
+input = "RawQuestionWithExcerpt"
+output = "QuestionWithExcerpt"
+llm = "llm_for_enrichment"
+prompt_template = """
+You are given a question and an excerpt. I want you to reformulate both the question and the excerpt.
+
+Here is the question:
+{{ raw_question_with_excerpt|tag("raw_question") }}
+
+Here is the excerpt:
+{{ raw_question_with_excerpt|tag("raw_excerpt") }}
+
+Please return your answer in english. And in a structured pydantic object of class QuestionWithExcerpt.
+Make sure your reformulation doesn't change the question difficulty.
+
+Example:
+- Question: "What is the height of the Eiffel Tower?"
+- Excerpt: "The Eiffel Tower is a famous tower in Paris, France. It is 320 meters tall."
+- Reformulated question: "What is the height of the Iron miss?"
+- Reformulated excerpt: "The Eiffel Tower is a famous (very well known) tower in Paris, France. It is 320 meters tall."
+
+Output:
+QuestionWithExcerpt(
+ question="What is the height of the Iron miss?",
+ excerpt="The Eiffel Tower is a famous (very well known) tower in Paris, France. It is 320 meters tall."
+)
+"""
+
+[pipe.answer_after_analysis]
+PipeLLM = "Answer knowingly after analyzing a question"
+input = "QuestionAnalysis"
+output = "ThoughtfulAnswer"
+llm = "llm_to_reason"
+prompt_template = """
+A question was asked:
+{{ question|tag }}
+
+A thoughtful analysis was given:
+{{ question_analysis|tag }}
+
+If the question was tricky or deceptive, don't get fooled!
+Answer in 4 parts:
+1- the_trap: Explain the trap in a 1 sentence
+2- the_counter: Counter by stating the right way to think about the question and avoid the trap
+3- the_lesson: Did we learn anything?
+4- the_answer: Then give a good answer expressed without mentioning the trap
+"""
+
+[pipe.answer_tricky_question_by_steps]
+PipeSequence = "Answer a tricky question by first analyzing its trickiness"
+input = "answer.Question"
+output = "ThoughtfulAnswer"
+steps = [
+ { pipe = "analyse_question_tricky", result = "question_analysis" },
+ { pipe = "answer_after_analysis", result = "answer" },
+]
+
+[pipe.conclude_thoughtful_answer]
+PipeJinja2 = "Conclude a thoughtful answer"
+input = "ThoughtfulAnswer"
+output = "ThoughtfulAnswerConclusion"
+jinja2 = "After analyzing the question, here is my answer: {{ thoughtful_answer.content.the_answer }}"
+
+
+[pipe.conclude_tricky_question_by_steps]
+PipeSequence = "Answer a tricky question by first analyzing its trickiness and then concluding"
+input = "answer.Question"
+output = "ThoughtfulAnswerConclusion"
+steps = [
+ { pipe = "analyse_question_tricky", result = "question_analysis" },
+ { pipe = "answer_after_analysis", result = "thoughtful_answer" },
+ { pipe = "conclude_thoughtful_answer", result = "thoughtful_answer_conclusion" },
+]
+
+[pipe.get_target_format]
+PipeLLM = "Analyze the most relevant format the answer should be in"
+input = "answer.Question"
+output = "TargetFormat"
+prompt_template = """
+You will be given a question and I want you to identify what format the answer should be returned in.
+- For instance, if the question is 'What is the height of the Eiffel Tower?', you should return 'a distance'.
+- For instance, if the question is 'Paul is 30 years old, John is half of Paul's age plus 20 years, who is older?', you should return 'a name'.
+
+Here is the question:
+ {{ question|tag}}
+"""
+
+[pipe.get_target_type]
+PipeLLM = "Define what is the most relevant type the answer should be in"
+input = "TargetFormat"
+output = "TargetType"
+prompt_template = """
+You are provided whith a format. I want you to identify what Python type the information should be stored in.
+
+- For instance a distance should be stored as a float.
+- For instance a name should be stored as a string.
+
+(Optional) If you need to indicate a dimension, please use the dimension attribute of the TargetType model.
+For instance, if the format is 'a distance', the TargetType should be 'float' and the dimension should be 'meters'.
+
+Here is the format:
+{{ target_format|tag }}
+"""
+
+[pipe.get_formatted_answer]
+PipeLLM = "Answer to the question while ensuring a relevant format"
+input = "answer.Question"
+output = "FormattedAnswer"
+prompt_template = """
+You are given a question. I want you to answer it in a specific format.
+Please, only return the most concise answer possible while respecting the expected format.
+
+Here is the question:
+{{ question|tag }}
+
+Here is the format I want you to return the answer in:
+{{ target_format|tag }}
+"""
+
+[pipe.get_formatted_answer_and_type]
+PipeJinja2 = "Define what is the most relevant type the answer should be in"
+input = "FormattedAnswer"
+output = "FormattedAnswerAndType"
+jinja2 = "The formatted answer is: {{ formatted_answer.content.text }}\n and the type is: {{ target_type.content.target_type }}"
+
+[pipe.answer_formatted_question_by_steps]
+PipeSequence = "Answer a question in a formatted way by first analyzing the most relevant format for the answer"
+input = "answer.Question"
+output = "FormattedAnswer"
+steps = [
+ { pipe = "get_target_format", result = "target_format" },
+ { pipe = "get_formatted_answer", result = "formatted_answer" },
+]
+
+[pipe.extract_target_format_with_excerpt]
+PipeLLM = "Analyze the most relevant format the answer should be in"
+input = "QuestionWithExcerpt"
+output = "TargetFormat"
+prompt_template = """
+You are given a question about a specific excerpt. I want you to analyze the most relevant format the answer should be in.
+This should help answering the question in the proper format.
+
+Here is the question:
+{{ question_with_excerpt.content.question|tag("question") }}
+
+Here is the excerpt:
+{{ question_with_excerpt.content.excerpt|tag("excerpt") }}
+
+For instance, if the question is 'What is the height of the Eiffel Tower?', you should return 'a distance'.
+For instance, if the question is 'Paul is 30 years old, John is half of Paul's age plus 20 years, who is older?', you should return 'a name'.
+Remain focus on **simple** formats: (number, name, text, distance, etc.)
+
+Return the most relevant format the answer should be in.
+Do not output the answer, only the format.
+"""
+
+[pipe.get_answer_with_excerpt]
+PipeLLM = "Answer to the question with excerpt"
+input = "QuestionWithExcerpt"
+output = "AnswerToAQuestionWithExcerpt"
+prompt_template = """
+I am asking you to read an excerpt and answer a question about it.
+
+Here is the excerpts:
+{{ question_with_excerpt.content.excerpt|tag("prompt") }}
+
+Here is the question:
+{{ question_with_excerpt.content.question|tag("prompt") }}
+
+Please return your answer in english.
+"""
+
+[pipe.get_formatted_answer_from_excerpt]
+PipeLLM = "Answer to the question with excerpt while ensuring a relevant format"
+input = "AnswerToAQuestionWithExcerpt"
+output = "FormattedAnswer"
+prompt_template = """
+Your are given an answer to a question about an excerpt.
+Given these instructions, please, format the answer and output it in the expected format.
+
+Here is the answer:
+{{ answer_to_a_question_with_excerpt|tag }}
+
+Here are the instructions about the format I want you to return the answer in:
+{{ target_format_with_excerpt|tag }}
+
+Make sure you output the answer in the expected format and in the most concise way possible.
+For instance, if the expected format is 'a number' and the answer is 'the height of the Eiffel Tower is 320 meters', you should return 320.
+Do not add quotes or any other text, only the answer.
+"""
+
+[pipe.answer_formatted_question_with_excerpt_by_steps]
+PipeSequence = "Answer a question about a specific excerpt in a formatted way by first analyzing the most relevant format for the answer"
+input = "QuestionWithExcerpt"
+output = "FormattedAnswer"
+steps = [
+ { pipe = "extract_target_format_with_excerpt", result = "target_format_with_excerpt" },
+ { pipe = "get_answer_with_excerpt", result = "answer_to_a_question_with_excerpt" },
+ { pipe = "get_formatted_answer_from_excerpt", result = "formatted_answer_from_excerpt" },
+]
+
+[pipe.answer_formatted_and_reformulated_question_with_excerpt_by_steps]
+PipeSequence = "Answer a question in a formatted way by first reformulating it then analyzing the most relevant format for the answer and output a type"
+input = "RawQuestionWithExcerpt"
+output = "FormattedAnswer"
+steps = [
+ { pipe = "reformulate_question_with_excerpt", result = "question_with_excerpt" },
+ { pipe = "extract_target_format_with_excerpt", result = "target_format_with_excerpt" },
+ { pipe = "get_answer_with_excerpt", result = "answer_to_a_question_with_excerpt" },
+ { pipe = "get_formatted_answer_from_excerpt", result = "formatted_answer_from_excerpt" },
+]
+
+[pipe.answer_formatted_question_and_type_by_steps]
+PipeSequence = "Answer a question in a formatted way by first analyzing the most relevant format for the answer and output a type"
+input = "answer.Question"
+output = "FormattedAnswerAndType"
+steps = [
+ { pipe = "get_target_format", result = "target_format" },
+ { pipe = "get_target_type", result = "target_type" },
+ { pipe = "get_formatted_answer", result = "formatted_answer" },
+ { pipe = "get_formatted_answer_and_type", result = "formatted_answer_and_type" },
+]
diff --git a/pipelex/libraries/pipelines/retrieve.py b/pipelex/libraries/pipelines/retrieve.py
new file mode 100644
index 000000000..a9e778431
--- /dev/null
+++ b/pipelex/libraries/pipelines/retrieve.py
@@ -0,0 +1,12 @@
+from pydantic import Field
+
+from pipelex.core.stuff_content import StructuredContent
+
+
+class RetrievedExcerpt(StructuredContent):
+ """
+ This model represents an excerpt from a text with its justification for being relevant to a question.
+ """
+
+ text: str
+ justification: str = Field(..., description="The justification for why this excerpt is relevant to the question")
diff --git a/pipelex/libraries/pipelines/retrieve.toml b/pipelex/libraries/pipelines/retrieve.toml
new file mode 100644
index 000000000..6c0780981
--- /dev/null
+++ b/pipelex/libraries/pipelines/retrieve.toml
@@ -0,0 +1,25 @@
+
+
+domain = "retrieve"
+definition = "The domain for retrieving relevant excerpts from text"
+
+[concept]
+RetrievedExcerpt = "An excerpt from a text with its justification for being relevant to a question"
+
+[pipe]
+[pipe.retrieve_excerpt]
+PipeLLM = "Find the most relevant excerpt in a text that answers a specific question"
+input = "native.Text"
+output = "RetrievedExcerpt"
+llm = "llm_to_retrieve"
+prompt_template = """
+Given this text:
+{{ text_content|tag }}
+
+Given this question:
+{{ question|tag }}
+
+Your task is to find all relevant excerpts from the text that contribute to answering this question.
+
+Output each excerpt ONLY for actual found excerpts.
+"""
diff --git a/pipelex/libraries/templates/base_templates.toml b/pipelex/libraries/templates/base_templates.toml
new file mode 100644
index 000000000..7a8da104b
--- /dev/null
+++ b/pipelex/libraries/templates/base_templates.toml
@@ -0,0 +1,17 @@
+
+
+[generic_prompts]
+
+structure_from_preliminary_text_system = "You are a data modeling expert specialized in extracting structure from text."
+structure_from_preliminary_text_user = """
+Your job is to extract and structure information from a text.
+Here is the text:
+{{ preliminary_text|tag("text") }}
+
+Now generate the JSON in the required format.
+Do not create information that is not in the text.
+"""
+
+[test_prompts]
+
+jinja2_test_template = "I want a {{ place_holder }} t-shirt."
diff --git a/pipelex/mission/activity/__init__.py b/pipelex/mission/activity/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/pipelex/mission/activity/__init__.py
@@ -0,0 +1 @@
+
diff --git a/pipelex/mission/activity/activity_handler.py b/pipelex/mission/activity/activity_handler.py
new file mode 100644
index 000000000..4e072775a
--- /dev/null
+++ b/pipelex/mission/activity/activity_handler.py
@@ -0,0 +1,131 @@
+import os
+from typing import Set, cast
+
+from pipelex import log
+from pipelex.config import get_config
+from pipelex.core.stuff import Stuff, StuffContent
+from pipelex.core.stuff_content import (
+ HtmlContent,
+ ImageContent,
+ ListContent,
+ MermaidContent,
+ NumberContent,
+ StructuredContent,
+ TextContent,
+)
+from pipelex.mission.activity.activity_models import ActivityReport
+from pipelex.tools.misc.file_fetch_utils import fetch_file_from_url_httpx
+from pipelex.tools.misc.file_utils import ensure_path, save_text_to_path
+from pipelex.tools.misc.json_utils import save_as_json_to_path
+
+
+class ActivityHandlerForResultFiles:
+ def __init__(self, result_dir_path: str):
+ self.result_dir_path = result_dir_path
+ self.images_dir_path = os.path.join(result_dir_path, "images")
+ ensure_path(self.images_dir_path)
+ imgg_config = get_config().cogt.imgg_config
+ imgg_param_defaults = imgg_config.imgg_param_defaults
+ self.image_output_format = imgg_param_defaults.output_format
+ self.already_handled_stuff: Set[str] = set()
+
+ def _generate_stuff_id(self, stuff: Stuff) -> str:
+ # Use name if available, otherwise just use code
+ name_part = stuff.stuff_name.replace(" ", "_") if stuff.stuff_name else ""
+ return f"{name_part}_{stuff.stuff_code}" if name_part else stuff.stuff_code
+
+ def handle_activity(self, activity_report: ActivityReport) -> None:
+ if isinstance(activity_report.content, Stuff):
+ the_stuff = activity_report.content
+ if the_stuff.stuff_code in self.already_handled_stuff:
+ log.info(f"Already handled stuff: {the_stuff.stuff_name}")
+ return
+ self.handle_stuff(stuff=the_stuff)
+ if code := the_stuff.stuff_code:
+ self.already_handled_stuff.add(code)
+ else:
+ log.error(f"Unhandled activity_report: {activity_report}")
+
+ def handle_stuff(self, stuff: Stuff) -> None:
+ # Create a directory for this stuff using its code and name
+ stuff_id = self._generate_stuff_id(stuff)
+
+ # Handle different content types
+ if isinstance(stuff.content, TextContent):
+ self._handle_text_content(content=stuff.content, stuff_id=stuff_id)
+ elif isinstance(stuff.content, NumberContent):
+ self._handle_number_content(content=stuff.content, stuff_id=stuff_id)
+ elif isinstance(stuff.content, ImageContent):
+ self._handle_image_content(content=stuff.content, stuff_id=stuff_id)
+ elif isinstance(stuff.content, HtmlContent):
+ self._handle_html_content(content=stuff.content, stuff_id=stuff_id)
+ elif isinstance(stuff.content, MermaidContent):
+ self._handle_mermaid_content(content=stuff.content, stuff_id=stuff_id)
+ elif isinstance(stuff.content, StructuredContent):
+ self._handle_structured_content(content=stuff.content, stuff_id=stuff_id)
+ elif isinstance(stuff.content, ListContent):
+ # TODO: check that all items are StuffContent
+ self._handle_list_content(content=cast(ListContent[StuffContent], stuff.content), stuff_id=stuff_id) # type: ignore
+ else:
+ log.error(f"Unhandled stuff content type: {type(stuff.content)}")
+
+ def _handle_text_content(self, content: TextContent, stuff_id: str) -> None:
+ stuff_dir = os.path.join(self.result_dir_path, stuff_id)
+ ensure_path(stuff_dir)
+
+ save_text_to_path(content.text, os.path.join(stuff_dir, f"{stuff_id}.txt"))
+ # Also save rendered versions
+ save_text_to_path(content.rendered_html(), os.path.join(stuff_dir, f"{stuff_id}.html"))
+ save_text_to_path(content.rendered_markdown(), os.path.join(stuff_dir, f"{stuff_id}.md"))
+
+ def _handle_number_content(self, content: NumberContent, stuff_id: str) -> None:
+ stuff_dir = os.path.join(self.result_dir_path, stuff_id)
+ ensure_path(stuff_dir)
+ save_text_to_path(str(content.number), os.path.join(stuff_dir, f"{stuff_id}.txt"))
+
+ def _handle_image_content(self, content: ImageContent, stuff_id: str) -> None:
+ # Save the image
+ image_path = os.path.join(self.images_dir_path, f"{stuff_id}.{self.image_output_format}")
+ if content.url.startswith("http"):
+ image_bytes: bytes = fetch_file_from_url_httpx(url=content.url, timeout=10)
+ with open(image_path, "wb") as image_file:
+ image_file.write(image_bytes)
+ else:
+ image_path = content.url
+
+ ensure_path(self.images_dir_path)
+
+ def _handle_html_content(self, content: HtmlContent, stuff_id: str) -> None:
+ stuff_dir = os.path.join(self.result_dir_path, stuff_id)
+ ensure_path(stuff_dir)
+ # Save the raw HTML
+ save_text_to_path(content.inner_html, os.path.join(stuff_dir, f"{stuff_id}.html"))
+ # Save CSS class
+ save_text_to_path(content.css_class, os.path.join(stuff_dir, f"{stuff_id}_css.txt"))
+
+ def _handle_mermaid_content(self, content: MermaidContent, stuff_id: str) -> None:
+ # Save the Mermaid code
+ save_text_to_path(content.mermaid_code, os.path.join(self.result_dir_path, f"{stuff_id}.mmd"))
+
+ def _handle_structured_content(self, content: StructuredContent, stuff_id: str) -> None:
+ stuff_dir = os.path.join(self.result_dir_path, stuff_id)
+ ensure_path(stuff_dir)
+ # Save the structured content as JSON
+ save_as_json_to_path(content, os.path.join(stuff_dir, f"{stuff_id}.json"))
+ # Save rendered versions
+ save_text_to_path(content.rendered_markdown(), os.path.join(stuff_dir, f"{stuff_id}.md"))
+
+ def _handle_list_content(self, content: ListContent[StuffContent], stuff_id: str) -> None:
+ stuff_dir = os.path.join(self.result_dir_path, stuff_id)
+ ensure_path(stuff_dir)
+ # Save each item in the list
+ items_dir = os.path.join(stuff_dir, f"{stuff_id}_items")
+ ensure_path(items_dir)
+ for i, item in enumerate(content.items):
+ item_dir = os.path.join(items_dir, f"item_{i}")
+ ensure_path(item_dir)
+ save_text_to_path(str(item), os.path.join(item_dir, f"{stuff_id}_item_{i}.txt"))
+
+ # Save rendered versions of the full list
+ save_text_to_path(content.rendered_markdown(), os.path.join(stuff_dir, f"{stuff_id}.md"))
+ save_text_to_path(content.rendered_json(), os.path.join(stuff_dir, f"{stuff_id}.json"))
diff --git a/pipelex/mission/activity/activity_manager.py b/pipelex/mission/activity/activity_manager.py
new file mode 100644
index 000000000..358dc55c0
--- /dev/null
+++ b/pipelex/mission/activity/activity_manager.py
@@ -0,0 +1,47 @@
+from typing import Dict
+
+from pydantic import Field
+from typing_extensions import override
+
+from pipelex import log
+from pipelex.mission.activity.activity_manager_protocol import ActivityManagerProtocol
+from pipelex.mission.activity.activity_models import ActivityCallback, ActivityReport
+from pipelex.tools.exceptions import RootException
+
+
+class ActivityManagerError(RootException):
+ pass
+
+
+class ActivityManager(ActivityManagerProtocol):
+ def __init__(self) -> None:
+ self.activity_callbacks: Dict[str, ActivityCallback] = Field(default_factory=dict)
+ log.debug("ActivityManager initialized")
+
+ @override
+ def setup(self) -> None:
+ self._reset()
+
+ @override
+ def teardown(self) -> None:
+ self._reset()
+ log.debug("ActivityManager teardown done")
+
+ def _reset(self):
+ self.activity_callbacks = {}
+
+ @override
+ def add_activity_callback(self, key: str, callback: ActivityCallback):
+ if key in self.activity_callbacks:
+ log.warning(f"Activity callback with key '{key}' already exists")
+ self.activity_callbacks[key] = callback
+
+ @override
+ def remove_activity_callback(self, key: str):
+ self.activity_callbacks.pop(key, None)
+
+ @override
+ def dispatch_activity(self, activity_report: ActivityReport):
+ for key, callback in self.activity_callbacks.items():
+ log.dev(f"Dispatching activity to callback '{key}'")
+ callback(activity_report)
diff --git a/pipelex/mission/activity/activity_manager_protocol.py b/pipelex/mission/activity/activity_manager_protocol.py
new file mode 100644
index 000000000..81783b55e
--- /dev/null
+++ b/pipelex/mission/activity/activity_manager_protocol.py
@@ -0,0 +1,44 @@
+from typing import Protocol
+
+from typing_extensions import override
+
+from pipelex.mission.activity.activity_models import ActivityCallback, ActivityReport
+
+
+class ActivityManagerProtocol(Protocol):
+ def setup(self) -> None:
+ pass
+
+ def teardown(self) -> None:
+ pass
+
+ def add_activity_callback(self, key: str, callback: ActivityCallback):
+ pass
+
+ def remove_activity_callback(self, key: str):
+ pass
+
+ def dispatch_activity(self, activity_report: ActivityReport):
+ pass
+
+
+class ActivityManagerNoOp(ActivityManagerProtocol):
+ @override
+ def setup(self) -> None:
+ pass
+
+ @override
+ def teardown(self) -> None:
+ pass
+
+ @override
+ def add_activity_callback(self, key: str, callback: ActivityCallback):
+ pass
+
+ @override
+ def remove_activity_callback(self, key: str):
+ pass
+
+ @override
+ def dispatch_activity(self, activity_report: ActivityReport):
+ pass
diff --git a/pipelex/mission/activity/activity_models.py b/pipelex/mission/activity/activity_models.py
new file mode 100644
index 000000000..e99c93bc5
--- /dev/null
+++ b/pipelex/mission/activity/activity_models.py
@@ -0,0 +1,13 @@
+from typing import Any, Callable
+
+from pydantic import BaseModel
+
+from pipelex.mission.job_metadata import JobMetadata
+
+
+class ActivityReport(BaseModel):
+ job_metadata: JobMetadata
+ content: Any
+
+
+ActivityCallback = Callable[[ActivityReport], None]
diff --git a/pipelex/mission/execute.py b/pipelex/mission/execute.py
new file mode 100644
index 000000000..483f53b9d
--- /dev/null
+++ b/pipelex/mission/execute.py
@@ -0,0 +1,46 @@
+from typing import Optional, Tuple
+
+from pipelex import pretty_print
+from pipelex.core.pipe_output import PipeOutput
+from pipelex.core.pipe_run_params import PipeOutputMultiplicity
+from pipelex.core.pipe_run_params_factory import PipeRunParamsFactory
+from pipelex.core.working_memory import WorkingMemory
+from pipelex.hub import get_mission_manager, get_pipe_router, get_report_delegate, get_required_pipe
+from pipelex.mission.job_metadata import JobMetadata
+from pipelex.pipe_works.pipe_job_factory import PipeJobFactory
+
+
+async def execute_mission(
+ pipe_code: str,
+ working_memory: Optional[WorkingMemory] = None,
+ output_name: Optional[str] = None,
+ output_multiplicity: Optional[PipeOutputMultiplicity] = None,
+ dynamic_output_concept_code: Optional[str] = None,
+) -> Tuple[PipeOutput, str]:
+ mission = get_mission_manager().add_new_mission()
+ mission_id = mission.mission_id
+ get_report_delegate().open_registry(mission_id=mission_id)
+ pipe = get_required_pipe(pipe_code=pipe_code)
+
+ job_metadata = JobMetadata(
+ mission_id=mission_id,
+ )
+
+ pipe_run_params = PipeRunParamsFactory.make_run_params(
+ output_multiplicity=output_multiplicity,
+ dynamic_output_concept_code=dynamic_output_concept_code,
+ )
+
+ pretty_print(pipe, title=f"Running pipe '{pipe_code}'")
+ if working_memory:
+ working_memory.pretty_print_summary()
+
+ pipe_job = PipeJobFactory.make_pipe_job(
+ pipe=pipe,
+ pipe_run_params=pipe_run_params,
+ job_metadata=job_metadata,
+ working_memory=working_memory,
+ output_name=output_name,
+ )
+
+ return await get_pipe_router().run_pipe_job(pipe_job), mission_id
diff --git a/pipelex/mission/job_metadata.py b/pipelex/mission/job_metadata.py
new file mode 100644
index 000000000..cbae48cd8
--- /dev/null
+++ b/pipelex/mission/job_metadata.py
@@ -0,0 +1,65 @@
+from datetime import datetime
+from enum import StrEnum
+from typing import List, Optional
+
+from pydantic import BaseModel, ConfigDict, Field
+
+from pipelex.mission.mission_models import SpecialMissionId
+
+
+class JobCategory(StrEnum):
+ MOCK_JOB = "mock_job"
+ LLM_JOB = "llm_job"
+ IMGG_JOB = "imgg_job"
+ PROMPTING_JOB = "prompting_job"
+ JINJA2_JOB = "jinja2_job"
+ OCR_JOB = "ocr_job"
+
+
+class UnitJobId(StrEnum):
+ LLM_GEN_TEXT = "llm_gen_text"
+ LLM_GEN_OBJECT = "llm_gen_object"
+ IMGG_TEXT_TO_IMAGE = "imgg_text_to_image"
+ OCR_EXTRACT_PAGES = "ocr_extract_pages"
+
+
+class JobMetadata(BaseModel):
+ model_config = ConfigDict(arbitrary_types_allowed=True)
+
+ mission_id: str = Field(default=SpecialMissionId.UNTITLED)
+ top_job_id: Optional[str] = None
+ pipe_job_ids: Optional[List[str]] = None
+ content_generation_job_id: Optional[str] = None
+ job_category: Optional[JobCategory] = None
+ unit_job_id: Optional[str] = None
+
+ started_at: Optional[datetime] = Field(default_factory=lambda: datetime.now())
+ completed_at: Optional[datetime] = None
+
+ @property
+ def duration(self) -> Optional[float]:
+ if self.started_at is not None and self.completed_at is not None:
+ return (self.completed_at - self.started_at).total_seconds()
+ return None
+
+ def update(self, updated_metadata: "JobMetadata"):
+ if updated_metadata.job_category:
+ self.job_category = updated_metadata.job_category
+ if updated_metadata.top_job_id:
+ self.top_job_id = updated_metadata.top_job_id
+ if updated_metadata.pipe_job_ids:
+ self.pipe_job_ids = self.pipe_job_ids or []
+ self.pipe_job_ids.extend(updated_metadata.pipe_job_ids)
+ if updated_metadata.content_generation_job_id:
+ self.content_generation_job_id = updated_metadata.content_generation_job_id
+ if updated_metadata.unit_job_id:
+ self.unit_job_id = updated_metadata.unit_job_id
+ if updated_metadata.started_at:
+ self.started_at = updated_metadata.started_at
+ if updated_metadata.completed_at:
+ self.completed_at = updated_metadata.completed_at
+
+ def copy_with_update(self, updated_metadata: "JobMetadata") -> "JobMetadata":
+ new_metadata = self.model_copy()
+ new_metadata.update(updated_metadata=updated_metadata)
+ return new_metadata
diff --git a/pipelex/mission/mission.py b/pipelex/mission/mission.py
new file mode 100644
index 000000000..4ff33840e
--- /dev/null
+++ b/pipelex/mission/mission.py
@@ -0,0 +1,5 @@
+from pydantic import BaseModel
+
+
+class Mission(BaseModel):
+ mission_id: str
diff --git a/pipelex/mission/mission_factory.py b/pipelex/mission/mission_factory.py
new file mode 100644
index 000000000..e293e72d4
--- /dev/null
+++ b/pipelex/mission/mission_factory.py
@@ -0,0 +1,11 @@
+import shortuuid
+
+from pipelex.mission.mission import Mission
+
+
+class MissionFactory:
+ @classmethod
+ def make_mission(cls) -> Mission:
+ return Mission(
+ mission_id=shortuuid.uuid(),
+ )
diff --git a/pipelex/mission/mission_manager.py b/pipelex/mission/mission_manager.py
new file mode 100644
index 000000000..4ca834966
--- /dev/null
+++ b/pipelex/mission/mission_manager.py
@@ -0,0 +1,44 @@
+from typing import Dict, Optional
+
+from pydantic import Field, RootModel
+from typing_extensions import override
+
+from pipelex.exceptions import MissionManagerNotFoundError
+from pipelex.mission.mission import Mission
+from pipelex.mission.mission_factory import MissionFactory
+from pipelex.mission.mission_manager_abstract import MissionManagerAbstract
+
+MissionManagerRoot = Dict[str, Mission]
+
+
+class MissionManager(MissionManagerAbstract, RootModel[MissionManagerRoot]):
+ root: MissionManagerRoot = Field(default_factory=dict)
+
+ @override
+ def setup(self):
+ pass
+
+ @override
+ def teardown(self):
+ self.root.clear()
+
+ @override
+ def get_optional_mission(self, mission_id: str) -> Optional[Mission]:
+ return self.root.get(mission_id)
+
+ @override
+ def get_mission(self, mission_id: str) -> Mission:
+ mission = self.get_optional_mission(mission_id=mission_id)
+ if mission is None:
+ raise MissionManagerNotFoundError(f"Mission {mission_id} not found")
+ return mission
+
+ def _set_mission(self, mission_id: str, mission: Mission) -> Mission:
+ self.root[mission_id] = mission
+ return mission
+
+ @override
+ def add_new_mission(self) -> Mission:
+ mission = MissionFactory.make_mission()
+ self._set_mission(mission_id=mission.mission_id, mission=mission)
+ return mission
diff --git a/pipelex/mission/mission_manager_abstract.py b/pipelex/mission/mission_manager_abstract.py
new file mode 100644
index 000000000..dfc69684d
--- /dev/null
+++ b/pipelex/mission/mission_manager_abstract.py
@@ -0,0 +1,26 @@
+from abc import ABC, abstractmethod
+from typing import Optional
+
+from pipelex.mission.mission import Mission
+
+
+class MissionManagerAbstract(ABC):
+ @abstractmethod
+ def setup(self) -> None:
+ pass
+
+ @abstractmethod
+ def teardown(self) -> None:
+ pass
+
+ @abstractmethod
+ def get_optional_mission(self, mission_id: str) -> Optional[Mission]:
+ pass
+
+ @abstractmethod
+ def get_mission(self, mission_id: str) -> Mission:
+ pass
+
+ @abstractmethod
+ def add_new_mission(self) -> Mission:
+ pass
diff --git a/pipelex/mission/mission_models.py b/pipelex/mission/mission_models.py
new file mode 100644
index 000000000..97c0ca6d0
--- /dev/null
+++ b/pipelex/mission/mission_models.py
@@ -0,0 +1,5 @@
+from enum import StrEnum
+
+
+class SpecialMissionId(StrEnum):
+ UNTITLED = "untitled"
diff --git a/pipelex/mission/track/__init__.py b/pipelex/mission/track/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/pipelex/mission/track/__init__.py
@@ -0,0 +1 @@
+
diff --git a/pipelex/mission/track/flow_chart.py b/pipelex/mission/track/flow_chart.py
new file mode 100644
index 000000000..856c12dd8
--- /dev/null
+++ b/pipelex/mission/track/flow_chart.py
@@ -0,0 +1,204 @@
+# pyright: reportUnknownVariableType=false
+# pyright: reportUnknownArgumentType=false
+# pyright: reportUnknownMemberType=false
+# pyright: reportUnknownParameterType=false
+# pyright: reportMissingTypeArgument=false
+from typing import Any, Dict, List, Optional, Tuple
+
+import networkx as nx
+import yaml
+
+from pipelex import log
+from pipelex.exceptions import JobHistoryError
+from pipelex.mission.track.tracker_config import TrackerConfig
+from pipelex.mission.track.tracker_models import (
+ EdgeAttributeKey,
+ EdgeCategory,
+ GraphTree,
+ NodeAttributeKey,
+ NodeCategory,
+ SubGraphClassDef,
+)
+from pipelex.tools.misc.mermaid_utils import clean_str_for_mermaid_node_title, make_mermaid_url
+from pipelex.tools.misc.string_utils import snake_to_capitalize_first_letter
+
+
+def nice_edge_tag(edge_tag: str) -> str:
+ return f'"{snake_to_capitalize_first_letter(edge_tag)}"'
+
+
+def _indent_line(line: str, indent: int) -> str:
+ return f"{' ' * indent}{line}"
+
+
+class MissionFlowChart:
+ def __init__(self, nx_graph: nx.DiGraph, start_node: str, tracker_config: TrackerConfig):
+ self.nx_graph = nx_graph
+ self._tracker_config = tracker_config
+ self.is_debug_mode = tracker_config.is_debug_mode
+ self.start_node = start_node
+ self.sub_graph_class_defs: List[SubGraphClassDef] = []
+ for sub_graph_index, sub_graph_color in enumerate(self._tracker_config.sub_graph_colors):
+ class_def_letter = chr(ord("a") + sub_graph_index)
+ class_def_name = f"sub_{class_def_letter}"
+ self.sub_graph_class_defs.append(SubGraphClassDef(name=class_def_name, color=sub_graph_color))
+
+ def generate_mermaid_flowchart(
+ self,
+ title: Optional[str] = None,
+ subtitle: Optional[str] = None,
+ ) -> Tuple[str, str]:
+ nb_nodes = len(self.nx_graph.nodes)
+ if nb_nodes == 0:
+ raise JobHistoryError("Graph has no nodes")
+ log.debug(f"Generating mermaid flowchart for the whole graph which holds {nb_nodes} nodes")
+ mermaid_settings: Dict[str, Any] = {}
+ if title:
+ mermaid_settings["title"] = title
+ mermaid_settings["config"] = {}
+ if self._tracker_config.applied_theme:
+ mermaid_settings["config"]["theme"] = self._tracker_config.applied_theme
+ if self._tracker_config.applied_layout:
+ mermaid_settings["config"]["layout"] = self._tracker_config.applied_layout
+ if self._tracker_config.applied_wrapping_width:
+ mermaid_settings["config"]["flowchart"] = {"wrappingWidth": self._tracker_config.applied_wrapping_width}
+ mermaid_code = "---\n"
+ mermaid_code += yaml.dump(mermaid_settings)
+ mermaid_code += "---\n"
+ mermaid_code += "flowchart LR\n"
+
+ graph_tree: GraphTree = GraphTree(nodes_by_subgraph={})
+
+ # First pass: Collect nodes into their respective subgraphs
+ for node in self.nx_graph.nodes:
+ node_attributes = self.nx_graph.nodes[node]
+ if not node_attributes:
+ raise JobHistoryError(f"Node attributes are empty for node '{node}'")
+ node_pipe_layer = node_attributes.get(NodeAttributeKey.SUBGRAPH)
+ if not node_pipe_layer:
+ node_pipe_layer = "Unknown"
+ elif not isinstance(node_pipe_layer, str):
+ raise JobHistoryError(f"Node '{node}' has no pipe stack: {node_attributes}")
+
+ sub_graph = node_pipe_layer or "root"
+ # Split sub_graph by "-" and keep the last token
+ if "-" in sub_graph:
+ sub_graph = sub_graph.split("-")[-1]
+ if sub_graph not in graph_tree.nodes_by_subgraph:
+ graph_tree.nodes_by_subgraph[sub_graph] = []
+ graph_tree.nodes_by_subgraph[sub_graph].append(node)
+
+ log.verbose(graph_tree, title="Graph tree")
+
+ subgraph_lines = self.generate_subgraph_lines(graph_tree)
+ mermaid_code += "\n".join(subgraph_lines)
+ mermaid_code += "\n"
+
+ # Generate subtitle
+ if subtitle:
+ # this is a hack to add something that looks like a subtitle, but it's actually a node with no stroke and no visible link
+ # if self.start_node is None:
+ # raise JobHistoryError("Start node is not set")
+ mermaid_code += f"""
+ classDef subtitleNodeClass fill:transparent,stroke:#333,stroke-width:0px;
+ __subtitle__["{subtitle}"]
+ class __subtitle__ subtitleNodeClass;
+ __subtitle__ --> {self.start_node}
+ linkStyle 0 stroke:transparent,stroke-width:0px
+"""
+
+ for sub_graph_class_def in self.sub_graph_class_defs:
+ mermaid_code += f"""
+ classDef {sub_graph_class_def.name} fill:{sub_graph_class_def.color},color:#333,stroke:#333;
+"""
+
+ # Generate edges
+ for edge in self.nx_graph.edges(data=True):
+ source, target, edge_data = edge
+ edge_tag: str
+ edge_type = EdgeCategory(edge_data[EdgeAttributeKey.EDGE_CATEGORY])
+ match edge_type:
+ case EdgeCategory.PIPE:
+ if pipe_code := edge_data.get(EdgeAttributeKey.PIPE_CODE):
+ edge_tag = nice_edge_tag(pipe_code)
+ mermaid_code += f" {source} -- {edge_tag} {self._tracker_config.pipe_edge_style} {target}\n"
+ else:
+ raise JobHistoryError(f"Pipe edge missing pipe code: {edge_data}")
+ case EdgeCategory.BATCH:
+ mermaid_code += f" {source} {self._tracker_config.branch_edge_style} {target}\n"
+ case EdgeCategory.AGGREGATE:
+ mermaid_code += f" {source} {self._tracker_config.aggregate_edge_style} {target}\n"
+ case EdgeCategory.CONDITION:
+ condition_expression = edge_data.get(EdgeAttributeKey.CONDITION_EXPRESSION)
+ if not condition_expression:
+ raise JobHistoryError(f"Condition edge missing condition expression: {edge_data}")
+ edge_tag = nice_edge_tag(condition_expression)
+ mermaid_code += f" {source} {self._tracker_config.condition_edge_style} {target}\n"
+ case EdgeCategory.CHOICE:
+ chosen_pipe_code = edge_data.get(EdgeAttributeKey.CHOSEN_PIPE)
+ if not chosen_pipe_code:
+ raise JobHistoryError(f"No chosen pipe code set for edge {source} --- {target}")
+ edge_tag = nice_edge_tag(chosen_pipe_code)
+ mermaid_code += f" {source} -- {edge_tag} {self._tracker_config.choice_edge_style} {target}\n"
+
+ url = make_mermaid_url(mermaid_code)
+ return mermaid_code, url
+
+ def generate_subgraph_lines(self, graph_tree: GraphTree) -> List[str]:
+ subgraph_lines: List[str] = []
+ subgraph_class_lines: List[str] = []
+
+ cycle = 0
+ for subgraph_name, nodes in graph_tree.nodes_by_subgraph.items():
+ node_lines: List[str] = []
+ for node in nodes:
+ # log.debug(f"generate_subgraph_lines for node '{node}'")
+ node_attributes = self.nx_graph.nodes[node]
+ if not node_attributes:
+ raise JobHistoryError(f"Node attributes are empty for node '{node}'")
+ node_category = NodeCategory(node_attributes[NodeAttributeKey.CATEGORY])
+ node_tag = node_attributes[NodeAttributeKey.TAG]
+ if not node_tag:
+ raise JobHistoryError(f"Node tag is empty for node '{node}'")
+ node_text = node_tag
+ if self.is_debug_mode:
+ if node_comment := node_attributes.get(NodeAttributeKey.COMMENT):
+ node_text += f"\n\n{node_comment}"
+ else:
+ node_text += "\n\nNo comment"
+ if node_debug_info := node_attributes.get(NodeAttributeKey.DEBUG_INFO):
+ node_text += f"\n\n{node_debug_info}"
+ match node_category:
+ case NodeCategory.SPECIAL:
+ node_lines.append(f'{node}(["{node_text}"])')
+ case NodeCategory.STUFF:
+ node_lines.append(f'{node}["{node_text}"]')
+ case NodeCategory.CONDITION:
+ node_lines.append(f'{node}{{"{node_text}"}}')
+ if self._tracker_config.is_include_interactivity:
+ if node_description := node_attributes.get(NodeAttributeKey.DESCRIPTION):
+ if not isinstance(node_description, str):
+ raise JobHistoryError(f"Node description is not a string: {node_description}")
+ node_description = clean_str_for_mermaid_node_title(node_description)
+ node_lines.append(f'click {node} stuff_node_callback "{node_description}"')
+
+ if not node_lines:
+ raise JobHistoryError(f"No node lines found for subgraph '{subgraph_name}'")
+
+ if subgraph_name == "root":
+ for mermaid_line in node_lines:
+ subgraph_lines.append(_indent_line(mermaid_line, 2))
+ else:
+ subgraph_lines.append(_indent_line(f'subgraph "{subgraph_name}"', 1))
+ subgraph_lines.append(_indent_line("direction LR", 1))
+ for mermaid_line in node_lines:
+ subgraph_lines.append(_indent_line(mermaid_line, 2))
+ subgraph_lines.append(_indent_line("end", 1))
+
+ class_def = self.sub_graph_class_defs[cycle % len(self.sub_graph_class_defs)]
+ subgraph_class_lines.append(f"class {subgraph_name} {class_def.name};")
+ cycle += 1
+
+ subgraph_lines.extend(subgraph_class_lines)
+
+ return subgraph_lines
diff --git a/pipelex/mission/track/mission_tracker.py b/pipelex/mission/track/mission_tracker.py
new file mode 100644
index 000000000..832aa529e
--- /dev/null
+++ b/pipelex/mission/track/mission_tracker.py
@@ -0,0 +1,358 @@
+# pyright: reportUnknownVariableType=false
+# pyright: reportUnknownArgumentType=false
+# pyright: reportUnknownMemberType=false
+# pyright: reportMissingTypeArgument=false
+from typing import Any, Dict, List, Optional
+
+import networkx as nx
+from typing_extensions import override
+
+from pipelex import log
+from pipelex.core.concept import Concept
+from pipelex.core.stuff import Stuff
+from pipelex.exceptions import JobHistoryError
+from pipelex.mission.track.flow_chart import MissionFlowChart
+from pipelex.mission.track.mission_tracker_protocol import MissionTrackerProtocol
+from pipelex.mission.track.tracker_config import TrackerConfig
+from pipelex.mission.track.tracker_models import (
+ EdgeAttributeKey,
+ EdgeCategory,
+ NodeAttributeKey,
+ NodeCategory,
+ SpecialNodeName,
+)
+from pipelex.pipe_controllers.pipe_condition_details import PipeConditionDetails
+from pipelex.tools.misc.mermaid_utils import print_mermaid_url
+
+
+# TODO: manage a separate graph for each mission_id
+# TODO: restore disabled tracking functionality in PipeBatch
+class MissionTracker(MissionTrackerProtocol):
+ def __init__(self, tracker_config: TrackerConfig):
+ self._tracker_config = tracker_config
+ self._is_debug_mode = tracker_config.is_debug_mode
+ self.is_active: bool = False
+ self.nx_graph: nx.DiGraph = nx.DiGraph()
+ self.start_node: Optional[str] = None
+
+ @override
+ def setup(self):
+ self.is_active = True
+
+ @override
+ def teardown(self):
+ self.is_active = False
+ self.nx_graph = nx.DiGraph()
+ self.start_node = None
+
+ def _get_node_name(self, node: str) -> Optional[str]:
+ node_attributes = self.nx_graph.nodes[node]
+ node_name = node_attributes[NodeAttributeKey.NAME]
+ if isinstance(node_name, str):
+ return node_name
+ else:
+ raise JobHistoryError(f"Node name is not a string: {node_name}")
+
+ def _pipe_layer_to_subgraph_name(self, pipe_layer: List[str]) -> str:
+ return "-".join(pipe_layer)
+
+ def _add_start_node(self) -> str:
+ node = SpecialNodeName.START
+ node_attributes: Dict[str, Any] = {
+ NodeAttributeKey.CATEGORY: NodeCategory.SPECIAL,
+ NodeAttributeKey.TAG: "Start",
+ NodeAttributeKey.NAME: "Start",
+ }
+ self.nx_graph.add_node(node, **node_attributes)
+ return node
+
+ def _make_stuff_node_tag(
+ self,
+ stuff: Stuff,
+ as_item_index: Optional[int] = None,
+ ) -> str:
+ concept_code = stuff.concept_code
+ concept_display = Concept.sentence_from_concept_code(concept_code=concept_code)
+ log.debug(f"Concept display: {concept_code} -> {concept_display}")
+ if stuff.is_list:
+ concept_display = f"List of [{concept_display}]"
+ if as_item_index is not None:
+ return f"**{concept_display}** #{as_item_index + 1}"
+ else:
+ name = stuff.stuff_name
+ if not name:
+ raise JobHistoryError(f"Stuff name is empty for stuff {stuff}")
+ return f"{name}:<br>**{concept_display}**"
+
+ def _add_stuff_node(
+ self,
+ stuff: Stuff,
+ pipe_layer: List[str],
+ comment: str,
+ as_item_index: Optional[int] = None,
+ ) -> str:
+ node = stuff.stuff_code
+ is_existing = self.nx_graph.has_node(node)
+ if is_existing:
+ if self._is_debug_mode:
+ existing_comment = self.nx_graph.nodes[node][NodeAttributeKey.COMMENT]
+ comment = f"{existing_comment}<br/>+ {comment}"
+ self.nx_graph.nodes[node][NodeAttributeKey.COMMENT] = comment
+ return node
+
+ stuff_content_rendered = stuff.content.rendered_plain()[:250]
+ stuff_content_type = type(stuff.content).__name__
+ stuff_description = f"{stuff_content_type}"
+ stuff_description += f"<br/><br/>{stuff_content_rendered}…"
+
+ node_tag = self._make_stuff_node_tag(
+ stuff=stuff,
+ as_item_index=as_item_index,
+ )
+ if stuff.is_text and self._tracker_config.is_include_text_preview:
+ node_tag += f"<br/>{stuff_content_rendered[:100]}"
+ pipe_layer_str = self._pipe_layer_to_subgraph_name(pipe_layer)
+ node_attributes: Dict[str, Any] = {
+ NodeAttributeKey.CATEGORY: NodeCategory.STUFF,
+ NodeAttributeKey.TAG: node_tag,
+ NodeAttributeKey.NAME: stuff.stuff_name,
+ NodeAttributeKey.DESCRIPTION: stuff_description,
+ NodeAttributeKey.DEBUG_INFO: stuff.stuff_code,
+ NodeAttributeKey.COMMENT: comment,
+ NodeAttributeKey.SUBGRAPH: pipe_layer_str,
+ }
+ self.nx_graph.add_node(node, **node_attributes)
+ return node
+
+ def _add_edge(
+ self,
+ from_node: str,
+ to_node: str,
+ edge_category: EdgeCategory,
+ attributes: Optional[Dict[str, Any]] = None,
+ ):
+ # Ensure both nodes exist with attributes
+ if not self.nx_graph.has_node(from_node):
+ raise JobHistoryError(f"Source node '{from_node}' does not exist")
+ if not self.nx_graph.has_node(to_node):
+ raise JobHistoryError(f"Target node '{to_node}' does not exist")
+ if not self.nx_graph.nodes[from_node]:
+ raise JobHistoryError(f"Source node '{from_node}' exists but has no attributes")
+ if not self.nx_graph.nodes[to_node]:
+ raise JobHistoryError(f"Target node '{to_node}' exists but has no attributes")
+
+ edge_attributes: Dict[str, Any] = {
+ EdgeAttributeKey.EDGE_CATEGORY: edge_category,
+ }
+ if attributes:
+ edge_attributes.update(attributes)
+ self.nx_graph.add_edge(from_node, to_node, **edge_attributes)
+
+ @override
+ def add_pipe_step(
+ self,
+ from_stuff: Optional[Stuff],
+ to_stuff: Stuff,
+ pipe_code: str,
+ comment: str,
+ pipe_layer: List[str],
+ as_item_index: Optional[int] = None,
+ is_with_edge: bool = True,
+ ):
+ if not self.is_active:
+ return
+ from_node: str
+ if from_stuff:
+ from_node = self._add_stuff_node(
+ stuff=from_stuff,
+ as_item_index=as_item_index,
+ pipe_layer=pipe_layer,
+ comment=comment,
+ )
+ else:
+ from_node = self._add_start_node()
+ if self.start_node is None:
+ self.start_node = from_node
+ to_node = self._add_stuff_node(
+ stuff=to_stuff,
+ as_item_index=as_item_index,
+ pipe_layer=pipe_layer,
+ comment=comment,
+ )
+ edge_caption = pipe_code
+ if self._is_debug_mode:
+ edge_caption += f" ({comment})"
+ edge_attributes: Dict[str, Any] = {
+ EdgeAttributeKey.PIPE_CODE: edge_caption,
+ }
+ if is_with_edge:
+ self._add_edge(
+ from_node=from_node,
+ to_node=to_node,
+ edge_category=EdgeCategory.PIPE,
+ attributes=edge_attributes,
+ )
+
+ @override
+ def add_batch_step(
+ self,
+ from_stuff: Optional[Stuff],
+ to_stuff: Stuff,
+ to_branch_index: int,
+ pipe_layer: List[str],
+ comment: str,
+ ):
+ if not self.is_active:
+ return
+ from_node: str
+ if from_stuff:
+ from_node = self._add_stuff_node(
+ stuff=from_stuff,
+ pipe_layer=pipe_layer,
+ comment=comment,
+ )
+ else:
+ from_node = self._add_start_node()
+ if self.start_node is None:
+ self.start_node = from_node
+ to_node = self._add_stuff_node(
+ stuff=to_stuff,
+ as_item_index=to_branch_index,
+ pipe_layer=pipe_layer,
+ comment=comment,
+ )
+ self._add_edge(
+ from_node=from_node,
+ to_node=to_node,
+ edge_category=EdgeCategory.BATCH,
+ )
+
+ @override
+ def add_aggregate_step(
+ self,
+ from_stuff: Stuff,
+ to_stuff: Stuff,
+ pipe_layer: List[str],
+ comment: str,
+ ):
+ if not self.is_active:
+ return
+ from_node = self._add_stuff_node(
+ stuff=from_stuff,
+ pipe_layer=pipe_layer,
+ comment=comment,
+ )
+ to_node = self._add_stuff_node(
+ stuff=to_stuff,
+ pipe_layer=pipe_layer,
+ comment=comment,
+ )
+ self._add_edge(
+ from_node=from_node,
+ to_node=to_node,
+ edge_category=EdgeCategory.AGGREGATE,
+ )
+
+ def _add_condition_node(self, condition: PipeConditionDetails, pipe_layer: List[str]) -> str:
+ node = condition.code
+ condition_node_tag = f"Condition:<br>**{condition.test_expression}<br>= {condition.evaluated_expression}**"
+ pipe_layer_str = self._pipe_layer_to_subgraph_name(pipe_layer)
+ node_attributes: Dict[str, Any] = {
+ NodeAttributeKey.CATEGORY: NodeCategory.CONDITION,
+ NodeAttributeKey.TAG: condition_node_tag,
+ NodeAttributeKey.NAME: condition.code,
+ NodeAttributeKey.SUBGRAPH: pipe_layer_str,
+ }
+ self.nx_graph.add_node(node, **node_attributes)
+ return node
+
+ @override
+ def add_condition_step(
+ self,
+ from_stuff: Stuff,
+ to_condition: PipeConditionDetails,
+ condition_expression: str,
+ pipe_layer: List[str],
+ comment: str,
+ ):
+ if not self.is_active:
+ return
+ from_node = self._add_stuff_node(
+ stuff=from_stuff,
+ pipe_layer=pipe_layer,
+ comment=comment,
+ )
+ to_node = self._add_condition_node(condition=to_condition, pipe_layer=pipe_layer)
+ edge_attributes: Dict[str, Any] = {
+ EdgeAttributeKey.CONDITION_EXPRESSION: condition_expression,
+ }
+ self._add_edge(
+ from_node=from_node,
+ to_node=to_node,
+ edge_category=EdgeCategory.CONDITION,
+ attributes=edge_attributes,
+ )
+
+ @override
+ def add_choice_step(
+ self,
+ from_condition: PipeConditionDetails,
+ to_stuff: Stuff,
+ pipe_layer: List[str],
+ comment: str,
+ ):
+ if not self.is_active:
+ return
+ to_node = self._add_stuff_node(
+ stuff=to_stuff,
+ pipe_layer=pipe_layer,
+ comment=comment,
+ )
+ edge_attributes: Dict[str, Any] = {
+ EdgeAttributeKey.CHOSEN_PIPE: from_condition.chosen_pipe_code,
+ }
+ self._add_edge(
+ from_node=from_condition.code,
+ to_node=to_node,
+ edge_category=EdgeCategory.CHOICE,
+ attributes=edge_attributes,
+ )
+
+ def _print_mermaid_flowchart_code_and_url(self, title: Optional[str] = None, subtitle: Optional[str] = None):
+ if not self.nx_graph.nodes:
+ log.info("No nodes in the mission tracker")
+ return
+ if self.start_node is None:
+ raise JobHistoryError("Start node is not set")
+ flowchart = MissionFlowChart(nx_graph=self.nx_graph, start_node=self.start_node, tracker_config=self._tracker_config)
+ mermaid_code, url = flowchart.generate_mermaid_flowchart(title=title, subtitle=subtitle)
+ print(mermaid_code)
+ title_to_print = "Mermaid flowchart URL"
+ if title:
+ title_to_print += f" for {title}"
+ print_mermaid_url(url=url, title=title_to_print)
+
+ def _print_mermaid_flowchart_url(self, title: Optional[str] = None, subtitle: Optional[str] = None):
+ if not self.nx_graph.nodes:
+ log.info("No nodes in the mission tracker")
+ return
+ if self.start_node is None:
+ raise JobHistoryError("Start node is not set")
+ flowchart = MissionFlowChart(nx_graph=self.nx_graph, start_node=self.start_node, tracker_config=self._tracker_config)
+ _, url = flowchart.generate_mermaid_flowchart(title=title, subtitle=subtitle)
+ title_to_print = "Mermaid flowchart URL"
+ if title:
+ title_to_print += f" for {title}"
+ print_mermaid_url(url=url, title=title_to_print)
+
+ @override
+ def output_flowchart(
+ self,
+ title: Optional[str] = None,
+ subtitle: Optional[str] = None,
+ is_detailed: bool = False,
+ ):
+ if is_detailed:
+ self._print_mermaid_flowchart_code_and_url(title=title, subtitle=subtitle)
+ else:
+ self._print_mermaid_flowchart_url(title=title, subtitle=subtitle)
diff --git a/pipelex/mission/track/mission_tracker_protocol.py b/pipelex/mission/track/mission_tracker_protocol.py
new file mode 100644
index 000000000..f71400134
--- /dev/null
+++ b/pipelex/mission/track/mission_tracker_protocol.py
@@ -0,0 +1,147 @@
+# pyright: reportUnknownVariableType=false
+# pyright: reportUnknownArgumentType=false
+# pyright: reportUnknownMemberType=false
+# pyright: reportMissingTypeArgument=false
+from typing import List, Optional, Protocol
+
+from typing_extensions import override
+
+from pipelex.core.stuff import Stuff
+from pipelex.pipe_controllers.pipe_condition_details import PipeConditionDetails
+
+
+class MissionTrackerProtocol(Protocol):
+ def setup(self): ...
+
+ def teardown(self): ...
+
+ # def reset(self): ...
+ def add_pipe_step(
+ self,
+ from_stuff: Optional[Stuff],
+ to_stuff: Stuff,
+ pipe_code: str,
+ comment: str,
+ pipe_layer: List[str],
+ as_item_index: Optional[int] = None,
+ is_with_edge: bool = True,
+ ): ...
+
+ def add_batch_step(
+ self,
+ from_stuff: Optional[Stuff],
+ to_stuff: Stuff,
+ to_branch_index: int,
+ pipe_layer: List[str],
+ comment: str,
+ ): ...
+
+ def add_aggregate_step(
+ self,
+ from_stuff: Stuff,
+ to_stuff: Stuff,
+ pipe_layer: List[str],
+ comment: str,
+ ): ...
+
+ def add_condition_step(
+ self,
+ from_stuff: Stuff,
+ to_condition: PipeConditionDetails,
+ condition_expression: str,
+ pipe_layer: List[str],
+ comment: str,
+ ): ...
+
+ def add_choice_step(
+ self,
+ from_condition: PipeConditionDetails,
+ to_stuff: Stuff,
+ pipe_layer: List[str],
+ comment: str,
+ ): ...
+
+ def output_flowchart(
+ self,
+ title: Optional[str] = None,
+ subtitle: Optional[str] = None,
+ is_detailed: bool = False,
+ ): ...
+
+
+class MissionTrackerNoOp(MissionTrackerProtocol):
+ """A no-operation implementation of MissionTrackerProtocol that does nothing.
+ This is useful when mission tracking needs to be disabled.
+ """
+
+ @override
+ def setup(self) -> None:
+ pass
+
+ @override
+ def teardown(self) -> None:
+ pass
+
+ @override
+ def add_pipe_step(
+ self,
+ from_stuff: Optional[Stuff],
+ to_stuff: Stuff,
+ pipe_code: str,
+ comment: str,
+ pipe_layer: List[str],
+ as_item_index: Optional[int] = None,
+ is_with_edge: bool = True,
+ ) -> None:
+ pass
+
+ @override
+ def add_batch_step(
+ self,
+ from_stuff: Optional[Stuff],
+ to_stuff: Stuff,
+ to_branch_index: int,
+ pipe_layer: List[str],
+ comment: str,
+ ) -> None:
+ pass
+
+ @override
+ def add_aggregate_step(
+ self,
+ from_stuff: Stuff,
+ to_stuff: Stuff,
+ pipe_layer: List[str],
+ comment: str,
+ ) -> None:
+ pass
+
+ @override
+ def add_condition_step(
+ self,
+ from_stuff: Stuff,
+ to_condition: PipeConditionDetails,
+ condition_expression: str,
+ pipe_layer: List[str],
+ comment: str,
+ ) -> None:
+ pass
+
+ @override
+ def add_choice_step(
+ self,
+ from_condition: PipeConditionDetails,
+ to_stuff: Stuff,
+ pipe_layer: List[str],
+ comment: str,
+ ) -> None:
+ pass
+
+ @override
+ def output_flowchart(
+ self,
+ title: Optional[str] = None,
+ subtitle: Optional[str] = None,
+ is_detailed: bool = False,
+ ) -> None:
+ pass
diff --git a/pipelex/mission/track/tracker_config.py b/pipelex/mission/track/tracker_config.py
new file mode 100644
index 000000000..99d8d2160
--- /dev/null
+++ b/pipelex/mission/track/tracker_config.py
@@ -0,0 +1,47 @@
+from typing import List, Literal, Optional, Union
+
+from pipelex.tools.config.models import ConfigModel
+
+
+class TrackerConfig(ConfigModel):
+ is_debug_mode: bool
+ is_include_text_preview: bool
+ is_include_interactivity: bool
+ theme: Union[str, Literal["auto"]]
+ layout: Union[str, Literal["auto"]]
+ wrapping_width: Union[int, Literal["auto"]]
+ nb_items_limit: Union[int, Literal["unlimited"]]
+ sub_graph_colors: List[str]
+ pipe_edge_style: str
+ branch_edge_style: str
+ aggregate_edge_style: str
+ condition_edge_style: str
+ choice_edge_style: str
+
+ @property
+ def applied_theme(self) -> Optional[str]:
+ if self.theme == "auto":
+ return None
+ else:
+ return self.theme
+
+ @property
+ def applied_layout(self) -> Optional[str]:
+ if self.layout == "auto":
+ return None
+ else:
+ return self.layout
+
+ @property
+ def applied_wrapping_width(self) -> Optional[int]:
+ if self.wrapping_width == "auto":
+ return None
+ else:
+ return self.wrapping_width
+
+ @property
+ def applied_nb_items_limit(self) -> Optional[int]:
+ if self.nb_items_limit == "unlimited":
+ return None
+ else:
+ return self.nb_items_limit
diff --git a/pipelex/mission/track/tracker_models.py b/pipelex/mission/track/tracker_models.py
new file mode 100644
index 000000000..1de2c0e4c
--- /dev/null
+++ b/pipelex/mission/track/tracker_models.py
@@ -0,0 +1,48 @@
+from enum import StrEnum
+from typing import Dict, List
+
+from pydantic import BaseModel
+
+
+class NodeCategory(StrEnum):
+ SPECIAL = "special"
+ STUFF = "stuff"
+ CONDITION = "condition"
+
+
+class NodeAttributeKey(StrEnum):
+ CATEGORY = "category"
+ NAME = "name"
+ TAG = "tag"
+ DESCRIPTION = "description"
+ DEBUG_INFO = "debug_info"
+ SUBGRAPH = "subgraph"
+ COMMENT = "comment"
+
+
+class SpecialNodeName(StrEnum):
+ START = "start"
+
+
+class EdgeCategory(StrEnum):
+ PIPE = "pipe"
+ BATCH = "batch"
+ AGGREGATE = "aggregate"
+ CONDITION = "condition"
+ CHOICE = "choice"
+
+
+class EdgeAttributeKey(StrEnum):
+ EDGE_CATEGORY = "edge_category"
+ PIPE_CODE = "pipe_code"
+ CONDITION_EXPRESSION = "condition_expression"
+ CHOSEN_PIPE = "chosen_pipe"
+
+
+class GraphTree(BaseModel):
+ nodes_by_subgraph: Dict[str, List[str]]
+
+
+class SubGraphClassDef(BaseModel):
+ name: str
+ color: str
diff --git a/pipelex/pipe_controllers/__init__.py b/pipelex/pipe_controllers/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/pipelex/pipe_controllers/__init__.py
@@ -0,0 +1 @@
+
diff --git a/pipelex/pipe_controllers/pipe_batch.py b/pipelex/pipe_controllers/pipe_batch.py
new file mode 100644
index 000000000..4c0074632
--- /dev/null
+++ b/pipelex/pipe_controllers/pipe_batch.py
@@ -0,0 +1,159 @@
+import asyncio
+from typing import Any, Coroutine, List, Optional, Set, cast
+
+import shortuuid
+from typing_extensions import override
+
+from pipelex import log
+from pipelex.config import get_config
+from pipelex.core.pipe_output import PipeOutput
+from pipelex.core.pipe_run_params import BatchParams, PipeRunParams
+from pipelex.core.stuff import Stuff
+from pipelex.core.stuff_content import ListContent, StuffContent
+from pipelex.core.stuff_factory import StuffFactory
+from pipelex.core.working_memory import WorkingMemory
+from pipelex.exceptions import PipeExecutionError
+from pipelex.hub import get_pipe_router
+from pipelex.mission.job_metadata import JobMetadata
+from pipelex.pipe_controllers.pipe_controller import PipeController
+
+
+class PipeBatch(PipeController):
+ """Runs a PipeSequence in parallel for each item in a list."""
+
+ branch_pipe_code: str
+ batch_params: Optional[BatchParams] = None
+
+ @override
+ def pipe_dependencies(self) -> Set[str]:
+ return set([self.branch_pipe_code])
+
+ @override
+ async def _run_controller_pipe(
+ self,
+ job_metadata: JobMetadata,
+ working_memory: WorkingMemory,
+ pipe_run_params: PipeRunParams,
+ output_name: Optional[str] = None,
+ ) -> PipeOutput:
+ """Run a sequence of steps in batch for each item in the input list."""
+ if not self.input_concept_code:
+ raise PipeExecutionError(f"Missing input concept code for pipe '{self.code}' but it is required for PipeBatch")
+ if pipe_run_params.final_stuff_code:
+ log.debug(f"PipeBatch.run_pipe() final_stuff_code: {pipe_run_params.final_stuff_code}")
+ pipe_run_params.final_stuff_code = None
+
+ pipe_run_params.push_pipe_layer(pipe_code=self.branch_pipe_code)
+ batch_params = pipe_run_params.batch_params or self.batch_params or BatchParams.make_default()
+ input_stuff_key = batch_params.input_list_stuff_name
+ input_stuff = working_memory.get_stuff(input_stuff_key)
+ input_stuff_code = input_stuff.stuff_code
+ input_content = input_stuff.content
+
+ if not isinstance(input_content, ListContent):
+ raise ValueError(
+ f"Input of PipeBatch must be ListContent, got {input_stuff.stuff_name or 'unnamed'} = {type(input_content)}. stuff: {input_stuff}"
+ )
+
+ # TODO: Make commented code work when inputing images named "a.b.c"
+ # sub_pipe = get_required_pipe(pipe_code=self.branch_pipe_code)
+ nb_history_items_limit = get_config().pipelex.tracker_config.applied_nb_items_limit
+ pipe_router = get_pipe_router()
+ input_content = cast(ListContent[StuffContent], input_content)
+ batch_output_stuff_code = shortuuid.uuid()
+ tasks: List[Coroutine[Any, Any, PipeOutput]] = []
+ item_stuffs: List[Stuff] = []
+ # required_stuff_lists: List[List[Stuff]] = []
+ branch_output_item_codes: List[str] = []
+ for branch_index, item in enumerate(input_content.items):
+ branch_output_item_code = f"{batch_output_stuff_code}-branch-{branch_index}"
+ branch_output_item_codes.append(branch_output_item_code)
+ if nb_history_items_limit and branch_index >= nb_history_items_limit:
+ break
+ branch_input_item_code = f"{input_stuff_code}-branch-{branch_index}"
+ item_input_stuff = StuffFactory.make_stuff(
+ code=branch_input_item_code,
+ concept_code=self.input_concept_code,
+ content=item,
+ name=batch_params.input_item_stuff_name,
+ )
+ item_stuffs.append(item_input_stuff)
+ branch_memory = working_memory.make_deep_copy()
+ branch_memory.set_new_main_stuff(stuff=item_input_stuff, name=batch_params.input_item_stuff_name)
+
+ # required_variables = sub_pipe.required_variables()
+ # required_stuffs = branch_memory.get_stuffs(names=required_variables)
+ # required_stuffs = [required_stuff for required_stuff in required_stuffs if required_stuff.stuff_code != input_stuff_code]
+ # required_stuff_lists.append(required_stuffs)
+ branch_pipe_run_params = pipe_run_params.model_copy(
+ deep=True,
+ update={
+ "final_stuff_code": branch_output_item_code,
+ },
+ )
+ tasks.append(
+ pipe_router.run_pipe_code(
+ pipe_code=self.branch_pipe_code,
+ job_metadata=job_metadata,
+ working_memory=branch_memory,
+ output_name=f"Batch result {branch_index + 1} of {output_name}",
+ pipe_run_params=branch_pipe_run_params,
+ )
+ )
+
+ pipe_outputs = await asyncio.gather(*tasks)
+
+ output_items: List[StuffContent] = []
+ output_stuffs: List[Stuff] = []
+ output_stuff_code = shortuuid.uuid()[:5]
+ for branch_index, pipe_output in enumerate(pipe_outputs):
+ branch_output_stuff = pipe_output.main_stuff
+ output_stuffs.append(branch_output_stuff)
+ output_items.append(branch_output_stuff.content)
+
+ list_content: ListContent[StuffContent] = ListContent(items=output_items)
+ output_stuff = StuffFactory.make_stuff(
+ code=output_stuff_code,
+ concept_code=self.output_concept_code,
+ content=list_content,
+ name=output_name,
+ )
+
+ # for branch_index, (required_stuff_list, item_input_stuff, item_output_stuff) in enumerate(
+ # zip(required_stuff_lists, item_stuffs, output_stuffs)
+ # ):
+ # get_mission_tracker().add_batch_step(
+ # from_stuff=input_stuff,
+ # to_stuff=item_input_stuff,
+ # to_branch_index=branch_index,
+ # pipe_layer=pipe_run_params.pipe_layers,
+ # comment="PipeBatch.run_pipe() in zip",
+ # )
+ # for required_stuff in required_stuff_list:
+ # get_mission_tracker().add_pipe_step(
+ # from_stuff=required_stuff,
+ # to_stuff=item_output_stuff,
+ # pipe_code=self.branch_pipe_code,
+ # pipe_layer=pipe_run_params.pipe_layers,
+ # comment="PipeBatch.run_pipe() on required_stuff_list",
+ # as_item_index=branch_index,
+ # is_with_edge=(required_stuff.stuff_name != MAIN_STUFF_NAME),
+ # )
+
+ # for branch_index, branch_output_stuff in enumerate(output_stuffs):
+ # branch_output_item_code = branch_output_item_codes[branch_index]
+ # get_mission_tracker().add_aggregate_step(
+ # from_stuff=branch_output_stuff,
+ # to_stuff=output_stuff,
+ # pipe_layer=pipe_run_params.pipe_layers,
+ # comment="PipeBatch.run_pipe() on branch_index of batch",
+ # )
+
+ working_memory.set_new_main_stuff(
+ stuff=output_stuff,
+ name=output_name,
+ )
+
+ return PipeOutput(
+ working_memory=working_memory,
+ )
diff --git a/pipelex/pipe_controllers/pipe_batch_factory.py b/pipelex/pipe_controllers/pipe_batch_factory.py
new file mode 100644
index 000000000..2d785a49b
--- /dev/null
+++ b/pipelex/pipe_controllers/pipe_batch_factory.py
@@ -0,0 +1,53 @@
+from typing import Any, Dict, Optional
+
+from typing_extensions import override
+
+from pipelex.core.pipe_blueprint import PipeBlueprint, PipeSpecificFactoryProtocol
+from pipelex.core.pipe_run_params import BatchParams
+from pipelex.pipe_controllers.pipe_batch import PipeBatch
+
+
+class PipeBatchBlueprint(PipeBlueprint):
+ branch_pipe_code: str
+
+ input_list_name: Optional[str] = None
+ input_item_name: Optional[str] = None
+
+
+class PipeBatchFactory(PipeSpecificFactoryProtocol[PipeBatchBlueprint, PipeBatch]):
+ @classmethod
+ @override
+ def make_pipe_from_blueprint(
+ cls,
+ domain_code: str,
+ pipe_code: str,
+ pipe_blueprint: PipeBatchBlueprint,
+ ) -> PipeBatch:
+ batch_params = BatchParams.make_optional_batch_params(
+ input_list_name=pipe_blueprint.input_list_name or False,
+ input_item_name=pipe_blueprint.input_item_name,
+ )
+ return PipeBatch(
+ domain=domain_code,
+ code=pipe_code,
+ definition=pipe_blueprint.definition,
+ input_concept_code=pipe_blueprint.input,
+ output_concept_code=pipe_blueprint.output,
+ branch_pipe_code=pipe_blueprint.branch_pipe_code,
+ batch_params=batch_params,
+ )
+
+ @classmethod
+ @override
+ def make_pipe_from_details_dict(
+ cls,
+ domain_code: str,
+ pipe_code: str,
+ details_dict: Dict[str, Any],
+ ) -> PipeBatch:
+ pipe_blueprint = PipeBatchBlueprint.model_validate(details_dict)
+ return cls.make_pipe_from_blueprint(
+ domain_code=domain_code,
+ pipe_code=pipe_code,
+ pipe_blueprint=pipe_blueprint,
+ )
diff --git a/pipelex/pipe_controllers/pipe_condition.py b/pipelex/pipe_controllers/pipe_condition.py
new file mode 100644
index 000000000..2d1a3e2af
--- /dev/null
+++ b/pipelex/pipe_controllers/pipe_condition.py
@@ -0,0 +1,155 @@
+from typing import Dict, Optional, Self, Set, cast
+
+import shortuuid
+from pydantic import model_validator
+from typing_extensions import override
+
+from pipelex import log
+from pipelex.core.pipe_output import PipeOutput
+from pipelex.core.pipe_run_params import PipeRunParams
+from pipelex.core.working_memory import WorkingMemory
+from pipelex.exceptions import PipeConditionError, PipeDefinitionError, PipeExecutionError, PipeInputError, WorkingMemoryStuffNotFoundError
+from pipelex.hub import get_mission_tracker, get_pipe_router
+from pipelex.mission.job_metadata import JobCategory, JobMetadata
+from pipelex.pipe_controllers.pipe_condition_details import PipeConditionDetails
+from pipelex.pipe_controllers.pipe_controller import PipeController
+from pipelex.pipe_operators.pipe_jinja2 import PipeJinja2, PipeJinja2Output
+from pipelex.tools.typing.validation_utils import has_exactly_one_among_attributes_from_list
+
+
+class PipeCondition(PipeController):
+ expression_jinja2: Optional[str]
+ expression: Optional[str]
+ pipe_map: Dict[str, str]
+ default_pipe_code: Optional[str] = None
+ add_alias_from_expression_to: Optional[str] = None
+
+ @model_validator(mode="after")
+ def validate_expression(self) -> Self:
+ if not has_exactly_one_among_attributes_from_list(self, attributes_list=["expression_jinja2", "expression"]):
+ raise PipeDefinitionError("PipeCondition should have exactly one of expression_jinja2 or expression")
+ return self
+
+ @property
+ def applied_expression_jinja2(self) -> str:
+ if self.expression_jinja2:
+ return self.expression_jinja2
+ elif self.expression:
+ return "{{ " + self.expression + " }}"
+ else:
+ raise PipeExecutionError("No expression or expression_jinja2 provided")
+
+ def _make_pipe_condition_details(self, evaluated_expression: str, chosen_pipe_code: str) -> PipeConditionDetails:
+ return PipeConditionDetails(
+ code=shortuuid.uuid()[:5],
+ test_expression=self.expression or self.applied_expression_jinja2,
+ pipe_map=self.pipe_map,
+ default_pipe_code=self.default_pipe_code,
+ evaluated_expression=evaluated_expression,
+ chosen_pipe_code=chosen_pipe_code,
+ )
+
+ @override
+ def pipe_dependencies(self) -> Set[str]:
+ pipe_codes = list(self.pipe_map.values())
+ if self.default_pipe_code:
+ pipe_codes.append(self.default_pipe_code)
+ return set(pipe_codes)
+
+ @override
+ async def _run_controller_pipe(
+ self,
+ job_metadata: JobMetadata,
+ working_memory: WorkingMemory,
+ pipe_run_params: PipeRunParams,
+ output_name: Optional[str] = None,
+ ) -> PipeOutput:
+ log.dev(f"{self.class_name} generating a '{self.output_concept_code}'")
+
+ # TODO: restore pipe_layer feature
+ # pipe_run_params.push_pipe_code(pipe_code=pipe_code)
+
+ pipe_jinja2 = PipeJinja2(
+ code="adhoc_for_pipe_condition",
+ domain=self.domain,
+ jinja2=self.applied_expression_jinja2,
+ )
+ jinja2_job_metadata = job_metadata.copy_with_update(
+ updated_metadata=JobMetadata(
+ job_category=JobCategory.JINJA2_JOB,
+ )
+ )
+ log.debug(f"Jinja2 expression: {self.applied_expression_jinja2}")
+ # evaluated_expression = (
+ # await pipe_jinja2.run_pipe(
+ # job_metadata=jinja2_job_metadata,
+ # working_memory=working_memory,
+ # pipe_run_params=pipe_run_params,
+ # )
+ # ).rendered_text.strip()
+ # TODO: restore the possibility above, without need to explicitly cast the output
+ pipe_output_1: PipeOutput = await pipe_jinja2.run_pipe(
+ job_metadata=jinja2_job_metadata,
+ working_memory=working_memory,
+ pipe_run_params=pipe_run_params,
+ )
+ pipe_jinja2_output = cast(PipeJinja2Output, pipe_output_1)
+ evaluated_expression = pipe_jinja2_output.rendered_text.strip()
+
+ if not evaluated_expression or evaluated_expression == "None":
+ error_msg = f"Conditional expression returned an empty string in pipe {self.code}:"
+ error_msg += f"\n\nExpression: {self.applied_expression_jinja2}"
+ raise PipeConditionError(error_msg)
+ log.debug(f"evaluated_expression: '{evaluated_expression}'")
+
+ log.debug(f"add_alias: {evaluated_expression} -> {self.add_alias_from_expression_to}")
+ if self.add_alias_from_expression_to:
+ working_memory.add_alias(
+ alias=evaluated_expression,
+ target=self.add_alias_from_expression_to,
+ )
+
+ chosen_pipe_code = self.pipe_map.get(evaluated_expression, self.default_pipe_code)
+ if not chosen_pipe_code:
+ error_msg = f"No pipe code found for evaluated expression '{evaluated_expression}' in pipe {self.code}:"
+ error_msg += f"\n\nExpression: {self.applied_expression_jinja2}"
+ error_msg += f"\n\nPipe map: {self.pipe_map}"
+ raise PipeConditionError(error_msg)
+
+ condition_details = self._make_pipe_condition_details(
+ evaluated_expression=evaluated_expression,
+ chosen_pipe_code=chosen_pipe_code,
+ )
+ required_variables = pipe_jinja2.required_variables()
+ log.debug(required_variables, title=f"Required variables for PipeCondition '{self.code}'")
+ required_stuff_names = set([required_variable for required_variable in required_variables if not required_variable.startswith("_")])
+ try:
+ required_stuffs = working_memory.get_stuffs(names=required_stuff_names)
+ except WorkingMemoryStuffNotFoundError as exc:
+ error_details = f"PipeCondition '{self.code}', stack: {pipe_run_params.pipe_layers}, required_variables: {required_variables}"
+ raise PipeInputError(f"Some required stuff(s) not found - {error_details}") from exc
+
+ for required_stuff in required_stuffs:
+ get_mission_tracker().add_condition_step(
+ from_stuff=required_stuff,
+ to_condition=condition_details,
+ condition_expression=self.expression or self.applied_expression_jinja2,
+ pipe_layer=pipe_run_params.pipe_layers,
+ comment="PipeCondition required for condition",
+ )
+
+ log.debug(f"Chosen pipe: {chosen_pipe_code}")
+ pipe_output: PipeOutput = await get_pipe_router().run_pipe_code(
+ pipe_code=chosen_pipe_code,
+ job_metadata=job_metadata,
+ working_memory=working_memory,
+ pipe_run_params=pipe_run_params,
+ output_name=output_name,
+ )
+ get_mission_tracker().add_choice_step(
+ from_condition=condition_details,
+ to_stuff=pipe_output.main_stuff,
+ pipe_layer=pipe_run_params.pipe_layers,
+ comment="PipeCondition chosen pipe",
+ )
+ return pipe_output
diff --git a/pipelex/pipe_controllers/pipe_condition_details.py b/pipelex/pipe_controllers/pipe_condition_details.py
new file mode 100644
index 000000000..10bbb6c70
--- /dev/null
+++ b/pipelex/pipe_controllers/pipe_condition_details.py
@@ -0,0 +1,13 @@
+from typing import Dict, Optional
+
+from pydantic import BaseModel
+
+
+class PipeConditionDetails(BaseModel):
+ code: str
+ test_expression: str
+ pipe_map: Dict[str, str]
+ default_pipe_code: Optional[str] = None
+
+ evaluated_expression: str
+ chosen_pipe_code: str
diff --git a/pipelex/pipe_controllers/pipe_condition_factory.py b/pipelex/pipe_controllers/pipe_condition_factory.py
new file mode 100644
index 000000000..f82ad4321
--- /dev/null
+++ b/pipelex/pipe_controllers/pipe_condition_factory.py
@@ -0,0 +1,53 @@
+from typing import Any, Dict, Optional
+
+from typing_extensions import override
+
+from pipelex.core.pipe_blueprint import PipeBlueprint, PipeSpecificFactoryProtocol
+from pipelex.pipe_controllers.pipe_condition import PipeCondition
+
+
+class PipeConditionBlueprint(PipeBlueprint):
+ expression_template: Optional[str] = None
+ expression: Optional[str] = None
+ # TODO: make the values of pipe_map a Union[str, PipeAdapter] or something to set a specific alias
+ pipe_map: Dict[str, str]
+ default_pipe_code: Optional[str] = None
+ add_alias_from_expression_to: Optional[str] = None
+
+
+class PipeConditionFactory(PipeSpecificFactoryProtocol[PipeConditionBlueprint, PipeCondition]):
+ @classmethod
+ @override
+ def make_pipe_from_blueprint(
+ cls,
+ domain_code: str,
+ pipe_code: str,
+ pipe_blueprint: PipeConditionBlueprint,
+ ) -> PipeCondition:
+ return PipeCondition(
+ domain=domain_code,
+ code=pipe_code,
+ definition=pipe_blueprint.definition,
+ input_concept_code=pipe_blueprint.input,
+ output_concept_code=pipe_blueprint.output,
+ expression_jinja2=pipe_blueprint.expression_template,
+ expression=pipe_blueprint.expression,
+ pipe_map=pipe_blueprint.pipe_map,
+ default_pipe_code=pipe_blueprint.default_pipe_code,
+ add_alias_from_expression_to=pipe_blueprint.add_alias_from_expression_to,
+ )
+
+ @classmethod
+ @override
+ def make_pipe_from_details_dict(
+ cls,
+ domain_code: str,
+ pipe_code: str,
+ details_dict: Dict[str, Any],
+ ) -> PipeCondition:
+ pipe_blueprint = PipeConditionBlueprint.model_validate(details_dict)
+ return cls.make_pipe_from_blueprint(
+ domain_code=domain_code,
+ pipe_code=pipe_code,
+ pipe_blueprint=pipe_blueprint,
+ )
diff --git a/pipelex/pipe_controllers/pipe_controller.py b/pipelex/pipe_controllers/pipe_controller.py
new file mode 100644
index 000000000..d56456f13
--- /dev/null
+++ b/pipelex/pipe_controllers/pipe_controller.py
@@ -0,0 +1,49 @@
+from abc import abstractmethod
+from typing import Optional
+
+from typing_extensions import override
+
+from pipelex.core.pipe_abstract import PipeAbstract
+from pipelex.core.pipe_output import PipeOutput
+from pipelex.core.pipe_run_params import PipeRunParams
+from pipelex.core.working_memory import WorkingMemory
+from pipelex.mission.job_metadata import JobMetadata
+
+
+class PipeController(PipeAbstract):
+ @override
+ async def run_pipe(
+ self,
+ job_metadata: JobMetadata,
+ working_memory: WorkingMemory,
+ pipe_run_params: PipeRunParams,
+ output_name: Optional[str] = None,
+ ) -> PipeOutput:
+ pipe_run_params.push_pipe_to_stack(pipe_code=self.code)
+ self.monitor_pipe_stack(pipe_run_params=pipe_run_params)
+
+ updated_metadata = JobMetadata(
+ pipe_job_ids=[self.code],
+ )
+ job_metadata.update(updated_metadata=updated_metadata)
+
+ pipe_output = await self._run_controller_pipe(
+ job_metadata=job_metadata,
+ working_memory=working_memory,
+ pipe_run_params=pipe_run_params,
+ output_name=output_name,
+ )
+
+ pipe_run_params.pop_pipe_from_stack(pipe_code=self.code)
+
+ return pipe_output
+
+ @abstractmethod
+ async def _run_controller_pipe(
+ self,
+ job_metadata: JobMetadata,
+ working_memory: WorkingMemory,
+ pipe_run_params: PipeRunParams,
+ output_name: Optional[str] = None,
+ ) -> PipeOutput:
+ pass
diff --git a/pipelex/pipe_controllers/pipe_parallel.py b/pipelex/pipe_controllers/pipe_parallel.py
new file mode 100644
index 000000000..b8c3d49bb
--- /dev/null
+++ b/pipelex/pipe_controllers/pipe_parallel.py
@@ -0,0 +1,104 @@
+import asyncio
+from typing import Any, Coroutine, Dict, List, Optional, Set
+
+from typing_extensions import override
+
+from pipelex import log
+from pipelex.core.pipe_output import PipeOutput
+from pipelex.core.pipe_run_params import PipeRunParams
+from pipelex.core.stuff import Stuff
+from pipelex.core.stuff_content import StuffContent
+from pipelex.core.stuff_factory import StuffFactory
+from pipelex.core.working_memory import WorkingMemory
+from pipelex.exceptions import PipeDefinitionError
+from pipelex.hub import get_mission_tracker
+from pipelex.mission.job_metadata import JobMetadata
+from pipelex.pipe_controllers.pipe_controller import PipeController
+from pipelex.pipe_controllers.sub_pipe import SubPipe
+
+
+class PipeParallel(PipeController):
+ """Runs a list of pipes in parallel to produce a list of results."""
+
+ parallel_sub_pipes: List[SubPipe]
+ add_each_output: bool
+ combined_output: Optional[str]
+
+ @override
+ def pipe_dependencies(self) -> Set[str]:
+ return set(sub_pipe.pipe_code for sub_pipe in self.parallel_sub_pipes)
+
+ @override
+ async def _run_controller_pipe(
+ self,
+ job_metadata: JobMetadata,
+ working_memory: WorkingMemory,
+ pipe_run_params: PipeRunParams,
+ output_name: Optional[str] = None,
+ ) -> PipeOutput:
+ """
+ Run a list of pipes in parallel.
+ """
+ if not self.add_each_output and not self.combined_output:
+ raise PipeDefinitionError("PipeParallel requires either add_each_output or combined_output to be set")
+ if pipe_run_params.final_stuff_code:
+ log.debug(f"PipeBatch.run_pipe() final_stuff_code: {pipe_run_params.final_stuff_code}")
+ pipe_run_params.final_stuff_code = None
+
+ tasks: List[Coroutine[Any, Any, PipeOutput]] = []
+
+ for parallel_sub_pipe in self.parallel_sub_pipes:
+ tasks.append(
+ parallel_sub_pipe.run(
+ job_metadata=job_metadata,
+ working_memory=working_memory.make_deep_copy(),
+ sub_pipe_run_params=pipe_run_params,
+ )
+ )
+
+ pipe_outputs = await asyncio.gather(*tasks)
+
+ output_stuff_content_items: List[StuffContent] = []
+ output_stuffs: Dict[str, Stuff] = {}
+ output_stuff_contents: Dict[str, StuffContent] = {}
+
+ for output_index, pipe_output in enumerate(pipe_outputs):
+ output_stuff = pipe_output.main_stuff
+ sub_pipe_output_name = self.parallel_sub_pipes[output_index].output_name
+ if not sub_pipe_output_name:
+ raise PipeDefinitionError("PipeParallel requires a result specified for each parallel sub pipe")
+ if self.add_each_output:
+ working_memory.add_new_stuff(name=sub_pipe_output_name, stuff=output_stuff)
+ output_stuff_content_items.append(output_stuff.content)
+ if sub_pipe_output_name in output_stuffs:
+ # TODO: check that at the blueprint / factory level
+ raise PipeDefinitionError(
+ f"PipeParallel requires unique output names for each parallel sub pipe, but {sub_pipe_output_name} is already used"
+ )
+ output_stuffs[sub_pipe_output_name] = output_stuff
+ if sub_pipe_output_name in output_stuff_contents:
+ # TODO: check that at the blueprint / factory level
+ raise PipeDefinitionError(
+ f"PipeParallel requires unique output names for each parallel sub pipe, but {sub_pipe_output_name} is already used"
+ )
+ output_stuff_contents[sub_pipe_output_name] = output_stuff.content
+ if combined_output := self.combined_output:
+ combined_output_stuff = StuffFactory.combine_stuffs(
+ concept_code=combined_output,
+ stuff_contents=output_stuff_contents,
+ name=output_name,
+ )
+ working_memory.set_new_main_stuff(
+ stuff=combined_output_stuff,
+ name=output_name,
+ )
+ for stuff in output_stuffs.values():
+ get_mission_tracker().add_aggregate_step(
+ from_stuff=stuff,
+ to_stuff=combined_output_stuff,
+ pipe_layer=pipe_run_params.pipe_layers,
+ comment="PipeParallel on output_stuffs",
+ )
+ return PipeOutput(
+ working_memory=working_memory,
+ )
diff --git a/pipelex/pipe_controllers/pipe_parallel_factory.py b/pipelex/pipe_controllers/pipe_parallel_factory.py
new file mode 100644
index 000000000..2f8b9aae1
--- /dev/null
+++ b/pipelex/pipe_controllers/pipe_parallel_factory.py
@@ -0,0 +1,59 @@
+from typing import Any, Dict, List, Optional
+
+from typing_extensions import override
+
+from pipelex.core.pipe_blueprint import PipeBlueprint, PipeSpecificFactoryProtocol
+from pipelex.exceptions import PipeDefinitionError
+from pipelex.pipe_controllers.pipe_parallel import PipeParallel
+from pipelex.pipe_controllers.sub_pipe import SubPipe
+from pipelex.pipe_controllers.sub_pipe_factory import SubPipeBlueprint
+
+
+class PipeParallelBlueprint(PipeBlueprint):
+ parallels: List[SubPipeBlueprint]
+ add_each_output: bool = True
+ combined_output: Optional[str] = None
+
+
+class PipeParallelFactory(PipeSpecificFactoryProtocol[PipeParallelBlueprint, PipeParallel]):
+ @classmethod
+ @override
+ def make_pipe_from_blueprint(
+ cls,
+ domain_code: str,
+ pipe_code: str,
+ pipe_blueprint: PipeParallelBlueprint,
+ ) -> PipeParallel:
+ parallel_sub_pipes: List[SubPipe] = []
+ for sub_pipe_blueprint in pipe_blueprint.parallels:
+ if not sub_pipe_blueprint.result:
+ raise PipeDefinitionError("PipeParallel requires a result specified for each parallel sub pipe")
+ sub_pipe = sub_pipe_blueprint.make_sub_pipe()
+ parallel_sub_pipes.append(sub_pipe)
+ if not pipe_blueprint.add_each_output and not pipe_blueprint.combined_output:
+ raise PipeDefinitionError("PipeParallel requires either add_each_output or combined_output to be set")
+ return PipeParallel(
+ domain=domain_code,
+ code=pipe_code,
+ definition=pipe_blueprint.definition,
+ input_concept_code=pipe_blueprint.input,
+ output_concept_code=pipe_blueprint.output,
+ parallel_sub_pipes=parallel_sub_pipes,
+ add_each_output=pipe_blueprint.add_each_output,
+ combined_output=pipe_blueprint.combined_output,
+ )
+
+ @classmethod
+ @override
+ def make_pipe_from_details_dict(
+ cls,
+ domain_code: str,
+ pipe_code: str,
+ details_dict: Dict[str, Any],
+ ) -> PipeParallel:
+ pipe_blueprint = PipeParallelBlueprint.model_validate(details_dict)
+ return cls.make_pipe_from_blueprint(
+ domain_code=domain_code,
+ pipe_code=pipe_code,
+ pipe_blueprint=pipe_blueprint,
+ )
diff --git a/pipelex/pipe_controllers/pipe_sequence.py b/pipelex/pipe_controllers/pipe_sequence.py
new file mode 100644
index 000000000..96c0ca86e
--- /dev/null
+++ b/pipelex/pipe_controllers/pipe_sequence.py
@@ -0,0 +1,60 @@
+from typing import List, Optional, Set
+
+from typing_extensions import override
+
+from pipelex import log
+from pipelex.core.pipe_output import PipeOutput
+from pipelex.core.pipe_run_params import PipeRunParams
+from pipelex.core.working_memory import WorkingMemory
+from pipelex.exceptions import PipeRunParamsError
+from pipelex.mission.job_metadata import JobMetadata
+from pipelex.pipe_controllers.pipe_controller import PipeController
+from pipelex.pipe_controllers.sub_pipe import SubPipe
+
+
+class PipeSequence(PipeController):
+ pipe_steps: List[SubPipe]
+
+ @override
+ def pipe_dependencies(self) -> Set[str]:
+ return set(step.pipe_code for step in self.pipe_steps)
+
+ @override
+ async def _run_controller_pipe(
+ self,
+ job_metadata: JobMetadata,
+ working_memory: WorkingMemory,
+ pipe_run_params: PipeRunParams,
+ output_name: Optional[str] = None,
+ ) -> PipeOutput:
+ log.debug(f"run_pipe_direct: output_name={output_name}")
+ pipe_run_params.push_pipe_layer(pipe_code=self.code)
+ if pipe_run_params.is_multiple_output_required:
+ raise PipeRunParamsError(
+ f"PipeSequence does not suppport multiple outputs, got output_multiplicity = {pipe_run_params.output_multiplicity}"
+ )
+ log.dev(f"{self.class_name} generating a '{self.output_concept_code}' named -> {output_name or 'unnamed'}")
+ log.dev(f"self.pipe_steps:\n{self.pipe_steps}")
+
+ if not self.output_concept_code:
+ raise ValueError("No output concept code")
+
+ current_memory = working_memory
+
+ for step_index, step in enumerate(self.pipe_steps):
+ step_run_params: PipeRunParams
+ # only the last step should apply the final_stuff_code
+ if step_index == len(self.pipe_steps) - 1:
+ step_run_params = pipe_run_params.model_copy()
+ else:
+ step_run_params = pipe_run_params.model_copy(update=({"final_stuff_code": None}))
+ pipe_output = await step.run(
+ working_memory=current_memory,
+ job_metadata=job_metadata,
+ sub_pipe_run_params=step_run_params,
+ )
+ current_memory = pipe_output.working_memory
+
+ return PipeOutput(
+ working_memory=current_memory,
+ )
diff --git a/pipelex/pipe_controllers/pipe_sequence_factory.py b/pipelex/pipe_controllers/pipe_sequence_factory.py
new file mode 100644
index 000000000..572bf186c
--- /dev/null
+++ b/pipelex/pipe_controllers/pipe_sequence_factory.py
@@ -0,0 +1,46 @@
+from typing import Any, Dict, List
+
+from typing_extensions import override
+
+from pipelex.core.pipe_blueprint import PipeBlueprint, PipeSpecificFactoryProtocol
+from pipelex.pipe_controllers.pipe_sequence import PipeSequence
+from pipelex.pipe_controllers.sub_pipe_factory import SubPipeBlueprint
+
+
+class PipeSequenceBlueprint(PipeBlueprint):
+ steps: List[SubPipeBlueprint]
+
+
+class PipeSequenceFactory(PipeSpecificFactoryProtocol[PipeSequenceBlueprint, PipeSequence]):
+ @classmethod
+ @override
+ def make_pipe_from_blueprint(
+ cls,
+ domain_code: str,
+ pipe_code: str,
+ pipe_blueprint: PipeSequenceBlueprint,
+ ) -> PipeSequence:
+ pipe_steps = [step.make_sub_pipe() for step in pipe_blueprint.steps]
+ return PipeSequence(
+ domain=domain_code,
+ code=pipe_code,
+ definition=pipe_blueprint.definition,
+ input_concept_code=pipe_blueprint.input,
+ output_concept_code=pipe_blueprint.output,
+ pipe_steps=pipe_steps,
+ )
+
+ @classmethod
+ @override
+ def make_pipe_from_details_dict(
+ cls,
+ domain_code: str,
+ pipe_code: str,
+ details_dict: Dict[str, Any],
+ ) -> PipeSequence:
+ pipe_blueprint = PipeSequenceBlueprint.model_validate(details_dict)
+ return cls.make_pipe_from_blueprint(
+ domain_code=domain_code,
+ pipe_code=pipe_code,
+ pipe_blueprint=pipe_blueprint,
+ )
diff --git a/pipelex/pipe_controllers/sub_pipe.py b/pipelex/pipe_controllers/sub_pipe.py
new file mode 100644
index 000000000..73f17e6f5
--- /dev/null
+++ b/pipelex/pipe_controllers/sub_pipe.py
@@ -0,0 +1,90 @@
+from typing import Optional
+
+from pydantic import BaseModel
+
+from pipelex import log, pretty_print
+from pipelex.core.pipe_output import PipeOutput
+from pipelex.core.pipe_run_params import BatchParams, PipeOutputMultiplicity, PipeRunParams
+from pipelex.core.working_memory import WorkingMemory
+from pipelex.exceptions import PipeInputError, WorkingMemoryStuffNotFoundError
+from pipelex.hub import get_mission_tracker, get_pipe_router, get_required_pipe
+from pipelex.mission.job_metadata import JobMetadata
+from pipelex.pipe_controllers.pipe_batch import PipeBatch
+from pipelex.pipe_controllers.pipe_condition import PipeCondition
+
+
+# TODO: decide if SubPipe should be a PipeAbstract (it's probably the case)
+# TODO: update job metadata
+class SubPipe(BaseModel):
+ pipe_code: str
+ output_name: Optional[str] = None
+ output_multiplicity: Optional[PipeOutputMultiplicity] = None
+ batch_params: Optional[BatchParams] = None
+
+ async def run(
+ self,
+ working_memory: WorkingMemory,
+ job_metadata: JobMetadata,
+ sub_pipe_run_params: PipeRunParams,
+ ) -> PipeOutput:
+ """Run a single operation self."""
+ log.debug(f"SubPipe {self.pipe_code} to generate {self.output_name}")
+ # step_run_params.push_pipe_code(pipe_code=self.pipe_code)
+ if self.output_multiplicity:
+ sub_pipe_run_params.output_multiplicity = self.output_multiplicity
+ pipe = get_required_pipe(pipe_code=self.pipe_code)
+ pipe_output: PipeOutput
+ sub_pipe_run_params.batch_params = self.batch_params
+ if batch_params := self.batch_params:
+ input_list_stuff = working_memory.get_stuff(name=batch_params.input_list_stuff_name)
+ input_concept_code = input_list_stuff.concept_code
+ output_concept_code = pipe.output_concept_code
+ pipe_batch = PipeBatch(
+ domain=pipe.domain,
+ code=self.pipe_code,
+ input_concept_code=input_concept_code,
+ output_concept_code=output_concept_code,
+ branch_pipe_code=self.pipe_code,
+ )
+ pipe_output = await pipe_batch.run_pipe(
+ job_metadata=job_metadata,
+ working_memory=working_memory,
+ pipe_run_params=sub_pipe_run_params,
+ output_name=self.output_name,
+ )
+ elif isinstance(pipe, PipeCondition):
+ pipe_output = await get_pipe_router().run_pipe_code(
+ pipe_code=self.pipe_code,
+ job_metadata=job_metadata,
+ working_memory=working_memory,
+ output_name=self.output_name,
+ pipe_run_params=sub_pipe_run_params,
+ )
+ else:
+ required_variables = pipe.required_variables()
+ log.debug(required_variables, title=f"Required variables for {self.pipe_code}")
+ required_stuff_names = set([required_variable for required_variable in required_variables if not required_variable.startswith("_")])
+ try:
+ required_stuffs = working_memory.get_stuffs(names=required_stuff_names)
+ except WorkingMemoryStuffNotFoundError as exc:
+ error_details = f"sub_pipe '{self.pipe_code}', stack: {sub_pipe_run_params.pipe_layers}, required_variables: {required_variables}"
+ raise PipeInputError(f"Some required stuff(s) not found - {error_details}") from exc
+ log.debug(required_stuffs, title=f"Required stuffs for {self.pipe_code}")
+ pipe_output = await get_pipe_router().run_pipe_code(
+ pipe_code=self.pipe_code,
+ job_metadata=job_metadata,
+ working_memory=working_memory,
+ output_name=self.output_name,
+ pipe_run_params=sub_pipe_run_params,
+ )
+ new_output_stuff = pipe_output.main_stuff
+ for stuff in required_stuffs:
+ get_mission_tracker().add_pipe_step(
+ from_stuff=stuff,
+ to_stuff=new_output_stuff,
+ pipe_code=self.pipe_code,
+ pipe_layer=sub_pipe_run_params.pipe_layers,
+ comment="SubPipe on required_stuff",
+ )
+ pretty_print(pipe_output.main_stuff, title=f"Pipe output for {self.pipe_code}")
+ return pipe_output
diff --git a/pipelex/pipe_controllers/sub_pipe_factory.py b/pipelex/pipe_controllers/sub_pipe_factory.py
new file mode 100644
index 000000000..6a68dac3c
--- /dev/null
+++ b/pipelex/pipe_controllers/sub_pipe_factory.py
@@ -0,0 +1,41 @@
+from typing import Optional, Self, Union
+
+from pydantic import BaseModel, ConfigDict, model_validator
+
+from pipelex.core.pipe_run_params import BatchParams, make_output_multiplicity
+from pipelex.exceptions import PipeDefinitionError
+from pipelex.pipe_controllers.sub_pipe import SubPipe
+from pipelex.tools.typing.validation_utils import has_more_than_one_among_attributes_from_list
+
+
+class SubPipeBlueprint(BaseModel):
+ model_config = ConfigDict(extra="forbid")
+
+ pipe: str
+ result: Optional[str] = None
+ nb_output: Optional[int] = None
+ multiple_output: Optional[bool] = None
+ batch_over: Union[bool, str] = False
+ batch_as: Optional[str] = None
+
+ @model_validator(mode="after")
+ def validate_multiple_output(self) -> Self:
+ if has_more_than_one_among_attributes_from_list(self, attributes_list=["nb_output", "multiple_output"]):
+ raise PipeDefinitionError("PipeStepBlueprint should have no more than one of nb_output or multiple_output")
+ return self
+
+ def make_sub_pipe(self) -> SubPipe:
+ output_multiplicity = make_output_multiplicity(
+ nb_output=self.nb_output,
+ multiple_output=self.multiple_output,
+ )
+ batch_params = BatchParams.make_optional_batch_params(
+ input_list_name=self.batch_over,
+ input_item_name=self.batch_as,
+ )
+ return SubPipe(
+ pipe_code=self.pipe,
+ output_name=self.result,
+ output_multiplicity=output_multiplicity,
+ batch_params=batch_params,
+ )
diff --git a/pipelex/pipe_operators/__init__.py b/pipelex/pipe_operators/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/pipelex/pipe_operators/__init__.py
@@ -0,0 +1 @@
+
diff --git a/pipelex/pipe_operators/pipe_func.py b/pipelex/pipe_operators/pipe_func.py
new file mode 100644
index 000000000..7b263e5c5
--- /dev/null
+++ b/pipelex/pipe_operators/pipe_func.py
@@ -0,0 +1,66 @@
+from typing import List, Optional, cast
+
+from typing_extensions import override
+
+from pipelex import log
+from pipelex.core.pipe_output import PipeOutput
+from pipelex.core.pipe_run_params import PipeRunParams
+from pipelex.core.stuff_content import ListContent, StuffContent, TextContent
+from pipelex.core.stuff_factory import StuffFactory
+from pipelex.core.working_memory import WorkingMemory
+from pipelex.mission.job_metadata import JobMetadata
+from pipelex.pipe_operators.pipe_operator import PipeOperator
+from pipelex.tools.func_registry import func_registry
+
+
+class PipeFuncOutput(PipeOutput):
+ pass
+
+
+class PipeFunc(PipeOperator):
+ function_name: str
+
+ @override
+ async def _run_operator_pipe(
+ self,
+ job_metadata: JobMetadata,
+ working_memory: WorkingMemory,
+ pipe_run_params: PipeRunParams,
+ output_name: Optional[str] = None,
+ ) -> PipeFuncOutput:
+ if not self.output_concept_code:
+ raise ValueError("PipeFunc should have a non-None output_concept_code")
+
+ log.debug(f"Applying function '{self.function_name}'")
+
+ function = func_registry.get_required_function(self.function_name)
+ if not callable(function):
+ raise ValueError(f"Function '{self.function_name}' is not callable")
+
+ func_output_object = function(working_memory=working_memory)
+ the_content: StuffContent
+ if isinstance(func_output_object, StuffContent):
+ the_content = func_output_object
+ elif isinstance(func_output_object, list):
+ func_result_list = cast(List[StuffContent], func_output_object)
+ the_content = ListContent(items=func_result_list)
+ elif isinstance(func_output_object, str):
+ the_content = TextContent(text=func_output_object)
+ else:
+ raise ValueError(f"Function '{self.function_name}' must return a StuffContent or a list, got {type(func_output_object)}")
+
+ output_stuff = StuffFactory.make_stuff(
+ name=output_name,
+ concept_code=self.output_concept_code,
+ content=the_content,
+ )
+
+ working_memory.set_new_main_stuff(
+ stuff=output_stuff,
+ name=output_name,
+ )
+
+ pipe_output = PipeFuncOutput(
+ working_memory=working_memory,
+ )
+ return pipe_output
diff --git a/pipelex/pipe_operators/pipe_func_factory.py b/pipelex/pipe_operators/pipe_func_factory.py
new file mode 100644
index 000000000..43ccafab5
--- /dev/null
+++ b/pipelex/pipe_operators/pipe_func_factory.py
@@ -0,0 +1,44 @@
+from typing import Any, Dict
+
+from typing_extensions import override
+
+from pipelex.core.pipe_blueprint import PipeBlueprint, PipeSpecificFactoryProtocol
+from pipelex.pipe_operators.pipe_func import PipeFunc
+
+
+class PipeFuncBlueprint(PipeBlueprint):
+ function_name: str
+
+
+class PipeFuncFactory(PipeSpecificFactoryProtocol[PipeFuncBlueprint, PipeFunc]):
+ @classmethod
+ @override
+ def make_pipe_from_blueprint(
+ cls,
+ domain_code: str,
+ pipe_code: str,
+ pipe_blueprint: PipeFuncBlueprint,
+ ) -> PipeFunc:
+ return PipeFunc(
+ domain=domain_code,
+ code=pipe_code,
+ definition=pipe_blueprint.definition,
+ input_concept_code=pipe_blueprint.input,
+ output_concept_code=pipe_blueprint.output,
+ function_name=pipe_blueprint.function_name,
+ )
+
+ @classmethod
+ @override
+ def make_pipe_from_details_dict(
+ cls,
+ domain_code: str,
+ pipe_code: str,
+ details_dict: Dict[str, Any],
+ ) -> PipeFunc:
+ pipe_blueprint = PipeFuncBlueprint.model_validate(details_dict)
+ return cls.make_pipe_from_blueprint(
+ domain_code=domain_code,
+ pipe_code=pipe_code,
+ pipe_blueprint=pipe_blueprint,
+ )
diff --git a/pipelex/pipe_operators/pipe_img_gen.py b/pipelex/pipe_operators/pipe_img_gen.py
new file mode 100644
index 000000000..2f9fa44e6
--- /dev/null
+++ b/pipelex/pipe_operators/pipe_img_gen.py
@@ -0,0 +1,165 @@
+from typing import List, Literal, Optional, Union, cast
+
+from pydantic import Field
+from typing_extensions import override
+
+from pipelex import log
+from pipelex.cogt.imgg.imgg_handle import ImggHandle
+from pipelex.cogt.imgg.imgg_job_components import AspectRatio, ImggJobParams
+from pipelex.cogt.imgg.imgg_prompt import ImggPrompt
+from pipelex.config import get_config
+from pipelex.core.concept_native import NativeConcept
+from pipelex.core.pipe_output import PipeOutput
+from pipelex.core.pipe_run_params import PipeOutputMultiplicity, PipeRunParams, output_multiplicity_to_apply
+from pipelex.core.stuff_content import ImageContent, ListContent, StuffContent, TextContent
+from pipelex.core.stuff_factory import StuffFactory
+from pipelex.core.working_memory import WorkingMemory
+from pipelex.exceptions import PipeRunParamsError
+from pipelex.hub import get_content_generator
+from pipelex.mission.job_metadata import JobMetadata
+from pipelex.pipe_operators.pipe_operator import PipeOperator
+
+
+class PipeImgGenOutput(PipeOutput):
+ @property
+ def image_urls(self) -> List[str]:
+ items = self.main_stuff_as_items(item_type=ImageContent)
+ return [item.url for item in items]
+
+
+class PipeImgGen(PipeOperator):
+ output_concept_code: str = NativeConcept.IMAGE.code
+ # TODO: wrap this up in imgg llm_presets like for llm
+ imgg_handle: Optional[ImggHandle] = None
+ aspect_ratio: Optional[AspectRatio] = Field(default=None, strict=False)
+ nb_steps: Optional[int] = Field(default=None, gt=0)
+ guidance_scale: Optional[float] = Field(default=None, gt=0)
+ is_safety_checker_enabled: Optional[bool] = None
+ safety_tolerance: Optional[int] = Field(default=None, ge=1, le=6)
+ is_raw: Optional[bool] = None
+ seed: Optional[Union[int, Literal["auto"]]] = None
+ output_multiplicity: PipeOutputMultiplicity
+
+ @override
+ async def _run_operator_pipe(
+ self,
+ job_metadata: JobMetadata,
+ working_memory: WorkingMemory,
+ pipe_run_params: PipeRunParams,
+ output_name: Optional[str] = None,
+ ) -> PipeImgGenOutput:
+ if not self.output_concept_code:
+ raise ValueError("PipeImgGen should have a non-None output_concept_code")
+
+ applied_output_multiplicity, _, _ = output_multiplicity_to_apply(
+ output_multiplicity_base=self.output_multiplicity or False,
+ output_multiplicity_override=pipe_run_params.output_multiplicity,
+ )
+
+ log.debug("Getting image generation prompt from context")
+ imgg_prompt_stuff = working_memory.get_stuff("imgg_prompt")
+ if not imgg_prompt_stuff:
+ raise ValueError("imgg_prompt not found in context")
+
+ imgg_prompt_text = cast(TextContent, imgg_prompt_stuff.content).text
+ imgg_config = get_config().cogt.imgg_config
+ imgg_param_defaults = imgg_config.imgg_param_defaults
+
+ seed_setting = self.seed or imgg_param_defaults.seed
+ seed: Optional[int]
+ if isinstance(seed_setting, str) and seed_setting == "auto":
+ seed = None
+ else:
+ seed = seed_setting
+
+ imgg_job_params = ImggJobParams(
+ nb_steps=self.nb_steps or imgg_param_defaults.nb_steps,
+ aspect_ratio=self.aspect_ratio or imgg_param_defaults.aspect_ratio,
+ guidance_scale=self.guidance_scale or imgg_param_defaults.guidance_scale,
+ is_safety_checker_enabled=self.is_safety_checker_enabled or imgg_param_defaults.is_safety_checker_enabled,
+ safety_tolerance=self.safety_tolerance or imgg_param_defaults.safety_tolerance,
+ is_raw=self.is_raw or imgg_param_defaults.is_raw,
+ output_format=imgg_param_defaults.output_format,
+ seed=seed,
+ )
+ imgg_handle = self.imgg_handle or imgg_config.default_imgg_handle
+ log.debug(f"Using imgg handle: {imgg_handle}")
+
+ the_content: StuffContent
+ image_urls: List[str] = []
+ nb_images: int
+ if isinstance(applied_output_multiplicity, bool):
+ if self.output_multiplicity:
+ msg = "Cannot guess how many images to generate if multiplicity is just True."
+ msg += f" Got PipeImgGen.output_multiplicity = {self.output_multiplicity},"
+ msg += f" and pipe_run_params.output_multiplicity = {pipe_run_params.output_multiplicity}."
+ msg += f" Tried to apply applied_output_multiplicity = {applied_output_multiplicity}."
+ raise PipeRunParamsError(msg)
+ else:
+ nb_images = 1
+ elif isinstance(applied_output_multiplicity, int):
+ nb_images = applied_output_multiplicity
+ else:
+ nb_images = 1
+
+ if nb_images > 1:
+ generated_image_list = await get_content_generator().make_image_list(
+ job_metadata=job_metadata,
+ imgg_handle=imgg_handle,
+ imgg_prompt=ImggPrompt(
+ positive_text=imgg_prompt_text,
+ ),
+ nb_images=nb_images,
+ imgg_job_params=imgg_job_params,
+ imgg_job_config=imgg_config.imgg_job_config,
+ wfid="imgg",
+ )
+ image_content_items: List[StuffContent] = []
+ for generated_image in generated_image_list:
+ image_content_items.append(
+ ImageContent(
+ url=generated_image.url,
+ source_prompt=imgg_prompt_text,
+ )
+ )
+ image_urls.append(generated_image.url)
+ the_content = ListContent(
+ items=image_content_items,
+ )
+ log.verbose(the_content, title="List of image contents")
+ else:
+ generated_image = await get_content_generator().make_single_image(
+ job_metadata=job_metadata,
+ imgg_handle=imgg_handle,
+ imgg_prompt=ImggPrompt(
+ positive_text=imgg_prompt_text,
+ ),
+ imgg_job_params=imgg_job_params,
+ imgg_job_config=imgg_config.imgg_job_config,
+ wfid="imgg",
+ )
+
+ generated_image_url = generated_image.url
+ image_urls = [generated_image_url]
+
+ the_content = ImageContent(
+ url=generated_image_url,
+ source_prompt=imgg_prompt_text,
+ )
+ log.verbose(the_content, title="Single image content")
+
+ output_stuff = StuffFactory.make_stuff(
+ name=output_name,
+ concept_code=self.output_concept_code,
+ content=the_content,
+ )
+
+ working_memory.set_new_main_stuff(
+ stuff=output_stuff,
+ name=output_name,
+ )
+
+ pipe_output = PipeImgGenOutput(
+ working_memory=working_memory,
+ )
+ return pipe_output
diff --git a/pipelex/pipe_operators/pipe_img_gen_factory.py b/pipelex/pipe_operators/pipe_img_gen_factory.py
new file mode 100644
index 000000000..ed617d2ea
--- /dev/null
+++ b/pipelex/pipe_operators/pipe_img_gen_factory.py
@@ -0,0 +1,64 @@
+from typing import Any, Dict, Literal, Optional, Union
+
+from pydantic import Field
+from typing_extensions import override
+
+from pipelex.cogt.imgg.imgg_handle import ImggHandle
+from pipelex.cogt.imgg.imgg_job_components import AspectRatio
+from pipelex.core.pipe_blueprint import PipeBlueprint, PipeSpecificFactoryProtocol
+from pipelex.pipe_operators.pipe_img_gen import PipeImgGen
+
+
+class PipeImgGenBlueprint(PipeBlueprint):
+ imgg_handle: Optional[ImggHandle] = None
+ aspect_ratio: Optional[AspectRatio] = Field(default=None, strict=False)
+ nb_steps: Optional[int] = Field(default=None, gt=0)
+ guidance_scale: Optional[float] = Field(default=None, gt=0)
+ is_safety_checker_enabled: Optional[bool] = None
+ safety_tolerance: Optional[int] = Field(default=None, ge=1, le=6)
+ is_raw: Optional[bool] = None
+ seed: Optional[Union[int, Literal["auto"]]] = None
+ nb_output: Optional[int] = Field(default=None, ge=1)
+
+
+class PipeImgGenFactory(PipeSpecificFactoryProtocol[PipeImgGenBlueprint, PipeImgGen]):
+ @classmethod
+ @override
+ def make_pipe_from_blueprint(
+ cls,
+ domain_code: str,
+ pipe_code: str,
+ pipe_blueprint: PipeImgGenBlueprint,
+ ) -> PipeImgGen:
+ output_multiplicity = pipe_blueprint.nb_output or 1
+ return PipeImgGen(
+ domain=domain_code,
+ code=pipe_code,
+ definition=pipe_blueprint.definition,
+ input_concept_code=pipe_blueprint.input,
+ output_concept_code=pipe_blueprint.output,
+ output_multiplicity=output_multiplicity,
+ imgg_handle=pipe_blueprint.imgg_handle,
+ aspect_ratio=pipe_blueprint.aspect_ratio,
+ nb_steps=pipe_blueprint.nb_steps,
+ guidance_scale=pipe_blueprint.guidance_scale,
+ is_safety_checker_enabled=pipe_blueprint.is_safety_checker_enabled,
+ safety_tolerance=pipe_blueprint.safety_tolerance,
+ is_raw=pipe_blueprint.is_raw,
+ seed=pipe_blueprint.seed,
+ )
+
+ @classmethod
+ @override
+ def make_pipe_from_details_dict(
+ cls,
+ domain_code: str,
+ pipe_code: str,
+ details_dict: Dict[str, Any],
+ ) -> PipeImgGen:
+ pipe_blueprint = PipeImgGenBlueprint.model_validate(details_dict)
+ return cls.make_pipe_from_blueprint(
+ domain_code=domain_code,
+ pipe_code=pipe_code,
+ pipe_blueprint=pipe_blueprint,
+ )
diff --git a/pipelex/pipe_operators/pipe_jinja2.py b/pipelex/pipe_operators/pipe_jinja2.py
new file mode 100644
index 000000000..9177eb2ff
--- /dev/null
+++ b/pipelex/pipe_operators/pipe_jinja2.py
@@ -0,0 +1,126 @@
+from typing import Any, ClassVar, Dict, Optional, Self, Set
+
+import shortuuid
+from jinja2 import TemplateSyntaxError
+from pydantic import ConfigDict, model_validator
+from typing_extensions import override
+
+from pipelex import log
+from pipelex.core.concept_native import NativeConcept
+from pipelex.core.pipe_output import PipeOutput
+from pipelex.core.pipe_run_params import PipeRunParams
+from pipelex.core.stuff import Stuff
+from pipelex.core.stuff_content import TextContent
+from pipelex.core.working_memory import WorkingMemory
+from pipelex.exceptions import PipeDefinitionError, PipeRunParamsError
+from pipelex.hub import get_content_generator, get_template, get_template_provider
+from pipelex.mission.job_metadata import JobMetadata
+from pipelex.pipe_operators.pipe_operator import PipeOperator
+from pipelex.tools.templating.jinja2_errors import Jinja2TemplateError
+from pipelex.tools.templating.jinja2_parsing import check_jinja2_parsing
+from pipelex.tools.templating.jinja2_required_variables import detect_jinja2_required_variables
+from pipelex.tools.templating.jinja2_template_category import Jinja2TemplateCategory
+from pipelex.tools.templating.templating_models import PromptingStyle
+from pipelex.tools.typing.validation_utils import has_exactly_one_among_attributes_from_list
+
+
+class PipeJinja2Output(PipeOutput):
+ @property
+ def rendered_text(self) -> str:
+ return self.main_stuff_as_text.text
+
+
+class PipeJinja2(PipeOperator):
+ model_config = ConfigDict(extra="forbid", strict=False)
+
+ adhoc_pipe_code: ClassVar[str] = "jinja2_render"
+ output_concept_code: str = NativeConcept.TEXT.code
+
+ jinja2_name: Optional[str] = None
+ jinja2: Optional[str] = None
+ prompting_style: Optional[PromptingStyle] = None
+ template_category: Jinja2TemplateCategory = Jinja2TemplateCategory.LLM_PROMPT
+
+ @model_validator(mode="after")
+ def validate_jinja2(self) -> Self:
+ if not has_exactly_one_among_attributes_from_list(self, attributes_list=["jinja2_name", "jinja2"]):
+ raise PipeDefinitionError("PipeJinja2 should have exactly one of jinja2_name or jinja2")
+ if self.jinja2:
+ try:
+ check_jinja2_parsing(jinja2_template_source=self.jinja2, template_category=self.template_category)
+ except TemplateSyntaxError as exc:
+ raise Jinja2TemplateError(f"Could not parse Jinja2 template included in PipeJinja2: {exc}") from exc
+ return self
+
+ @override
+ def validate_with_libraries(self):
+ if self.jinja2_name:
+ the_template = get_template(template_name=self.jinja2_name)
+ log.debug(f"Validated jinja2 template '{self.jinja2_name}':\n{the_template}")
+
+ @property
+ def desc(self) -> str:
+ if self.jinja2:
+ return f"Jinja2 included template, prompting style {self.prompting_style}"
+ elif jinja2_name := self.jinja2_name:
+ return f"Jinja2 template '{jinja2_name}', prompting style {self.prompting_style}"
+ else:
+ return "Jinja2 template not defined"
+
+ @override
+ def required_variables(self) -> Set[str]:
+ required_variables = detect_jinja2_required_variables(
+ template_category=self.template_category,
+ template_provider=get_template_provider(),
+ jinja2_name=self.jinja2_name,
+ jinja2=self.jinja2,
+ )
+ return required_variables
+
+ @override
+ async def _run_operator_pipe(
+ self,
+ job_metadata: JobMetadata,
+ working_memory: WorkingMemory,
+ pipe_run_params: PipeRunParams,
+ output_name: Optional[str] = None,
+ ) -> PipeJinja2Output:
+ if pipe_run_params.is_multiple_output_required:
+ raise PipeRunParamsError(
+ f"PipeJinja2 does not suppport multiple outputs, got output_multiplicity = {pipe_run_params.output_multiplicity}"
+ )
+ if not self.output_concept_code:
+ raise PipeRunParamsError("PipeJinja2 must have an output_concept_code")
+
+ context: Dict[str, Any] = working_memory.generate_stuff_artefact_dict()
+ if pipe_run_params:
+ context.update(**pipe_run_params.params)
+
+ jinja2_text = await get_content_generator().make_jinja2_text(
+ context=context,
+ jinja2_name=self.jinja2_name,
+ jinja2=self.jinja2,
+ prompting_style=self.prompting_style,
+ template_category=self.template_category,
+ )
+ log.verbose(f"Jinja2 rendered text:\n{jinja2_text}")
+ assert isinstance(jinja2_text, str)
+ the_content = TextContent(text=jinja2_text)
+
+ output_stuff = Stuff(
+ concept_code=self.output_concept_code,
+ content=the_content,
+ stuff_name=output_name,
+ stuff_code=shortuuid.uuid()[:5],
+ )
+
+ working_memory.set_new_main_stuff(
+ stuff=output_stuff,
+ name=output_name,
+ )
+
+ pipe_output = PipeJinja2Output(
+ working_memory=working_memory,
+ )
+
+ return pipe_output
diff --git a/pipelex/pipe_operators/pipe_jinja2_factory.py b/pipelex/pipe_operators/pipe_jinja2_factory.py
new file mode 100644
index 000000000..ab03b5e5a
--- /dev/null
+++ b/pipelex/pipe_operators/pipe_jinja2_factory.py
@@ -0,0 +1,107 @@
+from typing import Any, Dict, Optional
+
+from typing_extensions import override
+
+from pipelex.config import get_config
+from pipelex.core.pipe_blueprint import PipeBlueprint, PipeSpecificFactoryProtocol
+from pipelex.exceptions import PipeDefinitionError
+from pipelex.pipe_operators.pipe_jinja2 import PipeJinja2
+from pipelex.tools.templating.jinja2_environment import Jinja2TemplateCategory
+from pipelex.tools.templating.jinja2_parsing import check_jinja2_parsing
+from pipelex.tools.templating.template_preprocessor import preprocess_template
+from pipelex.tools.templating.templating_models import PromptingStyle
+
+
+class PipeJinja2Blueprint(PipeBlueprint):
+ jinja2_name: Optional[str] = None
+ jinja2: Optional[str] = None
+ prompting_style: Optional[PromptingStyle] = None
+ template_category: Jinja2TemplateCategory = Jinja2TemplateCategory.LLM_PROMPT
+
+
+class PipeJinja2Factory(PipeSpecificFactoryProtocol[PipeJinja2Blueprint, PipeJinja2]):
+ @classmethod
+ @override
+ def make_pipe_from_blueprint(
+ cls,
+ domain_code: str,
+ pipe_code: str,
+ pipe_blueprint: PipeJinja2Blueprint,
+ ) -> PipeJinja2:
+ preprocessed_template: Optional[str] = None
+ if pipe_blueprint.jinja2:
+ preprocessed_template = preprocess_template(pipe_blueprint.jinja2)
+ check_jinja2_parsing(
+ jinja2_template_source=preprocessed_template,
+ template_category=pipe_blueprint.template_category,
+ )
+ else:
+ preprocessed_template = None
+ return PipeJinja2(
+ domain=domain_code,
+ code=pipe_code,
+ definition=pipe_blueprint.definition,
+ input_concept_code=pipe_blueprint.input,
+ output_concept_code=pipe_blueprint.output,
+ jinja2_name=pipe_blueprint.jinja2_name,
+ jinja2=preprocessed_template,
+ prompting_style=pipe_blueprint.prompting_style,
+ template_category=pipe_blueprint.template_category,
+ )
+
+ @classmethod
+ @override
+ def make_pipe_from_details_dict(
+ cls,
+ domain_code: str,
+ pipe_code: str,
+ details_dict: Dict[str, Any],
+ ) -> PipeJinja2:
+ pipe_blueprint = PipeJinja2Blueprint.model_validate(details_dict)
+ return cls.make_pipe_from_blueprint(
+ domain_code=domain_code,
+ pipe_code=pipe_code,
+ pipe_blueprint=pipe_blueprint,
+ )
+
+ @classmethod
+ def make_pipe_jinja2_from_template_str(
+ cls,
+ domain_code: str,
+ template_str: Optional[str] = None,
+ template_name: Optional[str] = None,
+ ) -> PipeJinja2:
+ if template_str:
+ preprocessed_template = preprocess_template(template_str)
+ check_jinja2_parsing(
+ jinja2_template_source=preprocessed_template,
+ template_category=Jinja2TemplateCategory.LLM_PROMPT,
+ )
+ return PipeJinja2(
+ domain=domain_code,
+ code="adhoc_pipe_jinja2_from_template_str",
+ jinja2=preprocessed_template,
+ )
+ elif template_name:
+ return PipeJinja2(
+ domain=domain_code,
+ code="adhoc_pipe_jinja2_from_template_name",
+ jinja2_name=template_name,
+ )
+ else:
+ raise PipeDefinitionError("Either template_str or template_name must be provided to make_pipe_jinja2_from_template_str")
+
+ @classmethod
+ def make_pipe_jinja2_to_structure(
+ cls,
+ domain_code: str,
+ prompt_template_to_structure: Optional[str],
+ ) -> PipeJinja2:
+ jinja2_name = prompt_template_to_structure or get_config().pipelex.generic_template_names.structure_from_preliminary_text_user
+ prompting_style = PromptingStyle.make_default_prompting_style()
+ return PipeJinja2(
+ domain=domain_code,
+ code="adhoc_pipe_jinja2_to_structure",
+ jinja2_name=jinja2_name,
+ prompting_style=prompting_style,
+ )
diff --git a/pipelex/pipe_operators/pipe_llm.py b/pipelex/pipe_operators/pipe_llm.py
new file mode 100644
index 000000000..d4ae47478
--- /dev/null
+++ b/pipelex/pipe_operators/pipe_llm.py
@@ -0,0 +1,374 @@
+from enum import StrEnum
+from typing import List, Optional, Self, Set, Type, cast
+
+from kajson.class_registry import class_registry
+from pydantic import model_validator
+from typing_extensions import override
+
+from pipelex import log
+from pipelex.cogt.llm.llm_models.llm_deck import LLMSettingChoices
+from pipelex.cogt.llm.llm_models.llm_deck_check import check_llm_setting_with_deck
+from pipelex.cogt.llm.llm_models.llm_setting import LLMSetting
+from pipelex.cogt.llm.llm_prompt import LLMPrompt
+from pipelex.cogt.llm.llm_prompt_factory_abstract import LLMPromptFactoryAbstract
+from pipelex.config import get_config
+from pipelex.core.concept_factory import ConceptFactory
+from pipelex.core.concept_native import NativeConcept, NativeConceptClass
+from pipelex.core.domain import Domain, SpecialDomain
+from pipelex.core.pipe_output import PipeOutput
+from pipelex.core.pipe_run_params import (
+ PipeOutputMultiplicity,
+ PipeRunParamKey,
+ PipeRunParams,
+ output_multiplicity_to_apply,
+)
+from pipelex.core.stuff_content import ListContent, StuffContent, TextContent
+from pipelex.core.stuff_factory import StuffFactory
+from pipelex.core.working_memory import WorkingMemory
+from pipelex.exceptions import PipeDefinitionError, PipeExecutionError
+from pipelex.hub import (
+ get_concept_provider,
+ get_content_generator,
+ get_llm_deck,
+ get_optional_pipe,
+ get_required_concept,
+ get_required_domain,
+ get_required_pipe,
+ get_template,
+)
+from pipelex.mission.job_metadata import JobCategory, JobMetadata
+from pipelex.pipe_operators.pipe_jinja2_factory import PipeJinja2Factory
+from pipelex.pipe_operators.pipe_llm_prompt import PipeLLMPrompt, PipeLLMPromptOutput
+from pipelex.pipe_operators.pipe_operator import PipeOperator
+from pipelex.pipe_operators.piped_llm_prompt_factory import PipedLLMPromptFactory
+
+
+class StructuringMethod(StrEnum):
+ DIRECT = "direct"
+ PRELIMINARY_TEXT = "preliminary_text"
+
+
+class PipeLLMOutput(PipeOutput):
+ pass
+
+
+class PipeLLM(PipeOperator):
+ pipe_llm_prompt: PipeLLMPrompt
+ llm_choices: Optional[LLMSettingChoices] = None
+ structuring_method: Optional[StructuringMethod] = None
+ prompt_template_to_structure: Optional[str] = None
+ system_prompt_to_structure: Optional[str] = None
+ output_multiplicity: Optional[PipeOutputMultiplicity] = None
+
+ @model_validator(mode="after")
+ def validate_output_concept_consistency(self) -> Self:
+ if self.structuring_method is not None:
+ output_concept = get_required_concept(concept_code=self.output_concept_code)
+ if output_concept.structure_class_name == NativeConceptClass.TEXT:
+ raise PipeDefinitionError(f"Output concept '{self.output_concept_code}' is a TextConcept, so it cannot be structured")
+ return self
+
+ @override
+ def validate_with_libraries(self):
+ if self.input_concept_code and get_concept_provider().is_compatible_by_concept_code(
+ tested_concept_code=self.input_concept_code,
+ wanted_concept_code=NativeConcept.IMAGE.code,
+ ):
+ if not self.pipe_llm_prompt.user_images:
+ raise PipeDefinitionError(f"No user images provided for concept '{self.input_concept_code}' but it's required")
+ self.pipe_llm_prompt.validate_with_libraries()
+ if self.prompt_template_to_structure:
+ get_template(template_name=self.prompt_template_to_structure)
+ if self.system_prompt_to_structure:
+ get_template(template_name=self.system_prompt_to_structure)
+ if self.llm_choices:
+ for llm_setting in self.llm_choices.list_used_presets():
+ check_llm_setting_with_deck(llm_setting_or_preset_id=llm_setting)
+
+ @property
+ def llm_setting_main(self) -> LLMSetting:
+ return get_llm_deck().get_llm_setting_for_text(override=self.llm_choices)
+
+ @property
+ def llm_setting_for_object(self) -> LLMSetting:
+ return get_llm_deck().get_llm_setting_for_object(override=self.llm_choices)
+
+ @property
+ def llm_setting_for_object_direct(self) -> LLMSetting:
+ return get_llm_deck().get_llm_setting_for_object_direct(override=self.llm_choices)
+
+ @property
+ def llm_setting_for_object_list(self) -> LLMSetting:
+ return get_llm_deck().get_llm_setting_for_object_list(override=self.llm_choices)
+
+ @property
+ def llm_setting_for_object_list_direct(self) -> LLMSetting:
+ return get_llm_deck().get_llm_setting_for_object_list_direct(override=self.llm_choices)
+
+ @override
+ def required_variables(self) -> Set[str]:
+ required_variables: Set[str] = set()
+ required_variables.update(self.pipe_llm_prompt.required_variables())
+ return required_variables
+
+ @override
+ async def _run_operator_pipe(
+ self,
+ job_metadata: JobMetadata,
+ working_memory: WorkingMemory,
+ pipe_run_params: PipeRunParams,
+ output_name: Optional[str] = None,
+ ) -> PipeLLMOutput:
+ # interpret / unwrap the arguments
+ log.debug(f"PipeLLM pipe_code = {self.code}")
+ if self.output_concept_code == ConceptFactory.make_concept_code(
+ SpecialDomain.NATIVE,
+ NativeConcept.DYNAMIC.code,
+ ):
+ # TODO: This DYNAMIC_OUTPUT_CONCEPT should not be a field in the params attribute of PipeRunParams.
+ # It should be an attribute of PipeRunParams.
+ output_concept_code = pipe_run_params.dynamic_output_concept_code or pipe_run_params.params.get(PipeRunParamKey.DYNAMIC_OUTPUT_CONCEPT)
+ if not output_concept_code:
+ raise RuntimeError(f"No output concept code provided for dynamic output pipe '{self.code}'")
+ else:
+ output_concept_code = self.output_concept_code
+
+ applied_output_multiplicity, is_multiple_output, fixed_nb_output = output_multiplicity_to_apply(
+ output_multiplicity_base=self.output_multiplicity,
+ output_multiplicity_override=pipe_run_params.output_multiplicity,
+ )
+ log.debug(
+ f"PipeLLM pipe_code = {self.code}: applied_output_multiplicity = {applied_output_multiplicity}, "
+ f"is_multiple_output = {is_multiple_output}, fixed_nb_output = {fixed_nb_output}"
+ )
+
+ output_concept = get_required_concept(concept_code=output_concept_code)
+ if is_multiple_output:
+ if fixed_nb_output:
+ log.verbose(f"{self.class_name} generate {fixed_nb_output} x '{output_concept_code}' (class '{output_concept.structure_class_name}')")
+ else:
+ log.verbose(f"{self.class_name} generate a list of '{output_concept_code}' (class '{output_concept.structure_class_name}')")
+ else:
+ log.verbose(f"{self.class_name} generate a single '{output_concept_code}' (class '{output_concept.structure_class_name}')")
+
+ if not self.pipe_llm_prompt.prompting_style:
+ llm_deck = get_llm_deck()
+ llm_model = llm_deck.find_llm_model(llm_handle=self.llm_setting_main.llm_handle)
+ llm_family = llm_model.llm_family
+ if self.llm_setting_main.prompting_target:
+ log.dev(f"prompting_target for '{self.llm_setting_main.llm_handle}' from setting: {self.llm_setting_main}")
+ else:
+ log.dev(f"prompting_target for '{self.llm_setting_main.llm_handle}' from llm_family: {llm_family}")
+ prompting_target = self.llm_setting_main.prompting_target or llm_family.prompting_target
+ self.pipe_llm_prompt.prompting_style = get_config().pipelex.prompting_config.get_prompting_style(
+ prompting_target=prompting_target,
+ )
+
+ # prepare the job
+ prompt_job_metadata = job_metadata.copy_with_update(
+ updated_metadata=JobMetadata(
+ job_category=JobCategory.PROMPTING_JOB,
+ )
+ )
+
+ llm_prompt_run_params = PipeRunParams.copy_by_injecting_multiplicity(
+ pipe_run_params=pipe_run_params,
+ applied_output_multiplicity=applied_output_multiplicity,
+ )
+ # llm_prompt_1: LLMPrompt = (
+ # await self.pipe_llm_prompt.run_pipe(
+ # job_metadata=prompt_job_metadata,
+ # working_memory=working_memory,
+ # pipe_run_params=llm_prompt_run_params,
+ # )
+ # ).llm_prompt
+ # TODO: restore the possibility above, without need to explicitly cast the output
+ pipe_output: PipeOutput = await self.pipe_llm_prompt.run_pipe(
+ job_metadata=prompt_job_metadata,
+ working_memory=working_memory,
+ pipe_run_params=llm_prompt_run_params,
+ )
+ llm_prompt_1 = cast(PipeLLMPromptOutput, pipe_output).llm_prompt
+
+ if input_concept_code := self.input_concept_code:
+ if (
+ get_concept_provider().is_compatible_by_concept_code(
+ tested_concept_code=input_concept_code,
+ wanted_concept_code=NativeConcept.IMAGE.code,
+ )
+ and not llm_prompt_1.user_images
+ ):
+ raise PipeExecutionError(
+ f"No user images provided in the prompt with input concept '{input_concept_code}' but it's required for pipe '{self.code}'"
+ )
+
+ the_content: StuffContent
+ if output_concept.structure_class_name == NativeConceptClass.TEXT and not is_multiple_output:
+ log.debug(f"PipeLLM generating a single text output: {self.class_name}_gen_text")
+ generated_text: str = await get_content_generator().make_llm_text(
+ job_metadata=job_metadata,
+ llm_prompt_for_text=llm_prompt_1,
+ llm_setting_main=self.llm_setting_main,
+ wfid=f"{self.class_name}_gen_text",
+ )
+
+ the_content = TextContent(
+ text=generated_text,
+ )
+ else:
+ log.debug(f"PipeLLM generating {fixed_nb_output} output(s)" if fixed_nb_output else "PipeLLM generating a list of output(s)")
+
+ llm_prompt_2_factory: Optional[LLMPromptFactoryAbstract]
+ if structuring_method := self.structuring_method:
+ log.debug(f"PipeLLM pipe_code is '{self.code}' and structuring_method is '{structuring_method}'")
+ match structuring_method:
+ case StructuringMethod.DIRECT:
+ llm_prompt_2_factory = None
+ case StructuringMethod.PRELIMINARY_TEXT:
+ pipe = get_required_pipe(pipe_code=self.code)
+ # TODO: run_pipe() could get the domain at the same time as the pip_code
+ domain = get_required_domain(domain_code=pipe.domain)
+ prompt_template_to_structure = self.prompt_template_to_structure or domain.prompt_template_to_structure
+ user_pipe_jinja2 = PipeJinja2Factory.make_pipe_jinja2_to_structure(
+ domain_code=self.domain,
+ prompt_template_to_structure=prompt_template_to_structure,
+ )
+ system_prompt = self.system_prompt_to_structure or domain.system_prompt
+ pipe_llm_prompt_2 = PipeLLMPrompt(
+ code="adhoc_for_pipe_llm_prompt_2",
+ domain=self.domain,
+ user_pipe_jinja2=user_pipe_jinja2,
+ system_prompt=system_prompt,
+ )
+ llm_prompt_2_factory = PipedLLMPromptFactory(
+ pipe_llm_prompt=pipe_llm_prompt_2,
+ )
+ elif get_config().pipelex.structure_config.is_default_text_then_structure:
+ log.debug(f"PipeLLM pipe_code is '{self.code}' and is_default_text_then_structure")
+ # TODO: run_pipe() should get the domain along with the pip_code
+ if the_pipe := get_optional_pipe(pipe_code=self.code):
+ domain = get_required_domain(domain_code=the_pipe.domain)
+ else:
+ domain = Domain.make_default()
+ prompt_template_to_structure = self.prompt_template_to_structure or domain.prompt_template_to_structure
+ user_pipe_jinja2 = PipeJinja2Factory.make_pipe_jinja2_to_structure(
+ domain_code=self.domain,
+ prompt_template_to_structure=prompt_template_to_structure,
+ )
+ system_prompt = self.system_prompt_to_structure or domain.system_prompt
+ pipe_llm_prompt_2 = PipeLLMPrompt(
+ code="adhoc_for_pipe_llm_prompt_2",
+ domain=self.domain,
+ user_pipe_jinja2=user_pipe_jinja2,
+ system_prompt=system_prompt,
+ )
+ llm_prompt_2_factory = PipedLLMPromptFactory(
+ pipe_llm_prompt=pipe_llm_prompt_2,
+ )
+ else:
+ llm_prompt_2_factory = None
+
+ the_content = await self._llm_gen_object_stuff_content(
+ job_metadata=job_metadata,
+ is_multiple_output=is_multiple_output,
+ fixed_nb_output=fixed_nb_output,
+ output_class_name=output_concept.structure_class_name,
+ llm_prompt_1=llm_prompt_1,
+ llm_prompt_2_factory=llm_prompt_2_factory,
+ )
+
+ output_stuff = StuffFactory.make_stuff_using_concept(
+ name=output_name,
+ concept=output_concept,
+ content=the_content,
+ code=pipe_run_params.final_stuff_code,
+ )
+ working_memory.set_new_main_stuff(
+ stuff=output_stuff,
+ name=output_name,
+ )
+
+ pipe_output = PipeLLMOutput(
+ working_memory=working_memory,
+ )
+ return pipe_output
+
+ async def _llm_gen_object_stuff_content(
+ self,
+ job_metadata: JobMetadata,
+ is_multiple_output: bool,
+ fixed_nb_output: Optional[int],
+ output_class_name: str,
+ llm_prompt_1: LLMPrompt,
+ llm_prompt_2_factory: Optional[LLMPromptFactoryAbstract],
+ ) -> StuffContent:
+ content_class: Type[StuffContent] = class_registry.get_required_subclass(name=output_class_name, base_class=StuffContent)
+ task_desc: str
+ the_content: StuffContent
+
+ if is_multiple_output:
+ # We're generating a list of (possibly multiple) objects
+ if fixed_nb_output:
+ task_desc = f"{self.class_name}_gen_{fixed_nb_output}x{content_class.__class__.__name__}"
+ else:
+ task_desc = f"{self.class_name}_gen_list_{content_class.__class__.__name__}"
+ log.dev(task_desc)
+ generated_objects: List[StuffContent]
+ if llm_prompt_2_factory is not None:
+ # We're generating a list of objects using preliminary text
+ method_desc = "text_then_object"
+ log.dev(f"{task_desc} by {method_desc}")
+
+ generated_objects = await get_content_generator().make_text_then_object_list(
+ job_metadata=job_metadata,
+ object_class=content_class,
+ llm_prompt_for_text=llm_prompt_1,
+ llm_setting_main=self.llm_setting_main,
+ llm_prompt_factory_for_object_list=llm_prompt_2_factory,
+ llm_setting_for_object_list=self.llm_setting_for_object_list,
+ wfid=task_desc,
+ )
+ else:
+ # We're generating a list of objects directly
+ method_desc = "object_direct"
+ log.dev(f"{task_desc} by {method_desc}, content_class={content_class.__name__}")
+ generated_objects = await get_content_generator().make_object_list_direct(
+ job_metadata=job_metadata,
+ object_class=content_class,
+ llm_prompt_for_object_list=llm_prompt_1,
+ llm_setting_for_object_list=self.llm_setting_for_object_list_direct,
+ wfid=task_desc,
+ )
+
+ the_content = ListContent(items=generated_objects)
+ else:
+ # We're generating a single object
+ task_desc = f"{self.class_name}_gen_single_{content_class.__name__}"
+ log.verbose(task_desc)
+ if llm_prompt_2_factory is not None:
+ # We're generating a single object using preliminary text
+ method_desc = "text_then_object"
+ log.verbose(f"{task_desc} by {method_desc}")
+ generated_object = await get_content_generator().make_text_then_object(
+ job_metadata=job_metadata,
+ object_class=content_class,
+ llm_prompt_for_text=llm_prompt_1,
+ llm_setting_main=self.llm_setting_main,
+ llm_prompt_factory_for_object=llm_prompt_2_factory,
+ llm_setting_for_object=self.llm_setting_for_object,
+ wfid=task_desc,
+ )
+ else:
+ # We're generating a single object directly
+ method_desc = "object_direct"
+ log.verbose(f"{task_desc} by {method_desc}, content_class={content_class.__name__}")
+ generated_object = await get_content_generator().make_object_direct(
+ job_metadata=job_metadata,
+ object_class=content_class,
+ llm_prompt_for_object=llm_prompt_1,
+ llm_setting_for_object=self.llm_setting_for_object_direct,
+ wfid=task_desc,
+ )
+ the_content = generated_object
+
+ return the_content
diff --git a/pipelex/pipe_operators/pipe_llm_factory.py b/pipelex/pipe_operators/pipe_llm_factory.py
new file mode 100644
index 000000000..4e635fbeb
--- /dev/null
+++ b/pipelex/pipe_operators/pipe_llm_factory.py
@@ -0,0 +1,167 @@
+from typing import Any, Dict, List, Optional, Self
+
+from pydantic import model_validator
+from typing_extensions import override
+
+from pipelex.cogt.llm.llm_models.llm_deck import LLMSettingChoices
+from pipelex.cogt.llm.llm_models.llm_setting import LLMSettingOrPresetId
+from pipelex.core.pipe_blueprint import PipeBlueprint, PipeSpecificFactoryProtocol
+from pipelex.core.pipe_run_params import make_output_multiplicity
+from pipelex.exceptions import PipeDefinitionError
+from pipelex.hub import get_optional_domain
+from pipelex.pipe_operators.pipe_jinja2 import PipeJinja2
+from pipelex.pipe_operators.pipe_jinja2_factory import PipeJinja2Factory
+from pipelex.pipe_operators.pipe_llm import PipeLLM, StructuringMethod
+from pipelex.pipe_operators.pipe_llm_prompt import PipeLLMPrompt
+from pipelex.tools.templating.jinja2_errors import Jinja2TemplateError
+from pipelex.tools.typing.validation_utils import has_more_than_one_among_attributes_from_any_list
+
+
+class PipeLLMBlueprint(PipeBlueprint):
+ system_prompt_template: Optional[str] = None
+ system_prompt_template_name: Optional[str] = None
+ system_prompt_name: Optional[str] = None
+ system_prompt: Optional[str] = None
+
+ prompt_template: Optional[str] = None
+ template_name: Optional[str] = None
+ prompt_name: Optional[str] = None
+ prompt: Optional[str] = None
+
+ images: Optional[List[str]] = None
+
+ llm: Optional[LLMSettingOrPresetId] = None
+ llm_to_structure: Optional[LLMSettingOrPresetId] = None
+ llm_to_structure_direct: Optional[LLMSettingOrPresetId] = None
+ llm_to_structure_list: Optional[LLMSettingOrPresetId] = None
+ llm_to_structure_list_direct: Optional[LLMSettingOrPresetId] = None
+
+ structuring_method: Optional[StructuringMethod] = None
+ prompt_template_to_structure: Optional[str] = None
+ system_prompt_to_structure: Optional[str] = None
+
+ nb_output: Optional[int] = None
+ multiple_output: Optional[bool] = None
+
+ @model_validator(mode="after")
+ def validate_multiple_output(self) -> Self:
+ if attributes_list := has_more_than_one_among_attributes_from_any_list(
+ self,
+ attributes_lists=[
+ ["nb_output", "multiple_output"],
+ ["system_prompt", "system_prompt_name", "system_prompt_template", "system_prompt_template_name"],
+ ["prompt", "prompt_name", "prompt_template", "template_name"],
+ ],
+ ):
+ raise PipeDefinitionError(f"PipeLLMBlueprint should have no more than one of {attributes_list} among them")
+ return self
+
+
+class PipeLLMFactory(PipeSpecificFactoryProtocol[PipeLLMBlueprint, PipeLLM]):
+ @classmethod
+ @override
+ def make_pipe_from_blueprint(
+ cls,
+ domain_code: str,
+ pipe_code: str,
+ pipe_blueprint: PipeLLMBlueprint,
+ ) -> PipeLLM:
+ system_prompt_pipe_jinja2: Optional[PipeJinja2] = None
+ system_prompt: Optional[str] = None
+ if pipe_blueprint.system_prompt_template or pipe_blueprint.system_prompt_template_name:
+ try:
+ system_prompt_pipe_jinja2 = PipeJinja2(
+ code="adhoc_for_system_prompt",
+ domain=domain_code,
+ jinja2=pipe_blueprint.system_prompt_template,
+ jinja2_name=pipe_blueprint.system_prompt_template_name,
+ )
+ except Jinja2TemplateError as exc:
+ error_msg = f"Jinja2 template error in system prompt for pipe '{pipe_code}' in domain '{domain_code}': {exc}."
+ if pipe_blueprint.system_prompt_template:
+ error_msg += f"\nThe system prompt template is:\n{pipe_blueprint.system_prompt_template}"
+ else:
+ error_msg += "The system prompt template is not provided."
+ raise PipeDefinitionError(error_msg) from exc
+ elif not pipe_blueprint.system_prompt and not pipe_blueprint.system_prompt_name:
+ # really no system prompt provided, let's use the domain's default system prompt
+ if domain := get_optional_domain(domain_code=domain_code):
+ system_prompt = domain.system_prompt
+
+ user_pipe_jinja2: Optional[PipeJinja2] = None
+ if pipe_blueprint.prompt_template or pipe_blueprint.template_name:
+ try:
+ user_pipe_jinja2 = PipeJinja2Factory.make_pipe_jinja2_from_template_str(
+ domain_code=domain_code,
+ template_str=pipe_blueprint.prompt_template,
+ template_name=pipe_blueprint.template_name,
+ )
+ except Jinja2TemplateError as exc:
+ error_msg = f"Jinja2 syntax error in user prompt for pipe '{pipe_code}' in domain '{domain_code}': {exc}."
+ if pipe_blueprint.prompt_template:
+ error_msg += f"\nThe prompt template is:\n{pipe_blueprint.prompt_template}"
+ else:
+ error_msg += "The prompt template is not provided."
+ raise PipeDefinitionError(error_msg) from exc
+ elif pipe_blueprint.prompt is None and pipe_blueprint.prompt_name is None:
+ # no jinja2 provided, no verbatim name, no fixed text, let's use the pipe code as jinja2 name
+ user_pipe_jinja2 = PipeJinja2(
+ code="adhoc_for_user_prompt",
+ domain=domain_code,
+ jinja2_name=pipe_code,
+ )
+
+ pipe_llm_prompt = PipeLLMPrompt(
+ code="adhoc_for_pipe_llm_prompt",
+ domain=domain_code,
+ system_prompt_pipe_jinja2=system_prompt_pipe_jinja2,
+ system_prompt_verbatim_name=pipe_blueprint.system_prompt_name,
+ system_prompt=pipe_blueprint.system_prompt or system_prompt,
+ user_pipe_jinja2=user_pipe_jinja2,
+ user_prompt_verbatim_name=pipe_blueprint.prompt_name,
+ user_text=pipe_blueprint.prompt,
+ user_images=pipe_blueprint.images,
+ )
+
+ llm_settings = LLMSettingChoices(
+ for_text=pipe_blueprint.llm,
+ for_object=pipe_blueprint.llm_to_structure,
+ for_object_direct=pipe_blueprint.llm_to_structure_direct,
+ for_object_list=pipe_blueprint.llm_to_structure_list,
+ for_object_list_direct=pipe_blueprint.llm_to_structure_list_direct,
+ )
+
+ # output_multiplicity defaults to False for PipeLLM so unless it's run with explicit demand for multiple outputs,
+ # we'll generate only one output
+ output_multiplicity = make_output_multiplicity(
+ nb_output=pipe_blueprint.nb_output,
+ multiple_output=pipe_blueprint.multiple_output,
+ )
+ return PipeLLM(
+ domain=domain_code,
+ code=pipe_code,
+ definition=pipe_blueprint.definition,
+ input_concept_code=pipe_blueprint.input,
+ output_concept_code=pipe_blueprint.output,
+ pipe_llm_prompt=pipe_llm_prompt,
+ llm_choices=llm_settings,
+ structuring_method=pipe_blueprint.structuring_method,
+ prompt_template_to_structure=pipe_blueprint.prompt_template_to_structure,
+ system_prompt_to_structure=pipe_blueprint.system_prompt_to_structure,
+ output_multiplicity=output_multiplicity,
+ )
+
+ @classmethod
+ @override
+ def make_pipe_from_details_dict(
+ cls,
+ domain_code: str,
+ pipe_code: str,
+ details_dict: Dict[str, Any],
+ ) -> PipeLLM:
+ pipe_blueprint = PipeLLMBlueprint.model_validate(details_dict)
+ return cls.make_pipe_from_blueprint(
+ domain_code=domain_code,
+ pipe_code=pipe_code,
+ pipe_blueprint=pipe_blueprint,
+ )
diff --git a/pipelex/pipe_operators/pipe_llm_prompt.py b/pipelex/pipe_operators/pipe_llm_prompt.py
new file mode 100644
index 000000000..938967783
--- /dev/null
+++ b/pipelex/pipe_operators/pipe_llm_prompt.py
@@ -0,0 +1,265 @@
+from typing import ClassVar, List, Optional, Self, Set, cast
+
+from kajson.class_registry import class_registry
+from pydantic import model_validator
+from typing_extensions import override
+
+from pipelex import log
+from pipelex.cogt.image.prompt_image import PromptImage
+from pipelex.cogt.image.prompt_image_factory import PromptImageFactory
+from pipelex.cogt.llm.llm_prompt import LLMPrompt
+from pipelex.core.concept import Concept
+from pipelex.core.concept_native import NativeConcept
+from pipelex.core.pipe_output import PipeOutput
+from pipelex.core.pipe_run_params import PipeRunParams
+from pipelex.core.stuff_content import ImageContent, LLMPromptContent, StuffContent
+from pipelex.core.stuff_factory import StuffFactory
+from pipelex.core.working_memory import WorkingMemory
+from pipelex.exceptions import (
+ PipeDefinitionError,
+ PipeInputError,
+ PipeRunParamsError,
+ WorkingMemoryNotFoundError,
+ WorkingMemoryStuffNotFoundError,
+ WorkingMemoryTypeError,
+)
+from pipelex.hub import get_template
+from pipelex.mission.job_metadata import JobCategory, JobMetadata
+from pipelex.pipe_operators.pipe_jinja2 import PipeJinja2, PipeJinja2Output
+from pipelex.pipe_operators.pipe_operator import PipeOperator
+from pipelex.tools.templating.templating_models import PromptingStyle
+from pipelex.tools.typing.type_inspector import get_type_structure
+from pipelex.tools.typing.validation_utils import has_exactly_one_among_attributes_from_list, has_more_than_one_among_attributes_from_list
+
+
+class PipeLLMPromptOutput(PipeOutput):
+ @property
+ def llm_prompt(self) -> LLMPrompt:
+ return self.main_stuff_as(content_type=LLMPromptContent)
+
+
+# TODO: consider adding a PipeLLMPromptFactory for consistency
+class PipeLLMPrompt(PipeOperator):
+ adhoc_pipe_code: ClassVar[str] = "adhoc_pipe_code_for_prompt_llm"
+
+ output_concept_code: str = NativeConcept.LLM_PROMPT.code
+
+ prompting_style: Optional[PromptingStyle] = None
+
+ system_prompt_pipe_jinja2: Optional[PipeJinja2] = None
+ system_prompt_verbatim_name: Optional[str] = None
+ system_prompt: Optional[str] = None
+
+ user_pipe_jinja2: Optional[PipeJinja2] = None
+ user_prompt_verbatim_name: Optional[str] = None
+ user_text: Optional[str] = None
+
+ user_images: Optional[List[str]] = None
+
+ @model_validator(mode="after")
+ def validate_user_text(self) -> Self:
+ if not has_exactly_one_among_attributes_from_list(
+ obj=self,
+ attributes_list=[
+ "user_text",
+ "user_pipe_jinja2",
+ "user_prompt_verbatim_name",
+ ],
+ ):
+ raise PipeDefinitionError(
+ f"PipeLLMPrompt user text must have exactly one of user_text, user_pipe_jinja2 or user_prompt_verbatim_name: {self}"
+ )
+ if has_more_than_one_among_attributes_from_list(
+ obj=self,
+ attributes_list=[
+ "system_prompt",
+ "system_prompt_pipe_jinja2",
+ "system_prompt_verbatim_name",
+ ],
+ ):
+ raise PipeDefinitionError(
+ f"PipeLLMPrompt system got more than one of system_prompt, system_prompt_pipe_jinja2, system_prompt_verbatim_name: {self}"
+ )
+ return self
+
+ @override
+ def validate_with_libraries(self):
+ if self.user_prompt_verbatim_name:
+ get_template(template_name=self.user_prompt_verbatim_name)
+ if self.system_prompt_verbatim_name:
+ get_template(template_name=self.system_prompt_verbatim_name)
+
+ if self.user_pipe_jinja2:
+ self.user_pipe_jinja2.validate_with_libraries()
+ if self.system_prompt_pipe_jinja2:
+ self.system_prompt_pipe_jinja2.validate_with_libraries()
+
+ @override
+ def required_variables(self) -> Set[str]:
+ required_variables: Set[str] = set()
+ if self.user_pipe_jinja2:
+ required_variables.update(self.user_pipe_jinja2.required_variables())
+ if self.system_prompt_pipe_jinja2:
+ required_variables.update(self.system_prompt_pipe_jinja2.required_variables())
+ if self.user_images:
+ required_variables.update(self.user_images)
+ return required_variables
+
+ @override
+ async def _run_operator_pipe(
+ self,
+ job_metadata: JobMetadata,
+ working_memory: WorkingMemory,
+ pipe_run_params: PipeRunParams,
+ output_name: Optional[str] = None,
+ ) -> PipeLLMPromptOutput:
+ if pipe_run_params.is_multiple_output_required:
+ raise PipeRunParamsError(
+ f"PipeLLMPrompt does not suppport multiple outputs, got output_multiplicity = {pipe_run_params.output_multiplicity}"
+ )
+ if not self.output_concept_code:
+ raise PipeRunParamsError("PipeLLMPrompt must have a fixed non-None output_concept_code")
+
+ ############################################################
+ # User images
+ ############################################################
+ prompt_user_images: List[PromptImage] = []
+ if self.user_images:
+ for user_image_name in self.user_images:
+ log.debug(f"Getting user image '{user_image_name}' from context")
+ try:
+ prompt_image_content = working_memory.get_stuff_attribute(name=user_image_name, wanted_type=ImageContent)
+ except (WorkingMemoryNotFoundError, WorkingMemoryStuffNotFoundError, WorkingMemoryTypeError) as exc:
+ raise PipeInputError(f"A valid user image named '{user_image_name}' was not found in the working_memory: {exc}") from exc
+
+ if base_64 := prompt_image_content.base_64:
+ user_image = PromptImageFactory.make_prompt_image(base_64=base_64)
+ else:
+ image_uri = prompt_image_content.url
+ user_image = PromptImageFactory.make_prompt_image_from_uri(uri=image_uri)
+ prompt_user_images.append(user_image)
+
+ ############################################################
+ # User text
+ ############################################################
+ user_text = await self._unravel_text(
+ job_metadata=job_metadata,
+ working_memory=working_memory,
+ pipe_jinja2=self.user_pipe_jinja2,
+ text_verbatim_name=self.user_prompt_verbatim_name,
+ fixed_text=self.user_text,
+ pipe_run_params=pipe_run_params,
+ )
+ if not user_text:
+ raise ValueError("For user_text we need either a pipe_jinja2, a text_verbatim_name or a fixed user_text")
+
+ # Append output structure prompt if needed
+ if pipe_run_params.dynamic_output_concept_code:
+ user_text += PipeLLMPrompt.get_output_structure_prompt(output_concept=pipe_run_params.dynamic_output_concept_code)
+
+ ############################################################
+ # System text
+ ############################################################
+ system_text = await self._unravel_text(
+ job_metadata=job_metadata,
+ working_memory=working_memory,
+ pipe_jinja2=self.system_prompt_pipe_jinja2,
+ text_verbatim_name=self.system_prompt_verbatim_name,
+ fixed_text=self.system_prompt,
+ pipe_run_params=pipe_run_params,
+ )
+
+ ############################################################
+ # Full LLMPrompt
+ ############################################################
+ llm_prompt = LLMPromptContent(
+ system_text=system_text,
+ user_text=user_text,
+ user_images=prompt_user_images,
+ )
+
+ output_stuff = StuffFactory.make_stuff(
+ name=output_name,
+ concept_code=self.output_concept_code,
+ content=llm_prompt,
+ )
+
+ working_memory.set_new_main_stuff(
+ stuff=output_stuff,
+ name=output_name,
+ )
+
+ pipe_output = PipeLLMPromptOutput(
+ working_memory=working_memory,
+ )
+ return pipe_output
+
+ @staticmethod
+ def get_output_structure_prompt(output_concept: str) -> str:
+ class_name = Concept.extract_concept_name_from_str(concept_str=output_concept)
+ output_class = class_registry.get_class(class_name)
+ if not output_class:
+ return ""
+
+ fields = get_type_structure(output_class, base_class=StuffContent)
+
+ if not fields:
+ return ""
+
+ output_structure_prompt = (
+ f"\n\n---\nRequested output format: The output should contain the following fields:\n"
+ f"{chr(10).join(fields)}\n"
+ "You do NOT need to output a formatted JSON object, another LLM will take care of that. "
+ "However, you MUST clearly output the values for each of these fields in your response.\n---\n"
+ )
+ return output_structure_prompt
+
+ async def _unravel_text(
+ self,
+ job_metadata: JobMetadata,
+ working_memory: WorkingMemory,
+ pipe_run_params: PipeRunParams,
+ pipe_jinja2: Optional[PipeJinja2],
+ text_verbatim_name: Optional[str],
+ fixed_text: Optional[str],
+ ) -> Optional[str]:
+ the_text: Optional[str]
+ if pipe_jinja2:
+ log.verbose(f"Working with Jinja2 pipe '{pipe_jinja2.jinja2_name}'")
+ if (prompting_style := self.prompting_style) and not pipe_jinja2.prompting_style:
+ pipe_jinja2.prompting_style = prompting_style
+ log.verbose(f"Setting prompting style to {prompting_style}")
+
+ jinja2_job_metadata = job_metadata.copy_with_update(
+ updated_metadata=JobMetadata(
+ job_category=JobCategory.JINJA2_JOB,
+ )
+ )
+ # the_text = (
+ # await pipe_jinja2.run_pipe(
+ # job_metadata=jinja2_job_metadata,
+ # working_memory=working_memory,
+ # pipe_run_params=pipe_run_params,
+ # )
+ # ).rendered_text
+ # TODO: restore the possibility above, without need to explicitly cast the output
+ pipe_output: PipeOutput = await pipe_jinja2.run_pipe(
+ job_metadata=jinja2_job_metadata,
+ working_memory=working_memory,
+ pipe_run_params=pipe_run_params,
+ )
+ pipe_jinja2_output = cast(PipeJinja2Output, pipe_output)
+ the_text = pipe_jinja2_output.rendered_text
+
+ elif text_verbatim_name:
+ user_text_verbatim = get_template(
+ template_name=text_verbatim_name,
+ )
+ if not user_text_verbatim:
+ raise ValueError(f"Could not find text_verbatim template '{text_verbatim_name}'")
+ the_text = user_text_verbatim
+ elif fixed_text:
+ the_text = fixed_text
+ else:
+ the_text = None
+ return the_text
diff --git a/pipelex/pipe_operators/pipe_ocr.py b/pipelex/pipe_operators/pipe_ocr.py
new file mode 100644
index 000000000..4ed74042b
--- /dev/null
+++ b/pipelex/pipe_operators/pipe_ocr.py
@@ -0,0 +1,138 @@
+from typing import List, Optional
+
+from pydantic import model_validator
+from typing_extensions import Self, override
+
+from pipelex import log
+from pipelex.cogt.ocr.ocr_engine import OcrEngine
+from pipelex.cogt.ocr.ocr_handle import OcrHandle
+from pipelex.cogt.ocr.ocr_input import OcrInput
+from pipelex.cogt.ocr.ocr_job_components import OcrJobConfig, OcrJobParams
+from pipelex.core.pipe_output import PipeOutput
+from pipelex.core.pipe_run_params import PipeRunParams
+from pipelex.core.stuff_content import ImageContent, ListContent, PageContent, TextAndImagesContent, TextContent
+from pipelex.core.stuff_factory import StuffFactory
+from pipelex.core.working_memory import WorkingMemory
+from pipelex.exceptions import PipeDefinitionError
+from pipelex.hub import get_content_generator
+from pipelex.mission.job_metadata import JobMetadata
+from pipelex.pipe_operators.pipe_operator import PipeOperator
+from pipelex.tools.pdf.pypdfium2_renderer import pypdfium2_renderer
+from pipelex.tools.typing.validation_utils import has_exactly_one_among_attributes_from_list
+
+
+class PipeOcrOutput(PipeOutput):
+ pass
+
+
+class PipeOcr(PipeOperator):
+ ocr_engine: Optional[OcrEngine] = None
+ image_stuff_name: Optional[str] = None
+ pdf_stuff_name: Optional[str] = None
+ should_caption_images: bool
+ should_include_images: bool
+ should_include_page_views: bool
+ page_views_dpi: int
+
+ @model_validator(mode="after")
+ def validate_exactly_one_input_stuff_name(self) -> Self:
+ if not has_exactly_one_among_attributes_from_list(self, attributes_list=["image_stuff_name", "pdf_stuff_name"]):
+ raise PipeDefinitionError("Exactly one of 'image_stuff_name' or 'pdf_stuff_name' must be provided")
+ return self
+
+ @override
+ async def _run_operator_pipe(
+ self,
+ job_metadata: JobMetadata,
+ working_memory: WorkingMemory,
+ pipe_run_params: PipeRunParams,
+ output_name: Optional[str] = None,
+ ) -> PipeOcrOutput:
+ if not self.output_concept_code:
+ raise PipeDefinitionError("PipeOcr should have a non-None output_concept_code")
+
+ image_uri: Optional[str] = None
+ pdf_uri: Optional[str] = None
+ if self.image_stuff_name:
+ image_stuff = working_memory.get_stuff_as_image(name=self.image_stuff_name)
+ image_uri = image_stuff.url
+ elif self.pdf_stuff_name:
+ pdf_stuff = working_memory.get_stuff_as_pdf(name=self.pdf_stuff_name)
+ pdf_uri = pdf_stuff.url
+ else:
+ raise PipeDefinitionError("PipeOcr should have a non-None image_stuff_name or pdf_stuff_name")
+
+ ocr_handle = OcrHandle.MISTRAL_OCR
+ ocr_job_params = OcrJobParams(
+ should_include_images=self.should_include_images,
+ should_caption_images=self.should_caption_images,
+ should_include_page_views=self.should_include_page_views,
+ page_views_dpi=self.page_views_dpi,
+ )
+ ocr_input = OcrInput(
+ image_uri=image_uri,
+ pdf_uri=pdf_uri,
+ )
+ ocr_output = await get_content_generator().make_ocr_extract_pages(
+ ocr_input=ocr_input,
+ ocr_handle=ocr_handle,
+ job_metadata=job_metadata,
+ ocr_job_params=ocr_job_params,
+ ocr_job_config=OcrJobConfig(),
+ )
+
+ # Build the output stuff, which is a list of page contents
+ page_view_contents: List[ImageContent] = []
+ if self.should_include_page_views:
+ if pdf_uri:
+ for page in ocr_output.pages.values():
+ if page.page_view:
+ page_view_contents.append(ImageContent.make_from_extracted_image(extracted_image=page.page_view))
+ needs_to_generate_page_views: bool
+ if len(page_view_contents) == 0:
+ log.debug("No page views found in the OCR output")
+ needs_to_generate_page_views = True
+ elif len(page_view_contents) < len(ocr_output.pages):
+ log.warning(f"Only {len(page_view_contents)} page found in the OCR output, but {len(ocr_output.pages)} pages")
+ needs_to_generate_page_views = True
+ else:
+ log.debug("All page views found in the OCR output")
+ needs_to_generate_page_views = False
+
+ if needs_to_generate_page_views:
+ page_views = await pypdfium2_renderer.render_pdf_pages_from_uri(pdf_uri=pdf_uri, dpi=self.page_views_dpi)
+ page_view_contents = [ImageContent.make_from_image(image=img) for img in page_views]
+ elif image_uri:
+ page_view_contents = [ImageContent.make_from_str(str_value=image_uri)]
+
+ page_contents: List[PageContent] = []
+ for page_index, page in ocr_output.pages.items():
+ images = [ImageContent.make_from_extracted_image(extracted_image=img) for img in page.extracted_images]
+ page_view = page_view_contents[page_index] if self.should_include_page_views else None
+ page_contents.append(
+ PageContent(
+ text_and_images=TextAndImagesContent(
+ text=TextContent(text=page.text) if page.text else None,
+ images=images,
+ ),
+ page_view=page_view,
+ )
+ )
+
+ content: ListContent[PageContent] = ListContent(items=page_contents)
+
+ output_stuff = StuffFactory.make_stuff(
+ name=output_name,
+ concept_code=self.output_concept_code,
+ content=content,
+ )
+
+ working_memory.set_new_main_stuff(
+ stuff=output_stuff,
+ name=output_name,
+ )
+
+ pipe_output = PipeOcrOutput(
+ working_memory=working_memory,
+ )
+ return pipe_output
diff --git a/pipelex/pipe_operators/pipe_ocr_factory.py b/pipelex/pipe_operators/pipe_ocr_factory.py
new file mode 100644
index 000000000..b973b09bc
--- /dev/null
+++ b/pipelex/pipe_operators/pipe_ocr_factory.py
@@ -0,0 +1,72 @@
+from typing import Any, Dict, Optional
+
+from pydantic import model_validator
+from typing_extensions import Self, override
+
+from pipelex.cogt.ocr.ocr_engine_factory import OcrEngineFactory, OcrPlatform
+from pipelex.cogt.ocr.ocr_handle import OcrHandle
+from pipelex.core.pipe_blueprint import PipeBlueprint, PipeSpecificFactoryProtocol
+from pipelex.exceptions import PipeDefinitionError
+from pipelex.pipe_operators.pipe_ocr import PipeOcr
+from pipelex.tools.typing.validation_utils import has_exactly_one_among_attributes_from_list
+
+
+class PipeOcrBlueprint(PipeBlueprint):
+ definition: Optional[str] = None
+ image: Optional[str] = None
+ pdf: Optional[str] = None
+ ocr_platform: Optional[OcrPlatform] = None
+ page_images: bool = False
+ page_image_captions: bool = False
+ page_views: bool = False
+ page_views_dpi: int = 300
+
+ @model_validator(mode="after")
+ def validate_input_source(self) -> Self:
+ if not has_exactly_one_among_attributes_from_list(self, attributes_list=["image", "pdf"]):
+ raise PipeDefinitionError("Either 'image' or 'pdf' must be provided")
+ return self
+
+
+class PipeOcrFactory(PipeSpecificFactoryProtocol[PipeOcrBlueprint, PipeOcr]):
+ @classmethod
+ @override
+ def make_pipe_from_blueprint(
+ cls,
+ domain_code: str,
+ pipe_code: str,
+ pipe_blueprint: PipeOcrBlueprint,
+ ) -> PipeOcr:
+ ocr_platform = pipe_blueprint.ocr_platform or OcrPlatform.MISTRAL
+ match ocr_platform:
+ case OcrPlatform.MISTRAL:
+ ocr_engine = OcrEngineFactory.make_ocr_engine(ocr_handle=OcrHandle.MISTRAL_OCR)
+
+ return PipeOcr(
+ domain=domain_code,
+ code=pipe_code,
+ definition=pipe_blueprint.definition,
+ ocr_engine=ocr_engine,
+ output_concept_code=pipe_blueprint.output,
+ image_stuff_name=pipe_blueprint.image,
+ pdf_stuff_name=pipe_blueprint.pdf,
+ should_include_images=pipe_blueprint.page_images,
+ should_caption_images=pipe_blueprint.page_image_captions,
+ should_include_page_views=pipe_blueprint.page_views,
+ page_views_dpi=pipe_blueprint.page_views_dpi,
+ )
+
+ @classmethod
+ @override
+ def make_pipe_from_details_dict(
+ cls,
+ domain_code: str,
+ pipe_code: str,
+ details_dict: Dict[str, Any],
+ ) -> PipeOcr:
+ pipe_blueprint = PipeOcrBlueprint.model_validate(details_dict)
+ return cls.make_pipe_from_blueprint(
+ domain_code=domain_code,
+ pipe_code=pipe_code,
+ pipe_blueprint=pipe_blueprint,
+ )
diff --git a/pipelex/pipe_operators/pipe_operator.py b/pipelex/pipe_operators/pipe_operator.py
new file mode 100644
index 000000000..7b7b0d63e
--- /dev/null
+++ b/pipelex/pipe_operators/pipe_operator.py
@@ -0,0 +1,57 @@
+from abc import abstractmethod
+from typing import Optional
+
+from typing_extensions import override
+
+from pipelex.core.pipe_abstract import PipeAbstract
+from pipelex.core.pipe_output import PipeOutput
+from pipelex.core.pipe_run_params import PipeRunParams
+from pipelex.core.working_memory import WorkingMemory
+from pipelex.hub import get_activity_manager
+from pipelex.mission.activity.activity_models import ActivityReport
+from pipelex.mission.job_metadata import JobMetadata
+
+
+class PipeOperator(PipeAbstract):
+ @override
+ async def run_pipe(
+ self,
+ job_metadata: JobMetadata,
+ working_memory: WorkingMemory,
+ pipe_run_params: PipeRunParams,
+ output_name: Optional[str] = None,
+ ) -> PipeOutput:
+ pipe_run_params.push_pipe_to_stack(pipe_code=self.code)
+ self.monitor_pipe_stack(pipe_run_params=pipe_run_params)
+
+ updated_metadata = JobMetadata(
+ pipe_job_ids=[self.code],
+ )
+ job_metadata.update(updated_metadata=updated_metadata)
+
+ pipe_output = await self._run_operator_pipe(
+ job_metadata=job_metadata,
+ working_memory=working_memory,
+ pipe_run_params=pipe_run_params,
+ output_name=output_name,
+ )
+ get_activity_manager().dispatch_activity(
+ activity_report=ActivityReport(
+ job_metadata=job_metadata,
+ content=pipe_output.main_stuff,
+ )
+ )
+
+ pipe_run_params.pop_pipe_from_stack(pipe_code=self.code)
+
+ return pipe_output
+
+ @abstractmethod
+ async def _run_operator_pipe(
+ self,
+ job_metadata: JobMetadata,
+ working_memory: WorkingMemory,
+ pipe_run_params: PipeRunParams,
+ output_name: Optional[str] = None,
+ ) -> PipeOutput:
+ pass
diff --git a/pipelex/pipe_operators/piped_llm_prompt_factory.py b/pipelex/pipe_operators/piped_llm_prompt_factory.py
new file mode 100644
index 000000000..4b43bcfb4
--- /dev/null
+++ b/pipelex/pipe_operators/piped_llm_prompt_factory.py
@@ -0,0 +1,46 @@
+from typing import Any, cast
+
+from typing_extensions import override
+
+from pipelex.cogt.llm.llm_prompt import LLMPrompt
+from pipelex.cogt.llm.llm_prompt_factory_abstract import LLMPromptFactoryAbstract, make_empty_prompt
+from pipelex.cogt.llm.llm_prompt_template_inputs import LLMPromptTemplateInputs
+from pipelex.core.pipe_output import PipeOutput
+from pipelex.core.pipe_run_params_factory import PipeRunParamsFactory
+from pipelex.core.working_memory_factory import WorkingMemoryFactory
+from pipelex.mission.job_metadata import JobMetadata
+from pipelex.pipe_operators.pipe_llm_prompt import PipeLLMPrompt, PipeLLMPromptOutput
+
+
+class PipedLLMPromptFactory(LLMPromptFactoryAbstract):
+ pipe_llm_prompt: PipeLLMPrompt
+ proto_prompt: LLMPrompt = make_empty_prompt()
+ base_template_inputs: LLMPromptTemplateInputs = LLMPromptTemplateInputs()
+
+ @property
+ @override
+ def desc(self) -> str:
+ return f"{PipedLLMPromptFactory.__name__} based on proto prompt: {self.proto_prompt} and base inputs: {self.base_template_inputs}"
+
+ @override
+ async def make_llm_prompt_from_args(
+ self,
+ **prompt_arguments: Any,
+ ) -> LLMPrompt:
+ arguments_dict = prompt_arguments.copy()
+ working_memory = WorkingMemoryFactory.make_from_strings_from_dict(input_dict=arguments_dict)
+ # llm_prompt: LLMPrompt = (
+ # await self.pipe_llm_prompt.run_pipe(
+ # pipe_run_params=PipeRunParamsFactory.make_run_params(),
+ # job_metadata=JobMetadata(session_id=get_config().session_id),
+ # working_memory=working_memory,
+ # )
+ # ).llm_prompt
+ # TODO: restore the possibility above, without need to explicitly cast the output
+ pipe_output: PipeOutput = await self.pipe_llm_prompt.run_pipe(
+ pipe_run_params=PipeRunParamsFactory.make_run_params(),
+ job_metadata=JobMetadata(),
+ working_memory=working_memory,
+ )
+ llm_prompt = cast(PipeLLMPromptOutput, pipe_output).llm_prompt
+ return llm_prompt
diff --git a/pipelex/pipe_works/__init__.py b/pipelex/pipe_works/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/pipelex/pipe_works/__init__.py
@@ -0,0 +1 @@
+
diff --git a/pipelex/pipe_works/pipe_job.py b/pipelex/pipe_works/pipe_job.py
new file mode 100644
index 000000000..90bdf326b
--- /dev/null
+++ b/pipelex/pipe_works/pipe_job.py
@@ -0,0 +1,16 @@
+from typing import Optional
+
+from pydantic import BaseModel, Field
+
+from pipelex.core.pipe_abstract import PipeAbstract
+from pipelex.core.pipe_run_params import PipeRunParams
+from pipelex.core.working_memory import WorkingMemory
+from pipelex.mission.job_metadata import JobMetadata
+
+
+class PipeJob(BaseModel):
+ pipe: PipeAbstract
+ working_memory: WorkingMemory = Field(default_factory=WorkingMemory)
+ pipe_run_params: PipeRunParams
+ job_metadata: JobMetadata
+ output_name: Optional[str] = None
diff --git a/pipelex/pipe_works/pipe_job_factory.py b/pipelex/pipe_works/pipe_job_factory.py
new file mode 100644
index 000000000..30e75bf5e
--- /dev/null
+++ b/pipelex/pipe_works/pipe_job_factory.py
@@ -0,0 +1,31 @@
+from typing import Optional
+
+from pipelex.core.pipe_abstract import PipeAbstract
+from pipelex.core.pipe_run_params import PipeRunParams
+from pipelex.core.pipe_run_params_factory import PipeRunParamsFactory
+from pipelex.core.working_memory import WorkingMemory
+from pipelex.mission.job_metadata import JobMetadata
+from pipelex.pipe_works.pipe_job import PipeJob
+
+
+class PipeJobFactory:
+ @classmethod
+ def make_pipe_job(
+ cls,
+ pipe: PipeAbstract,
+ pipe_run_params: Optional[PipeRunParams] = None,
+ working_memory: Optional[WorkingMemory] = None,
+ job_metadata: Optional[JobMetadata] = None,
+ output_name: Optional[str] = None,
+ ) -> PipeJob:
+ job_metadata = job_metadata or JobMetadata()
+ working_memory = working_memory or WorkingMemory()
+ if not pipe_run_params:
+ pipe_run_params = PipeRunParamsFactory.make_run_params()
+ return PipeJob(
+ job_metadata=job_metadata,
+ working_memory=working_memory,
+ pipe_run_params=pipe_run_params,
+ pipe=pipe,
+ output_name=output_name,
+ )
diff --git a/pipelex/pipe_works/pipe_router.py b/pipelex/pipe_works/pipe_router.py
new file mode 100644
index 000000000..233a50326
--- /dev/null
+++ b/pipelex/pipe_works/pipe_router.py
@@ -0,0 +1,59 @@
+from typing import Optional, cast
+
+from typing_extensions import override
+
+from pipelex import log
+from pipelex.core.pipe_output import PipeOutputType
+from pipelex.core.pipe_run_params import PipeRunParams
+from pipelex.core.working_memory import WorkingMemory
+from pipelex.hub import get_required_pipe
+from pipelex.mission.job_metadata import JobMetadata
+from pipelex.pipe_works.pipe_job_factory import PipeJobFactory
+from pipelex.pipe_works.pipe_router_protocol import PipeJob, PipeRouterProtocol
+
+
+class PipeRouter(PipeRouterProtocol):
+ @override
+ async def run_pipe_job(
+ self,
+ pipe_job: PipeJob,
+ wfid: Optional[str] = None,
+ ) -> PipeOutputType: # pyright: ignore[reportInvalidTypeVarUse]
+ log.debug(f"PipeRouter run_pipe_job: pipe_code={pipe_job.pipe.code}")
+ working_memory = pipe_job.working_memory
+
+ pipe = pipe_job.pipe
+ log.verbose(f"Routing {pipe.__class__.__name__} pipe '{pipe_job.pipe.code}': {pipe.definition}")
+
+ pipe_output = await pipe.run_pipe(
+ job_metadata=pipe_job.job_metadata,
+ working_memory=working_memory,
+ output_name=pipe_job.output_name,
+ pipe_run_params=pipe_job.pipe_run_params,
+ )
+ return cast(PipeOutputType, pipe_output)
+
+ @override
+ async def run_pipe_code(
+ self,
+ pipe_code: str,
+ pipe_run_params: Optional[PipeRunParams] = None,
+ job_metadata: Optional[JobMetadata] = None,
+ working_memory: Optional[WorkingMemory] = None,
+ output_name: Optional[str] = None,
+ wfid: Optional[str] = None,
+ ) -> PipeOutputType: # pyright: ignore[reportInvalidTypeVarUse]
+ log.debug(f"PipeRouter run_pipe_code: pipe_code={pipe_code}")
+ pipe = get_required_pipe(pipe_code)
+ pipe_job = PipeJobFactory.make_pipe_job(
+ pipe=pipe,
+ pipe_run_params=pipe_run_params,
+ working_memory=working_memory,
+ job_metadata=job_metadata,
+ output_name=output_name,
+ )
+ pipe_output: PipeOutputType = await self.run_pipe_job(
+ pipe_job=pipe_job,
+ wfid=wfid,
+ )
+ return pipe_output
diff --git a/pipelex/pipe_works/pipe_router_protocol.py b/pipelex/pipe_works/pipe_router_protocol.py
new file mode 100644
index 000000000..df9b01a4e
--- /dev/null
+++ b/pipelex/pipe_works/pipe_router_protocol.py
@@ -0,0 +1,25 @@
+from typing import Optional, Protocol
+
+from pipelex.core.pipe_output import PipeOutputType
+from pipelex.core.pipe_run_params import PipeRunParams
+from pipelex.core.working_memory import WorkingMemory
+from pipelex.mission.job_metadata import JobMetadata
+from pipelex.pipe_works.pipe_job import PipeJob
+
+
+class PipeRouterProtocol(Protocol):
+ async def run_pipe_job(
+ self,
+ pipe_job: PipeJob,
+ wfid: Optional[str] = None,
+ ) -> PipeOutputType: ... # pyright: ignore[reportInvalidTypeVarUse]
+
+ async def run_pipe_code(
+ self,
+ pipe_code: str,
+ pipe_run_params: Optional[PipeRunParams] = None,
+ job_metadata: Optional[JobMetadata] = None,
+ working_memory: Optional[WorkingMemory] = None,
+ output_name: Optional[str] = None,
+ wfid: Optional[str] = None,
+ ) -> PipeOutputType: ... # pyright: ignore[reportInvalidTypeVarUse]
diff --git a/pipelex/pipelex.py b/pipelex/pipelex.py
new file mode 100644
index 000000000..90fbb7ed7
--- /dev/null
+++ b/pipelex/pipelex.py
@@ -0,0 +1,237 @@
+from importlib.metadata import metadata
+from typing import Any, ClassVar, List, Optional, Self, Type
+
+from dotenv import load_dotenv
+from kajson.class_registry import class_registry
+from pydantic import ValidationError
+from rich import print
+
+from pipelex import log
+from pipelex.cogt.content_generation.content_generator import ContentGenerator
+from pipelex.cogt.content_generation.content_generator_protocol import ContentGeneratorProtocol
+from pipelex.cogt.inference.inference_manager import InferenceManager
+from pipelex.cogt.inference.inference_report_manager import InferenceReportManager
+from pipelex.cogt.llm.llm_models.llm_model import LATEST_VERSION_NAME
+from pipelex.cogt.llm.llm_models.llm_model_library import LLMModelLibrary
+from pipelex.cogt.plugin_manager import PluginManager
+from pipelex.config import PipelexConfig, get_config
+from pipelex.core.registry_models import PipelexRegistryModels
+from pipelex.exceptions import PipelexConfigError, PipelexSetupError
+from pipelex.hub import PipelexHub, set_pipelex_hub
+from pipelex.libraries.library_manager import LibraryManager
+from pipelex.mission.activity.activity_manager import ActivityManager
+from pipelex.mission.activity.activity_manager_protocol import ActivityManagerNoOp, ActivityManagerProtocol
+from pipelex.mission.mission_manager import MissionManager
+from pipelex.mission.track.mission_tracker import MissionTracker
+from pipelex.mission.track.mission_tracker_protocol import MissionTrackerNoOp, MissionTrackerProtocol
+from pipelex.pipe_works.pipe_router import PipeRouter
+from pipelex.pipe_works.pipe_router_protocol import PipeRouterProtocol
+from pipelex.test_extras.registry_test_models import PipelexTestModels
+from pipelex.tools.config.models import ConfigRoot
+from pipelex.tools.func_registry import func_registry
+from pipelex.tools.runtime_manager import runtime_manager
+from pipelex.tools.secrets.env_secrets_provider import EnvSecretsProvider
+from pipelex.tools.secrets.secrets_provider_abstract import SecretsProviderAbstract
+from pipelex.tools.templating.template_library import TemplateLibrary
+from pipelex.tools.typing.pydantic_utils import format_pydantic_validation_error
+
+PACKAGE_NAME = __name__.split(".", maxsplit=1)[0]
+PACKAGE_VERSION = metadata(PACKAGE_NAME)["Version"]
+
+
+class Pipelex:
+ _pipelex_instance: ClassVar[Optional[Self]] = None
+
+ def __new__(
+ cls,
+ pipelex_cls: Optional[Type[Self]] = None,
+ pipelex_hub: Optional[PipelexHub] = None,
+ config_cls: Optional[Type[ConfigRoot]] = None,
+ ready_made_config: Optional[ConfigRoot] = None,
+ template_provider: Optional[TemplateLibrary] = None,
+ llm_model_provider: Optional[LLMModelLibrary] = None,
+ plugin_manager: Optional[PluginManager] = None,
+ inference_manager: Optional[InferenceManager] = None,
+ mission_manager: Optional[MissionManager] = None,
+ mission_tracker: Optional[MissionTracker] = None,
+ activity_manager: Optional[ActivityManagerProtocol] = None,
+ ) -> Self:
+ if cls._pipelex_instance is not None:
+ raise RuntimeError(
+ "Pipelex is a singleton, it is instantiated only once. Its instance is private. All you need is accesible through the hub."
+ )
+ if pipelex_cls is None:
+ pipelex_cls = cls
+
+ if not issubclass(pipelex_cls, cls):
+ raise TypeError(f"{pipelex_cls!r} is not a subclass of {cls.__name__}")
+
+ return super().__new__(pipelex_cls)
+
+ def __init__(
+ self,
+ pipelex_cls: Optional[Type[Self]] = None,
+ pipelex_hub: Optional[PipelexHub] = None,
+ config_cls: Optional[Type[ConfigRoot]] = None,
+ ready_made_config: Optional[ConfigRoot] = None,
+ template_provider: Optional[TemplateLibrary] = None,
+ llm_model_provider: Optional[LLMModelLibrary] = None,
+ plugin_manager: Optional[PluginManager] = None,
+ inference_manager: Optional[InferenceManager] = None,
+ mission_manager: Optional[MissionManager] = None,
+ mission_tracker: Optional[MissionTracker] = None,
+ activity_manager: Optional[ActivityManagerProtocol] = None,
+ ) -> None:
+ print(f"{PACKAGE_NAME} version {PACKAGE_VERSION} init started...", flush=True)
+ self.pipelex_hub = pipelex_hub or PipelexHub()
+ set_pipelex_hub(self.pipelex_hub)
+
+ # tools
+ if ready_made_config is not None:
+ if config_cls is not None:
+ raise PipelexConfigError("config_cls must be None when ready_made_config is provided")
+ self.pipelex_hub.set_config(ready_made_config)
+ else:
+ if config_cls is None:
+ config_cls = PipelexConfig
+ try:
+ self.pipelex_hub.setup_config(config_cls=config_cls)
+ except ValidationError as exc:
+ error_msg = format_pydantic_validation_error(exc)
+ raise PipelexConfigError(f"Error because of: {error_msg}") from exc
+ for extra_env_file in get_config().pipelex.extra_env_files:
+ load_dotenv(dotenv_path=extra_env_file, override=True)
+ log.configure(
+ project_name=get_config().project_name or "unknown_project",
+ log_config=get_config().pipelex.log_config,
+ )
+ log.info("Logs are configured")
+
+ # tools
+ self.template_provider = template_provider or TemplateLibrary()
+ self.pipelex_hub.set_template_provider(self.template_provider)
+
+ # cogt
+ self.llm_model_provider = llm_model_provider or LLMModelLibrary()
+ self.pipelex_hub.set_llm_models_provider(self.llm_model_provider)
+ self.plugin_manager = plugin_manager or PluginManager()
+ self.pipelex_hub.set_plugin_manager(self.plugin_manager)
+ self.inference_manager = inference_manager or InferenceManager()
+ self.pipelex_hub.set_inference_manager(self.inference_manager)
+
+ self.report_manager = InferenceReportManager(report_config=get_config().cogt.cogt_report_config)
+ self.pipelex_hub.set_report_delegate(self.report_manager)
+
+ # pipelex libraries
+ self.library_manager = LibraryManager()
+ self.pipelex_hub.set_domain_provider(domain_provider=self.library_manager.domain_library)
+ self.pipelex_hub.set_concept_provider(concept_provider=self.library_manager.concept_library)
+ self.pipelex_hub.set_pipe_provider(pipe_provider=self.library_manager.pipe_library)
+
+ # pipelex mission
+ self.mission_tracker: MissionTrackerProtocol
+ if mission_tracker:
+ self.mission_tracker = mission_tracker
+ elif get_config().pipelex.feature_config.is_mission_tracking_enabled:
+ self.mission_tracker = MissionTracker(tracker_config=get_config().pipelex.tracker_config)
+ else:
+ self.mission_tracker = MissionTrackerNoOp()
+ self.pipelex_hub.set_mission_tracker(mission_tracker=self.mission_tracker)
+ self.mission_manager = mission_manager or MissionManager()
+ self.pipelex_hub.set_mission_manager(mission_manager=self.mission_manager)
+
+ self.activity_manager: ActivityManagerProtocol
+ if activity_manager:
+ self.activity_manager = activity_manager
+ elif get_config().pipelex.feature_config.is_activity_tracking_enabled:
+ self.activity_manager = ActivityManager()
+ else:
+ self.activity_manager = ActivityManagerNoOp()
+ self.pipelex_hub.set_activity_manager(activity_manager=self.activity_manager)
+
+ Pipelex._pipelex_instance = self
+ log.info(f"{PACKAGE_NAME} version {PACKAGE_VERSION} init done")
+
+ def setup(
+ self,
+ secrets_provider: Optional[SecretsProviderAbstract] = None,
+ content_generator: Optional[ContentGeneratorProtocol] = None,
+ pipe_router: Optional[PipeRouterProtocol] = None,
+ structure_classes: Optional[List[Type[Any]]] = None,
+ ):
+ # tools
+ self.pipelex_hub.set_secrets_provider(secrets_provider or EnvSecretsProvider())
+
+ # cogt
+ self.pipelex_hub.set_content_generator(content_generator or ContentGenerator())
+ self.report_manager.setup()
+ class_registry.register_classes(PipelexRegistryModels.get_all_models())
+ if runtime_manager.is_unit_testing:
+ log.debug("Registering test models for unit testing")
+ class_registry.register_classes(PipelexTestModels.get_all_models())
+ self.activity_manager.setup()
+
+ if structure_classes:
+ class_registry.register_classes(structure_classes)
+
+ self.pipelex_hub.set_pipe_router(pipe_router or PipeRouter())
+
+ # mission
+ self.mission_tracker.setup()
+ self.mission_manager.setup()
+
+ log.debug(f"{PACKAGE_NAME} version {PACKAGE_VERSION} setup done for {get_config().project_name}")
+
+ def finish_setup(self):
+ try:
+ self.template_provider.setup()
+ self.llm_model_provider.setup()
+ llm_deck = self.library_manager.load_deck()
+ for llm_model in self.llm_model_provider.get_all_llm_models():
+ if llm_model.version == LATEST_VERSION_NAME:
+ llm_deck.add_llm_handle_to_llm_engine_blueprint(
+ llm_handle=llm_model.llm_name,
+ llm_engine_default=llm_model.llm_name,
+ )
+ llm_deck.validate_llm_presets()
+ self.library_manager.load_libraries()
+ if self.library_manager.llm_deck is None:
+ raise PipelexSetupError("LLM deck is not loaded")
+ self.pipelex_hub.set_llm_deck_provider(llm_deck_provider=self.library_manager.llm_deck)
+ self.library_manager.validate_libraries()
+ except ValidationError as exc:
+ error_msg = format_pydantic_validation_error(exc)
+ raise PipelexSetupError(f"Error because of: {error_msg}") from exc
+ log.debug(f"{PACKAGE_NAME} version {PACKAGE_VERSION} finish setup done for {get_config().project_name}")
+
+ def teardown(self):
+ # pipelex
+ self.mission_manager.teardown()
+ self.mission_tracker.teardown()
+ self.library_manager.teardown()
+ self.template_provider.teardown()
+ self.activity_manager.teardown()
+
+ # cogt
+ self.inference_manager.teardown()
+ self.report_manager.teardown()
+ self.llm_model_provider.teardown()
+
+ # tools
+ class_registry.reset()
+ func_registry.teardown()
+
+ Pipelex._pipelex_instance = None
+ project_name = get_config().project_name
+ log.debug(f"{PACKAGE_NAME} version {PACKAGE_VERSION} teardown done for {get_config().project_name} (except config & logs)")
+ self.pipelex_hub.reset_config()
+ print(f"{PACKAGE_NAME} version {PACKAGE_VERSION} config reset done for {project_name}")
+
+ # TODO: add kwargs to make() so that subclasses can employ specific parameters
+ @classmethod
+ def make(cls, structure_classes: Optional[List[Type[Any]]] = None) -> Self:
+ pipelex_instance = cls()
+ pipelex_instance.setup(structure_classes=structure_classes)
+ pipelex_instance.finish_setup()
+ log.info(f"Boot sequence completed for {get_config().project_name} and session id {get_config().session_id}")
+ return pipelex_instance
diff --git a/pipelex/pipelex.toml b/pipelex/pipelex.toml
new file mode 100644
index 000000000..b6a7c3c40
--- /dev/null
+++ b/pipelex/pipelex.toml
@@ -0,0 +1,233 @@
+
+
+[pipelex]
+extra_env_files = []
+
+[pipelex.feature_config]
+# WIP/Experimental feature flags
+is_mission_tracking_enabled = false
+is_activity_tracking_enabled = false
+
+####################################################################################################
+# Log config
+####################################################################################################
+
+[pipelex.log_config]
+default_log_level = "INFO"
+
+is_console_logging_enabled = true
+
+json_logs_indent = 4
+presentation_line_width = 120
+silenced_problem_ids = ["azure_openai_no_stream_options"]
+caller_info_template = "file_line"
+is_caller_info_enabled = false
+
+poor_loggers = [
+ "kajson.decoder.sandbox",
+ "kajson.encoder.sandbox",
+ "class_registry.sandbox",
+]
+generic_poor_logger = "#sandbox"
+
+[pipelex.log_config.package_log_levels]
+# for logger names, the dots "." have been replaced by "-" to avoid toml parsing issues
+# TODO: use quotes to re-enable names with dots
+anthropic = "INFO"
+asyncio = "INFO"
+botocore = "INFO"
+botocore-credentials = "WARNING"
+google = "INFO"
+httpx = "WARNING"
+httpcore = "INFO"
+openai = "INFO"
+instructor = "INFO"
+urllib3-connectionpool = "INFO"
+urllib3-util-retry = "INFO"
+
+kajson = "INFO"
+kajson-decoder-sandbox = "INFO"
+kajson-encoder-sandbox = "INFO"
+
+pipelex = "INFO"
+
+
+[pipelex.log_config.rich_log_config]
+is_show_time = false
+is_show_level = true
+is_link_path_enabled = true
+is_markup_enabled = false
+highlighter_name = "json"
+is_rich_tracebacks = true
+is_tracebacks_word_wrap = true
+is_tracebacks_show_locals = false
+tracebacks_suppress = []
+keywords_to_hilight = []
+
+[pipelex.aws_config]
+api_key_method = "env" # "env", "secret_provider"
+aws_region = ""
+
+aws_access_key_id_env_var_name = "AWS_ACCESS_KEY_ID"
+aws_secret_access_key_env_var_name = "AWS_SECRET_ACCESS_KEY"
+aws_region_env_var_name = "AWS_REGION"
+aws_access_key_id_secret_name = "AWS_ACCESS_KEY_ID"
+aws_secret_access_key_secret_name = "AWS_SECRET_ACCESS_KEY"
+
+[cogt]
+
+[cogt.inference_manager_config]
+is_auto_setup_preset_llm = true
+is_auto_setup_preset_imgg = true
+is_auto_setup_preset_ocr = true
+
+[cogt.cogt_report_config]
+is_log_costs_to_console = false
+is_generate_cost_report_file_enabled = true
+cost_report_dir_path = "reports"
+cost_report_base_name = "cost_report"
+cost_report_extension = "xlsx"
+cost_report_unit_scale = 1.0
+
+[cogt.llm_config]
+default_max_images = 100
+
+[cogt.llm_config.instructor_config]
+is_openai_structured_output_enabled = false
+
+[cogt.llm_config.llm_job_config]
+max_retries = 3
+is_streaming_enabled = false
+
+####################################################################################################
+# Config to use LLM Platforms
+####################################################################################################
+
+[cogt.llm_config.preferred_platforms]
+# These overrride the defaults set for any llm handle
+# "gpt-4o-mini" = "openai"
+
+[cogt.llm_config.openai_openai_config]
+api_key_method = "env" # "env", "secret_provider"
+api_key_env_var_name = "OPENAI_API_KEY"
+api_key_secret_name = "OPENAI_API_KEY"
+
+[cogt.llm_config.azure_openai_config]
+api_endpoint = ""
+api_version = "2024-05-01-preview"
+api_key_method = "env" # "env", "secret_provider"
+api_key_env_var_name = "AZURE_OPENAI_API_KEY"
+api_key_secret_name = "AZURE_OPENAI_API_KEY"
+
+# TODO: handle multiple azure openai accounts with different resource groups and account names for various llm model
+
+[cogt.llm_config.perplexity_config]
+api_endpoint = "https://api.perplexity.ai"
+api_key_method = "env" # "env", "secret_provider"
+api_key_env_var_name = "PERPLEXITY_API_KEY"
+api_key_secret_name = "PERPLEXITY_API_KEY"
+
+[cogt.llm_config.vertexai_config]
+project_id = ""
+region = ""
+
+[cogt.llm_config.mistral_config]
+api_key_secret_name = "MISTRAL_API_KEY"
+
+[cogt.llm_config.bedrock_config]
+client_method = "aioboto3"
+aws_region = ""
+
+[cogt.llm_config.anthropic_config]
+api_key_method = "env" # "env", "secret_provider"
+api_key_env_var_name = "ANTHROPIC_API_KEY"
+api_key_secret_name = "ANTHROPIC_API_KEY"
+
+[cogt.llm_config.custom_openai_config]
+base_url = "http://localhost:11434/v1"
+
+####################################################################################################
+# Image generation config
+####################################################################################################
+
+[cogt.imgg_config]
+imgg_handles = ["fal-ai/flux-pro", "fal-ai/fast-lightning-sdxl"]
+default_imgg_handle = "fal-ai/flux-pro/v1.1-ultra" # use "fal-ai/fast-lightning-sdxl" for SDXL Lightning cheap and fast
+
+[cogt.imgg_config.imgg_job_config]
+is_sync_mode = false
+
+[cogt.imgg_config.imgg_param_defaults]
+aspect_ratio = "square" # "square", "landscape_4_3", "landscape_16_9", "landscape_21_9", "portrait_3_4", "portrait_9_16", "portrait_9_21"
+nb_steps = 1 # 28 for Flux, one of [1,2,4,8] for SDXL Lightning
+guidance_scale = 3.5
+is_safety_checker_enabled = true
+safety_tolerance = 5
+is_raw = false
+output_format = "jpg"
+seed = "auto"
+# seed = 1
+
+####################################################################################################
+# OCR config
+####################################################################################################
+
+[cogt.ocr_config]
+ocr_handles = ["mistral/mistral-ocr-latest"]
+page_output_text_file_name = "page_text.md"
+
+####################################################################################################
+# Pipelex prompting config
+####################################################################################################
+
+[pipelex.prompting_config]
+default_prompting_style = { tag_style = "ticks" }
+
+[pipelex.prompting_config.prompting_styles]
+openai = { tag_style = "ticks" }
+anthropic = { tag_style = "xml" }
+mistral = { tag_style = "square_brackets" }
+gemini = { tag_style = "xml" }
+
+[pipelex.structure_config]
+is_default_text_then_structure = false # turn this to true to get better results: generates text before structuring
+
+
+####################################################################################################
+# Pipelex libraries config
+####################################################################################################
+
+[pipelex.library_config]
+
+[pipelex.generic_template_names]
+structure_from_preliminary_text_system = "structure_from_preliminary_text_system"
+structure_from_preliminary_text_user = "structure_from_preliminary_text_user"
+
+####################################################################################################
+# History graph config
+####################################################################################################
+
+[pipelex.tracker_config]
+is_debug_mode = false
+is_include_text_preview = false
+is_include_interactivity = false
+nb_items_limit = "unlimited"
+theme = "base"
+layout = "dagre" # "elk", "dagre", "fixed"
+sub_graph_colors = ["#e6f5ff", "#fff5f7", "#f0fff0"]
+wrapping_width = "auto"
+
+# TODO: adapt the length of the edges to different cases?
+pipe_edge_style = "---->"
+branch_edge_style = "-...-"
+aggregate_edge_style = "-...-"
+condition_edge_style = "-----"
+choice_edge_style = "-----"
+
+####################################################################################################
+# Pipelex run config
+####################################################################################################
+
+[pipelex.pipe_run_config]
+# TODO: this config value is not applied yet
+pipe_stack_limit = 20
diff --git a/pipelex/py.typed b/pipelex/py.typed
new file mode 100644
index 000000000..e69de29bb
diff --git a/pipelex/run.py b/pipelex/run.py
new file mode 100644
index 000000000..1c3614e05
--- /dev/null
+++ b/pipelex/run.py
@@ -0,0 +1,77 @@
+from typing import Optional
+
+from pipelex import pretty_print
+from pipelex.core.pipe_abstract import PipeAbstract
+from pipelex.core.pipe_output import PipeOutput
+from pipelex.core.pipe_run_params import PipeOutputMultiplicity, PipeRunParams
+from pipelex.core.pipe_run_params_factory import PipeRunParamsFactory
+from pipelex.core.working_memory import WorkingMemory
+from pipelex.hub import get_pipe_router, get_required_pipe
+from pipelex.mission.job_metadata import JobMetadata
+from pipelex.pipe_works.pipe_job_factory import PipeJobFactory
+
+
+async def run_pipe_code(
+ pipe_code: str,
+ working_memory: Optional[WorkingMemory] = None,
+ output_name: Optional[str] = None,
+ output_multiplicity: Optional[PipeOutputMultiplicity] = None,
+ dynamic_output_concept_code: Optional[str] = None,
+ job_id: Optional[str] = None,
+) -> PipeOutput:
+ """
+ Simple wrapper to run a pipe with a working memory using the default PipeRouter.
+
+ Args:
+ pipe_code: The code of the pipe to run
+ working_memory: The working memory containing all necessary stuffs
+ output_name: The name of the output for the main output of the pipe
+ output_multiplicity: The multiplicity of the output
+ output_concept_code: Optional output concept code to use for dynamic output concept
+ job_id: Optional job ID (defaults to pipe_code)
+
+ Returns:
+ PipeOutput: The output of the pipe execution
+ """
+ pipe = get_required_pipe(pipe_code=pipe_code)
+
+ job_metadata = JobMetadata(
+ top_job_id=job_id or pipe_code,
+ )
+
+ pipe_run_params = PipeRunParamsFactory.make_run_params(
+ output_multiplicity=output_multiplicity,
+ dynamic_output_concept_code=dynamic_output_concept_code,
+ )
+
+ pretty_print(pipe, title=f"Running pipe '{pipe_code}'")
+ if working_memory:
+ working_memory.pretty_print_summary()
+
+ pipe_job = PipeJobFactory.make_pipe_job(
+ pipe=pipe,
+ pipe_run_params=pipe_run_params,
+ job_metadata=job_metadata,
+ working_memory=working_memory,
+ output_name=output_name,
+ )
+
+ return await get_pipe_router().run_pipe_job(pipe_job)
+
+
+async def run_pipe(
+ pipe: PipeAbstract,
+ pipe_run_params: PipeRunParams,
+ job_metadata: JobMetadata,
+ working_memory: Optional[WorkingMemory] = None,
+ output_name: Optional[str] = None,
+) -> PipeOutput:
+ pipe_job = PipeJobFactory.make_pipe_job(
+ pipe=pipe,
+ pipe_run_params=pipe_run_params,
+ job_metadata=job_metadata,
+ working_memory=working_memory,
+ output_name=output_name,
+ )
+
+ return await get_pipe_router().run_pipe_job(pipe_job)
diff --git a/pipelex/test_extras/__init__.py b/pipelex/test_extras/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/pipelex/test_extras/__init__.py
@@ -0,0 +1 @@
+
diff --git a/pipelex/test_extras/registry_test_models.py b/pipelex/test_extras/registry_test_models.py
new file mode 100644
index 000000000..24c198c70
--- /dev/null
+++ b/pipelex/test_extras/registry_test_models.py
@@ -0,0 +1,15 @@
+from typing import ClassVar, List
+
+from pipelex.core.stuff_content import StructuredContent
+from pipelex.tools.registry_models import ModelType, RegistryModels
+
+
+class FictionCharacter(StructuredContent):
+ name: str
+ age: int
+ job: str
+ backstory: str
+
+
+class PipelexTestModels(RegistryModels):
+ TEST_MODELS: ClassVar[List[ModelType]] = [FictionCharacter]
diff --git a/pipelex/test_extras/shared_pytest_plugins.py b/pipelex/test_extras/shared_pytest_plugins.py
new file mode 100644
index 000000000..94faa7f80
--- /dev/null
+++ b/pipelex/test_extras/shared_pytest_plugins.py
@@ -0,0 +1,25 @@
+import pytest
+
+from pipelex.libraries.library_config import LibraryConfig
+from pipelex.tools.runtime_manager import RunMode, runtime_manager
+
+
[email protected](scope="session", autouse=True)
+def set_run_mode():
+ runtime_manager.set_run_mode(run_mode=RunMode.UNIT_TEST)
+
+
[email protected](scope="session")
+def manage_pipelex_libraries():
+ LibraryConfig.export_libraries(overwrite=False)
+ yield
+ # TODO: make it safe to erase/replace standard libraries in client projects without touching custom stuff
+ # LibraryConfig.remove_libraries()
+
+
[email protected](scope="session")
+def manage_pipelex_libraries_with_overwrite():
+ LibraryConfig.export_libraries(overwrite=True)
+ yield
+ # TODO: make it safe to erase/replace standard libraries in client projects without touching custom stuff
+ # LibraryConfig.remove_libraries()
diff --git a/pipelex/tools/__init__.py b/pipelex/tools/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/pipelex/tools/__init__.py
@@ -0,0 +1 @@
+
diff --git a/pipelex/tools/aws/__init__.py b/pipelex/tools/aws/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/pipelex/tools/aws/__init__.py
@@ -0,0 +1 @@
+
diff --git a/pipelex/tools/aws/aws_config.py b/pipelex/tools/aws/aws_config.py
new file mode 100644
index 000000000..da99bd73c
--- /dev/null
+++ b/pipelex/tools/aws/aws_config.py
@@ -0,0 +1,61 @@
+from enum import StrEnum
+from typing import Tuple
+
+from pydantic import Field
+
+from pipelex import log
+from pipelex.hub import get_secret
+from pipelex.tools.config.models import ConfigModel
+from pipelex.tools.environment import EnvVarNotFoundError, get_optional_env, get_required_env
+from pipelex.tools.exceptions import ToolException
+from pipelex.tools.secrets.secrets_errors import SecretNotFoundError
+
+
+class AwsCredentialsError(ToolException):
+ pass
+
+
+class AwsKeyMethod(StrEnum):
+ SECRET_PROVIDER = "secret_provider"
+ ENV = "env"
+
+
+class AwsConfig(ConfigModel):
+ api_key_method: AwsKeyMethod = Field(strict=False)
+ aws_region: str
+
+ aws_access_key_id_env_var_name: str
+ aws_secret_access_key_env_var_name: str
+ aws_region_env_var_name: str
+
+ aws_access_key_id_secret_name: str
+ aws_secret_access_key_secret_name: str
+
+ def get_aws_access_keys(self) -> Tuple[str, str, str]:
+ return self.get_aws_access_keys_with_method(api_key_method=self.api_key_method)
+
+ def get_aws_access_keys_with_method(self, api_key_method: AwsKeyMethod) -> Tuple[str, str, str]:
+ aws_access_key_id: str
+ aws_secret_access_key: str
+ aws_region: str
+ match api_key_method:
+ case AwsKeyMethod.ENV:
+ log.debug("Getting AWS access keys from environment (key id and secret access key).")
+ try:
+ aws_access_key_id = get_required_env(self.aws_access_key_id_env_var_name)
+ aws_secret_access_key = get_required_env(self.aws_secret_access_key_env_var_name)
+ except EnvVarNotFoundError as exc:
+ raise AwsCredentialsError(f"Error getting AWS access keys from environment: {exc}") from exc
+ log.debug("Getting AWS region from environment (priority override) or from aws_config.")
+ aws_region = get_optional_env(self.aws_region_env_var_name) or self.aws_region
+ case AwsKeyMethod.SECRET_PROVIDER:
+ log.debug("Getting AWS secret access key from secrets provider (key id and secret access key).")
+ try:
+ aws_access_key_id = get_secret(self.aws_access_key_id_secret_name)
+ aws_secret_access_key = get_secret(self.aws_secret_access_key_secret_name)
+ except SecretNotFoundError as exc:
+ raise AwsCredentialsError("Error getting AWS access keys from secrets provider.") from exc
+ log.debug("Getting AWS region from environment (priority override) or from aws_config.")
+ aws_region = get_optional_env(self.aws_region_env_var_name) or self.aws_region
+
+ return aws_access_key_id, aws_secret_access_key, aws_region
diff --git a/pipelex/tools/config/__init__.py b/pipelex/tools/config/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/pipelex/tools/config/__init__.py
@@ -0,0 +1 @@
+
diff --git a/pipelex/tools/config/manager.py b/pipelex/tools/config/manager.py
new file mode 100644
index 000000000..3a413fb47
--- /dev/null
+++ b/pipelex/tools/config/manager.py
@@ -0,0 +1,227 @@
+import os
+from configparser import ConfigParser
+from typing import Any, Dict, Optional
+
+import toml
+
+from pipelex.tools.config.models import (
+ CONFIG_BASE_OVERRIDES_AFTER_ENV,
+ CONFIG_BASE_OVERRIDES_BEFORE_ENV,
+)
+from pipelex.tools.misc.json_utils import deep_update
+from pipelex.tools.misc.toml_utils import failable_load_toml_from_path
+from pipelex.tools.runtime_manager import runtime_manager
+
+CONFIG_NAME = "pipelex.toml"
+
+
+class ConfigManager:
+ @property
+ def is_in_pipelex_config(self) -> bool:
+ return os.path.basename(self.local_root_dir) == "pipelex"
+
+ @property
+ def pipelex_root_dir(self) -> str:
+ """Get the root directory of the installed pipelex package.
+
+ Uses __file__ to locate the package directory, which works in both
+ development and installed modes.
+ """
+ current_dir = os.path.dirname(os.path.abspath(__file__))
+ return os.path.dirname(os.path.dirname(current_dir))
+
+ @property
+ def local_root_dir(self) -> str:
+ """Get the root directory of the project using pipelex.
+ This is the directory from where the command is being run."""
+ return os.path.abspath(os.getcwd())
+
+ def get_pipelex_config(self) -> Dict[str, Any]:
+ """Get the pipelex configuration from pipelex.toml.
+
+ Returns:
+ Dict[str, Any]: The configuration dictionary from pipelex.toml
+ """
+ config_path = os.path.join(self.pipelex_root_dir, CONFIG_NAME)
+ config = failable_load_toml_from_path(config_path)
+ return config or {}
+
+ def get_local_config(self) -> Dict[str, Any]:
+ """Get the local pipelex configuration from pipelex.toml in the project root.
+
+ Returns:
+ Dict[str, Any]: The configuration dictionary from the local pipelex.toml
+ """
+ config_path = os.path.join(self.local_root_dir, CONFIG_NAME)
+ config = failable_load_toml_from_path(config_path)
+ return config or {}
+
+ def load_inheritance_config(self, the_pipelex_config: Dict[str, Any]):
+ """
+ Load the config by inheritance in a pyproject.toml file.
+ This will be removed in the future.
+ Requires to have a pyproject.toml file in the project root.
+ """
+ pyproject_path = os.path.join(self.local_root_dir, "pyproject.toml")
+ if not os.path.exists(pyproject_path):
+ print(f"pyproject.toml not found in {self.local_root_dir}")
+ return
+
+ pyproject = toml.load(pyproject_path)
+
+ pyproject = toml.load(pyproject_path)
+ if "tool" in pyproject and "pipelex" in pyproject["tool"] and "config_inheritance" in pyproject["tool"]["pipelex"]:
+ for config_name in pyproject["tool"]["pipelex"]["config_inheritance"]:
+ print(f"Loading config inheritance for {config_name}")
+ # First check if it's a local dependency in poetry
+ package_path: Optional[str] = None
+ if "tool" in pyproject and "poetry" in pyproject["tool"] and "dependencies" in pyproject["tool"]["poetry"]:
+ dep_config: Dict[str, Any] = pyproject["tool"]["poetry"]["dependencies"].get(config_name, {})
+ if "path" in dep_config:
+ # It's a local path
+ local_path: str = str(dep_config["path"])
+ package_path = os.path.abspath(os.path.join(self.local_root_dir, local_path))
+
+ if not package_path:
+ # Try to find in .venv
+ venv_path = os.path.join(self.local_root_dir, ".venv")
+ if os.path.exists(venv_path):
+ site_packages = os.path.join(venv_path, "lib", "python3.11", "site-packages", config_name)
+ if os.path.exists(site_packages):
+ package_path = site_packages
+
+ if package_path:
+ config_path = os.path.join(package_path, "pipelex.toml")
+ print(f"Loading config inheritance for {config_name} from {config_path}")
+ if os.path.exists(config_path):
+ print(f"Found config inheritance for {config_name} from {config_path}")
+ config = failable_load_toml_from_path(config_path)
+ if config:
+ deep_update(the_pipelex_config, config)
+
+ def load_config(self) -> Dict[str, Any]:
+ """Load and merge configurations from pipelex and local config files.
+
+ The configuration is loaded and merged in the following order:
+ 1. Base pipelex config (pipelex.toml)
+ 2. Local project config (pipelex.toml) if not in pipelex package
+ 3. Override configs in sequence:
+ - pipelex_local.toml (before env)
+ - pipelex_{environment}.toml
+ - pipelex_{run_mode}.toml
+ - pipelex_user.toml (after env)
+
+ Returns:
+ Dict[str, Any]: The merged configuration dictionary
+ """
+ #################### 1. Load pipelex config ####################
+ pipelex_config = self.get_pipelex_config()
+
+ #################### 2. Load inheritance config for internal use ####################
+ # TODO: Undocumented feature, soon to be removed.
+ self.load_inheritance_config(pipelex_config)
+
+ #################### 3. Load local (current project) config ####################
+ if not self.is_in_pipelex_config:
+ local_config = self.get_local_config()
+ if local_config:
+ deep_update(pipelex_config, local_config)
+
+ #################### 4. Load overrides for the current project ####################
+ list_of_overrides = (
+ CONFIG_BASE_OVERRIDES_BEFORE_ENV + [runtime_manager.environment] + [runtime_manager.run_mode] + CONFIG_BASE_OVERRIDES_AFTER_ENV
+ )
+ for override in list_of_overrides:
+ if override:
+ if override == runtime_manager.run_mode.UNIT_TEST:
+ override_path = os.path.join(self.local_root_dir, "tests", f"pipelex_{override}.toml")
+ else:
+ override_path = os.path.join(self.local_root_dir, "pipelex" if self.is_in_pipelex_config else "", f"pipelex_{override}.toml")
+ if override_dict := failable_load_toml_from_path(override_path):
+ deep_update(pipelex_config, override_dict)
+
+ return pipelex_config
+
+ def get_project_name(self) -> Optional[str]:
+ """Get the project name from configuration files.
+
+ Checks the following files in order:
+ 1. pipelex's pyproject.toml
+ 2. Local pyproject.toml (poetry or other tools)
+ 3. setup.cfg
+ 4. setup.py
+
+ Returns:
+ Optional[str]: The project name or None if not found
+ """
+ # First check pipelex's pyproject.toml
+ pipelex_pyproject_path = os.path.join(os.path.dirname(self.local_root_dir), "pyproject.toml")
+ try:
+ pyproject = toml.load(pipelex_pyproject_path)
+ if project_name := pyproject.get("tool", {}).get("poetry", {}).get("name"):
+ if isinstance(project_name, str):
+ return project_name
+ except FileNotFoundError:
+ pass
+ except toml.TomlDecodeError as exc:
+ print(f"Failed to parse pipelex pyproject.toml at {pipelex_pyproject_path}: {exc}")
+ except (KeyError, TypeError, AttributeError) as exc:
+ print(f"Invalid structure in pipelex pyproject.toml at {pipelex_pyproject_path}: {exc}")
+
+ # Check local pyproject.toml
+ pyproject_path = os.path.join(self.local_root_dir, "pyproject.toml")
+ try:
+ pyproject = toml.load(pyproject_path)
+ # Check poetry config
+ if poetry_name := pyproject.get("tool", {}).get("poetry", {}).get("name"):
+ if isinstance(poetry_name, str):
+ return poetry_name
+ # Check project config (PEP 621)
+ if project_name := pyproject.get("project", {}).get("name"):
+ if isinstance(project_name, str):
+ return project_name
+ except FileNotFoundError as exc:
+ print(f"Local pyproject.toml not found at {pyproject_path}: {exc}")
+ except toml.TomlDecodeError as exc:
+ print(f"Failed to parse local pyproject.toml at {pyproject_path}: {exc}")
+ except (KeyError, TypeError, AttributeError) as exc:
+ print(f"Invalid structure in local pyproject.toml at {pyproject_path}: {exc}")
+
+ # Check setup.cfg
+ setup_cfg_path = os.path.join(self.local_root_dir, "setup.cfg")
+ try:
+ config = ConfigParser()
+ config.read(setup_cfg_path)
+ if config.has_section("metadata"):
+ if cfg_name := config.get("metadata", "name", fallback=None):
+ return cfg_name
+ except FileNotFoundError as exc:
+ print(f"setup.cfg not found at {setup_cfg_path}: {exc}")
+ except (ValueError, OSError) as exc:
+ print(f"Failed to parse setup.cfg at {setup_cfg_path}: {exc}")
+
+ # Check setup.py as last resort
+ setup_py_path = os.path.join(self.local_root_dir, "setup.py")
+ try:
+ with open(setup_py_path) as f:
+ content = f.read()
+ # Simple string search for name parameter
+ for line in content.splitlines():
+ if "name=" in line or "name =" in line:
+ # Extract value between quotes
+ for quote in ['"', "'"]:
+ start = line.find(quote)
+ if start != -1:
+ end = line.find(quote, start + 1)
+ if end != -1:
+ return line[start + 1 : end]
+ except FileNotFoundError as exc:
+ print(f"setup.py not found at {setup_py_path}: {exc}")
+ except (IOError, UnicodeDecodeError) as exc:
+ print(f"Failed to read setup.py at {setup_py_path}: {exc}")
+
+ print("Could not find project name in any of the configuration files")
+ return None
+
+
+config_manager = ConfigManager()
diff --git a/pipelex/tools/config/models.py b/pipelex/tools/config/models.py
new file mode 100644
index 000000000..be6770cae
--- /dev/null
+++ b/pipelex/tools/config/models.py
@@ -0,0 +1,79 @@
+from enum import StrEnum
+from typing import Any, Dict, Optional, Type, TypeVar, Union
+
+from pydantic import BaseModel, ConfigDict, ValidationError
+
+from pipelex.tools.exceptions import ConfigModelError, ConfigValidationError
+from pipelex.tools.typing.pydantic_utils import format_pydantic_validation_error
+
+CONFIG_BASE_OVERRIDES_BEFORE_ENV = ["local"]
+CONFIG_BASE_OVERRIDES_AFTER_ENV = ["super"]
+
+
+class SecretMethod(StrEnum):
+ NONE = "none"
+ ENV_VAR = "env_var"
+ SECRET_PROVIDER = "secret_provider"
+
+
+StrEnumType = TypeVar("StrEnumType", bound=StrEnum)
+
+
+class ConfigModel(BaseModel):
+ model_config = ConfigDict(extra="forbid", strict=True)
+
+ @staticmethod
+ def transform_dict_str_to_enum(
+ input_dict: Dict[str, str],
+ key_enum_cls: Optional[Type[StrEnumType]] = None,
+ value_enum_cls: Optional[Type[StrEnumType]] = None,
+ ) -> Union[Dict[str, StrEnumType], Dict[StrEnumType, str], Dict[StrEnumType, StrEnumType]]:
+ """
+ Transforms a dictionary with str values into a dictionary with enum values.
+
+ Args:
+ input_dict: Dictionary with string values to be transformed.
+ key_enum_cls: The StrEnum class to convert the keys to (if needed)
+ value_enum_cls: The StrEnum class to convert the values to (if needed).
+
+ Returns:
+ A dictionary where the values are converted to the given StrEnum type.
+ """
+ # return {key: value_enum_cls(value) for key, value in input_dict.items()}
+ if key_enum_cls and value_enum_cls:
+ return {key_enum_cls(key): value_enum_cls(value) for key, value in input_dict.items()}
+ elif key_enum_cls:
+ return {key_enum_cls(key): value for key, value in input_dict.items()}
+ elif value_enum_cls:
+ return {key: value_enum_cls(value) for key, value in input_dict.items()}
+ else:
+ raise ConfigModelError("Either key_enum_cls or value_enum_cls must be provided.")
+
+
+class ConfigRoot(ConfigModel):
+ """
+ Main configuration class for the project.
+
+ Attributes:
+ project_name (str): Name of the current project.
+ """
+
+ project_name: Optional[str] = None
+
+ def __init__(self, **kwargs: Any):
+ """
+ Initialize the Config instance.
+
+ Args:
+ **kwargs: Keyword arguments for configuration.
+
+ Raises:
+ ConfigValidationError: If the provided data is invalid.
+ """
+
+ try:
+ super().__init__(**kwargs)
+ except ValidationError as exc:
+ validation_error_msg = format_pydantic_validation_error(exc)
+ error_msg = f"Could not create config of type {type(self)} with provided data: {validation_error_msg}"
+ raise ConfigValidationError(message=error_msg) from exc
diff --git a/pipelex/tools/environment.py b/pipelex/tools/environment.py
new file mode 100644
index 000000000..4fb965291
--- /dev/null
+++ b/pipelex/tools/environment.py
@@ -0,0 +1,51 @@
+import os
+from typing import Optional
+
+from dotenv import load_dotenv
+
+from pipelex.tools.exceptions import ToolException
+
+load_dotenv(dotenv_path=".env", override=True)
+
+
+class EnvVarNotFoundError(ToolException):
+ pass
+
+
+def get_required_env(key: str) -> str:
+ value = os.getenv(key)
+ if not value:
+ raise EnvVarNotFoundError(f"Missing '{key} 'in environment.")
+ return value
+
+
+def get_optional_env(key: str) -> Optional[str]:
+ value = os.getenv(key)
+ return value
+
+
+def set_env(key: str, value: str) -> None:
+ os.environ[key] = value
+ return None
+
+
+def get_rooted_path(root: str, path: Optional[str] = None) -> str:
+ if path is None:
+ path = ""
+ if path.startswith(root):
+ return path
+ elif os.path.isabs(path):
+ return path
+ else:
+ joined = os.path.join(root, path)
+ # remove edning "/" if any
+ if joined.endswith("/"):
+ joined = joined[:-1]
+ return joined
+
+
+def get_env_rooted_path(root_env: str, path: Optional[str] = None) -> str:
+ root = os.getenv(root_env)
+ if root is None:
+ root = ""
+ return get_rooted_path(root, path)
diff --git a/pipelex/tools/exceptions.py b/pipelex/tools/exceptions.py
new file mode 100644
index 000000000..85e4e958d
--- /dev/null
+++ b/pipelex/tools/exceptions.py
@@ -0,0 +1,42 @@
+import logging
+
+from kajson.sandbox_manager import sandbox_manager
+
+
+class RootException(Exception):
+ def __init__(self, message: str):
+ super().__init__(message)
+ self.message = message
+
+
+class ToolException(RootException):
+ pass
+
+
+class TracebackMessageError(RootException):
+ def __init__(self, message: str):
+ super().__init__(message)
+ logger_name = __name__
+ if sandbox_manager.is_in_sandbox():
+ generic_poor_logger = "#sandbox"
+ logger = logging.getLogger(generic_poor_logger)
+ logger.error(message)
+ else:
+ self.logger = logging.getLogger(logger_name)
+ self.logger.exception(message)
+
+
+class FatalError(TracebackMessageError):
+ pass
+
+
+class ConfigValidationError(FatalError):
+ pass
+
+
+class ConfigNotFoundError(RootException):
+ pass
+
+
+class ConfigModelError(ValueError, FatalError):
+ pass
diff --git a/pipelex/tools/func_registry.py b/pipelex/tools/func_registry.py
new file mode 100644
index 000000000..142446cb5
--- /dev/null
+++ b/pipelex/tools/func_registry.py
@@ -0,0 +1,128 @@
+import logging
+from typing import Any, Callable, Dict, List, Optional, TypeVar
+
+from kajson.sandbox_manager import sandbox_manager
+from pydantic import Field, PrivateAttr, RootModel
+
+from pipelex.tools.exceptions import ToolException
+from pipelex.tools.log.log_levels import LOGGING_LEVEL_VERBOSE
+
+FUNC_REGISTRY_LOGGER_CHANNEL_NAME = "func_registry"
+FUNC_REGISTRY_LOGGER_CHANNEL_NAME_IN_SANDBOX = "func_registry.sandbox"
+
+# Type variable for generic function types
+T = TypeVar("T")
+FuncRegistryDict = Dict[str, Callable[..., Any]]
+
+
+class FuncRegistryError(ToolException):
+ pass
+
+
+class FuncRegistry(RootModel[FuncRegistryDict]):
+ root: FuncRegistryDict = Field(default_factory=dict)
+ _logger: logging.Logger = PrivateAttr(logging.getLogger(FUNC_REGISTRY_LOGGER_CHANNEL_NAME))
+
+ def log(self, message: str) -> None:
+ if sandbox_manager.is_in_sandbox():
+ logger = logging.getLogger(FUNC_REGISTRY_LOGGER_CHANNEL_NAME_IN_SANDBOX)
+ logger.debug(message)
+ else:
+ self._logger.debug(message)
+
+ def teardown(self) -> None:
+ """Resets the registry to an empty state."""
+ self.root.clear()
+
+ def register_function(
+ self,
+ func: Callable[..., Any],
+ name: Optional[str] = None,
+ should_warn_if_already_registered: bool = True,
+ ) -> None:
+ """Registers a function in the registry with a name."""
+ key = name or func.__name__
+ if key in self.root:
+ if should_warn_if_already_registered:
+ self.log(f"Function '{key}' already exists in registry")
+ else:
+ self.log(f"Registered new single function '{key}' in registry")
+ self.root[key] = func
+
+ def unregister_function(self, func: Callable[..., Any]) -> None:
+ """Unregisters a function from the registry."""
+ key = func.__name__
+ if key not in self.root:
+ raise FuncRegistryError(f"Function '{key}' not found in registry")
+ del self.root[key]
+ self.log(f"Unregistered single function '{key}' from registry")
+
+ def unregister_function_by_name(self, name: str) -> None:
+ """Unregisters a function from the registry by its name."""
+ if name not in self.root:
+ raise FuncRegistryError(f"Function '{name}' not found in registry")
+ del self.root[name]
+
+ def register_functions_dict(self, functions: Dict[str, Callable[..., Any]]) -> None:
+ """Registers multiple functions in the registry with names."""
+ self.root.update(functions)
+ nb_functions = len(functions)
+ if nb_functions > 1:
+ self.log(f"Registered {nb_functions} functions in registry")
+ functions_list_str = "\n".join([f"{key}: {value.__name__}" for key, value in functions.items()])
+ logging.log(level=LOGGING_LEVEL_VERBOSE, msg=functions_list_str)
+ else:
+ self.log(f"Registered single function '{list(functions.values())[0].__name__}' in registry")
+
+ def register_functions(self, functions: List[Callable[..., Any]]) -> None:
+ """Registers multiple functions in the registry with names."""
+ if not functions:
+ self.log("register_functions called with empty list of functions to register")
+ return
+
+ for func in functions:
+ key = func.__name__
+ if key in self.root:
+ self.log(f"Function '{key}' already exists in registry, skipping")
+ continue
+ self.root[key] = func
+
+ nb_functions = len(functions)
+ if nb_functions > 1:
+ self.log(f"Registered {nb_functions} functions in registry")
+ functions_list_str = "\n".join([f"{func.__name__}: {func}" for func in functions])
+ logging.log(level=LOGGING_LEVEL_VERBOSE, msg=functions_list_str)
+ else:
+ self.log(f"Registered single function '{functions[0].__name__}' in registry")
+
+ def get_function(self, name: str) -> Optional[Callable[..., Any]]:
+ """Retrieves a function from the registry by its name. Returns None if not found."""
+ return self.root.get(name)
+
+ def get_required_function(self, name: str) -> Callable[..., Any]:
+ """Retrieves a function from the registry by its name. Raises an error if not found."""
+ if name not in self.root:
+ raise FuncRegistryError(f"Function '{name}' not found in registry")
+ return self.root[name]
+
+ def get_required_function_with_signature(self, name: str, expected_signature: Callable[..., T]) -> Callable[..., T]:
+ """
+ Retrieves a function from the registry by its name and verifies it matches the expected signature.
+ Raises an error if not found or if signature doesn't match.
+ """
+ if name not in self.root:
+ raise FuncRegistryError(f"Function '{name}' not found in registry")
+
+ func = self.root[name]
+ # Note: This is a basic signature check. For more thorough type checking,
+ # you might want to use typing.get_type_hints() or a more sophisticated type checker
+ if not callable(func):
+ raise FuncRegistryError(f"'{name}' is not a callable function")
+ return func
+
+ def has_function(self, name: str) -> bool:
+ """Checks if a function is in the registry by its name."""
+ return name in self.root
+
+
+func_registry = FuncRegistry()
diff --git a/pipelex/tools/log/__init__.py b/pipelex/tools/log/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/pipelex/tools/log/__init__.py
@@ -0,0 +1 @@
+
diff --git a/pipelex/tools/log/log.py b/pipelex/tools/log/log.py
new file mode 100644
index 000000000..fd45d7b58
--- /dev/null
+++ b/pipelex/tools/log/log.py
@@ -0,0 +1,375 @@
+import logging
+from typing import Any, Dict, Optional, Union
+
+from pipelex.tools.log.log_config import (
+ LogConfig,
+ LogLevel,
+)
+from pipelex.tools.log.log_dispatch import LogDispatch
+from pipelex.tools.log.log_formatter import EmojiLogFormatter, LevelAndEmojiLogFormatter
+from pipelex.tools.log.log_levels import LOGGING_LEVEL_DEV, LOGGING_LEVEL_VERBOSE
+
+
+class Log:
+ """
+ A class for managing logging configurations and operations.
+ """
+
+ ########################################################
+ # Init and Configure
+ ########################################################
+
+ def __init__(self):
+ """
+ Initialize the Log class with default attributes.
+ """
+ self.project_name: Optional[str] = None
+ self._log_config_instance: Optional[LogConfig] = None
+ self.rich_handler: Optional[logging.Handler] = None
+ self.poor_handler: Optional[logging.Handler] = None
+ self.log_dispatch: LogDispatch = LogDispatch()
+
+ @property
+ def _log_config(self) -> LogConfig:
+ """
+ Get the log configuration, raising an error if it's not set.
+
+ Returns:
+ LogConfig: The current log configuration.
+
+ Raises:
+ RuntimeError: If the log configuration is not set.
+ """
+ if self._log_config_instance is None:
+ raise RuntimeError("LogConfig is not set. You must initialize Pipelex first.")
+ return self._log_config_instance
+
+ def reset(self):
+ """
+ Reset the logging system.
+ """
+ # Remove all handlers from the root logger
+ root_logger = logging.getLogger()
+ for handler in root_logger.handlers[:]:
+ root_logger.removeHandler(handler)
+ handler.close()
+
+ # Remove handlers from poor loggers
+ if self._log_config_instance:
+ poor_loggers = set(self._log_config_instance.poor_loggers + [self._log_config_instance.generic_poor_logger])
+ for logger_name in poor_loggers:
+ logger = logging.getLogger(logger_name)
+ for handler in logger.handlers[:]:
+ logger.removeHandler(handler)
+ handler.close()
+
+ logging.shutdown()
+ self.project_name = None
+ self._log_config_instance = None
+ self.rich_handler = None
+ self.poor_handler = None
+ self.log_dispatch.reset()
+
+ def configure(
+ self,
+ project_name: str,
+ log_config: LogConfig,
+ ):
+ """
+ Configure the logging system with the given project name and log configuration.
+
+ Args:
+ project_name (str): The name of the project.
+ log_config (LogConfig): The log configuration to use.
+
+ Raises:
+ RuntimeError: If the log configuration is already set.
+ """
+ if self._log_config_instance is not None:
+ raise RuntimeError("LogConfig is already set. You can only call log.configure() once.")
+
+ self.log_dispatch.configure(
+ project_name=project_name,
+ log_config=log_config,
+ )
+
+ self._log_config_instance = log_config
+
+ self.project_name = project_name
+ self.rich_handler = log_config.rich_log_config.make_rich_handler()
+ self.rich_handler.setFormatter(EmojiLogFormatter())
+
+ # Configure the root logger
+ root_logger = logging.getLogger()
+ root_logger.setLevel(log_config.default_log_level.int_logging_level)
+ root_logger.addHandler(self.rich_handler)
+
+ self.poor_handler = logging.StreamHandler()
+ self.poor_handler.setFormatter(LevelAndEmojiLogFormatter())
+ poor_loggers = set(log_config.poor_loggers + [log_config.generic_poor_logger])
+ for logger_name in poor_loggers:
+ # print(f"Configuring poor logger: {logger_name}")
+ logger = logging.getLogger(logger_name)
+ logger.setLevel(log_config.default_log_level.int_logging_level)
+ logger.addHandler(self.poor_handler)
+ logger.propagate = False
+
+ self.set_levels_for_packages(package_log_levels=log_config.package_log_levels)
+
+ self.verbose("Logs configured")
+ self.verbose(f"Config set for {project_name}")
+
+ def set_rich_log_formatter(self, formatter: logging.Formatter):
+ """
+ Set the formatter for the rich log handler.
+
+ Args:
+ formatter (logging.Formatter): The formatter to use for rich logging.
+ """
+ if self.rich_handler is None:
+ raise RuntimeError("Rich log handler is not set.")
+ self.rich_handler.setFormatter(formatter)
+
+ def set_poor_log_formatter(self, formatter: logging.Formatter):
+ """
+ Set the formatter for the poor log handler.
+
+ Args:
+ formatter (logging.Formatter): The formatter to use for poor logging.
+ """
+ if self.poor_handler is None:
+ raise RuntimeError("Poor log handler is not set.")
+ self.poor_handler.setFormatter(formatter)
+
+ def _should_ignore(self, problem_id: Optional[str] = None) -> bool:
+ """
+ Check if a log message should be ignored based on the problem ID.
+
+ Args:
+ problem_id (Optional[str]): The problem ID to check.
+
+ Returns:
+ bool: True if the message should be ignored, False otherwise.
+ """
+ if problem_id and problem_id in self._log_config.silenced_problem_ids:
+ return True
+ else:
+ return False
+
+ ########################################################
+ # Public methods
+ ########################################################
+
+ def set_level_by_int(self, level_int: int):
+ """
+ Set the log level using an integer value.
+
+ Args:
+ level_int (int): The integer representation of the log level.
+ """
+ logging.getLogger().setLevel(level_int)
+
+ def set_level_by_name(self, level_name: str):
+ """
+ Set the log level using a string name.
+
+ Args:
+ level_name (str): The name of the log level.
+ """
+ print(f"Setting default logs to '{level_name=}'")
+ if level_name.upper() == LogLevel.DEV:
+ level = LOGGING_LEVEL_DEV
+ elif level_name.upper() == LogLevel.OFF:
+ level = LOGGING_LEVEL_DEV
+ else:
+ level = getattr(logging, level_name.upper())
+ self.set_level_by_int(level)
+
+ def set_level(self, level: LogLevel):
+ """
+ Set the default log level for all loggers.
+
+ Args:
+ level (LogLevel): The log level to set.
+ """
+ # print(f"Setting default logs to {level=}")
+ self.set_level_by_int(level_int=level.int_logging_level)
+
+ def set_level_for_package(self, package_name: str, level: LogLevel):
+ """
+ Set the log level for a specific package.
+
+ Args:
+ package_name (str): The name of the package.
+ level (LogLevel): The log level to set for the package.
+ """
+ logger_name = package_name.replace("-", ".")
+ # print(f"Setting {logger_name=} to {level=}")
+ logging.getLogger(logger_name).setLevel(level.int_logging_level)
+
+ def set_levels_for_packages(self, package_log_levels: Dict[str, LogLevel]):
+ """
+ Set log levels for multiple packages.
+
+ Args:
+ package_log_levels (Dict[str, LogLevel]): A dictionary mapping package names to log levels.
+ """
+ for package_name, level in package_log_levels.items():
+ self.set_level_for_package(package_name=package_name, level=level)
+
+ def verbose(
+ self,
+ content: Union[str, Any],
+ title: Optional[str] = None,
+ inline: Optional[str] = None,
+ ):
+ """
+ Log a verbose message.
+
+ Args:
+ content (Union[str, Any]): The content to log.
+ title (Optional[str], optional): The title of the log message. Defaults to None.
+ inline (Optional[str], optional): Inline title for the log message. Defaults to None.
+ Used to display the title inline, only if the title arg is None.
+ """
+ severity = LOGGING_LEVEL_VERBOSE
+ self.log_dispatch.dispatch(content=content, severity=severity, title=title, inline=inline)
+
+ def debug(
+ self,
+ content: Union[str, Any],
+ title: Optional[str] = None,
+ inline: Optional[str] = None,
+ ):
+ """
+ Log a debug message.
+
+ Args:
+ content (Union[str, Any]): The content to log.
+ title (Optional[str], optional): The title of the log message. Defaults to None.
+ inline (Optional[str], optional): Inline title for the log message. Defaults to None.
+ Used to display the title inline, only if the title arg is None.
+ """
+ severity = logging.DEBUG
+ self.log_dispatch.dispatch(content=content, severity=severity, title=title, inline=inline)
+
+ def dev(
+ self,
+ content: Union[str, Any],
+ title: Optional[str] = None,
+ inline: Optional[str] = None,
+ ):
+ """
+ Log a development message.
+
+ Args:
+ content (Union[str, Any]): The content to log.
+ title (Optional[str], optional): The title of the log message. Defaults to None.
+ inline (Optional[str], optional): Inline title for the log message. Defaults to None.
+ Used to display the title inline, only if the title arg is None.
+ """
+ severity = LOGGING_LEVEL_DEV
+ self.log_dispatch.dispatch(content=content, severity=severity, title=title, inline=inline)
+
+ def info(
+ self,
+ content: Union[str, Any],
+ title: Optional[str] = None,
+ inline: Optional[str] = None,
+ ):
+ """
+ Log an info message.
+
+ Args:
+ content (Union[str, Any]): The content to log.
+ title (Optional[str], optional): The title of the log message. Defaults to None.
+ inline (Optional[str], optional): Inline title for the log message. Defaults to None.
+ Used to display the title inline, only if the title arg is None.
+ """
+ severity = logging.INFO
+ self.log_dispatch.dispatch(content=content, severity=severity, title=title, inline=inline)
+
+ def warning(
+ self,
+ content: Union[str, Any],
+ title: Optional[str] = None,
+ inline: Optional[str] = None,
+ problem_id: Optional[str] = None,
+ ):
+ """
+ Log a warning message.
+
+ Args:
+ content (Union[str, Any]): The content to log.
+ title (Optional[str], optional): The title of the log message. Defaults to None.
+ inline (Optional[str], optional): Inline title for the log message. Defaults to None.
+ Used to display the title inline, only if the title arg is None.
+ problem_id (Optional[str], optional): A problem ID to associate with the warning. Defaults to None.
+ """
+ if self._should_ignore(problem_id=problem_id):
+ return
+ severity = logging.WARNING
+ self.log_dispatch.dispatch(content=content, severity=severity, title=title, inline=inline)
+
+ def error(
+ self,
+ content: Union[str, Any],
+ title: Optional[str] = None,
+ inline: Optional[str] = None,
+ include_exception: bool = False,
+ problem_id: Optional[str] = None,
+ ):
+ """
+ Log an error message.
+
+ Args:
+ content (Union[str, Any]): The content to log.
+ title (Optional[str], optional): The title of the log message. Defaults to None.
+ inline (Optional[str], optional): Inline title for the log message. Defaults to None.
+ Used to display the title inline, only if the title arg is None.
+ include_exception (bool, optional): Whether to include exception information. Defaults to False.
+ problem_id (Optional[str], optional): A problem ID to associate with the error. Defaults to None.
+ """
+ if self._should_ignore(problem_id=problem_id):
+ return
+ severity = logging.ERROR
+ self.log_dispatch.dispatch(
+ content=content,
+ severity=severity,
+ title=title,
+ inline=inline,
+ include_exception=include_exception,
+ )
+
+ def critical(
+ self,
+ content: Union[str, Any],
+ title: Optional[str] = None,
+ inline: Optional[str] = None,
+ include_exception: bool = False,
+ problem_id: Optional[str] = None,
+ ):
+ """
+ Log a critical message.
+
+ Args:
+ content (Union[str, Any]): The content to log.
+ title (Optional[str], optional): The title of the log message. Defaults to None.
+ inline (Optional[str], optional): Inline title for the log message. Defaults to None.
+ Used to display the title inline, only if the title arg is None.
+ include_exception (bool, optional): Whether to include exception information. Defaults to False.
+ problem_id (Optional[str], optional): A problem ID to associate with the critical message. Defaults to None.
+ """
+ if self._should_ignore(problem_id=problem_id):
+ return
+ severity = logging.CRITICAL
+ self.log_dispatch.dispatch(
+ content=content,
+ severity=severity,
+ title=title,
+ inline=inline,
+ include_exception=include_exception,
+ )
+
+
+log = Log()
diff --git a/pipelex/tools/log/log_config.py b/pipelex/tools/log/log_config.py
new file mode 100644
index 000000000..910e555a0
--- /dev/null
+++ b/pipelex/tools/log/log_config.py
@@ -0,0 +1,106 @@
+from enum import Enum, StrEnum
+from typing import Dict, List, cast
+
+from pydantic import Field, field_validator
+from rich.highlighter import Highlighter, JSONHighlighter, ReprHighlighter
+from rich.logging import RichHandler
+
+from pipelex.tools.config.models import ConfigModel
+from pipelex.tools.log.log_levels import LogLevel
+
+
+class HighlighterName(StrEnum):
+ JSON = "json"
+ REPR = "repr"
+
+
+class PROBLEM_IDS(StrEnum):
+ AZURE_OPENAI_NO_STREAM_OPTIONS = "Azure OpenAI no stream_options"
+
+
+class CallerInfoTemplate(Enum):
+ FILE_LINE = "file_line"
+ FILE_LINE_FUNC = "file_line_func"
+ FUNC = "func"
+ FILE_FUNC = "file_func"
+ FUNC_LINE = "func_line"
+ FUNC_MODULE = "func_module"
+ FUNC_MODULE_LINE = "func_module_line"
+
+ @classmethod
+ def for_template_key(cls, key: "CallerInfoTemplate") -> str:
+ templates: Dict[CallerInfoTemplate, str] = {
+ cls.FILE_LINE: "{file}:{line}",
+ cls.FILE_LINE_FUNC: "{file}:{line} {func}",
+ cls.FUNC: "{func}",
+ cls.FILE_FUNC: "{file} {func}",
+ cls.FUNC_LINE: "{func} {line}",
+ cls.FUNC_MODULE: "{func} {module}",
+ cls.FUNC_MODULE_LINE: "{func} {module} {line}",
+ }
+ return templates.get(key, "")
+
+
+class RichLogConfig(ConfigModel):
+ is_show_time: bool
+ is_show_level: bool
+ is_link_path_enabled: bool
+ highlighter_name: HighlighterName = Field(strict=False)
+ is_markup_enabled: bool
+ is_rich_tracebacks: bool
+ is_tracebacks_word_wrap: bool
+ is_tracebacks_show_locals: bool
+ tracebacks_suppress: List[str]
+ keywords_to_hilight: List[str]
+
+ def make_rich_handler(self) -> RichHandler:
+ highlighter: Highlighter
+ match self.highlighter_name:
+ case HighlighterName.JSON:
+ highlighter = JSONHighlighter()
+ case HighlighterName.REPR:
+ highlighter = ReprHighlighter()
+
+ return RichHandler(
+ show_time=self.is_show_time,
+ show_level=self.is_show_level,
+ enable_link_path=self.is_link_path_enabled,
+ highlighter=highlighter,
+ markup=self.is_markup_enabled,
+ rich_tracebacks=self.is_rich_tracebacks,
+ tracebacks_word_wrap=self.is_tracebacks_word_wrap,
+ tracebacks_show_locals=self.is_tracebacks_show_locals,
+ tracebacks_suppress=self.tracebacks_suppress,
+ keywords=self.keywords_to_hilight,
+ )
+
+
+class LogConfig(ConfigModel):
+ default_log_level: LogLevel = Field(strict=False)
+ package_log_levels: Dict[str, LogLevel]
+
+ is_console_logging_enabled: bool
+
+ json_logs_indent: int
+ presentation_line_width: int
+ is_caller_info_enabled: bool
+ caller_info_template: CallerInfoTemplate = Field(strict=False)
+
+ silenced_problem_ids: List[str]
+
+ rich_log_config: RichLogConfig
+
+ # logger name to use for safe logging without fancy features like code filepath and stuff
+ generic_poor_logger: str
+ poor_loggers: List[str]
+
+ @field_validator("package_log_levels", mode="before")
+ def validate_package_log_levels(cls, value: Dict[str, str]) -> Dict[str, LogLevel]:
+ """
+ Validate the package log levels dictionary.
+ """
+ the_dict = cast(
+ Dict[str, LogLevel],
+ ConfigModel.transform_dict_str_to_enum(input_dict=value, value_enum_cls=LogLevel),
+ )
+ return the_dict
diff --git a/pipelex/tools/log/log_dispatch.py b/pipelex/tools/log/log_dispatch.py
new file mode 100644
index 000000000..47b8162b2
--- /dev/null
+++ b/pipelex/tools/log/log_dispatch.py
@@ -0,0 +1,287 @@
+import inspect
+import logging
+import os
+import traceback
+from typing import Any, List, Optional, Union
+
+from kajson.sandbox_manager import sandbox_manager
+
+from pipelex.tools.log.log_config import (
+ CallerInfoTemplate,
+ LogConfig,
+)
+from pipelex.tools.misc.json_utils import purify_json, purify_json_dict, purify_json_list
+
+
+class LogDispatch:
+ """
+ A class for handling log dispatching to both console and Google Cloud.
+ """
+
+ ########################################################
+ # Init and Configure
+ ########################################################
+ # TODO: more elegant init for log_dispatch / log
+ def __init__(self):
+ self.project_name: Optional[str] = None
+ self._log_config_instance: Optional[LogConfig] = None
+
+ def reset(self):
+ """
+ Reset the log dispatch.
+ """
+ self.project_name = None
+ self._log_config_instance = None
+
+ @property
+ def _log_config(self) -> LogConfig:
+ """
+ Retrieves the log configuration.
+
+ Raises:
+ RuntimeError: If LogConfig is not set.
+
+ Returns:
+ LogConfig: The current log configuration.
+ """
+ if self._log_config_instance is None:
+ raise RuntimeError("LogConfig is not set. You must call pipelex_hub.set_config().")
+ return self._log_config_instance
+
+ def configure(
+ self,
+ project_name: str,
+ log_config: LogConfig,
+ ):
+ """
+ Configures the LogDispatch with project name and log configuration.
+
+ Args:
+ project_name (str): The name of the project.
+ log_config (LogConfig): The log configuration to use.
+
+ Raises:
+ RuntimeError: If LogConfig is already set.
+ """
+ if self._log_config_instance is not None:
+ raise RuntimeError("LogConfig is already set. You can only call log.configure() once.")
+ self._log_config_instance = log_config
+ self.project_name = project_name
+
+ ########################################################
+ # Private methods
+ ########################################################
+
+ def dispatch(
+ self,
+ content: Union[str, Any],
+ severity: int,
+ title: Optional[str] = None,
+ inline: Optional[str] = None,
+ include_exception: bool = False,
+ ):
+ """
+ Dispatches a log message to appropriate logging methods based on content type.
+
+ Args:
+ content (Union[str, Any]): The content to be logged.
+ severity (int): The severity level of the log message.
+ title (Optional[str], optional): The title of the log message. Defaults to None.
+ inline (Optional[str], optional): Inline title for the log message. Defaults to None.
+ Used to display the title inline, only if the title arg is None.
+ include_exception (bool, optional): Whether to include exception traceback. Defaults to False.
+ """
+ caller_info_str: Optional[str] = None
+ if (
+ (self._log_config.is_caller_info_enabled)
+ and (frame0 := inspect.currentframe())
+ and (frame1 := frame0.f_back)
+ # and (frame2 := frame1.f_back)
+ and (caller_frame := frame1.f_back)
+ ):
+ caller_info = inspect.getframeinfo(caller_frame)
+ caller_file = caller_info.filename
+ cwd = os.getcwd()
+ try:
+ caller_file = os.path.relpath(caller_file, cwd)
+ except ValueError:
+ # This can happen if the file is on a different drive (on Windows)
+ # In this case, we'll keep the absolute path
+ pass
+ caller_line = caller_info.lineno
+ caller_func = caller_info.function
+ template_str = CallerInfoTemplate.for_template_key(key=self._log_config.caller_info_template)
+ caller_info_str = template_str.format(file=caller_file, line=caller_line, func=caller_func)
+
+ if isinstance(content, str):
+ self._log_message(
+ message=content,
+ severity=severity,
+ caller_info_str=caller_info_str,
+ title=title,
+ inline=inline,
+ include_exception=include_exception,
+ )
+ else:
+ self._log_data(
+ data=content,
+ severity=severity,
+ caller_info_str=caller_info_str,
+ title=title,
+ include_exception=include_exception,
+ )
+
+ def _log_message(
+ self,
+ message: str,
+ severity: int,
+ caller_info_str: Optional[str],
+ title: Optional[str] = None,
+ inline: Optional[str] = None,
+ include_exception: bool = False,
+ ):
+ """
+ Logs a message to both console and Google Cloud.
+
+ Args:
+ message (str): The message to be logged.
+ severity (int): The severity level of the log message.
+ caller_info_str (Optional[str]): Information about the caller.
+ title (Optional[str], optional): The title of the log message. Defaults to None.
+ inline (Optional[str], optional): Inline title for the log message. Defaults to None.
+ Used to display the title inline, only if the title arg is None.
+ include_exception (bool, optional): Whether to include exception traceback. Defaults to False.
+ """
+ if title is not None:
+ message = f"{title}:\n{message}"
+ elif inline is not None:
+ message = f"{inline}: {message}"
+
+ message_for_console = message
+ if caller_info_str is not None:
+ message_for_console = f"{caller_info_str}: {message}"
+
+ if include_exception:
+ message += f"\n{traceback.format_exc()}"
+ self._log_to_console(message=message_for_console, severity=severity)
+
+ def _log_data(
+ self,
+ data: Any,
+ severity: int,
+ caller_info_str: Optional[str],
+ title: Optional[str] = None,
+ include_exception: bool = False,
+ ):
+ """
+ Logs potentially structured data (maybe it's a dict or a list) to both console and Google Cloud.
+
+ Args:
+ data (Any): The data to be logged.
+ severity (int): The severity level of the log message.
+ caller_info_str (Optional[str]): Information about the caller.
+ title (Optional[str], optional): The title of the log message. Defaults to None.
+ include_exception (bool, optional): Whether to include exception traceback. Defaults to False.
+ """
+ if data is None:
+ message = "None"
+ if title is not None:
+ message = f"{title}:\n{message}"
+ if caller_info_str is not None:
+ message = f"{caller_info_str}: {message}"
+ if include_exception:
+ message += f"\n{traceback.format_exc()}"
+ self._log_to_console(message=message, severity=severity)
+ elif isinstance(data, dict):
+ dict_string: str
+ _, dict_string = purify_json_dict(
+ data=data,
+ indent=self._log_config.json_logs_indent,
+ is_warning_enabled=True,
+ )
+ message = f"\n{dict_string}"
+ if title is not None:
+ message = f"{title}:{message}"
+ if caller_info_str is not None:
+ message = f"{caller_info_str}: {message}"
+ if include_exception:
+ message += f"\n{traceback.format_exc()}"
+ self._log_to_console(message=message, severity=severity)
+ elif isinstance(data, list):
+ list_data: List[Any] = data
+ _, list_string = purify_json_list(data=list_data, indent=self._log_config.json_logs_indent)
+ message = f"\n{list_string}"
+ if title is not None:
+ message = f"{title}:{message}"
+ if caller_info_str is not None:
+ message = f"{caller_info_str}: {message}"
+ if include_exception:
+ message += f"\n{traceback.format_exc()}"
+ self._log_to_console(message=message, severity=severity)
+ else:
+ _, dict_string = purify_json(
+ data=data,
+ indent=self._log_config.json_logs_indent,
+ is_warning_enabled=False,
+ )
+ message = f"\n{dict_string}"
+ if title is not None:
+ message = f"{title}:{message}"
+ if caller_info_str is not None:
+ message = f"{caller_info_str}: {message}"
+ if include_exception:
+ message += f"\n{traceback.format_exc()}"
+ self._log_to_console(message=message, severity=severity)
+
+ def _log_to_console(self, message: str, severity: int):
+ """
+ Logs a message to the console.
+
+ Args:
+ message (str): The message to be logged.
+ severity (int): The severity level of the log message.
+ """
+ if not self._log_config.is_console_logging_enabled:
+ return
+
+ if sandbox_manager.is_in_sandbox():
+ logger = logging.getLogger(self._log_config.generic_poor_logger)
+ logger.log(level=severity, msg=message, stacklevel=6)
+ return
+
+ stack = inspect.stack()
+ try:
+ logging_module_path = os.path.abspath(__file__)
+ log_origin_name = "unknown"
+
+ for frame_info in stack[1:]:
+ try:
+ frame = frame_info.frame
+ module = inspect.getmodule(frame)
+
+ if module is None:
+ continue
+
+ if hasattr(module, "__file__") and module.__file__ is not None:
+ module_file = os.path.abspath(module.__file__)
+ else:
+ continue
+
+ if module_file == logging_module_path or module_file.endswith("/log.py"):
+ continue
+ else:
+ if module.__name__ == "__main__":
+ if self.project_name is None:
+ raise RuntimeError("Project name is not set. You must call initialize Pipelex first.")
+ log_origin_name = self.project_name
+ else:
+ log_origin_name = module.__name__.split(sep=".", maxsplit=1)[0]
+ break
+ finally:
+ del frame_info
+
+ logger = logging.getLogger(log_origin_name)
+ logger.log(level=severity, msg=message, stacklevel=5)
+ finally:
+ if stack:
+ del stack
diff --git a/pipelex/tools/log/log_formatter.py b/pipelex/tools/log/log_formatter.py
new file mode 100644
index 000000000..1a8af6e08
--- /dev/null
+++ b/pipelex/tools/log/log_formatter.py
@@ -0,0 +1,93 @@
+import logging
+from typing import Dict, Optional
+
+from typing_extensions import override
+
+from pipelex.tools.log.log_levels import LOGGING_LEVEL_DEV, LOGGING_LEVEL_VERBOSE
+from pipelex.tools.misc.terminal_utils import BOLD_FONT, RESET_FONT, TerminalColor
+
+
+# TODO: move these to the config
+def emoji_for_channel(channel_name: str) -> Optional[str]:
+ channel_emojis: Dict[str, str] = {
+ "root": "",
+ "werkzeug": "📡",
+ "urllib3.connectionpool": "⚡️",
+ }
+
+ emoji = channel_emojis.get(channel_name, None)
+ if emoji == "":
+ # blank emoji is OK
+ return emoji
+ elif emoji:
+ return emoji
+ elif channel_name.startswith("google"):
+ return "🌀"
+ elif channel_name.startswith("openai"):
+ return "⚪️"
+ elif channel_name.startswith("kajson"):
+ # space added to make it look better
+ return "*️⃣ "
+ elif channel_name.startswith("#sandbox"):
+ # space added to make it look better
+ return "🧿 "
+ elif channel_name.startswith("pipelex"):
+ return "🧠"
+ else:
+ return None
+
+
+class EmojiLogFormatter(logging.Formatter):
+ @override
+ def format(self, record: logging.LogRecord):
+ log_fmt: str
+ emoji = emoji_for_channel(record.name)
+ if emoji == "":
+ log_fmt = "%(message)s"
+ elif emoji:
+ log_fmt = f"{emoji}: %(message)s"
+ else:
+ log_fmt = "[%(name)s]: %(message)s"
+ formatter = logging.Formatter(log_fmt)
+
+ return formatter.format(record)
+
+
+log_level_color: Dict[int, TerminalColor] = {
+ LOGGING_LEVEL_VERBOSE: TerminalColor.WHITE,
+ logging.DEBUG: TerminalColor.GREEN,
+ LOGGING_LEVEL_DEV: TerminalColor.CYAN,
+ logging.INFO: TerminalColor.BLUE,
+ logging.WARNING: TerminalColor.YELLOW,
+ logging.ERROR: TerminalColor.RED,
+ logging.CRITICAL: TerminalColor.MAGENTA,
+}
+
+# added spaces and truncated to 5 characters to make it look better
+log_level_tag: Dict[int, str] = {
+ LOGGING_LEVEL_VERBOSE: "VERBO",
+ logging.DEBUG: "DEBUG",
+ LOGGING_LEVEL_DEV: "DEV ",
+ logging.INFO: "INFO ",
+ logging.WARNING: f"{BOLD_FONT}WARNING{RESET_FONT}",
+ logging.ERROR: f"{BOLD_FONT}/ERROR\\{RESET_FONT}",
+ logging.CRITICAL: f"{BOLD_FONT}CRITICAL{RESET_FONT}",
+}
+
+
+class LevelAndEmojiLogFormatter(logging.Formatter):
+ @override
+ def format(self, record: logging.LogRecord):
+ emoji = emoji_for_channel(record.name)
+ color = log_level_color.get(record.levelno, RESET_FONT)
+ tag = log_level_tag.get(record.levelno, "?????")
+ if emoji:
+ log_fmt = f"{emoji} {color}{tag}:{RESET_FONT} %(message)s"
+ else:
+ log_fmt = f"{color}{tag}:%(name)s{RESET_FONT} %(message)s"
+ formatter = logging.Formatter(log_fmt)
+
+ if record.levelno in [logging.WARNING, logging.ERROR, logging.CRITICAL]:
+ record.msg = f"{color}{BOLD_FONT}{record.msg}{RESET_FONT}"
+
+ return formatter.format(record)
diff --git a/pipelex/tools/log/log_levels.py b/pipelex/tools/log/log_levels.py
new file mode 100644
index 000000000..1445601a6
--- /dev/null
+++ b/pipelex/tools/log/log_levels.py
@@ -0,0 +1,53 @@
+import logging
+from enum import StrEnum
+
+# custom logging level for development, between DEBUG and INFO
+LOGGING_LEVEL_DEV = 15
+LOGGING_LEVEL_DEV_NAME = "DEV"
+logging.addLevelName(LOGGING_LEVEL_DEV, LOGGING_LEVEL_DEV_NAME)
+# custom logging level for maximal verbosity, below DEBUG
+LOGGING_LEVEL_VERBOSE = 5
+LOGGING_LEVEL_VERBOSE_NAME = "VERBOSE"
+logging.addLevelName(LOGGING_LEVEL_VERBOSE, LOGGING_LEVEL_VERBOSE_NAME)
+
+
+class LogLevel(StrEnum):
+ VERBOSE = LOGGING_LEVEL_VERBOSE_NAME
+ DEBUG = "DEBUG"
+ DEV = LOGGING_LEVEL_DEV_NAME
+ INFO = "INFO"
+ WARNING = "WARNING"
+ ERROR = "ERROR"
+ CRITICAL = "CRITICAL"
+ OFF = "OFF"
+
+ @property
+ def int_logging_level(self) -> int:
+ match self:
+ case LogLevel.VERBOSE:
+ return LOGGING_LEVEL_VERBOSE
+ case LogLevel.DEBUG:
+ return logging.DEBUG
+ case LogLevel.DEV:
+ return LOGGING_LEVEL_DEV
+ case LogLevel.INFO:
+ return logging.INFO
+ case LogLevel.WARNING:
+ return logging.WARNING
+ case LogLevel.ERROR:
+ return logging.ERROR
+ case LogLevel.CRITICAL:
+ return logging.CRITICAL
+ case LogLevel.OFF:
+ return int(logging.CRITICAL) + 1
+
+ @staticmethod
+ def from_int(logging_level: int) -> "LogLevel":
+ if logging_level == LOGGING_LEVEL_VERBOSE:
+ return LogLevel.VERBOSE
+ elif logging_level == LOGGING_LEVEL_DEV:
+ return LogLevel.DEV
+ elif logging_level > int(logging.CRITICAL):
+ return LogLevel.OFF
+ else:
+ return LogLevel(logging.getLevelName(logging_level))
diff --git a/pipelex/tools/misc/__init__.py b/pipelex/tools/misc/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/pipelex/tools/misc/__init__.py
@@ -0,0 +1 @@
+
diff --git a/pipelex/tools/misc/base_64_utils.py b/pipelex/tools/misc/base_64_utils.py
new file mode 100644
index 000000000..409092a0a
--- /dev/null
+++ b/pipelex/tools/misc/base_64_utils.py
@@ -0,0 +1,46 @@
+import asyncio
+import base64
+
+import aiofiles
+
+from pipelex.tools.misc.file_utils import save_bytes_to_binary_file
+
+
+def load_binary_as_base64(path: str) -> bytes:
+ with open(path, "rb") as fp:
+ return base64.b64encode(fp.read())
+
+
+async def load_binary_as_base64_async(path: str) -> bytes:
+ async with aiofiles.open(path, "rb") as fp: # type: ignore[reportUnknownMemberType]
+ data_bytes = await fp.read()
+ return base64.b64encode(data_bytes)
+
+
+def encode_to_base64(data_bytes: bytes) -> bytes:
+ b64 = base64.b64encode(data_bytes)
+ return b64
+
+
+async def encode_to_base64_async(data_bytes: bytes) -> bytes:
+ # Use asyncio.to_thread to run the CPU-bound task in a separate thread
+ b64 = await asyncio.to_thread(base64.b64encode, data_bytes)
+ return b64
+
+
+def save_base64_to_binary_file(
+ b64: str,
+ file_path: str,
+):
+ # Ensure we're getting clean base64 data without any prefixes
+ base64_str = b64
+ # Remove potential data URL prefix if present
+ if "," in base64_str:
+ base64_str = base64_str.split(",", 1)[1]
+ if "data:" in base64_str and ";base64," in base64_str:
+ base64_str = base64_str.split(";base64,", 1)[1]
+
+ # Decode base64
+ byte_data = base64.b64decode(base64_str)
+
+ save_bytes_to_binary_file(file_path=file_path, byte_data=byte_data)
diff --git a/pipelex/tools/misc/file_fetch_utils.py b/pipelex/tools/misc/file_fetch_utils.py
new file mode 100644
index 000000000..2d9b73683
--- /dev/null
+++ b/pipelex/tools/misc/file_fetch_utils.py
@@ -0,0 +1,36 @@
+from typing import Optional
+
+import httpx
+from httpx import Response
+
+
+async def fetch_file_from_url_httpx_async(
+ url: str,
+ timeout: Optional[int] = None,
+) -> bytes:
+ async with httpx.AsyncClient() as client:
+ response: Response = await client.get(
+ url,
+ timeout=timeout,
+ follow_redirects=True,
+ )
+ response.raise_for_status() # Raise exception for 4XX/5XX status codes
+
+ bytes_content: bytes = response.content
+ return bytes_content
+
+
+def fetch_file_from_url_httpx(
+ url: str,
+ timeout: Optional[int] = None,
+) -> bytes:
+ with httpx.Client() as client:
+ response: Response = client.get(
+ url,
+ timeout=timeout,
+ follow_redirects=True,
+ )
+ response.raise_for_status() # Raise exception for 4XX/5XX status codes
+
+ bytes_content: bytes = response.content
+ return bytes_content
diff --git a/pipelex/tools/misc/file_utils.py b/pipelex/tools/misc/file_utils.py
new file mode 100644
index 000000000..e87e5404d
--- /dev/null
+++ b/pipelex/tools/misc/file_utils.py
@@ -0,0 +1,358 @@
+import importlib.resources
+import os
+import shutil
+from pathlib import Path
+from typing import List, Optional
+
+########################################################
+# Save & Load
+########################################################
+
+
+def save_bytes_to_binary_file(file_path: str, byte_data: bytes, create_directory: bool = False) -> str:
+ """
+ Write binary data to a file.
+
+ Args:
+ file_path (str): Path where the binary data will be saved
+ byte_data (bytes): Binary data to be written
+
+ Returns:
+ str: Path to the saved file
+ """
+ # Ensure the directory exists
+ if create_directory:
+ ensure_directory_exists(os.path.dirname(file_path))
+
+ with open(file_path, "wb") as f:
+ f.write(byte_data)
+ return file_path
+
+
+def save_text_to_path(text: str, path: str, create_directory: bool = False):
+ """
+ Writes text content to a file at the specified path.
+
+ This function opens a file in write mode and writes the provided text to it.
+ If the file already exists, it will be overwritten.
+
+ Args:
+ text (str): The text content to write to the file.
+ path (str): The file path where the content should be saved.
+ create_directory (bool, optional): Whether to create the directory if it doesn't exist.
+ Defaults to False.
+
+ Raises:
+ IOError: If there are issues writing to the file (e.g., permission denied).
+ """
+ if create_directory:
+ directory = os.path.dirname(path)
+ if directory:
+ ensure_directory_exists(directory)
+
+ with open(path, "w", encoding="utf-8") as file:
+ file.write(text)
+
+
+def load_text_from_path(path: str) -> str:
+ """
+ Reads and returns the entire contents of a text file.
+
+ This function opens a file in text mode using UTF-8 encoding and reads
+ its entire contents into a string.
+
+ Args:
+ path (str): The file path to read from.
+
+ Returns:
+ str: The complete contents of the file as a string.
+
+ Raises:
+ FileNotFoundError: If the file does not exist.
+ """
+ with open(path, encoding="utf-8") as file:
+ return file.read()
+
+
+def failable_load_text_from_path(path: str) -> Optional[str]:
+ """
+ Attempts to read a text file, returning None if the file doesn't exist.
+
+ This function is a safer version of load_text_from_path that handles missing files
+ gracefully by returning None instead of raising an error.
+
+ Args:
+ path (str): The file path to read from.
+
+ Returns:
+ Optional[str]: The complete contents of the file as a string, or None if the file doesn't exist.
+ """
+ if not path_exists(path):
+ return None
+ return load_text_from_path(path)
+
+
+########################################################
+# Copy & Remove
+########################################################
+
+
+def copy_file(source_path: str, target_path: str, overwrite: bool = True) -> None:
+ """
+ Copies a file from the source path to the target path.
+
+ Creates any necessary parent directories for the target path if they don't exist.
+
+ Args:
+ source_path (str): The path to the source file.
+ target_path (str): The path to the target file.
+ overwrite (bool, optional): Whether to overwrite existing files. Defaults to True.
+ """
+ # Ensure the target directory exists
+ target_dir = os.path.dirname(target_path)
+ if target_dir:
+ ensure_directory_exists(target_dir)
+
+ if not os.path.exists(target_path) or overwrite:
+ shutil.copy2(source_path, target_path)
+
+
+def copy_file_from_package(
+ package_name: str,
+ file_path_in_package: str,
+ target_path: str,
+ overwrite: bool = True,
+) -> None:
+ """
+ Copies a file from a package to a target directory.
+ """
+ file_path = str(importlib.resources.files(package_name).joinpath(file_path_in_package))
+ copy_file(
+ source_path=file_path,
+ target_path=target_path,
+ overwrite=overwrite,
+ )
+
+
+def copy_folder_from_package(
+ package_name: str,
+ folder_path_in_package: str,
+ target_dir: str,
+ overwrite: bool = True,
+ non_overwrite_files: Optional[List[str]] = None,
+) -> None:
+ """
+ Copies a folder from a package to a target directory.
+
+ This function walks through the specified folder in the package and copies
+ all files and directories to the target directory, preserving the directory
+ structure.
+
+ Args:
+ package_name (str): The name of the package to copy from.
+ folder_path_in_package (str): The path to the folder in the package to copy.
+ target_dir (str): The target directory to copy the folder to.
+ overwrite (bool, optional): Whether to overwrite existing files. Defaults to True.
+ """
+ os.makedirs(target_dir, exist_ok=True)
+
+ # Use importlib.resources to get the path to the package resource
+ data_dir_str = str(importlib.resources.files(package_name).joinpath(folder_path_in_package))
+
+ copied_files: list[str] = []
+
+ # Walk through all directories and files recursively
+ for root, _, files in os.walk(data_dir_str):
+ # Create the corresponding subdirectory in the target directory
+ rel_path = os.path.relpath(root, data_dir_str)
+ target_subdir = os.path.join(target_dir, rel_path) if rel_path != "." else target_dir
+ os.makedirs(target_subdir, exist_ok=True)
+
+ if non_overwrite_files is None:
+ non_overwrite_files = []
+
+ # Copy all files in the current directory
+ for file in files:
+ src_file = os.path.join(root, file)
+ dest_file = os.path.join(target_subdir, file)
+
+ # Check if the file exists and respect the overwrite parameter
+ if not os.path.exists(dest_file) or (overwrite and file not in non_overwrite_files):
+ copy_file(
+ source_path=src_file,
+ target_path=dest_file,
+ overwrite=overwrite,
+ )
+ copied_files.append(dest_file)
+
+
+def remove_file(file_path: str):
+ """
+ Removes a file if it exists at the specified path.
+
+ This function checks if a file exists before attempting to remove it,
+ preventing errors from trying to remove non-existent files.
+
+ Args:
+ file_path (str): The path to the file to be removed.
+
+ Note:
+ This function silently succeeds if the file doesn't exist.
+ """
+ if path_exists(file_path):
+ os.remove(file_path)
+
+
+def remove_folder(folder_path: str) -> None:
+ """
+ Removes a folder if it exists at the specified path.
+
+ This function checks if a folder exists before attempting to remove it,
+ preventing errors from trying to remove non-existent folders.
+
+ Args:
+ folder_path (str): The path to the folder to be removed.
+ """
+ if os.path.exists(folder_path):
+ shutil.rmtree(folder_path)
+
+
+########################################################
+# Check & get paths
+########################################################
+
+
+def ensure_directory_exists(directory_path: str) -> None:
+ """
+ Creates a directory and any necessary parent directories if they don't exist.
+
+ Args:
+ directory_path (str): The path to the directory to create.
+ """
+ os.makedirs(directory_path, exist_ok=True)
+
+
+def ensure_path(path: str) -> bool:
+ """
+ Ensures a directory exists at the specified path, creating it if necessary.
+
+ This function checks if a directory exists at the given path. If it doesn't exist,
+ it creates the directory and any necessary parent directories.
+
+ Args:
+ path (str): The path where the directory should exist.
+
+ Returns:
+ bool: True if the directory was created, False if it already existed.
+ """
+ typed_path = Path(path)
+ if typed_path.exists():
+ return False
+ typed_path.mkdir(parents=True, exist_ok=True)
+ return True
+
+
+def path_exists(path_str: str) -> bool:
+ """
+ Checks if a file or directory exists at the specified path.
+
+ This function converts the input string path to a Path object and checks
+ if anything exists at that location in the filesystem.
+
+ Args:
+ path_str (str): The path to check for existence.
+
+ Returns:
+ bool: True if a file or directory exists at the path, False otherwise.
+ """
+ path = Path(path_str)
+ return path.exists()
+
+
+def get_incremental_directory_path(base_path: str, base_name: str, start_at: int = 1) -> str:
+ """
+ Generates a unique directory path by incrementing a counter until an unused path is found.
+
+ This function creates a directory path in the format 'base_path/base_name_XX' where XX
+ is a two-digit number that starts at start_at and increments until an unused path is found.
+ The directory is then created at this path.
+
+ Args:
+ base_path (str): The parent directory where the new directory will be created.
+ base_name (str): The base name for the directory (will be appended with _XX).
+ start_at (int, optional): The number to start counting from. Defaults to 1.
+
+ Returns:
+ str: The path to the newly created directory.
+ """
+ counter = start_at
+ while True:
+ tested_path = f"{base_path}/{base_name}_%02d" % counter
+ if not path_exists(tested_path):
+ break
+ counter += 1
+ ensure_path(tested_path)
+ return tested_path
+
+
+def get_incremental_file_path(
+ base_path: str,
+ base_name: str,
+ extension: str,
+ start_at: int = 1,
+ avoid_suffix_if_possible: bool = False,
+) -> str:
+ """
+ Generates a unique file path by incrementing a counter until an unused path is found.
+
+ This function creates a file path in the format 'base_path/base_name_XX.extension' where XX
+ is a two-digit number that starts at start_at and increments until an unused path is found.
+ Unlike get_incremental_directory_path, this function only generates the path and does not create the file.
+
+ Args:
+ base_path (str): The directory where the file path will be generated.
+ base_name (str): The base name for the file (will be appended with _XX).
+ extension (str): The file extension (without the dot).
+ start_at (int, optional): The number to start counting from. Defaults to 1.
+
+ Returns:
+ str: A unique file path that does not exist in the filesystem.
+ """
+ if avoid_suffix_if_possible:
+ # try without adding the suffix
+ tested_path = f"{base_path}/{base_name}.{extension}"
+ if not path_exists(tested_path):
+ return tested_path
+
+ # we must add a number to the base name
+ counter = start_at
+ while True:
+ tested_path = f"{base_path}/{base_name}_%02d.{extension}" % counter
+ if not path_exists(tested_path):
+ break
+ counter += 1
+ return tested_path
+
+
+########################################################
+# Find files
+########################################################
+
+
+def find_files_in_dir(dir_path: str, pattern: str, is_recursive: bool) -> List[Path]:
+ """
+ Find files matching a pattern in a directory.
+
+ Args:
+ dir_path: Directory path to search in
+ pattern: File pattern to match (e.g. "*.py")
+ recursive: Whether to search recursively in subdirectories
+
+ Returns:
+ List of matching Path objects
+ """
+ path = Path(dir_path)
+ if is_recursive:
+ return list(path.rglob(pattern))
+ else:
+ return list(path.glob(pattern))
diff --git a/pipelex/tools/misc/filetype_utils.py b/pipelex/tools/misc/filetype_utils.py
new file mode 100644
index 000000000..1ee664d8f
--- /dev/null
+++ b/pipelex/tools/misc/filetype_utils.py
@@ -0,0 +1,89 @@
+import base64
+import binascii
+from pathlib import Path
+from typing import Union
+
+import filetype
+from pydantic import BaseModel
+
+from pipelex.tools.exceptions import ToolException
+
+
+class FileTypeException(ToolException):
+ pass
+
+
+class FileType(BaseModel):
+ extension: str
+ mime: str
+
+
+def detect_file_type_from_path(path: Union[str, Path]) -> FileType:
+ """
+ Detect the file type of a file at a given path.
+
+ Args:
+ path: The path to the file to detect the type of.
+
+ Returns:
+ A FileType object containing the file extension and MIME type of the file.
+
+ Raises:
+ FileTypeException: If the file type cannot be identified.
+ """
+ kind = filetype.guess(path) # pyright: ignore[reportUnknownMemberType]
+ if kind is None:
+ raise FileTypeException(f"Could not identify file type of '{path!s}'")
+ extension = f"{kind.extension}"
+ mime = f"{kind.mime}"
+ return FileType(extension=extension, mime=mime)
+
+
+def detect_file_type_from_bytes(buf: bytes) -> FileType:
+ """
+ Detect the file type of a given bytes object.
+
+ Args:
+ buf: The bytes object to detect the type of.
+
+ Returns:
+ A FileType object containing the file extension and MIME type of the file.
+
+ Raises:
+ FileTypeException: If the file type cannot be identified.
+ """
+ kind = filetype.guess(buf) # pyright: ignore[reportUnknownMemberType]
+ if kind is None:
+ raise FileTypeException(f"Could not identify file type of given bytes: {buf[:300]!r}")
+ extension = f"{kind.extension}"
+ mime = f"{kind.mime}"
+ return FileType(extension=extension, mime=mime)
+
+
+def detect_file_type_from_base64(b64: Union[str, bytes]) -> FileType:
+ """
+ Detect the file type of a given Base-64-encoded string.
+
+ Args:
+ b64: The Base-64-encoded bytes or string to detect the type of.
+
+ Returns:
+ A FileType object containing the file extension and MIME type of the file.
+
+ Raises:
+ FileTypeException: If the file type cannot be identified.
+ """
+ # Normalise to bytes holding only the Base-64 alphabet
+ if isinstance(b64, bytes):
+ b64_bytes = b64
+ else: # str → handle optional data-URL header
+ if b64.lstrip().startswith("data:") and "," in b64:
+ b64 = b64.split(",", 1)[1]
+ b64_bytes = b64.encode("ascii") # Base-64 is pure ASCII
+
+ try:
+ raw = base64.b64decode(b64_bytes, validate=True)
+ except binascii.Error as exc: # malformed Base-64
+ raise FileTypeException(f"Could not identify file type of given bytes because input is not valid Base-64: {exc}") from exc
+
+ return detect_file_type_from_bytes(buf=raw)
diff --git a/pipelex/tools/misc/json_utils.py b/pipelex/tools/misc/json_utils.py
new file mode 100644
index 000000000..4df097c2b
--- /dev/null
+++ b/pipelex/tools/misc/json_utils.py
@@ -0,0 +1,390 @@
+import json
+from typing import Any, Dict, List, Optional, Tuple, Union, cast
+
+from kajson import kajson
+from pydantic import BaseModel
+
+from pipelex.tools.exceptions import ToolException
+from pipelex.tools.misc.file_utils import save_text_to_path
+
+JsonContent = Union[Dict[Any, Any], List[Any]]
+
+
+class ArgumentTypeError(ToolException):
+ pass
+
+
+class JsonTypeError(ToolException):
+ pass
+
+
+def json_str(some_object: Any, title: Optional[str] = None, is_spaced: bool = False) -> str:
+ """
+ Creates a formatted JSON string representation of any Python object with optional title and spacing.
+
+ This function is a higher-level wrapper around purify_json that provides additional formatting
+ options. It always uses 4-space indentation and disables warning wrapping for non-serializable
+ data.
+
+ Args:
+ some_object (Any): The object to convert to a JSON string. Can be any type supported
+ by purify_json.
+ title (Optional[str], optional): A title to prepend to the JSON string. If provided,
+ the output will be in the format "title: {json_string}". Defaults to None.
+ is_spaced (bool, optional): If True, adds newlines before and after the JSON string
+ for better readability. Defaults to False.
+
+ Returns:
+ str: The formatted JSON string representation of the object.
+
+ Example:
+ >>> data = {"name": "test", "values": [1, 2, 3]}
+ >>> print(json_str(data, title="Data", is_spaced=True))
+
+ Data: {
+ "name": "test",
+ "values": [1, 2, 3]
+ }
+
+ """
+ _, json_string = purify_json(some_object, indent=4, is_warning_enabled=False)
+ if title:
+ json_string = f"{title}: {json_string}"
+ if is_spaced:
+ json_string = f"\n{json_string}\n"
+ return json_string
+
+
+def save_as_json_to_path(
+ object_to_save: Any,
+ path: str,
+ indent: Optional[int] = 4,
+ is_warning_enabled: bool = True,
+):
+ """
+ Saves a Python object as a JSON file at the specified path.
+
+ This function converts a Python object to a JSON string and saves it to a file. The object
+ is first purified to ensure JSON compatibility before saving.
+
+ Args:
+ object_to_save (Any): The Python object to be saved as JSON. Can be any JSON-serializable object.
+ path (str): The file path where the JSON file will be saved.
+ indent (Optional[int], optional): Number of spaces for JSON formatting indentation. Defaults to 4.
+ is_warning_enabled (bool, optional): Whether to show warnings during JSON purification. Defaults to True.
+
+ Returns:
+ None
+ """
+ _, json_string = purify_json(object_to_save, indent=indent, is_warning_enabled=is_warning_enabled)
+ save_text_to_path(json_string, path)
+
+
+def load_json_from_path(path: str) -> JsonContent:
+ """
+ Loads and parses a JSON file from the specified path.
+
+ This function reads a JSON file and returns its contents as a Python object.
+ The file is read using UTF-8 encoding.
+
+ Args:
+ path (str): The file path to the JSON file to be loaded.
+
+ Returns:
+ JsonContent: The parsed JSON content as a Python object (can be a dict, list, string, number, bool, or None).
+
+ Raises:
+ FileNotFoundError: If the file does not exist.
+ json.JSONDecodeError: If the file contains invalid JSON.
+ """
+ with open(path, encoding="utf-8") as file:
+ json_content: JsonContent = json.load(file)
+ return json_content
+
+
+def load_json_dict_from_path(path: str) -> Dict[Any, Any]:
+ """
+ Loads a JSON file and ensures it contains a dictionary.
+
+ This function reads a JSON file and verifies that its content is a dictionary.
+ It uses load_json_from_path internally and adds type checking.
+
+ Args:
+ path (str): The file path to the JSON file to be loaded.
+
+ Returns:
+ Dict[Any, Any]: The parsed JSON content as a Python dictionary.
+
+ Raises:
+ JsonTypeError: If the JSON content is not a dictionary.
+ FileNotFoundError: If the file does not exist.
+ json.JSONDecodeError: If the file contains invalid JSON.
+ """
+ json_content: JsonContent = load_json_from_path(path)
+ if isinstance(json_content, dict):
+ return json_content
+ else:
+ raise JsonTypeError(f"{path} is not a dict")
+
+
+def deep_update(target_dict: Dict[str, Any], updates: Dict[str, Any]):
+ """
+ Recursively updates a dictionary with values from another dictionary.
+
+ This function performs a deep merge of two dictionaries, handling nested
+ dictionaries and lists. For dictionaries, it recursively updates values,
+ and for lists, it concatenates them.
+
+ Args:
+ target_dict (Dict[str, Any]): The dictionary to update. This dictionary
+ will be modified in place.
+ updates (Dict[str, Any]): The dictionary containing updates to apply.
+
+ Example:
+ >>> base = {"a": 1, "b": {"x": 2, "y": 3}, "c": [1, 2]}
+ >>> updates = {"b": {"y": 4, "z": 5}, "c": [3, 4]}
+ >>> deep_update(base, updates)
+ >>> print(base)
+ {'a': 1, 'b': {'x': 2, 'y': 4, 'z': 5}, 'c': [1, 2, 3, 4]}
+ """
+ for key, value in updates.items():
+ if isinstance(value, dict) and key in target_dict and isinstance(target_dict[key], dict):
+ deep_update(target_dict[key], value) # type: ignore
+ elif isinstance(value, list) and key in target_dict and isinstance(target_dict[key], list):
+ target_dict[key] = list(target_dict[key] + value) # type: ignore
+ else:
+ target_dict[key] = value
+
+
+def remove_none_values(json_content: JsonContent) -> JsonContent:
+ """
+ Recursively removes all None values from a JSON-compatible data structure.
+
+ This function traverses dictionaries and lists, removing any keys with None values
+ from dictionaries and processing nested structures. It preserves the structure of
+ the input while cleaning out None values at any depth.
+
+ Args:
+ json_content (JsonContent): The JSON-compatible data structure (dict or list)
+ to process. Can contain nested dictionaries and lists.
+
+ Returns:
+ JsonContent: A new data structure of the same type as the input, but with all
+ None values removed from dictionaries at any level of nesting.
+
+ Example:
+ >>> data = {
+ ... "name": "test",
+ ... "value": None,
+ ... "nested": {"key": "exists", "empty": None},
+ ... "list": [1, None, {"key": None}]
+ ... }
+ >>> result = remove_none_values(data)
+ >>> print(result)
+ {
+ "name": "test",
+ "nested": {"key": "exists"},
+ "list": [1, {}]
+ }
+ """
+ if isinstance(json_content, dict):
+ json_content = cast(Dict[str, Any], json_content)
+ return {key: remove_none_values(json_content=value) for key, value in json_content.items() if value is not None}
+ else:
+ return [remove_none_values(item) for item in json_content]
+
+
+def purify_json(data: Any, indent: Optional[int] = None, is_warning_enabled: bool = True) -> Tuple[Union[Dict[Any, Any], List[Any]], str]:
+ """
+ Converts any Python object into a JSON-serializable format and its string representation.
+
+ This function handles various types of input data:
+ - Pydantic BaseModel instances are converted using their model_dump method
+ - Lists of BaseModel instances are converted element by element
+ - Other types are attempted to be JSON serialized directly
+ - If standard JSON serialization fails, it attempts using kajson or falls back to str conversion
+
+ Args:
+ data (Any): The data to convert. Can be a Pydantic model, list, dict, or any other type.
+ indent (Optional[int], optional): Number of spaces for JSON formatting indentation. Defaults to None.
+ is_warning_enabled (bool, optional): If True, wraps non-serializable data in a warning object.
+ Defaults to True.
+
+ Returns:
+ Tuple[Union[Dict[Any, Any], List[Any]], str]: A tuple containing:
+ - The purified data structure (either a dict or list)
+ - The JSON string representation of the data
+
+ Example:
+ >>> model = SomeModel(name="test")
+ >>> data, json_str = purify_json(model)
+ >>> print(json_str)
+ '{"name": "test"}'
+ """
+ dict_string: str
+ if isinstance(data, BaseModel):
+ return purify_json(
+ data.model_dump(serialize_as_any=True),
+ indent=indent,
+ is_warning_enabled=is_warning_enabled,
+ )
+
+ if isinstance(data, list):
+ the_list = data # type: ignore
+ if not the_list:
+ return [], "[]"
+ if isinstance(the_list[0], BaseModel):
+ the_list_of_base_models: List[BaseModel] = the_list
+ pure_list = [item.model_dump(serialize_as_any=True) for item in the_list_of_base_models]
+ dict_string = json.dumps(pure_list, indent=indent, default=str)
+ return pure_list, dict_string
+
+ try:
+ dict_string = json.dumps(data, indent=indent)
+ pure_dict: Union[Dict[Any, Any], List[Any]] = data
+ except TypeError:
+ try:
+ dict_string = kajson.dumps(data, indent=indent) # pyright: ignore[reportUnknownMemberType]
+ except Exception:
+ # print(f"Error: type {type(e)}", e)
+ if is_warning_enabled:
+ data = {"!": data}
+ # dict_string = kajson.dumps(data, indent=indent, default=str)
+ dict_string = json.dumps(data, indent=indent, default=str)
+ pure_dict = json.loads(dict_string)
+ return pure_dict, dict_string
+
+
+def purify_json_list(data: List[Any], indent: Optional[int] = None) -> Tuple[List[Any], str]:
+ """
+ Converts a list of Python objects into a JSON-serializable list and its string representation.
+
+ This function specifically handles lists and provides specialized processing for lists of
+ Pydantic BaseModel instances. It attempts multiple serialization methods to ensure successful
+ conversion.
+
+ Args:
+ data (List[Any]): The list to convert. Can contain Pydantic models or other types.
+ indent (Optional[int], optional): Number of spaces for JSON formatting indentation.
+ Defaults to None.
+
+ Returns:
+ Tuple[List[Any], str]: A tuple containing:
+ - The purified list with JSON-serializable elements
+ - The JSON string representation of the list
+
+ Example:
+ >>> models = [SomeModel(name="test1"), SomeModel(name="test2")]
+ >>> data, json_str = purify_json_list(models)
+ >>> print(json_str)
+ '[{"name": "test1"}, {"name": "test2"}]'
+ """
+ list_string: str
+ pure_list: List[Any]
+
+ if not data:
+ return [], "[]"
+ if isinstance(data[0], BaseModel):
+ the_list_of_base_models: List[BaseModel] = data
+ pure_list = [item.model_dump(serialize_as_any=True) for item in the_list_of_base_models]
+ list_string = json.dumps(pure_list, indent=indent, default=str)
+ return pure_list, list_string
+
+ try:
+ list_string = json.dumps(data, indent=indent)
+ pure_list = data
+ except TypeError:
+ try:
+ list_string = kajson.dumps(data, indent=indent) # pyright: ignore[reportUnknownMemberType]
+ except Exception:
+ # print(f"Error: type {type(e)}", e)
+ list_string = json.dumps(data, indent=indent, default=str)
+ pure_list = json.loads(list_string)
+ return pure_list, list_string
+
+
+def purify_json_dict(data: Any, indent: Optional[int] = None, is_warning_enabled: bool = True) -> Tuple[Dict[str, Any], str]:
+ """
+ Converts any Python object into a JSON-serializable dictionary and its string representation.
+
+ This function specifically handles dictionary-like objects and Pydantic BaseModel instances,
+ converting them to pure dictionaries that can be JSON serialized. It includes multiple
+ fallback mechanisms for handling non-standard JSON types.
+
+ Args:
+ data (Any): The data to convert. Can be a Pydantic model or dictionary-like object.
+ indent (Optional[int], optional): Number of spaces for JSON formatting indentation.
+ Defaults to None.
+ is_warning_enabled (bool, optional): If True, wraps non-serializable data in a warning
+ object with a "!" key. Defaults to True.
+
+ Returns:
+ Tuple[Dict[str, Any], str]: A tuple containing:
+ - The purified dictionary with JSON-serializable values
+ - The JSON string representation of the dictionary
+
+ Raises:
+ ArgumentTypeError: If the input data is a list instead of a dictionary-like object.
+
+ Example:
+ >>> model = SomeModel(name="test", value=123)
+ >>> data, json_str = purify_json_dict(model)
+ >>> print(json_str)
+ '{"name": "test", "value": 123}'
+ """
+ dict_string: str
+ if isinstance(data, BaseModel):
+ return purify_json_dict(
+ data.model_dump(serialize_as_any=True),
+ indent=indent,
+ is_warning_enabled=is_warning_enabled,
+ )
+
+ if isinstance(data, list):
+ raise ArgumentTypeError("The data is a list, not a dict")
+
+ try:
+ dict_string = json.dumps(data, indent=indent)
+ pure_dict: Dict[str, Any] = data
+ except TypeError:
+ try:
+ dict_string = kajson.dumps(data, indent=indent) # pyright: ignore[reportUnknownMemberType]
+ except Exception:
+ # print(f"Error: type {type(e)}", e)
+ if is_warning_enabled:
+ data = {"!": data}
+ # dict_string = kajson.dumps(data, indent=indent, default=str)
+ dict_string = json.dumps(data, indent=indent, default=str)
+ pure_dict = json.loads(dict_string)
+ return pure_dict, dict_string
+
+
+def pure_json_str(data: Any, indent: Optional[int] = None, is_warning_enabled: bool = True) -> str:
+ """
+ Converts any Python object directly to its JSON string representation.
+
+ This is a convenience wrapper around purify_json that returns only the string
+ representation, discarding the intermediate data structure. It inherits all the
+ type handling capabilities of purify_json.
+
+ Args:
+ data (Any): The data to convert to a JSON string. Can be any type supported
+ by purify_json.
+ indent (Optional[int], optional): Number of spaces for JSON formatting indentation.
+ Defaults to None.
+ is_warning_enabled (bool, optional): If True, wraps non-serializable data in a
+ warning object. Defaults to True.
+
+ Returns:
+ str: The JSON string representation of the data.
+
+ Example:
+ >>> model = SomeModel(name="test")
+ >>> json_str = pure_json_str(model, indent=2)
+ >>> print(json_str)
+ '{
+ "name": "test"
+ }'
+ """
+ _, json_string = purify_json(data, indent=indent, is_warning_enabled=is_warning_enabled)
+ return json_string
diff --git a/pipelex/tools/misc/markdown_utils.py b/pipelex/tools/misc/markdown_utils.py
new file mode 100644
index 000000000..0eed92341
--- /dev/null
+++ b/pipelex/tools/misc/markdown_utils.py
@@ -0,0 +1,65 @@
+from typing import Any, Dict, List
+
+from pipelex.tools.misc.json_utils import purify_json_dict
+from pipelex.tools.misc.string_utils import snake_to_capitalize_first_letter
+
+
+def convert_to_markdown(data: Any, level: int = 1, is_pretty: bool = False) -> str:
+ """
+ Convert arbitrary JSON-compatible Python data to a Markdown string
+ without needing to specify the markdown type explicitly.
+ """
+ if isinstance(data, dict):
+ the_dict: Dict[str, Any] = data
+ # Treat keys as headings and values as their content
+ dict_result_lines: List[str] = []
+ for key, value in the_dict.items():
+ heading_prefix = "#" * min(level, 6) # Limit heading levels to 6
+ # Use the key as a heading
+ if is_pretty:
+ converted_line = f"{heading_prefix} {snake_to_capitalize_first_letter(key)}"
+ else:
+ converted_line = f"{heading_prefix} {key}"
+ # Convert the value recursively, increasing the heading level
+ # dict_result_lines.append(convert_to_markdown(data=value, level=level + 1))
+ converted_value = convert_to_markdown(data=value, level=level + 1)
+ converted_value_nb_lines = len(converted_value.split("\n"))
+ if converted_value_nb_lines > 1:
+ dict_result_lines.append(converted_line)
+ dict_result_lines.append(converted_value)
+ else:
+ dict_result_lines.append(f"{converted_line}: {converted_value}")
+ return "\n\n".join(line for line in dict_result_lines if line.strip())
+
+ elif isinstance(data, list):
+ # Treat lists as bullet lists. If list items are complex,
+ # they get recursively converted. If they are simple strings,
+ # they become list items.
+ if not data:
+ return ""
+ the_list: List[Any] = data
+ list_result_lines: List[str] = []
+ for item in the_list:
+ # Convert the item first
+ item_md = convert_to_markdown(item, level=level)
+ # If the item is multiline, indent it, else just place it as a bullet
+ lines = item_md.split("\n")
+ # The first line as a bullet point
+ first_line = f"- {lines[0]}"
+ subsequent_lines = [f" {line}" for line in lines[1:] if line.strip()]
+ list_result_lines.append(first_line)
+ list_result_lines.extend(subsequent_lines)
+ return "\n".join(list_result_lines)
+
+ elif isinstance(data, (str, int, float, bool)):
+ # Simple scalar types become paragraphs (strings) or inline text
+ # If it's a string with multiple lines, just output them as-is.
+ return str(data)
+
+ elif data is None:
+ # No value
+ return "None"
+
+ else:
+ pure_dict, _ = purify_json_dict(data, is_warning_enabled=False)
+ return convert_to_markdown(pure_dict, level=level)
diff --git a/pipelex/tools/misc/mermaid_utils.py b/pipelex/tools/misc/mermaid_utils.py
new file mode 100644
index 000000000..0afe479be
--- /dev/null
+++ b/pipelex/tools/misc/mermaid_utils.py
@@ -0,0 +1,50 @@
+import base64
+import json
+import zlib
+
+from pipelex import pretty_print
+
+
+def encode_pako_encore_from_bytes(state_bytes: bytes) -> str:
+ compressed = zlib.compress(state_bytes, level=9)
+ serialized_string = base64.urlsafe_b64encode(compressed).decode("utf-8")
+ return f"pako:{serialized_string}"
+
+
+def encode_pako_from_string(state: str) -> str:
+ state_bytes = state.encode("utf-8")
+ return encode_pako_encore_from_bytes(state_bytes)
+
+
+def make_mermaid_url(mermaid_code: str) -> str:
+ as_dict = {
+ "code": mermaid_code,
+ "mermaid": {
+ "theme": "default",
+ },
+ }
+ encoded = encode_pako_from_string(json.dumps(as_dict))
+ url = f"https://mermaid.live/edit#{encoded}"
+ return url
+
+
+def clean_str_for_mermaid_node_title(text: str) -> str:
+ """
+ Cleans a string to be safely used as a Mermaid node title by replacing quotes
+ with similar Unicode characters that won't interfere with Mermaid syntax.
+
+ Args:
+ text: The string to clean
+
+ Returns:
+ The cleaned string with quotes replaced
+ """
+ # Replace single and double quotes with similar Unicode characters
+ text = text.replace('"', "″") # Replace with prime symbol
+ text = text.replace("'", "′") # Replace with curly quote
+ return text
+
+
+def print_mermaid_url(url: str, title: str):
+ pretty_print("⚠️ Warning: By clicking on the following mermaid URL, you send data to https://mermaid.live/.", border_style="red")
+ pretty_print(url, title=title, border_style="yellow")
diff --git a/pipelex/tools/misc/path_utils.py b/pipelex/tools/misc/path_utils.py
new file mode 100644
index 000000000..8eaf78a87
--- /dev/null
+++ b/pipelex/tools/misc/path_utils.py
@@ -0,0 +1,112 @@
+import os
+import urllib.parse
+from enum import StrEnum
+from typing import Optional, Tuple
+
+
+class InterpretedPathOrUrl(StrEnum):
+ FILE_URI = "file_uri"
+ FILE_PATH = "file_path"
+ URL = "uri"
+ FILE_NAME = "file_name"
+ BASE_64 = "base_64"
+
+ @property
+ def desc(self) -> str:
+ match self:
+ case InterpretedPathOrUrl.FILE_URI:
+ return "File URI"
+ case InterpretedPathOrUrl.FILE_PATH:
+ return "File Path"
+ case InterpretedPathOrUrl.URL:
+ return "URL"
+ case InterpretedPathOrUrl.FILE_NAME:
+ return "File Name"
+ case InterpretedPathOrUrl.BASE_64:
+ return "Base 64"
+
+
+def interpret_path_or_url(path_or_uri: str) -> InterpretedPathOrUrl:
+ """
+ Determines whether a string represents a file URI, URL, or file path.
+
+ This function analyzes the input string to categorize it as one of three types:
+ - File URI (starts with "file://")
+ - URL (starts with "http")
+ - File path (anything else)
+
+ Args:
+ path_or_uri (str): The string to interpret, which could be a file URI,
+ URL, or file path.
+
+ Returns:
+ InterpretedPathOrUrl: An enum value indicating the type of the input string:
+ - FILE_URI for file:// URIs
+ - FILE_PATH for everything else
+ - URL for http(s) URLs
+ - FILE_NAME for file names
+ - BASE_64 for base64-encoded images
+
+ Example:
+ >>> interpret_path_or_url("file:///home/user/file.txt")
+ InterpretedPathOrUrl.FILE_URI
+ >>> interpret_path_or_url("https://example.com")
+ InterpretedPathOrUrl.URL
+ >>> interpret_path_or_url("/home/user/file.txt")
+ InterpretedPathOrUrl.FILE_PATH
+ """
+ if path_or_uri.startswith("file://"):
+ return InterpretedPathOrUrl.FILE_URI
+ elif path_or_uri.startswith("http"):
+ return InterpretedPathOrUrl.URL
+ elif os.sep in path_or_uri:
+ return InterpretedPathOrUrl.FILE_PATH
+ else:
+ return InterpretedPathOrUrl.FILE_NAME
+
+
+def clarify_path_or_url(path_or_uri: str) -> Tuple[Optional[str], Optional[str]]:
+ """
+ Separates a path_or_uri string into either a file path or online URL component.
+
+ This function processes the input string to determine its type and returns
+ the appropriate components. For file URIs, it converts them to regular file paths.
+ Only one of the returned values will be non-None.
+
+ Args:
+ path_or_uri (str): The string to process, which could be a file URI,
+ URL, or file path.
+
+ Returns:
+ Tuple[Optional[str], Optional[str]]: A tuple containing:
+ - file_path: The file path if the input is a file path or URI, None otherwise
+ - url: The URL if the input is a URL, None otherwise
+
+ Example:
+ >>> clarify_path_or_url("file:///home/user/file.txt")
+ ('/home/user/file.txt', None)
+ >>> clarify_path_or_url("https://example.com")
+ (None, 'https://example.com')
+ >>> clarify_path_or_url("/home/user/file.txt")
+ ('/home/user/file.txt', None)
+ """
+ file_path: Optional[str]
+ url: Optional[str]
+ match interpret_path_or_url(path_or_uri):
+ case InterpretedPathOrUrl.FILE_URI:
+ parsed_uri = urllib.parse.urlparse(path_or_uri)
+ file_path = urllib.parse.unquote(parsed_uri.path)
+ url = None
+ case InterpretedPathOrUrl.URL:
+ file_path = None
+ url = path_or_uri
+ case InterpretedPathOrUrl.FILE_PATH:
+ # it's a file path
+ file_path = path_or_uri
+ url = None
+ case InterpretedPathOrUrl.FILE_NAME:
+ file_path = path_or_uri
+ url = None
+ case InterpretedPathOrUrl.BASE_64:
+ raise NotImplementedError("Base 64 is not supported yet by clarify_path_or_url")
+ return file_path, url
diff --git a/pipelex/tools/misc/pretty.py b/pipelex/tools/misc/pretty.py
new file mode 100644
index 000000000..b671c6d52
--- /dev/null
+++ b/pipelex/tools/misc/pretty.py
@@ -0,0 +1,111 @@
+import shutil
+from typing import Any, List, Optional, Union
+
+from kajson.sandbox_manager import sandbox_manager
+from rich import print as rich_print
+from rich.panel import Panel
+from rich.pretty import Pretty
+from rich.style import StyleType
+from rich.text import Text, TextType
+
+from pipelex.tools.misc.terminal_utils import BOLD_FONT, RESET_FONT, TerminalColor
+
+TEXT_COLOR = TerminalColor.WHITE
+TITLE_COLOR = TerminalColor.CYAN
+BORDER_COLOR = TerminalColor.YELLOW
+
+
+def pretty_print(
+ content: Union[str, Any],
+ title: Optional[TextType] = None,
+ subtitle: Optional[TextType] = None,
+ border_style: Optional[StyleType] = None,
+):
+ if sandbox_manager.is_in_sandbox():
+ # we are in a sandbox, so we can't use rich
+ pretty_print_in_sandbox(content=content, title=title, subtitle=subtitle)
+ else:
+ pretty_print_using_rich(content=content, title=title, subtitle=subtitle, border_style=border_style)
+
+
+def pretty_print_using_rich(
+ content: Union[str, Any],
+ title: Optional[TextType] = None,
+ subtitle: Optional[TextType] = None,
+ border_style: Optional[StyleType] = None,
+):
+ if isinstance(content, str):
+ if content.startswith(("http://", "https://")):
+ content = Text(content, style="link " + content, no_wrap=True)
+ else:
+ content = Text(str(content)) # Treat all other strings as plain text
+ else:
+ content = Pretty(content)
+ panel = Panel(
+ content,
+ title=title,
+ subtitle=subtitle,
+ expand=False,
+ title_align="left",
+ subtitle_align="right",
+ padding=(0, 1),
+ border_style=border_style or "",
+ )
+ rich_print(panel)
+
+
+def pretty_print_in_sandbox(
+ content: Union[str, Any],
+ title: Optional[TextType] = None,
+ subtitle: Optional[TextType] = None,
+):
+ if isinstance(content, str) and content.startswith(("http://", "https://")):
+ pretty_print_url_in_sandbox(content=content, title=title, subtitle=subtitle)
+ return
+ title = title or ""
+ if subtitle:
+ title += f" ({subtitle})"
+ terminal_width = shutil.get_terminal_size().columns
+ content_str = f"{content}"
+ max_content_width = terminal_width - len(title) - 8 # Accounting for frame and padding
+ wrapped_lines: List[str] = []
+ for line in content_str.splitlines():
+ while len(line) > max_content_width:
+ wrapped_lines.append(line[:max_content_width])
+ line = line[max_content_width:]
+ wrapped_lines.append(line)
+
+ if not wrapped_lines:
+ wrapped_lines.append("")
+
+ frame_width = max(len(title) + 6, max(len(line) for line in wrapped_lines) + 6)
+ top_border = "╭" + "─" * (frame_width - 2) + "╮"
+ bottom_border = "╰" + "─" * (frame_width - 2) + "╯"
+
+ print(f"{BORDER_COLOR}{top_border}{RESET_FONT}")
+ if title:
+ print(f"{BORDER_COLOR}│ {BOLD_FONT}{TITLE_COLOR}{title}{RESET_FONT}:{' ' * (frame_width - len(title) - 4)}{BORDER_COLOR}│{RESET_FONT}")
+ for line in wrapped_lines:
+ padding = " " * (frame_width - len(line) - 3)
+ print(f"{BORDER_COLOR}│ {TEXT_COLOR}{line}{RESET_FONT}{padding}{BORDER_COLOR}│{RESET_FONT}")
+ print(f"{BORDER_COLOR}{bottom_border}{RESET_FONT}")
+
+
+def pretty_print_url_in_sandbox(
+ content: Union[str, Any],
+ title: Optional[TextType] = None,
+ subtitle: Optional[TextType] = None,
+):
+ title = title or ""
+ if subtitle:
+ title += f" ({subtitle})"
+ terminal_width = shutil.get_terminal_size().columns
+ frame_width = terminal_width - 2
+ top_border = "╭" + "─" * (frame_width - 2) + "╮"
+ bottom_border = "╰" + "─" * (frame_width - 2) + "╯"
+
+ print(f"{BORDER_COLOR}{top_border}{RESET_FONT}")
+ if title:
+ print(f"{BORDER_COLOR}│ {BOLD_FONT}{TITLE_COLOR}{title}{RESET_FONT}:{' ' * (frame_width - len(title) - 4)}{BORDER_COLOR}│{RESET_FONT}")
+ print(f"{TEXT_COLOR}{content}{RESET_FONT}")
+ print(f"{BORDER_COLOR}{bottom_border}{RESET_FONT}")
diff --git a/pipelex/tools/misc/string_utils.py b/pipelex/tools/misc/string_utils.py
new file mode 100644
index 000000000..671b52d6e
--- /dev/null
+++ b/pipelex/tools/misc/string_utils.py
@@ -0,0 +1,198 @@
+import re
+from typing import Any, List, Optional
+
+
+def has_text(text: str) -> bool:
+ """
+ Checks if a string contains any alphanumeric characters.
+
+ This function uses a regex pattern to check for the presence of any alphanumeric
+ character, including non-ASCII characters (e.g., é, ñ, etc.).
+
+ Args:
+ text (str): The string to check for alphanumeric content.
+
+ Returns:
+ bool: True if the string contains at least one alphanumeric character, False otherwise.
+ """
+ return bool(re.search(r"\w", text))
+
+
+def is_none_or_has_text(text: Optional[str]) -> bool:
+ """
+ Checks if a string is None or contains alphanumeric characters.
+
+ This function combines a None check with the has_text function to validate that
+ a string is either None or contains meaningful content.
+
+ Args:
+ text (Optional[str]): The string to check, which can be None.
+
+ Returns:
+ bool: True if the string is None or contains at least one alphanumeric character,
+ False if it's an empty string or contains only non-alphanumeric characters.
+ """
+ return text is None or has_text(text)
+
+
+def can_inject_text(value: Optional[Any]) -> bool:
+ """
+ Checks if a value can be safely converted to a string containing alphanumeric characters.
+
+ This function attempts to convert any value to a string and checks if it contains
+ alphanumeric characters. It handles None values and exceptions gracefully, making it
+ safe for type-uncertain inputs.
+
+ Args:
+ value (Optional[Any]): Any value that might be convertible to a string, including None.
+
+ Returns:
+ bool: True if the value can be converted to a string containing alphanumeric characters,
+ False if the value is None, empty, or cannot be safely converted to a string.
+ """
+ if not value:
+ return False
+ try:
+ return has_text(f"{value}")
+ except Exception:
+ return False
+
+
+def is_not_none_and_has_text(text: Optional[str]) -> bool:
+ """
+ Checks if a string is not None and contains alphanumeric characters.
+
+ This function combines a None check with the has_text function to validate that
+ a string exists and contains meaningful content. It's the opposite of is_none_or_has_text.
+
+ Args:
+ text (Optional[str]): The string to check, which can be None.
+
+ Returns:
+ bool: True if the string is not None and contains at least one alphanumeric character,
+ False if it's None, empty, or contains only non-alphanumeric characters.
+ """
+ return text is not None and has_text(text)
+
+
+def camel_to_snake_case(name: str) -> str:
+ """
+ Converts a camelCase string to snake_case format.
+
+ This function identifies word boundaries in camelCase by looking for transitions
+ between lowercase and uppercase letters, then joins the words with underscores.
+
+ Args:
+ name (str): The camelCase string to convert (e.g., "myVariableName").
+
+ Returns:
+ str: The snake_case version of the string (e.g., "my_variable_name").
+
+ Example:
+ >>> camel_to_snake_case("thisIsATest")
+ 'this_is_a_test'
+ """
+ s1 = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", name)
+ return re.sub("([a-z0-9])([A-Z])", r"\1_\2", s1).lower()
+
+
+def pascal_case_to_snake_case(name: str) -> str:
+ """
+ Converts a PascalCase string to snake_case format.
+
+ This function is a wrapper around camel_to_snake_case, as the same conversion
+ rules apply to both PascalCase and camelCase strings.
+
+ Args:
+ name (str): The PascalCase string to convert (e.g., "MyVariableName").
+
+ Returns:
+ str: The snake_case version of the string (e.g., "my_variable_name").
+
+ Example:
+ >>> pascal_case_to_snake_case("ThisIsATest")
+ 'this_is_a_test'
+ """
+ return camel_to_snake_case(name=name)
+
+
+def pascal_case_to_sentence(name: str) -> str:
+ """
+ Converts a PascalCase string to a capitalized sentence.
+
+ This function splits a PascalCase string at word boundaries and spaces.
+ - Preserves fully uppercase words (e.g., "BOB", "JSON")
+ - Converts PascalCase components to lowercase (e.g., "LowKey" -> "low key")
+
+ Args:
+ name (str): The string to convert (e.g., "ThisIsATest" or "BOB LowKey").
+
+ Returns:
+ str: The formatted string with preserved uppercase words (e.g., "BOB low key").
+
+ Example:
+ >>> pascal_case_to_sentence("HelloWorld")
+ 'Hello world'
+ >>> pascal_case_to_sentence("BOB LowKey")
+ 'BOB low key'
+ >>> pascal_case_to_sentence("ParseJSONData")
+ 'Parse JSON data'
+ """
+ # First split by spaces
+ space_parts: List[str] = name.split()
+ result_parts: List[str] = []
+
+ for part in space_parts:
+ if part.isupper():
+ # Preserve fully uppercase words
+ result_parts.append(part)
+ else:
+ # Handle PascalCase parts
+ words: List[str] = re.findall(r"([A-Z][a-z]+|[A-Z]{2,}(?=[A-Z][a-z]|\d|\W|$)|[A-Z]{2,}|[0-9]+)", part)
+ processed_words: List[str] = [word if word.isupper() else word.lower() for word in words]
+ result_parts.append(" ".join(processed_words))
+
+ return " ".join(result_parts).capitalize()
+
+
+def snake_to_pascal_case(snake_str: str) -> str:
+ """
+ Converts a snake_case string to PascalCase format.
+
+ This function splits the string at underscores, capitalizes the first letter
+ of each component, and joins them together without separators.
+
+ Args:
+ snake_str (str): The snake_case string to convert (e.g., "my_variable_name").
+
+ Returns:
+ str: The PascalCase version of the string (e.g., "MyVariableName").
+
+ Example:
+ >>> snake_to_pascal_case("hello_world")
+ 'HelloWorld'
+ """
+ components = snake_str.split("_")
+ return "".join(x.title() for x in components)
+
+
+def snake_to_capitalize_first_letter(snake_str: str) -> str:
+ """
+ Converts a snake_case string to a space-separated string with the first letter capitalized.
+
+ This function splits the string at underscores, joins the components with spaces,
+ and capitalizes only the first letter of the entire string.
+
+ Args:
+ snake_str (str): The snake_case string to convert (e.g., "hello_world").
+
+ Returns:
+ str: The space-separated string with first letter capitalized (e.g., "Hello world").
+
+ Example:
+ >>> snake_to_capitalize_first_letter("this_is_a_test")
+ 'This is a test'
+ """
+ components = snake_str.split("_")
+ phrase = " ".join(components)
+ return phrase.capitalize()
diff --git a/pipelex/tools/misc/terminal_utils.py b/pipelex/tools/misc/terminal_utils.py
new file mode 100644
index 000000000..ebaa4ba15
--- /dev/null
+++ b/pipelex/tools/misc/terminal_utils.py
@@ -0,0 +1,14 @@
+from enum import StrEnum
+
+BOLD_FONT = "\033[1m"
+RESET_FONT = "\033[0m"
+
+
+class TerminalColor(StrEnum):
+ RED = "\033[0;31m"
+ GREEN = "\033[0;32m"
+ BLUE = "\033[0;34m"
+ WHITE = "\033[0;37m"
+ CYAN = "\033[0;36m"
+ MAGENTA = "\033[0;35m"
+ YELLOW = "\033[0;33m"
diff --git a/pipelex/tools/misc/toml_utils.py b/pipelex/tools/misc/toml_utils.py
new file mode 100644
index 000000000..6bacd4091
--- /dev/null
+++ b/pipelex/tools/misc/toml_utils.py
@@ -0,0 +1,17 @@
+from typing import Any, Dict, Optional
+
+import toml
+
+from pipelex.tools.misc.file_utils import path_exists
+
+
+def load_toml_from_path(path: str) -> Dict[str, Any]:
+ with open(path) as file:
+ dict_from_toml = toml.load(file)
+ return dict_from_toml
+
+
+def failable_load_toml_from_path(path: str) -> Optional[Dict[str, Any]]:
+ if not path_exists(path):
+ return None
+ return load_toml_from_path(path)
diff --git a/pipelex/tools/pdf/__init__.py b/pipelex/tools/pdf/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/pipelex/tools/pdf/__init__.py
@@ -0,0 +1 @@
+
diff --git a/pipelex/tools/pdf/pypdfium2_renderer.py b/pipelex/tools/pdf/pypdfium2_renderer.py
new file mode 100644
index 000000000..8917c7702
--- /dev/null
+++ b/pipelex/tools/pdf/pypdfium2_renderer.py
@@ -0,0 +1,74 @@
+from __future__ import annotations
+
+import asyncio
+import pathlib
+from typing import List
+
+import pypdfium2 as pdfium
+from PIL import Image
+from pypdfium2.raw import FPDFBitmap_BGRA
+
+from pipelex.tools.exceptions import ToolException
+from pipelex.tools.misc.file_fetch_utils import fetch_file_from_url_httpx_async
+from pipelex.tools.misc.path_utils import clarify_path_or_url
+
+
+class PyPdfium2RendererError(ToolException):
+ pass
+
+
+PdfInput = str | pathlib.Path | bytes
+
+
+class PyPdfium2Renderer:
+ """
+ Thread-safe PDF page renderer built on pypdfium2.
+
+ • All entry into the native PDFium library is protected by a single
+ asyncio.Lock, so the enclosing *process* is safe even if other
+ libraries spin up worker threads.
+
+ • Heavy work runs inside `asyncio.to_thread`, keeping the event-loop
+ responsive for the rest of your application.
+ """
+
+ _pdfium_lock: asyncio.Lock = asyncio.Lock() # shared per process
+
+ # ---- internal blocking helper ------------------------------------
+ @staticmethod
+ def _render_pdf_pages_sync(pdf_input: PdfInput, dpi: float = 300) -> List[Image.Image]:
+ pdf_doc = pdfium.PdfDocument(pdf_input)
+ images: List[Image.Image] = []
+ for index in range(len(pdf_doc)):
+ # page = doc.get_page(index)
+ page = pdf_doc[index]
+
+ pil_img: Image.Image = page.render( # pyright: ignore[reportUnknownMemberType, reportUnknownVariableType]
+ scale=dpi / 72, # pyright: ignore[reportArgumentType]
+ force_bitmap_format=FPDFBitmap_BGRA, # always 4-channel
+ rev_byteorder=True, # so we get RGBA
+ ).to_pil()
+
+ images.append(pil_img) # pyright: ignore[reportUnknownArgumentType]
+ page.close()
+ pdf_doc.close()
+ return images
+
+ # ---- public async façade -----------------------------------------
+ async def render_pdf_pages(self, pdf_input: PdfInput, dpi: int = 300) -> List[Image.Image]:
+ """Render *one* page and return PNG bytes."""
+ async with self._pdfium_lock:
+ return await asyncio.to_thread(self._render_pdf_pages_sync, pdf_input, dpi)
+
+ async def render_pdf_pages_from_uri(self, pdf_uri: str, dpi: int = 300) -> List[Image.Image]:
+ pdf_path, pdf_url = clarify_path_or_url(path_or_uri=pdf_uri) # pyright: ignore
+ if pdf_url:
+ pdf_bytes = await fetch_file_from_url_httpx_async(url=pdf_url)
+ return await self.render_pdf_pages(pdf_input=pdf_bytes, dpi=dpi)
+ elif pdf_path:
+ return await self.render_pdf_pages(pdf_input=pdf_path, dpi=dpi)
+ else:
+ raise PyPdfium2RendererError(f"Invalid PDF URI: {pdf_uri}")
+
+
+pypdfium2_renderer = PyPdfium2Renderer()
diff --git a/pipelex/tools/registry_models.py b/pipelex/tools/registry_models.py
new file mode 100644
index 000000000..d4f175d5f
--- /dev/null
+++ b/pipelex/tools/registry_models.py
@@ -0,0 +1,27 @@
+from typing import Any, Callable, List, Set, Type
+
+from pydantic import BaseModel
+
+ModelType = Type[BaseModel]
+
+
+class RegistryModels:
+ @classmethod
+ def get_all_models(cls) -> List[ModelType]:
+ model_lists: List[List[ModelType]] = [getattr(cls, attr) for attr in dir(cls) if isinstance(getattr(cls, attr), list)]
+ all_models: Set[ModelType] = set()
+ for model_list in model_lists:
+ all_models.update(model_list)
+
+ return list(all_models)
+
+
+class RegistryFuncs:
+ @classmethod
+ def get_all_functions(cls) -> List[Callable[..., Any]]:
+ functions: List[Callable] = [] # pyright: ignore[reportMissingTypeArgument, reportUnknownVariableType]
+ for attr in dir(cls):
+ attr_value = getattr(cls, attr)
+ if callable(attr_value):
+ functions.append(attr_value) # pyright: ignore[reportUnknownMemberType]
+ return functions # pyright: ignore[reportUnknownVariableType]
diff --git a/pipelex/tools/runtime_manager.py b/pipelex/tools/runtime_manager.py
new file mode 100644
index 000000000..56a2309c6
--- /dev/null
+++ b/pipelex/tools/runtime_manager.py
@@ -0,0 +1,94 @@
+from enum import StrEnum
+from typing import Optional
+
+from pydantic import BaseModel
+
+from pipelex.tools.environment import get_optional_env
+
+RUN_MODE_ENV_VAR_KEY = "RUN_MODE"
+
+
+class RunMode(StrEnum):
+ NORMAL = "normal"
+ UNIT_TEST = "unit_test"
+
+ @classmethod
+ def get_from_env_var(cls) -> "RunMode":
+ if mode_str := get_optional_env(RUN_MODE_ENV_VAR_KEY):
+ return RunMode(mode_str)
+ else:
+ return RunMode.NORMAL
+
+
+class WorkerMode(StrEnum):
+ """
+ Used for external worker, note that it can be run "for unit tests" even if it's not a unit test.
+ """
+
+ NORMAL = "normal"
+ UNIT_TEST = "unit_test"
+
+
+class RunEnvironment(StrEnum):
+ LOCAL = "local"
+ DEV = "dev"
+ STAGING = "staging"
+ PROD = "prod"
+
+ @classmethod
+ def get_from_env_var(cls) -> "RunEnvironment":
+ return RunEnvironment(get_optional_env("ENV") or RunEnvironment.DEV)
+
+
+class ProblemReaction(StrEnum):
+ NONE = "none"
+ LOG = "log"
+ RAISE = "raise"
+
+
+class ProblemReactions(BaseModel):
+ template_inputs: ProblemReaction
+ prompt_templates: ProblemReaction
+ job: ProblemReaction
+
+
+class RuntimeManager(BaseModel):
+ _environment: RunEnvironment = RunEnvironment.get_from_env_var()
+ _run_mode: RunMode = RunMode.get_from_env_var()
+ _worker_mode: Optional[WorkerMode] = None
+
+ problem_reactions: ProblemReactions = ProblemReactions(
+ template_inputs=ProblemReaction.LOG,
+ prompt_templates=ProblemReaction.LOG,
+ job=ProblemReaction.LOG,
+ )
+
+ def set_run_mode(self, run_mode: RunMode):
+ self._run_mode = run_mode
+ # print(f"Set run mode to '{run_mode}'")
+
+ def set_worker_mode(self, worker_mode: WorkerMode):
+ self._worker_mode = worker_mode
+
+ @property
+ def environment(self) -> RunEnvironment:
+ return self._environment
+
+ @property
+ def run_mode(self) -> RunMode:
+ return self._run_mode
+
+ @property
+ def worker_mode(self) -> Optional[WorkerMode]:
+ return self._worker_mode
+
+ @property
+ def is_unit_testing(self) -> bool:
+ return self.run_mode == RunMode.UNIT_TEST
+
+ @property
+ def should_check_intermediate_configs(self) -> bool:
+ return self.is_unit_testing
+
+
+runtime_manager = RuntimeManager()
diff --git a/pipelex/tools/secrets/__init__.py b/pipelex/tools/secrets/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/pipelex/tools/secrets/__init__.py
@@ -0,0 +1 @@
+
diff --git a/pipelex/tools/secrets/env_secrets_provider.py b/pipelex/tools/secrets/env_secrets_provider.py
new file mode 100644
index 000000000..dc12a9a8a
--- /dev/null
+++ b/pipelex/tools/secrets/env_secrets_provider.py
@@ -0,0 +1,32 @@
+from typing import Optional
+
+from typing_extensions import override
+
+from pipelex.tools.environment import EnvVarNotFoundError, get_optional_env, get_required_env
+from pipelex.tools.secrets.secrets_errors import SecretNotFoundError
+from pipelex.tools.secrets.secrets_provider_abstract import SecretsProviderAbstract
+
+
+class EnvSecretsProvider(SecretsProviderAbstract):
+ @override
+ def get_required_secret(self, secret_id: str) -> str:
+ try:
+ return get_required_env(key=secret_id)
+ except EnvVarNotFoundError as exc:
+ raise SecretNotFoundError(f"Secret '{secret_id}' not found") from exc
+
+ @override
+ def get_optional_secret(self, secret_id: str) -> Optional[str]:
+ return get_optional_env(key=secret_id)
+
+ @override
+ def get_required_secret_specific_version(self, secret_id: str, version_id: str) -> str:
+ raise NotImplementedError("EnvSecretsProvider does not support specific versions")
+
+ @override
+ def get_optional_secret_specific_version(self, secret_id: str, version_id: str) -> Optional[str]:
+ raise NotImplementedError("EnvSecretsProvider does not support specific versions")
+
+ @override
+ def set_secret_as_env_var(self, secret_id: str, version_id: str = "latest"):
+ pass
diff --git a/pipelex/tools/secrets/secrets_errors.py b/pipelex/tools/secrets/secrets_errors.py
new file mode 100644
index 000000000..0f39641ab
--- /dev/null
+++ b/pipelex/tools/secrets/secrets_errors.py
@@ -0,0 +1,5 @@
+from pipelex.tools.exceptions import ToolException
+
+
+class SecretNotFoundError(ToolException):
+ pass
diff --git a/pipelex/tools/secrets/secrets_provider_abstract.py b/pipelex/tools/secrets/secrets_provider_abstract.py
new file mode 100644
index 000000000..a5ce8ca94
--- /dev/null
+++ b/pipelex/tools/secrets/secrets_provider_abstract.py
@@ -0,0 +1,24 @@
+from abc import ABC, abstractmethod
+from typing import Optional
+
+LATEST_SECRET_VERSION_NAME = "latest"
+
+
+class SecretsProviderAbstract(ABC):
+ @abstractmethod
+ def get_required_secret(self, secret_id: str) -> str: ...
+
+ @abstractmethod
+ def get_optional_secret(self, secret_id: str) -> Optional[str]: ...
+
+ @abstractmethod
+ def get_required_secret_specific_version(self, secret_id: str, version_id: str) -> str: ...
+
+ @abstractmethod
+ def get_optional_secret_specific_version(self, secret_id: str, version_id: str) -> Optional[str]: ...
+
+ @abstractmethod
+ def set_secret_as_env_var(self, secret_id: str, version_id: str = LATEST_SECRET_VERSION_NAME): ...
+
+ def get_secret(self, secret_id: str) -> str:
+ return self.get_required_secret(secret_id=secret_id)
diff --git a/pipelex/tools/templating/__init__.py b/pipelex/tools/templating/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/pipelex/tools/templating/__init__.py
@@ -0,0 +1 @@
+
diff --git a/pipelex/tools/templating/jinja2_environment.py b/pipelex/tools/templating/jinja2_environment.py
new file mode 100644
index 000000000..6d513780a
--- /dev/null
+++ b/pipelex/tools/templating/jinja2_environment.py
@@ -0,0 +1,82 @@
+from typing import Tuple
+
+from jinja2 import BaseLoader, Environment, PackageLoader
+
+from pipelex.tools.templating.jinja2_template_category import Jinja2TemplateCategory
+from pipelex.tools.templating.jinja2_template_loader import Jinja2TemplateLoader
+from pipelex.tools.templating.template_provider_abstract import TemplateProviderAbstract
+
+
+def make_jinja2_env_from_loader(
+ template_category: Jinja2TemplateCategory,
+ loader: BaseLoader,
+) -> Environment:
+ match template_category:
+ case Jinja2TemplateCategory.HTML:
+ jinja2_env = Environment(
+ loader=loader,
+ enable_async=True,
+ autoescape=False,
+ trim_blocks=True,
+ lstrip_blocks=True,
+ )
+ case Jinja2TemplateCategory.MARKDOWN:
+ jinja2_env = Environment(
+ loader=loader,
+ enable_async=True,
+ autoescape=False,
+ trim_blocks=True,
+ lstrip_blocks=True,
+ )
+ case Jinja2TemplateCategory.MERMAID:
+ jinja2_env = Environment(
+ loader=loader,
+ enable_async=True,
+ autoescape=False,
+ trim_blocks=False,
+ lstrip_blocks=False,
+ )
+ case Jinja2TemplateCategory.LLM_PROMPT:
+ jinja2_env = Environment(
+ loader=loader,
+ enable_async=True,
+ autoescape=False,
+ trim_blocks=False,
+ lstrip_blocks=False,
+ )
+ return jinja2_env
+
+
+def make_jinja2_env_from_package(
+ template_category: Jinja2TemplateCategory,
+ package_name: str,
+ package_path: str,
+) -> Tuple[Environment, BaseLoader]:
+ full_package_path = f"{package_path}/jinja2_{template_category}"
+ loader = PackageLoader(
+ package_name=package_name,
+ package_path=full_package_path,
+ )
+ jinja2_env = make_jinja2_env_from_loader(template_category=template_category, loader=loader)
+ return jinja2_env, loader
+
+
+def make_jinja2_env_without_loader(
+ template_category: Jinja2TemplateCategory,
+) -> Environment:
+ loader = BaseLoader()
+ jinja2_env = make_jinja2_env_from_loader(template_category=template_category, loader=loader)
+ return jinja2_env
+
+
+def make_jinja2_env_from_template_provider(
+ template_category: Jinja2TemplateCategory,
+ template_provider: TemplateProviderAbstract,
+) -> Tuple[Environment, BaseLoader]:
+ loader = Jinja2TemplateLoader(template_provider=template_provider)
+ jinja2_env = make_jinja2_env_from_loader(template_category=template_category, loader=loader)
+
+ filters = template_category.filters
+ for filter_name, filter_function in filters.items():
+ jinja2_env.filters[filter_name] = filter_function # type: ignore
+ return jinja2_env, loader
diff --git a/pipelex/tools/templating/jinja2_errors.py b/pipelex/tools/templating/jinja2_errors.py
new file mode 100644
index 000000000..79bf0195f
--- /dev/null
+++ b/pipelex/tools/templating/jinja2_errors.py
@@ -0,0 +1,34 @@
+from typing import Optional
+
+from pipelex.tools.exceptions import ToolException
+
+
+class Jinja2TemplateError(ToolException):
+ pass
+
+
+class Jinja2StuffError(ToolException):
+ pass
+
+
+class Jinja2ContextError(ToolException):
+ pass
+
+
+class Jinja2RenderError(ToolException):
+ pass
+
+
+class Jinja2DetectVariablesError(ToolException):
+ pass
+
+
+def make_jinja2_error_explanation(jinja2_name: Optional[str], template_text: Optional[str]) -> str:
+ explanation = ""
+ if jinja2_name:
+ explanation += f"\nJinja2 name: '{jinja2_name}'\n"
+ if template_text:
+ explanation += f"\ntemplate:\n\n{template_text}'\n"
+ if not explanation:
+ explanation = "No template text or Jinja2 name"
+ return explanation
diff --git a/pipelex/tools/templating/jinja2_filters.py b/pipelex/tools/templating/jinja2_filters.py
new file mode 100644
index 000000000..443dc71aa
--- /dev/null
+++ b/pipelex/tools/templating/jinja2_filters.py
@@ -0,0 +1,92 @@
+from enum import StrEnum
+from typing import Any, Optional
+
+from jinja2 import pass_context
+from jinja2.runtime import Context, Undefined
+
+from pipelex.tools.templating.jinja2_errors import Jinja2ContextError
+from pipelex.tools.templating.jinja2_models import Jinja2ContextKey, Jinja2TaggableAbstract
+from pipelex.tools.templating.templating_models import TagStyle, TextFormat
+
+########################################################################################
+# Jinja2 filters
+########################################################################################
+
+ALLOWED_FILTERS = ["tag", "format"]
+
+
+# Filter to format some Stuff or any object with the appropriate text formatting methods
+@pass_context
+def text_format(context: Context, value: Any, text_format: Optional[TextFormat] = None) -> Any:
+ if text_format:
+ if isinstance(text_format, str): # pyright: ignore[reportUnnecessaryIsInstance]
+ applied_text_format = TextFormat(text_format)
+ elif isinstance(text_format, TextFormat): # pyright: ignore[reportUnnecessaryIsInstance]
+ applied_text_format = text_format
+ else:
+ raise Jinja2ContextError(f"Invalid text format: '{text_format}'")
+ else:
+ applied_text_format = TextFormat(context.get(Jinja2ContextKey.TEXT_FORMAT, default=TextFormat.PLAIN))
+
+ if hasattr(value, "rendered_str"):
+ rendered_str = value.rendered_str(text_format=applied_text_format)
+ return rendered_str
+ elif hasattr(value, applied_text_format.render_method_name):
+ render_method = getattr(value, applied_text_format.render_method_name)
+ rendered_str = render_method()
+ return rendered_str
+ elif isinstance(value, StrEnum):
+ return value.value
+ else:
+ return value
+
+
+# TODO: better separate tag and render
+# Filter to tag the variable with a tag style and a provided name, appropriate for tagging in a prompt
+@pass_context
+def tag(context: Context, value: Any, tag_name: Optional[str] = None) -> Any:
+ if isinstance(value, Undefined):
+ # maybe we don't need this check
+ if tag_name:
+ raise Jinja2ContextError(f"Jinja2 undefined value with tag_name '{tag_name}'.")
+ else:
+ raise Jinja2ContextError("Jinja2 undefined value.")
+
+ if isinstance(value, Jinja2TaggableAbstract):
+ value, tag_name = value.render_tagged_for_jinja2(context=context, tag_name=tag_name)
+
+ return render_any_tagged_for_jinja2(context=context, value=value, tag_name=tag_name)
+
+
+def render_any_tagged_for_jinja2(context: Context, value: Any, tag_name: Optional[str] = None) -> Any:
+ tag_style_str = context.get(Jinja2ContextKey.TAG_STYLE)
+ tag_style: TagStyle
+ if tag_style_str:
+ tag_style = TagStyle(tag_style_str)
+ else:
+ raise Jinja2ContextError(f"Tag style is required for Jinja2 tag filter (context.name = {context.name})")
+
+ tagged: Any
+ if tag_name:
+ match tag_style:
+ case TagStyle.NO_TAG:
+ tagged = value
+ case TagStyle.TICKS:
+ tagged = f"{tag_name}: ```\n{value}\n```"
+ case TagStyle.XML:
+ tagged = f"<{tag_name}>\n{value}\n</{tag_name}>"
+ case TagStyle.SQUARE_BRACKETS:
+ tagged = f"[{tag_name}]\n{value}\n[/{tag_name}]"
+ else:
+ match tag_style:
+ case TagStyle.NO_TAG:
+ tagged = value
+ case TagStyle.TICKS:
+ tagged = f"```\n{value}\n```"
+ case TagStyle.XML:
+ fallback_tag_name = "data"
+ tagged = f"<{fallback_tag_name}>\n{value}\n</{fallback_tag_name}>"
+ case TagStyle.SQUARE_BRACKETS:
+ fallback_tag_name = "data"
+ tagged = f"[{fallback_tag_name}]\n{value}\n[/{fallback_tag_name}]"
+ return tagged
diff --git a/pipelex/tools/templating/jinja2_models.py b/pipelex/tools/templating/jinja2_models.py
new file mode 100644
index 000000000..e5362cbe2
--- /dev/null
+++ b/pipelex/tools/templating/jinja2_models.py
@@ -0,0 +1,21 @@
+from abc import ABC, abstractmethod
+from enum import StrEnum
+from typing import Any, Optional, Tuple
+
+from jinja2.runtime import Context
+
+
+class Jinja2FilterName(StrEnum):
+ FORMAT = "format"
+ TAG = "tag"
+
+
+class Jinja2ContextKey(StrEnum):
+ TAG_STYLE = "tag_style"
+ TEXT_FORMAT = "text_format"
+
+
+class Jinja2TaggableAbstract(ABC):
+ @abstractmethod
+ def render_tagged_for_jinja2(self, context: Context, tag_name: Optional[str] = None) -> Tuple[Any, Optional[str]]:
+ pass
diff --git a/pipelex/tools/templating/jinja2_parsing.py b/pipelex/tools/templating/jinja2_parsing.py
new file mode 100644
index 000000000..0a3ee950c
--- /dev/null
+++ b/pipelex/tools/templating/jinja2_parsing.py
@@ -0,0 +1,10 @@
+from pipelex.tools.templating.jinja2_environment import make_jinja2_env_without_loader
+from pipelex.tools.templating.jinja2_template_category import Jinja2TemplateCategory
+
+
+def check_jinja2_parsing(
+ jinja2_template_source: str,
+ template_category: Jinja2TemplateCategory = Jinja2TemplateCategory.LLM_PROMPT,
+):
+ jinja2_env = make_jinja2_env_without_loader(template_category=template_category)
+ jinja2_env.parse(jinja2_template_source)
diff --git a/pipelex/tools/templating/jinja2_rendering.py b/pipelex/tools/templating/jinja2_rendering.py
new file mode 100644
index 000000000..4a6c8a4e6
--- /dev/null
+++ b/pipelex/tools/templating/jinja2_rendering.py
@@ -0,0 +1,103 @@
+from typing import Any, Dict, Optional
+
+from jinja2 import Template, meta
+from jinja2.exceptions import (
+ TemplateAssertionError,
+ TemplateSyntaxError,
+ UndefinedError,
+)
+
+from pipelex import log
+from pipelex.tools.templating.jinja2_errors import (
+ Jinja2ContextError,
+ Jinja2RenderError,
+ Jinja2StuffError,
+ make_jinja2_error_explanation,
+)
+from pipelex.tools.templating.jinja2_models import Jinja2ContextKey
+from pipelex.tools.templating.jinja2_required_variables import make_jinja2_env_from_template_provider
+from pipelex.tools.templating.jinja2_template_category import Jinja2TemplateCategory
+from pipelex.tools.templating.template_provider_abstract import TemplateProviderAbstract
+from pipelex.tools.templating.templating_models import PromptingStyle
+
+########################################################################################
+# Jinja2 rendering
+########################################################################################
+
+
+def _add_to_templating_context(temlating_context: Dict[str, Any], jinja2_context_key: Jinja2ContextKey, value: Any) -> None:
+ if jinja2_context_key in temlating_context:
+ raise Jinja2StuffError(f"Jinja2 context key '{jinja2_context_key}' already in temlating_context")
+ temlating_context[jinja2_context_key] = value
+
+
+async def render_jinja2(
+ template_category: Jinja2TemplateCategory,
+ template_provider: TemplateProviderAbstract,
+ temlating_context: Dict[str, Any],
+ jinja2_name: Optional[str] = None,
+ jinja2: Optional[str] = None,
+ prompting_style: Optional[PromptingStyle] = None,
+) -> str:
+ jinja2_env, loader = make_jinja2_env_from_template_provider(
+ template_category=template_category,
+ template_provider=template_provider,
+ )
+
+ template: Template
+ template_source: str
+ try:
+ if jinja2:
+ template = jinja2_env.from_string(jinja2)
+ template_source = jinja2
+ elif jinja2_name:
+ template = jinja2_env.get_template(jinja2_name)
+ template_source = loader.get_source(jinja2_env, jinja2_name)[0]
+ else:
+ raise Jinja2StuffError("No jinja2 or jinja2_name in Jinja2Assignment")
+ except TemplateAssertionError as exc:
+ explanation = make_jinja2_error_explanation(jinja2_name=jinja2_name, template_text=jinja2)
+ raise Jinja2RenderError(f"Jinja2 render error: '{exc}' {explanation}") from exc
+
+ parsed_ast = jinja2_env.parse(template_source)
+ if undeclared_variables := meta.find_undeclared_variables(parsed_ast):
+ undeclared_variables.discard("preliminary_text")
+ if undeclared_variables:
+ log.verbose(undeclared_variables, "Jinja2 undeclared_variables")
+ # pretty_print(undeclared_variables, title="Jinja2 undeclared_variables")
+ temlating_context = temlating_context.copy()
+ if prompting_style:
+ _add_to_templating_context(
+ temlating_context=temlating_context,
+ jinja2_context_key=Jinja2ContextKey.TAG_STYLE,
+ value=prompting_style.tag_style,
+ )
+ _add_to_templating_context(
+ temlating_context=temlating_context,
+ jinja2_context_key=Jinja2ContextKey.TEXT_FORMAT,
+ value=prompting_style.text_format,
+ )
+
+ # TODO: restore preferences using templating manager
+ # if get_config().pipelex.preferences.is_include_prefs_in_jinja2_context:
+ # _add_to_templating_context(
+ # temlating_context=temlating_context,
+ # jinja2_context_key=Jinja2ContextKey.PREFERENCES,
+ # value=get_config().pipelex.preferences,
+ # )
+
+ try:
+ generated_text: str = await template.render_async(**temlating_context)
+ except Jinja2StuffError as stuff_error:
+ explanation = make_jinja2_error_explanation(jinja2_name=jinja2_name, template_text=template_source)
+ raise Jinja2RenderError(f"Jinja2 render — stuff error: '{stuff_error}' {explanation}") from stuff_error
+ except TemplateSyntaxError as syntax_error:
+ explanation = make_jinja2_error_explanation(jinja2_name=jinja2_name, template_text=template_source)
+ raise Jinja2RenderError(f"Jinja2 render — syntax error: '{syntax_error}' {explanation}") from syntax_error
+ except UndefinedError as undef_error:
+ explanation = make_jinja2_error_explanation(jinja2_name=jinja2_name, template_text=template_source)
+ raise Jinja2RenderError(f"Jinja2 render — undefined error: '{undef_error}' {explanation}") from undef_error
+ except Jinja2ContextError as context_error:
+ explanation = make_jinja2_error_explanation(jinja2_name=jinja2_name, template_text=template_source)
+ raise Jinja2RenderError(f"Jinja2 render — context error: '{context_error}' {explanation}") from context_error
+ return generated_text
diff --git a/pipelex/tools/templating/jinja2_required_variables.py b/pipelex/tools/templating/jinja2_required_variables.py
new file mode 100644
index 000000000..346d57bd9
--- /dev/null
+++ b/pipelex/tools/templating/jinja2_required_variables.py
@@ -0,0 +1,62 @@
+from typing import Optional, Set
+
+from jinja2 import meta
+from jinja2.exceptions import (
+ TemplateSyntaxError,
+ UndefinedError,
+)
+
+from pipelex.tools.templating.jinja2_environment import make_jinja2_env_from_template_provider
+from pipelex.tools.templating.jinja2_errors import Jinja2DetectVariablesError, Jinja2StuffError, make_jinja2_error_explanation
+from pipelex.tools.templating.jinja2_template_category import Jinja2TemplateCategory
+from pipelex.tools.templating.template_provider_abstract import TemplateProviderAbstract
+
+
+def detect_jinja2_required_variables(
+ template_category: Jinja2TemplateCategory,
+ template_provider: TemplateProviderAbstract,
+ jinja2_name: Optional[str] = None,
+ jinja2: Optional[str] = None,
+) -> Set[str]:
+ """
+ Returns a list of variables required by the Jinja2 template.
+
+ Args:
+ template_category: Category of the template (HTML, MARKDOWN, etc.), used to set the appropriate jinja2 environment settings
+ template_library: Library containing templates
+ jinja2_name: Name of template in library (optional)
+ jinja2: Direct Jinja2 template string (optional)
+
+ Returns:
+ List of variable names required by the template
+
+ Raises:
+ Jinja2StuffError: If neither jinja2 nor jinja2_name is provided
+ """
+ jinja2_env, loader = make_jinja2_env_from_template_provider(
+ template_category=template_category,
+ template_provider=template_provider,
+ )
+
+ template_source: str
+ if jinja2:
+ template_source = jinja2
+ elif jinja2_name:
+ template_source = loader.get_source(jinja2_env, jinja2_name)[0]
+ else:
+ raise Jinja2StuffError("No jinja2 or jinja2_name provided")
+
+ try:
+ parsed_ast = jinja2_env.parse(template_source)
+ undeclared_variables = meta.find_undeclared_variables(parsed_ast)
+ except Jinja2StuffError as stuff_error:
+ explanation = make_jinja2_error_explanation(jinja2_name=jinja2_name, template_text=template_source)
+ raise Jinja2DetectVariablesError(f"Jinja2 detect variables — stuff error: '{stuff_error}' {explanation}") from stuff_error
+ except TemplateSyntaxError as syntax_error:
+ explanation = make_jinja2_error_explanation(jinja2_name=jinja2_name, template_text=template_source)
+ raise Jinja2DetectVariablesError(f"Jinja2 detect variables — syntax error: '{syntax_error}' {explanation}") from syntax_error
+ except UndefinedError as undef_error:
+ explanation = make_jinja2_error_explanation(jinja2_name=jinja2_name, template_text=template_source)
+ raise Jinja2DetectVariablesError(f"Jinja2 detect variables — undefined error: '{undef_error}' {explanation}") from undef_error
+
+ return undeclared_variables
diff --git a/pipelex/tools/templating/jinja2_template_category.py b/pipelex/tools/templating/jinja2_template_category.py
new file mode 100644
index 000000000..725eaa594
--- /dev/null
+++ b/pipelex/tools/templating/jinja2_template_category.py
@@ -0,0 +1,26 @@
+from enum import StrEnum
+from typing import Any, Callable, Dict, Optional
+
+from jinja2.runtime import Context
+
+from pipelex.tools.templating.jinja2_filters import tag, text_format
+from pipelex.tools.templating.jinja2_models import Jinja2FilterName
+from pipelex.tools.templating.templating_models import TextFormat
+
+
+class Jinja2TemplateCategory(StrEnum):
+ HTML = "html"
+ MARKDOWN = "markdown"
+ MERMAID = "mermaid"
+ LLM_PROMPT = "llm_prompt"
+
+ @property
+ def filters(self) -> Dict[Jinja2FilterName, Callable[[Context, Any, Optional[TextFormat]], Any]]:
+ match self:
+ case Jinja2TemplateCategory.HTML | Jinja2TemplateCategory.MARKDOWN | Jinja2TemplateCategory.MERMAID:
+ return {}
+ case Jinja2TemplateCategory.LLM_PROMPT:
+ return {
+ Jinja2FilterName.FORMAT: text_format,
+ Jinja2FilterName.TAG: tag,
+ }
diff --git a/pipelex/tools/templating/jinja2_template_loader.py b/pipelex/tools/templating/jinja2_template_loader.py
new file mode 100644
index 000000000..fcdbf7361
--- /dev/null
+++ b/pipelex/tools/templating/jinja2_template_loader.py
@@ -0,0 +1,19 @@
+from typing import Callable, Optional, Tuple
+
+from jinja2 import BaseLoader, Environment
+from typing_extensions import override
+
+from pipelex import log
+from pipelex.tools.templating.template_provider_abstract import TemplateProviderAbstract
+
+
+class Jinja2TemplateLoader(BaseLoader):
+ def __init__(self, template_provider: TemplateProviderAbstract) -> None:
+ super().__init__()
+ self.template_provider = template_provider
+
+ @override
+ def get_source(self, environment: Environment, template: str) -> Tuple[str, Optional[str], Optional[Callable[[], bool]]]:
+ the_template = self.template_provider.get_template(template_name=template)
+ log.debug(f"TemplateLoader.get_source: template='{template}'")
+ return the_template, None, None
diff --git a/pipelex/tools/templating/template_library.py b/pipelex/tools/templating/template_library.py
new file mode 100644
index 000000000..8f64a73c3
--- /dev/null
+++ b/pipelex/tools/templating/template_library.py
@@ -0,0 +1,93 @@
+from typing import Any, Dict
+
+from jinja2 import TemplateSyntaxError
+from pydantic import Field, RootModel, ValidationError
+from typing_extensions import override
+
+from pipelex import log
+from pipelex.libraries.library_config import LibraryConfig
+from pipelex.tools.exceptions import ToolException
+from pipelex.tools.misc.toml_utils import load_toml_from_path
+from pipelex.tools.templating.jinja2_parsing import check_jinja2_parsing
+from pipelex.tools.templating.jinja2_template_category import Jinja2TemplateCategory
+from pipelex.tools.templating.template_preprocessor import preprocess_template
+from pipelex.tools.templating.template_provider_abstract import TemplateNotFoundError, TemplateProviderAbstract
+from pipelex.tools.typing.pydantic_utils import format_pydantic_validation_error
+
+TemplateLibraryRoot = Dict[str, str]
+
+
+class TemplateLibraryError(ToolException):
+ pass
+
+
+class TemplateLibrary(TemplateProviderAbstract, RootModel[TemplateLibraryRoot]):
+ root: TemplateLibraryRoot = Field(default_factory=dict)
+
+ @override
+ def setup(self) -> None:
+ template_toml_paths = LibraryConfig.get_templates_paths()
+ for template_toml_path in template_toml_paths:
+ self._load_from_toml(toml_path=template_toml_path)
+ self.validate_templates(template_category=Jinja2TemplateCategory.LLM_PROMPT)
+
+ @override
+ def teardown(self) -> None:
+ self.root = {}
+
+ @override
+ def get_template(self, template_name: str) -> str:
+ try:
+ return self.root[template_name]
+ except KeyError as exc:
+ raise TemplateNotFoundError(f"Template '{template_name}' not found in template library") from exc
+
+ def _set_template(self, template: str, name: str):
+ preprocessed_template = preprocess_template(template)
+ self.root[name] = preprocessed_template
+
+ def _add_new_template(self, template: str, name: str):
+ if name in self.root:
+ raise TemplateLibraryError(f"Template '{name}' already exists in the library")
+ self._set_template(template=template, name=name)
+
+ def _load_from_toml(self, toml_path: str):
+ nb_concepts_before = len(self.root)
+ library_dict = load_toml_from_path(path=toml_path)
+ for start_domain, templates in library_dict.items():
+ self._load_from_recursive_dict(domain=start_domain, recursive_dict=templates)
+ toml_name = toml_path.split("/")[-1]
+ log.debug(f"Loaded {len(self.root) - nb_concepts_before} templates from '{toml_name}'")
+
+ def _load_from_recursive_dict(self, domain: str, recursive_dict: Dict[str, Any]):
+ for name, obj in recursive_dict.items():
+ try:
+ if isinstance(obj, str):
+ # it's a template
+ template = obj
+ self._add_new_template(template=template, name=name)
+ elif isinstance(obj, dict):
+ # this is not a templae but a subdomain
+ sub_recursive_dict: Dict[str, str] = obj
+ domain = f"{domain}/{name}"
+ self._load_from_recursive_dict(domain=domain, recursive_dict=sub_recursive_dict)
+ else:
+ raise TemplateLibraryError(f"Unexpected type for key '{name}' in recursive_dict: {type(obj)}")
+ except ValidationError as exc:
+ error_msg = format_pydantic_validation_error(exc)
+ raise TemplateLibraryError(f"Error loading concept '{name}' of domain '{domain}' because of: {error_msg}") from exc
+
+ def validate_templates(self, template_category: Jinja2TemplateCategory):
+ for template_name, template in self.root.items():
+ try:
+ check_jinja2_parsing(
+ jinja2_template_source=template,
+ template_category=template_category,
+ )
+ except TemplateSyntaxError as exc:
+ error_msg = f"Jinja2 syntax error in template '{template_name}': {exc}."
+ if template:
+ error_msg += f"\nThe template is:\n{template}"
+ else:
+ error_msg += "The template is empty."
+ raise TemplateLibraryError(error_msg) from exc
diff --git a/pipelex/tools/templating/template_preprocessor.py b/pipelex/tools/templating/template_preprocessor.py
new file mode 100644
index 000000000..2f9c3e145
--- /dev/null
+++ b/pipelex/tools/templating/template_preprocessor.py
@@ -0,0 +1,81 @@
+import re
+from re import Match
+from typing import List
+
+from pipelex.tools.templating.jinja2_errors import Jinja2TemplateError
+from pipelex.tools.templating.jinja2_filters import ALLOWED_FILTERS
+
+
+def _detect_non_existent_filters(template_str: str) -> None:
+ """Check a template string for non-existent Jinja2 filters.
+
+ Args:
+ template_str: The template string to check
+
+ Raises:
+ Jinja2TemplateError: If any non-allowed filters are found
+ """
+ # Pattern to match Jinja2 filter syntax: {{ variable|filter() }} or {{ variable|filter(param) }}
+ # This handles:
+ # - {{ variable|filter }}
+ # - {{ variable|filter() }}
+ # - {{ variable|filter(param) }}
+ # - {{ variable|filter(param1, param2) }}
+ filter_pattern = r"\{\{\s*[^|}]+\|\s*([a-zA-Z0-9_]+)(?:\([^)]*\))?\s*\}\}"
+ matches = re.finditer(filter_pattern, template_str)
+
+ invalid_filters: List[str] = []
+ for match in matches:
+ filter_name = match.group(1)
+ if filter_name not in ALLOWED_FILTERS:
+ invalid_filters.append(filter_name)
+
+ if invalid_filters:
+ raise Jinja2TemplateError(f"Invalid Jinja2 filters found: {invalid_filters}. Only the following filters are allowed: {ALLOWED_FILTERS}")
+
+
+# Handle @variable patterns
+def replace_at_variable(match: Match[str]) -> str:
+ variable: str = match.group(1)
+ return f'{{{{ {variable}|tag("{variable}") }}}}'
+
+
+# Handle $variable patterns
+def replace_dollar_variable(match: Match[str]) -> str:
+ variable: str = match.group(1)
+ if variable.endswith("."):
+ # trailing dot can't be in a variable name so it must be a punctuation in the template sentence, so we remove it
+ variable = variable[:-1]
+ return f"{{{{ {variable}|format() }}}}"
+
+
+def preprocess_template(template: str) -> str:
+ """
+ Preprocess a template string to interpret our syntax patterns and convert them to Jinja2 syntax.
+ Also, detect the use of non-existent filters.
+ """
+ _detect_non_existent_filters(template_str=template)
+
+ processed_template = template
+ changes_made = False
+
+ # TODO: allow escape patterns
+
+ # Replace @variable patterns
+ new_template = re.sub(r"@([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)
+ if new_template != processed_template:
+ changes_made = True
+ processed_template = new_template
+
+ if changes_made:
+ # pretty_print(template, "Original template")
+ # pretty_print(processed_template, "Processed template")
+ pass
+
+ return processed_template
diff --git a/pipelex/tools/templating/template_provider_abstract.py b/pipelex/tools/templating/template_provider_abstract.py
new file mode 100644
index 000000000..ea9a23d9d
--- /dev/null
+++ b/pipelex/tools/templating/template_provider_abstract.py
@@ -0,0 +1,21 @@
+from abc import ABC, abstractmethod
+
+from pipelex.tools.exceptions import ToolException
+
+
+class TemplateNotFoundError(ToolException):
+ pass
+
+
+class TemplateProviderAbstract(ABC):
+ @abstractmethod
+ def setup(self) -> None:
+ pass
+
+ @abstractmethod
+ def teardown(self) -> None:
+ pass
+
+ @abstractmethod
+ def get_template(self, template_name: str) -> str:
+ pass
diff --git a/pipelex/tools/templating/templating_models.py b/pipelex/tools/templating/templating_models.py
new file mode 100644
index 000000000..5ef5af2d5
--- /dev/null
+++ b/pipelex/tools/templating/templating_models.py
@@ -0,0 +1,37 @@
+from enum import StrEnum
+from typing import Self
+
+from pydantic import BaseModel, Field
+from typing_extensions import override
+
+
+class TextFormat(StrEnum):
+ PLAIN = "plain"
+ MARKDOWN = "markdown"
+ HTML = "html"
+ JSON = "json"
+ SPREADSHEET = "spreadsheet"
+
+ @property
+ def render_method_name(self):
+ return f"rendered_{self}"
+
+
+class TagStyle(StrEnum):
+ NO_TAG = "no_tag"
+ TICKS = "ticks"
+ XML = "xml"
+ SQUARE_BRACKETS = "square_brackets"
+
+
+class PromptingStyle(BaseModel):
+ tag_style: TagStyle = Field(strict=False)
+ text_format: TextFormat = Field(TextFormat.PLAIN, strict=False)
+
+ @override
+ def __str__(self):
+ return f"{self.tag_style}/{self.text_format}"
+
+ @classmethod
+ def make_default_prompting_style(cls) -> Self:
+ return cls(tag_style=TagStyle.NO_TAG, text_format=TextFormat.PLAIN)
diff --git a/pipelex/tools/typing/module_inspector.py b/pipelex/tools/typing/module_inspector.py
new file mode 100644
index 000000000..7805bb98c
--- /dev/null
+++ b/pipelex/tools/typing/module_inspector.py
@@ -0,0 +1,67 @@
+import importlib.util
+import inspect
+import os
+import sys
+from typing import Any, List, Optional, Type
+
+
+class ModuleFileError(Exception):
+ """Exception raised for errors related to module file operations."""
+
+ pass
+
+
+def import_module_from_file(file_path: str) -> Any:
+ """Imports a module from a file path.
+
+ Args:
+ file_path: Path to the Python file to import
+
+ Returns:
+ The imported module
+
+ Raises:
+ ModuleFileError: If the file is not a Python file or cannot be loaded
+ """
+ # Validate that the file is a Python file
+ if not file_path.endswith(".py"):
+ raise ModuleFileError(f"File {file_path} is not a Python file (must end with .py)")
+
+ module_name = file_path[:-3].replace(os.sep, ".")
+ module = importlib.import_module(module_name)
+
+ # Add the module to sys.modules to ensure proper imports within the module
+ sys.modules[module_name] = module
+ return module
+
+
+def find_classes_in_module(
+ module: Any,
+ base_class: Optional[Type[Any]],
+ include_imported: bool,
+) -> List[Type[Any]]:
+ """
+ Finds all classes in a module that match the criteria.
+
+ Args:
+ module: The module to search for classes
+ base_class: Optional base class to filter classes: will only return classes that are subclasses of this base_class
+ include_imported: Whether to include classes imported from other modules
+
+ Returns:
+ List of class types that match the criteria
+ """
+ classes: List[Type[Any]] = []
+ module_name = module.__name__
+
+ # Find all classes in the module
+ for _, obj in inspect.getmembers(module, inspect.isclass):
+ # Skip classes that are imported from other modules
+ if not include_imported and obj.__module__ != module_name:
+ continue
+
+ # Add the class if it's a subclass of base_class or if base_class is None
+ if base_class is None or issubclass(obj, base_class):
+ classes.append(obj)
+
+ return classes
diff --git a/pipelex/tools/typing/pydantic_utils.py b/pipelex/tools/typing/pydantic_utils.py
new file mode 100644
index 000000000..727bc9e05
--- /dev/null
+++ b/pipelex/tools/typing/pydantic_utils.py
@@ -0,0 +1,213 @@
+from enum import StrEnum
+from typing import Any, ClassVar, Dict, List, Optional, Sequence, Set, TypeVar, Union
+
+from pydantic import BaseModel, ValidationError
+from rich.repr import Result as RichReprResult
+from typing_extensions import override
+
+BaseModelTypeVar = TypeVar("BaseModelTypeVar", bound=BaseModel)
+
+
+def format_pydantic_validation_error(exc: ValidationError) -> str:
+ """Format a Pydantic ValidationError into a readable string with detailed error information.
+
+ Args:
+ exc: The Pydantic ValidationError exception
+
+ Returns:
+ A formatted string containing categorized validation errors
+ """
+ error_msg = "Validation error(s):"
+
+ # Collect different types of validation errors
+ missing_fields = [f"{'.'.join(map(str, err['loc']))}" for err in exc.errors() if err["type"] == "missing"]
+ extra_fields = [f"{'.'.join(map(str, err['loc']))}: {err['input']}" for err in exc.errors() if err["type"] == "extra_forbidden"]
+ type_errors = [f"{'.'.join(map(str, err['loc']))}: expected {err['type']}" for err in exc.errors() if err["type"] == "type_error"]
+ value_errors = [f"{'.'.join(map(str, err['loc']))}: {err['msg']}" for err in exc.errors() if err["type"] == "value_error"]
+ enum_errors = [f"{'.'.join(map(str, err['loc']))}: invalid enum value" for err in exc.errors() if err["type"] == "enum"]
+
+ # Add each type of error to the message if present
+ if missing_fields:
+ error_msg += f"\nMissing required fields: {missing_fields}"
+ if extra_fields:
+ error_msg += f"\nExtra forbidden fields: {extra_fields}"
+ if type_errors:
+ error_msg += f"\nType errors: {type_errors}"
+ if value_errors:
+ error_msg += f"\nValue errors: {value_errors}"
+ if enum_errors:
+ error_msg += f"\nEnum errors: {enum_errors}"
+
+ # If none of the specific error types were found, add the raw error messages
+ if not any([missing_fields, extra_fields, type_errors, value_errors, enum_errors]):
+ error_msg += "\nOther validation errors:"
+ for err in exc.errors():
+ error_msg += f"\n{'.'.join(map(str, err['loc']))}: {err['type']}: {err['msg']}"
+
+ return error_msg
+
+
+def convert_strenum_to_str(
+ obj: Dict[str, Any] | List[Any] | StrEnum | Any,
+) -> Dict[str, Any] | List[Any] | str | Any:
+ if isinstance(obj, dict):
+ obj_dict: Dict[str, Any] = obj
+ return {str(key): convert_strenum_to_str(value) for key, value in obj_dict.items()}
+ elif isinstance(obj, list):
+ obj_list: List[Any] = obj
+ return [convert_strenum_to_str(item) for item in obj_list]
+ elif isinstance(obj, StrEnum):
+ if hasattr(obj, "display_name"):
+ return obj.display_name() # type: ignore
+ return str(obj)
+ else:
+ return obj
+
+
+class ExtraFieldAttribute(StrEnum):
+ IS_HIDDEN = "is_hidden"
+
+
+class FieldVisibility(StrEnum):
+ ALL_FIELDS = "all_fields"
+ NO_HIDDEN_FIELDS = "no_hidden_fields"
+ ONLY_HIDDEN_FIELDS = "only_hidden_fields"
+
+
+def clean_model_to_dict(obj: BaseModel) -> Dict[str, Any]:
+ dict_dump = serialize_model(
+ obj=obj,
+ field_visibility=FieldVisibility.NO_HIDDEN_FIELDS,
+ is_stringify_enums=True,
+ )
+ if not isinstance(dict_dump, dict):
+ raise TypeError(f"Expected dict, got {type(dict_dump)}")
+ result_dict: Dict[str, Any] = dict_dump
+ return result_dict
+
+
+def serialize_model(
+ obj: Any,
+ field_visibility: FieldVisibility = FieldVisibility.NO_HIDDEN_FIELDS,
+ is_stringify_enums: bool = True,
+) -> Union[Dict[str, Any], List[Any], Any]:
+ """
+ Recursively serialize a Pydantic BaseModel (and its nested BaseModels)
+ into a dictionary, omitting any fields marked with
+ 'json_schema_extra={ExtraFieldAttribute.IS_HIDDEN: True}'.
+
+ If 'obj' is not a BaseModel, return it as-is (useful for nested lists/dicts).
+ """
+ # If it's not a Pydantic model, return it directly
+ if not isinstance(obj, BaseModel):
+ # Might be a primitive type, list, dict, etc.
+ # We only handle nesting if it's inside BaseModels
+ return obj
+
+ # Identify which fields should be excluded
+ fields_to_exclude: Set[str] = set()
+
+ for field_name, field_info in obj.model_fields.items():
+ json_schema_extra = field_info.json_schema_extra
+ is_hidden = json_schema_extra and isinstance(json_schema_extra, dict) and json_schema_extra.get(ExtraFieldAttribute.IS_HIDDEN) is True
+ match field_visibility:
+ case FieldVisibility.ALL_FIELDS:
+ pass
+ case FieldVisibility.NO_HIDDEN_FIELDS:
+ if is_hidden:
+ fields_to_exclude.add(field_name)
+ case FieldVisibility.ONLY_HIDDEN_FIELDS:
+ if not is_hidden:
+ fields_to_exclude.add(field_name)
+
+ # Build a dict, omitting hidden fields. Recursively handle nested models.
+ data: Dict[str, Any] = {}
+ for field_name, _ in obj.model_fields.items():
+ if field_name in fields_to_exclude:
+ continue # Skip hidden fields
+
+ value = getattr(obj, field_name)
+
+ # If the value is another BaseModel, recurse
+ if isinstance(value, BaseModel):
+ data[field_name] = serialize_model(
+ obj=value,
+ field_visibility=field_visibility,
+ is_stringify_enums=is_stringify_enums,
+ )
+
+ # If it's a list, we recurse for each item
+ elif isinstance(value, list):
+ value_list: List[Any] = value
+ data[field_name] = [
+ serialize_model(
+ obj=item,
+ field_visibility=field_visibility,
+ is_stringify_enums=is_stringify_enums,
+ )
+ for item in value_list
+ ]
+
+ # If it's a dict, we can similarly recurse for any nested BaseModels inside the dict
+ elif isinstance(value, dict):
+ value_dict: Dict[str, Any] = value
+ data[field_name] = {
+ key: serialize_model(
+ obj=value,
+ field_visibility=field_visibility,
+ is_stringify_enums=is_stringify_enums,
+ )
+ for key, value in value_dict.items()
+ }
+
+ elif is_stringify_enums and isinstance(value, StrEnum):
+ if hasattr(value, "display_name"):
+ data[field_name] = value.display_name() # type: ignore
+ else:
+ data[field_name] = str(value)
+
+ # Otherwise, just store the raw value
+ else:
+ data[field_name] = value
+
+ return data
+
+
+class CustomBaseModel(BaseModel):
+ truncate_length: ClassVar[int] = 50
+ truncate_suffix: ClassVar[str] = "…"
+
+ @override
+ def __rich_repr__(self) -> RichReprResult: # type: ignore
+ for item in super().__rich_repr__(): # type: ignore
+ if isinstance(item, tuple):
+ tuple_item: tuple[Any, ...] = item
+ if len(tuple_item) >= 2:
+ name = tuple_item[0]
+ value = tuple_item[1]
+ should_truncate = (name == "base_64" and isinstance(value, str) and len(value) > self.truncate_length) or (
+ name == "url" and isinstance(value, str) and value.startswith("data:image/") and len(value) > self.truncate_length
+ )
+ if should_truncate:
+ truncated_value = value[: self.truncate_length] + self.truncate_suffix
+ if len(tuple_item) == 3:
+ yield name, truncated_value, tuple_item[2]
+ else:
+ yield name, truncated_value
+ else:
+ yield item
+ else:
+ yield item
+
+ @override
+ def __repr_args__(self) -> Sequence[tuple[Optional[str], Any]]:
+ processed_args: list[tuple[Optional[str], Any]] = []
+ for name, value in super().__repr_args__():
+ should_truncate = (name == "base_64" and isinstance(value, str) and len(value) > self.truncate_length) or (
+ name == "url" and isinstance(value, str) and value.startswith("data:image/") and len(value) > self.truncate_length
+ )
+ if should_truncate:
+ processed_args.append((name, value[: self.truncate_length] + self.truncate_suffix))
+ else:
+ processed_args.append((name, value))
+ return processed_args
diff --git a/pipelex/tools/typing/type_inspector.py b/pipelex/tools/typing/type_inspector.py
new file mode 100644
index 000000000..62c82b890
--- /dev/null
+++ b/pipelex/tools/typing/type_inspector.py
@@ -0,0 +1,117 @@
+from enum import Enum, StrEnum
+from typing import Any, Dict, List, Optional, Set, Type, Union, get_type_hints
+
+from pydantic import BaseModel
+
+
+def pretty_type(tp: object) -> str:
+ """Pretty print a type, with special handling for containers, literals and enums."""
+ origin = getattr(tp, "__origin__", None)
+ args = getattr(tp, "__args__", None)
+ if origin is None:
+ if isinstance(tp, type):
+ return tp.__name__
+ return str(tp)
+
+ if origin is Union and args:
+ non_none = [a for a in args if a is not type(None)]
+ if len(non_none) == 1 and len(args) == 2:
+ return f"Optional[{pretty_type(non_none[0])}]"
+ return f"Union[{', '.join(pretty_type(a) for a in args)}]"
+
+ if str(origin).endswith("Literal") and args: # Handle both typing.Literal and typing_extensions.Literal
+ # For enum values, just get their values
+ values: List[str] = []
+ for arg in args:
+ if isinstance(arg, Enum) or isinstance(arg, StrEnum):
+ values.append(f"'{arg.value}'")
+ else:
+ values.append(repr(arg))
+ return f"Literal[{', '.join(values)}]"
+
+ if (origin is list or origin is List) and args:
+ return f"List[{pretty_type(args[0])}]"
+ if (origin is dict or origin is Dict) and args:
+ return f"Dict[{pretty_type(args[0])}, {pretty_type(args[1])}]"
+ return str(tp)
+
+
+def get_type_structure(
+ tp: object,
+ seen_types: Optional[Set[str]] = None,
+ collected: Optional[List[Type[Any]]] = None,
+ base_class: Type[Any] = BaseModel,
+) -> List[str]:
+ """
+ Get the structure of a type, listing referenced subclasses of base_class after the parent class.
+
+ Args:
+ tp: The type to analyze
+ seen_types: Set of already seen type names to avoid cycles
+ collected: List of collected types to analyze
+ base_class: The base class to check for inheritance (defaults to BaseModel)
+ """
+ if seen_types is None:
+ seen_types = set()
+ if collected is None:
+ collected = []
+
+ def collect_types(tp: object):
+ origin = getattr(tp, "__origin__", None)
+ args = getattr(tp, "__args__", None)
+ if origin and args:
+ if origin is Union:
+ non_none = [a for a in args if a is not type(None)]
+ if len(non_none) == 1:
+ collect_types(non_none[0])
+ else:
+ for arg in non_none:
+ collect_types(arg)
+ elif origin in (list, List):
+ collect_types(args[0])
+ elif origin in (dict, Dict):
+ collect_types(args[0])
+ collect_types(args[1])
+ return
+
+ if isinstance(tp, type):
+ if issubclass(tp, base_class) and tp.__name__ not in seen_types:
+ seen_types.add(tp.__name__)
+ collected.append(tp)
+ type_hints = get_type_hints(tp)
+ model_fields: Dict[str, Any] = getattr(tp, "model_fields", {})
+ if model_fields:
+ for fname, _ in model_fields.items():
+ ftype = type_hints[fname]
+ collect_types(ftype)
+ elif hasattr(tp, "__annotations__"):
+ for fname, ftype in type_hints.items():
+ collect_types(ftype)
+
+ collect_types(tp)
+ output: List[str] = []
+ for idx, ctp in enumerate(collected):
+ if idx > 0:
+ output.append("")
+ output.extend(pretty_print_class_structure(ctp))
+ return output
+
+
+def pretty_print_class_structure(tp: Type[Any]) -> List[str]:
+ lines: List[str] = []
+ lines.append(f"Class '{tp.__name__}':")
+ if tp.__doc__:
+ lines.append(f"{tp.__doc__}")
+ type_hints = get_type_hints(tp)
+ model_fields: Dict[str, Any] = getattr(tp, "model_fields", {})
+ if model_fields:
+ for fname, f in model_fields.items():
+ ftype = type_hints[fname]
+ line = f"- {fname} ({pretty_type(ftype)})"
+ if hasattr(f, "description") and getattr(f, "description", None):
+ line += f": {f.description}"
+ lines.append(line)
+ elif hasattr(tp, "__annotations__"):
+ for fname, ftype in type_hints.items():
+ lines.append(f"- {fname} ({str(ftype)})")
+ return lines
diff --git a/pipelex/tools/typing/validation_utils.py b/pipelex/tools/typing/validation_utils.py
new file mode 100644
index 000000000..544684790
--- /dev/null
+++ b/pipelex/tools/typing/validation_utils.py
@@ -0,0 +1,52 @@
+from typing import Any, List, Optional
+
+
+def has_exactly_one_among_attributes_from_list(obj: Any, attributes_list: List[str]) -> bool:
+ """
+ Checks if exactly one attribute from a list of attributes is non-None in an object.
+
+ This function is useful for validating mutually exclusive attributes in data models
+ or configurations, ensuring that exactly one of the specified attributes has a value.
+
+ Args:
+ obj (Any): The object to check attributes on. Must support getattr().
+ attributes_list (List[str]): List of attribute names to check.
+
+ Returns:
+ bool: True if exactly one attribute from the list is non-None,
+ False otherwise.
+ """
+ provided_attributes = [attribute for attribute in attributes_list if getattr(obj, attribute) is not None]
+ return len(provided_attributes) == 1
+
+
+def has_more_than_one_among_attributes_from_list(obj: Any, attributes_list: List[str]) -> bool:
+ """
+ Checks if more than one attribute from a list of attributes is non-None in an object.
+
+ This function is useful for detecting conflicts in configurations or data models
+ where attributes are supposed to be mutually exclusive.
+
+ Args:
+ obj (Any): The object to check attributes on. Must support getattr().
+ attributes_list (List[str]): List of attribute names to check.
+
+ Returns:
+ bool: True if more than one attribute from the list is non-None,
+ False otherwise.
+ """
+ provided_attributes = [attribute for attribute in attributes_list if getattr(obj, attribute) is not None]
+ return len(provided_attributes) > 1
+
+
+def has_more_than_one_among_attributes_from_any_list(obj: Any, attributes_lists: List[List[str]]) -> Optional[List[str]]:
+ """
+ Checks if more than one attribute from any list of attributes is non-None in an object.
+
+ This function is useful for detecting conflicts in configurations or data models
+ where attributes are supposed to be mutually exclusive.
+ """
+ for attributes_list in attributes_lists:
+ if has_more_than_one_among_attributes_from_list(obj, attributes_list):
+ return attributes_list
+ return None
diff --git a/poetry.lock b/poetry.lock
new file mode 100644
index 000000000..faca403bf
--- /dev/null
+++ b/poetry.lock
@@ -0,0 +1,4346 @@
+# This file is automatically @generated by Poetry 2.0.1 and should not be changed by hand.
+
+[[package]]
+name = "aioboto3"
+version = "13.4.0"
+description = "Async boto3 wrapper"
+optional = true
+python-versions = "<4.0,>=3.8"
+groups = ["main"]
+markers = "extra == \"bedrock\""
+files = [
+ {file = "aioboto3-13.4.0-py3-none-any.whl", hash = "sha256:d78f3400ef3a01b4d5515108ef244941894a0bc39c4716321a00e15898d7e002"},
+ {file = "aioboto3-13.4.0.tar.gz", hash = "sha256:3105f9e5618c686c90050e60eb5ebf9e28f7f8c4e0fa162d4481aaa402008aab"},
+]
+
+[package.dependencies]
+aiobotocore = {version = "2.18.0", extras = ["boto3"]}
+aiofiles = ">=23.2.1"
+
+[package.extras]
+chalice = ["chalice (>=1.24.0)"]
+s3cse = ["cryptography (>=2.3.1)"]
+
+[[package]]
+name = "aiobotocore"
+version = "2.18.0"
+description = "Async client for aws services using botocore and aiohttp"
+optional = true
+python-versions = ">=3.8"
+groups = ["main"]
+markers = "extra == \"bedrock\""
+files = [
+ {file = "aiobotocore-2.18.0-py3-none-any.whl", hash = "sha256:89634470946944baf0a72fe2939cdd5f98b61335d400ca55f3032aca92989ec1"},
+ {file = "aiobotocore-2.18.0.tar.gz", hash = "sha256:c54db752c5a742bf1a05c8359a93f508b4bf702b0e6be253a4c9ef1f9c9b6706"},
+]
+
+[package.dependencies]
+aiohttp = ">=3.9.2,<4.0.0"
+aioitertools = ">=0.5.1,<1.0.0"
+boto3 = {version = ">=1.36.0,<1.36.2", optional = true, markers = "extra == \"boto3\""}
+botocore = ">=1.36.0,<1.36.2"
+jmespath = ">=0.7.1,<2.0.0"
+multidict = ">=6.0.0,<7.0.0"
+python-dateutil = ">=2.1,<3.0.0"
+urllib3 = {version = ">=1.25.4,<2.2.0 || >2.2.0,<3", markers = "python_version >= \"3.10\""}
+wrapt = ">=1.10.10,<2.0.0"
+
+[package.extras]
+awscli = ["awscli (>=1.37.0,<1.37.2)"]
+boto3 = ["boto3 (>=1.36.0,<1.36.2)"]
+
+[[package]]
+name = "aiofiles"
+version = "23.2.1"
+description = "File support for asyncio."
+optional = false
+python-versions = ">=3.7"
+groups = ["main"]
+files = [
+ {file = "aiofiles-23.2.1-py3-none-any.whl", hash = "sha256:19297512c647d4b27a2cf7c34caa7e405c0d60b5560618a29a9fe027b18b0107"},
+ {file = "aiofiles-23.2.1.tar.gz", hash = "sha256:84ec2218d8419404abcb9f0c02df3f34c6e0a68ed41072acfb1cef5cbc29051a"},
+]
+
+[[package]]
+name = "aiohappyeyeballs"
+version = "2.6.1"
+description = "Happy Eyeballs for asyncio"
+optional = false
+python-versions = ">=3.9"
+groups = ["main"]
+files = [
+ {file = "aiohappyeyeballs-2.6.1-py3-none-any.whl", hash = "sha256:f349ba8f4b75cb25c99c5c2d84e997e485204d2902a9597802b0371f09331fb8"},
+ {file = "aiohappyeyeballs-2.6.1.tar.gz", hash = "sha256:c3f9d0113123803ccadfdf3f0faa505bc78e6a72d1cc4806cbd719826e943558"},
+]
+
+[[package]]
+name = "aiohttp"
+version = "3.12.0"
+description = "Async http client/server framework (asyncio)"
+optional = false
+python-versions = ">=3.9"
+groups = ["main"]
+files = [
+ {file = "aiohttp-3.12.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:91fca62b1a454a72c48345ad3af0327c87a7352598049fd9fd02b5c96deca456"},
+ {file = "aiohttp-3.12.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:4cd2ffa8cefce24305e573780d3d4a1bc8904bb76bc208509108bac04bc85c71"},
+ {file = "aiohttp-3.12.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:b011907c9f024d9b2017a2c12ca8abea571b919ebd85d42f16bd91a716dc7de2"},
+ {file = "aiohttp-3.12.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d9c8db3b45fb114739bc3daae85ceb03b2bcb11f11f2d1eae25b00b989cd306a"},
+ {file = "aiohttp-3.12.0-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:976607ee1790d2e6d1666f89f64afd9397af2647b5a99a84dc664a3ac715754f"},
+ {file = "aiohttp-3.12.0-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e76898841d4e655ac5e7e2f1e146d9e56ee1ffd2ce2dd31b41ab23bcfb29b209"},
+ {file = "aiohttp-3.12.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:3ad61b28652898b25e7c8d42970b9f27f7eff068623704aad4424e2ee9409a80"},
+ {file = "aiohttp-3.12.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ba8d85d36edc6698ef94cf8f7fcf5992cc2d9b639de67a1112799d5020c91a63"},
+ {file = "aiohttp-3.12.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:5123488226a61df4a515dc3d5c3c0b578660ec3c22d2579599ce2e45335655db"},
+ {file = "aiohttp-3.12.0-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:a03fb47a954df7fb0d587053e2feafdd5306828fc8a764b456775fc00d2d82a9"},
+ {file = "aiohttp-3.12.0-cp310-cp310-musllinux_1_2_armv7l.whl", hash = "sha256:bf9acc3914c921ea8fb0bcda3d07ece85d09eff035bd7c11cea826aa5dd827a5"},
+ {file = "aiohttp-3.12.0-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:c7cfb0b19e775143982e34a472f9da66067c22b66ce7a56e88f851752a467f15"},
+ {file = "aiohttp-3.12.0-cp310-cp310-musllinux_1_2_ppc64le.whl", hash = "sha256:2eba07f1de9a02920f34761c8b8e375f91fd98304a80ff0287f8e9e2804decf7"},
+ {file = "aiohttp-3.12.0-cp310-cp310-musllinux_1_2_s390x.whl", hash = "sha256:d46d99d028ad4a566f980bc8790099288824212c0f21a275d546be403cbcb7bc"},
+ {file = "aiohttp-3.12.0-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:0bd190e4c418c1072563dd998ae118dfb588101f60c1af396e5cd42023f29259"},
+ {file = "aiohttp-3.12.0-cp310-cp310-win32.whl", hash = "sha256:709d823cc86d0c3ab4e9b449fefba47a1a8586fe65a00d5fbce393458be9da1c"},
+ {file = "aiohttp-3.12.0-cp310-cp310-win_amd64.whl", hash = "sha256:a44b25ade659f8736b0f2c32cfd2b59449defad41c5f1e514b94a338c777226f"},
+ {file = "aiohttp-3.12.0-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:38ab87bc3c2f2c3861438e537cbd6732d72b73f2b82ea9ba4b214b6aca170ad9"},
+ {file = "aiohttp-3.12.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:8862c9b190854c0ff3f5a3f25abee9ed7641aee6eccdc81aed2c3d427623d3dc"},
+ {file = "aiohttp-3.12.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:8cd1eb1d5498cc541ce40946e148371e23efefcf48afdaa68f49328d2849f393"},
+ {file = "aiohttp-3.12.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:07b7e64a7c325e2d87523e1f8210bdba0e2e159703ad00f75bff336134d8490a"},
+ {file = "aiohttp-3.12.0-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:1accf0a2270e1e05b453d1dd0f51f176148eec81306c39da39b7af5b29e1d56b"},
+ {file = "aiohttp-3.12.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:8c3aaae0180d804b4fe95cee7fe03c2ff362828c5ebb7a8370132957104b6311"},
+ {file = "aiohttp-3.12.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c0ab714799a6fd698715d9fc1d1a546a99288288939506fede60d133dc53328b"},
+ {file = "aiohttp-3.12.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:02b33c67d7db1a4b2df28e5c1e4d8c025db8e4432b3d054db3ea695063cbfc52"},
+ {file = "aiohttp-3.12.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3718948668ae986d53bd2c443ffc82e6559de2bec1d66a215c1c5e059d80ff37"},
+ {file = "aiohttp-3.12.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:fc9f188d2b864f65b17cee23d7a1923285df0c7b978058b0e2006426700d4c93"},
+ {file = "aiohttp-3.12.0-cp311-cp311-musllinux_1_2_armv7l.whl", hash = "sha256:0851359eeb146690c19d368a1c86acf33dc17535ac8123e25a0eff5f5fa110e1"},
+ {file = "aiohttp-3.12.0-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:3fcc1ccd74c932ce6b6fad61e054baa23e6624db8f5a9ec462af023abe5c600d"},
+ {file = "aiohttp-3.12.0-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:062eaf38763c6b22fcbd47a97ba06952ad7751ed7b054a690cddeed4f50547fe"},
+ {file = "aiohttp-3.12.0-cp311-cp311-musllinux_1_2_s390x.whl", hash = "sha256:b19f964b9130d572f0fed752417446ff6622fd1288e8c7860824a0dd57cd8dd5"},
+ {file = "aiohttp-3.12.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:b210c1cdc7f1a45714d17510b7e049ca7b15766b66f8c278a2c73a6021bbc389"},
+ {file = "aiohttp-3.12.0-cp311-cp311-win32.whl", hash = "sha256:6859c7ecd01cbcc839476c7d9504a19bf334bbe45715df611d351103945a9d23"},
+ {file = "aiohttp-3.12.0-cp311-cp311-win_amd64.whl", hash = "sha256:0159620f09dd338bab29e7136efd51c971462a5bb69dcdace39a2c581e87c4af"},
+ {file = "aiohttp-3.12.0-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:71fe01ddea2673973f1958c3776da990106e33a02a4a5c708d4bb34717cae712"},
+ {file = "aiohttp-3.12.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:9ce499a7ea20925572d52f86cd42e16690f4db2ff56933710bf759cf1ec68212"},
+ {file = "aiohttp-3.12.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:75a7d00e20221b1bb8a04e14dba850596cdafeac10fb112ce7b6ef0ad1f9bd42"},
+ {file = "aiohttp-3.12.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9f9cb8f69371d50ba61f061065d440edcbebf00cb4ef2141465a9e753a00ecb9"},
+ {file = "aiohttp-3.12.0-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:037a53da5016e8fa33840ecddb2bdc20091d731e0fe866f4f9d9364a94504856"},
+ {file = "aiohttp-3.12.0-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:851543bb8dd5db048c0b6a7454cae3fd0f618a592cbb70844ec0d548767b5763"},
+ {file = "aiohttp-3.12.0-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2688fb204b07c2bffcb12795b6384ec051d927147e0ec542ba3518dd60a86f2f"},
+ {file = "aiohttp-3.12.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9cbc8604c21a163ee492542b344a4f02797d48d38d335af47490d77c0e15d2ed"},
+ {file = "aiohttp-3.12.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:754d5fd1a47656592d3b11488652fba567d00c6492e9304ba59255dfee8b856f"},
+ {file = "aiohttp-3.12.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:2a613da41e577256d13929bbb4a95cadb570aebeab3914a24fc0056ae843d3c7"},
+ {file = "aiohttp-3.12.0-cp312-cp312-musllinux_1_2_armv7l.whl", hash = "sha256:9c8f9e1de28529751345f1e55cb405f22ff09fb251a1bce7fc7e915d0ee49d1f"},
+ {file = "aiohttp-3.12.0-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:32c1977f5354fef6b43b98ac830c87bddaafcfb6516c520e3241fef8f3e299e7"},
+ {file = "aiohttp-3.12.0-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:4ac3e360ab9c1b7893ae5c254a222986162bafa9f981fa85f09bad7b1527fed4"},
+ {file = "aiohttp-3.12.0-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:b3e62337e0a24925fefe638f8dd91be4324ac7f2bbbe9d8d0ae992bd35b2dc45"},
+ {file = "aiohttp-3.12.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:7285a756ba23e99f1a24cf41e8440f06a1d2cba595ee2cc1acb854e4262e2075"},
+ {file = "aiohttp-3.12.0-cp312-cp312-win32.whl", hash = "sha256:b53cd833233a09d5a22481a7e936bfdce46845e3b09f1b936d383d5c14d39ba6"},
+ {file = "aiohttp-3.12.0-cp312-cp312-win_amd64.whl", hash = "sha256:68e4a94c3bf80e93340d4c9108f57b46b019ca88eddec18bf5c8e1ded463cbef"},
+ {file = "aiohttp-3.12.0-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:6ab223f5d0bd30f1b419addc4aef37f8d7723027e3d92393281cba97f8529209"},
+ {file = "aiohttp-3.12.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:c5beab804eeff85cfae5c053e0d3bb7a7cdc2756ced50a586c56deb8b8ce16b9"},
+ {file = "aiohttp-3.12.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:bb157df65c18f4c84dd2a3b989975076d228866e6c4872220139c385bb0fea3b"},
+ {file = "aiohttp-3.12.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c9dff812b540fd31e08678fb1caed2498c294e0f75262829259588992ca59372"},
+ {file = "aiohttp-3.12.0-cp313-cp313-manylinux_2_17_armv7l.manylinux2014_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:f4f06d93c08670b8deb6e965578c804eecd85450319f403ed5695e7105ca4f38"},
+ {file = "aiohttp-3.12.0-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:bc77ef0cd57e669f4835ccced3e374c14a9890ef5b99427c5712d965b1a3dca3"},
+ {file = "aiohttp-3.12.0-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:16acea48107e36eb672530b155be727d701658c8e0132f5c38919431063df1aa"},
+ {file = "aiohttp-3.12.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8314272c09dfb3424a3015222b950ca4a0845165fa43528f079a67dd0d98bd56"},
+ {file = "aiohttp-3.12.0-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c9b51e1f1fe9ef73e3dc23908586d7ea3aa928da1b44a38f0cb0c3f60cfcfa76"},
+ {file = "aiohttp-3.12.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:471858b4cb972205fbc46b9485d8d532092df0189dd681869616bbbc7192ead3"},
+ {file = "aiohttp-3.12.0-cp313-cp313-musllinux_1_2_armv7l.whl", hash = "sha256:47d30f5fc30bd9dfe8875374aa05f566719d82e9026839dd5c59f281fb94d302"},
+ {file = "aiohttp-3.12.0-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:1c4ae2aced91b2e879f16d4f0225c7733e007367403a195c2f72d9c01dac4b68"},
+ {file = "aiohttp-3.12.0-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:c2d61673e3eec7f703419ae430417ac84305095220af11524f9496f7c0b81dc6"},
+ {file = "aiohttp-3.12.0-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:a08d1c18b588ddfd049f4ac082b9935ee68a3796dc7ad70c8317605a8bd7e298"},
+ {file = "aiohttp-3.12.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:33bb4ab2c7b86bf0ef19d426afcc3e60f08415b8e46b9cdb67b632c1d48931a3"},
+ {file = "aiohttp-3.12.0-cp313-cp313-win32.whl", hash = "sha256:199bfe20aebba88c94113def5c5f7eb8abeca55caf4dab8060fa25f573f062e5"},
+ {file = "aiohttp-3.12.0-cp313-cp313-win_amd64.whl", hash = "sha256:9c24ce9ccfe2c24e391bdd72f3d5ff9c42ed1f8b15f813cb4b4c22e0d5930433"},
+ {file = "aiohttp-3.12.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:438c44e1d0b58b2fe0c02c0bc265ebd7908b84cf1788ab53afbda459f072ee00"},
+ {file = "aiohttp-3.12.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:77f1ce28d4ed7c2aac4c23d290232771def64de95b10c06173a00be5d0ebf635"},
+ {file = "aiohttp-3.12.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:796fd64d36d1b2a1c96fea93b4423a693494f7c5439cb6139f609ad1b26c6e55"},
+ {file = "aiohttp-3.12.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d219bcc62e4470d91fea9ecff2c1563976d1363e294da8c4b79d8463f9abd60e"},
+ {file = "aiohttp-3.12.0-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:b5f6e7c74db7e88e1a6d62b2838f7cb9211d6786ae41b016faf0c1eae01fff18"},
+ {file = "aiohttp-3.12.0-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e898963e18f8734ee5f8772367beb29791ca861e0e1f7ddfeb90e75c7a6c7c83"},
+ {file = "aiohttp-3.12.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2bfcbca6abc6337cdb4b7d5329fb4bce598dcf72e67ceaafadd1cf46d95a90cc"},
+ {file = "aiohttp-3.12.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:222fdf305be960495793b872ccebc64b03d761cdf7351533c87101529840ddee"},
+ {file = "aiohttp-3.12.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f7931a21d80d1a2ba30d238b38228a7fcb3160a4a22eb2d555e80eb5962015f2"},
+ {file = "aiohttp-3.12.0-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:dbcff7b1dce09bb430e0035cdbf734a69a0c87c753e6cd2c7e87dca46e3f2443"},
+ {file = "aiohttp-3.12.0-cp39-cp39-musllinux_1_2_armv7l.whl", hash = "sha256:d1bf5632b57266aeb3af47b6ab96ef6927d20add906815f15e20ab3b15ca3fd6"},
+ {file = "aiohttp-3.12.0-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:2241d73ff8d2fb429d446e1286c5fd9a6f38c34ce5d617a28be7345abc505168"},
+ {file = "aiohttp-3.12.0-cp39-cp39-musllinux_1_2_ppc64le.whl", hash = "sha256:459196d2f86edd9588079a5c338007e744c4d02fe64231de005b47fa2d465d78"},
+ {file = "aiohttp-3.12.0-cp39-cp39-musllinux_1_2_s390x.whl", hash = "sha256:3a6785d737ad7acc95c28f945d58f65876b80715da9f9b312edb0e7a61b2a459"},
+ {file = "aiohttp-3.12.0-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:4744aa06674299040d7a560e79282df7e66769882cfc0a4f602d5d2e3b972660"},
+ {file = "aiohttp-3.12.0-cp39-cp39-win32.whl", hash = "sha256:19ae1ca271325184153c51b08512758e4c8cf631e39f37cf96b9f39d8de9be2f"},
+ {file = "aiohttp-3.12.0-cp39-cp39-win_amd64.whl", hash = "sha256:243281975c4a4fa7af43f35c962ed15ecd3f45342ef2052dd1afcf55afa14902"},
+ {file = "aiohttp-3.12.0.tar.gz", hash = "sha256:e3f0a2b4d7fb16c0d584d9b8860f1e46d39f7d93372b25a6f80c10015a7acdab"},
+]
+
+[package.dependencies]
+aiohappyeyeballs = ">=2.5.0"
+aiosignal = ">=1.1.2"
+attrs = ">=17.3.0"
+frozenlist = ">=1.1.1"
+multidict = ">=4.5,<7.0"
+propcache = ">=0.2.0"
+yarl = ">=1.17.0,<2.0"
+
+[package.extras]
+speedups = ["Brotli", "aiodns (>=3.3.0)", "brotlicffi"]
+
+[[package]]
+name = "aioitertools"
+version = "0.12.0"
+description = "itertools and builtins for AsyncIO and mixed iterables"
+optional = true
+python-versions = ">=3.8"
+groups = ["main"]
+markers = "extra == \"bedrock\""
+files = [
+ {file = "aioitertools-0.12.0-py3-none-any.whl", hash = "sha256:fc1f5fac3d737354de8831cbba3eb04f79dd649d8f3afb4c5b114925e662a796"},
+ {file = "aioitertools-0.12.0.tar.gz", hash = "sha256:c2a9055b4fbb7705f561b9d86053e8af5d10cc845d22c32008c43490b2d8dd6b"},
+]
+
+[package.extras]
+dev = ["attribution (==1.8.0)", "black (==24.8.0)", "build (>=1.2)", "coverage (==7.6.1)", "flake8 (==7.1.1)", "flit (==3.9.0)", "mypy (==1.11.2)", "ufmt (==2.7.1)", "usort (==1.0.8.post1)"]
+docs = ["sphinx (==8.0.2)", "sphinx-mdinclude (==0.6.2)"]
+
+[[package]]
+name = "aiosignal"
+version = "1.3.2"
+description = "aiosignal: a list of registered asynchronous callbacks"
+optional = false
+python-versions = ">=3.9"
+groups = ["main"]
+files = [
+ {file = "aiosignal-1.3.2-py2.py3-none-any.whl", hash = "sha256:45cde58e409a301715980c2b01d0c28bdde3770d8290b5eb2173759d9acb31a5"},
+ {file = "aiosignal-1.3.2.tar.gz", hash = "sha256:a8c255c66fafb1e499c9351d0bf32ff2d8a0321595ebac3b93713656d2436f54"},
+]
+
+[package.dependencies]
+frozenlist = ">=1.1.0"
+
+[[package]]
+name = "annotated-types"
+version = "0.7.0"
+description = "Reusable constraint types to use with typing.Annotated"
+optional = false
+python-versions = ">=3.8"
+groups = ["main"]
+files = [
+ {file = "annotated_types-0.7.0-py3-none-any.whl", hash = "sha256:1f02e8b43a8fbbc3f3e0d4f0f4bfc8131bcb4eebe8849b8e5c773f3a1c582a53"},
+ {file = "annotated_types-0.7.0.tar.gz", hash = "sha256:aff07c09a53a08bc8cfccb9c85b05f1aa9a2a6f23728d790723543408344ce89"},
+]
+
+[[package]]
+name = "anthropic"
+version = "0.49.0"
+description = "The official Python library for the anthropic API"
+optional = true
+python-versions = ">=3.8"
+groups = ["main"]
+markers = "extra == \"anthropic\""
+files = [
+ {file = "anthropic-0.49.0-py3-none-any.whl", hash = "sha256:bbc17ad4e7094988d2fa86b87753ded8dce12498f4b85fe5810f208f454a8375"},
+ {file = "anthropic-0.49.0.tar.gz", hash = "sha256:c09e885b0f674b9119b4f296d8508907f6cff0009bc20d5cf6b35936c40b4398"},
+]
+
+[package.dependencies]
+anyio = ">=3.5.0,<5"
+distro = ">=1.7.0,<2"
+httpx = ">=0.23.0,<1"
+jiter = ">=0.4.0,<1"
+pydantic = ">=1.9.0,<3"
+sniffio = "*"
+typing-extensions = ">=4.10,<5"
+
+[package.extras]
+bedrock = ["boto3 (>=1.28.57)", "botocore (>=1.31.57)"]
+vertex = ["google-auth (>=2,<3)"]
+
+[[package]]
+name = "anyio"
+version = "4.9.0"
+description = "High level compatibility layer for multiple asynchronous event loop implementations"
+optional = false
+python-versions = ">=3.9"
+groups = ["main"]
+files = [
+ {file = "anyio-4.9.0-py3-none-any.whl", hash = "sha256:9f76d541cad6e36af7beb62e978876f3b41e3e04f2c1fbf0884604c0a9c4d93c"},
+ {file = "anyio-4.9.0.tar.gz", hash = "sha256:673c0c244e15788651a4ff38710fea9675823028a6f08a5eda409e0c9840a028"},
+]
+
+[package.dependencies]
+idna = ">=2.8"
+sniffio = ">=1.1"
+typing_extensions = {version = ">=4.5", markers = "python_version < \"3.13\""}
+
+[package.extras]
+doc = ["Sphinx (>=8.2,<9.0)", "packaging", "sphinx-autodoc-typehints (>=1.2.0)", "sphinx_rtd_theme"]
+test = ["anyio[trio]", "blockbuster (>=1.5.23)", "coverage[toml] (>=7)", "exceptiongroup (>=1.2.0)", "hypothesis (>=4.0)", "psutil (>=5.9)", "pytest (>=7.0)", "trustme", "truststore (>=0.9.1)", "uvloop (>=0.21)"]
+trio = ["trio (>=0.26.1)"]
+
+[[package]]
+name = "attrs"
+version = "25.3.0"
+description = "Classes Without Boilerplate"
+optional = false
+python-versions = ">=3.8"
+groups = ["main"]
+files = [
+ {file = "attrs-25.3.0-py3-none-any.whl", hash = "sha256:427318ce031701fea540783410126f03899a97ffc6f61596ad581ac2e40e3bc3"},
+ {file = "attrs-25.3.0.tar.gz", hash = "sha256:75d7cefc7fb576747b2c81b4442d4d4a1ce0900973527c011d1030fd3bf4af1b"},
+]
+
+[package.extras]
+benchmark = ["cloudpickle", "hypothesis", "mypy (>=1.11.1)", "pympler", "pytest (>=4.3.0)", "pytest-codspeed", "pytest-mypy-plugins", "pytest-xdist[psutil]"]
+cov = ["cloudpickle", "coverage[toml] (>=5.3)", "hypothesis", "mypy (>=1.11.1)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-xdist[psutil]"]
+dev = ["cloudpickle", "hypothesis", "mypy (>=1.11.1)", "pre-commit-uv", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-xdist[psutil]"]
+docs = ["cogapp", "furo", "myst-parser", "sphinx", "sphinx-notfound-page", "sphinxcontrib-towncrier", "towncrier"]
+tests = ["cloudpickle", "hypothesis", "mypy (>=1.11.1)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-xdist[psutil]"]
+tests-mypy = ["mypy (>=1.11.1)", "pytest-mypy-plugins"]
+
+[[package]]
+name = "boto3"
+version = "1.36.1"
+description = "The AWS SDK for Python"
+optional = true
+python-versions = ">=3.8"
+groups = ["main"]
+markers = "extra == \"bedrock\""
+files = [
+ {file = "boto3-1.36.1-py3-none-any.whl", hash = "sha256:eb21380d73fec6645439c0d802210f72a0cdb3295b02953f246ff53f512faa8f"},
+ {file = "boto3-1.36.1.tar.gz", hash = "sha256:258ab77225a81d3cf3029c9afe9920cd9dec317689dfadec6f6f0a23130bb60a"},
+]
+
+[package.dependencies]
+botocore = ">=1.36.1,<1.37.0"
+jmespath = ">=0.7.1,<2.0.0"
+s3transfer = ">=0.11.0,<0.12.0"
+
+[package.extras]
+crt = ["botocore[crt] (>=1.21.0,<2.0a0)"]
+
+[[package]]
+name = "boto3-stubs"
+version = "1.38.23"
+description = "Type annotations for boto3 1.38.23 generated with mypy-boto3-builder 8.11.0"
+optional = false
+python-versions = ">=3.8"
+groups = ["dev"]
+files = [
+ {file = "boto3_stubs-1.38.23-py3-none-any.whl", hash = "sha256:fb6f97862fa67f8c3052a936ef4e012880a6c0719fce5b94b24e205c300c24dd"},
+ {file = "boto3_stubs-1.38.23.tar.gz", hash = "sha256:f7632c193f06828b984d7e2bcfbc8c5eca8066ed390a235ad9f35f72307512bc"},
+]
+
+[package.dependencies]
+botocore-stubs = "*"
+types-s3transfer = "*"
+typing-extensions = {version = ">=4.1.0", markers = "python_version < \"3.12\""}
+
+[package.extras]
+accessanalyzer = ["mypy-boto3-accessanalyzer (>=1.38.0,<1.39.0)"]
+account = ["mypy-boto3-account (>=1.38.0,<1.39.0)"]
+acm = ["mypy-boto3-acm (>=1.38.0,<1.39.0)"]
+acm-pca = ["mypy-boto3-acm-pca (>=1.38.0,<1.39.0)"]
+all = ["mypy-boto3-accessanalyzer (>=1.38.0,<1.39.0)", "mypy-boto3-account (>=1.38.0,<1.39.0)", "mypy-boto3-acm (>=1.38.0,<1.39.0)", "mypy-boto3-acm-pca (>=1.38.0,<1.39.0)", "mypy-boto3-amp (>=1.38.0,<1.39.0)", "mypy-boto3-amplify (>=1.38.0,<1.39.0)", "mypy-boto3-amplifybackend (>=1.38.0,<1.39.0)", "mypy-boto3-amplifyuibuilder (>=1.38.0,<1.39.0)", "mypy-boto3-apigateway (>=1.38.0,<1.39.0)", "mypy-boto3-apigatewaymanagementapi (>=1.38.0,<1.39.0)", "mypy-boto3-apigatewayv2 (>=1.38.0,<1.39.0)", "mypy-boto3-appconfig (>=1.38.0,<1.39.0)", "mypy-boto3-appconfigdata (>=1.38.0,<1.39.0)", "mypy-boto3-appfabric (>=1.38.0,<1.39.0)", "mypy-boto3-appflow (>=1.38.0,<1.39.0)", "mypy-boto3-appintegrations (>=1.38.0,<1.39.0)", "mypy-boto3-application-autoscaling (>=1.38.0,<1.39.0)", "mypy-boto3-application-insights (>=1.38.0,<1.39.0)", "mypy-boto3-application-signals (>=1.38.0,<1.39.0)", "mypy-boto3-applicationcostprofiler (>=1.38.0,<1.39.0)", "mypy-boto3-appmesh (>=1.38.0,<1.39.0)", "mypy-boto3-apprunner (>=1.38.0,<1.39.0)", "mypy-boto3-appstream (>=1.38.0,<1.39.0)", "mypy-boto3-appsync (>=1.38.0,<1.39.0)", "mypy-boto3-apptest (>=1.38.0,<1.39.0)", "mypy-boto3-arc-zonal-shift (>=1.38.0,<1.39.0)", "mypy-boto3-artifact (>=1.38.0,<1.39.0)", "mypy-boto3-athena (>=1.38.0,<1.39.0)", "mypy-boto3-auditmanager (>=1.38.0,<1.39.0)", "mypy-boto3-autoscaling (>=1.38.0,<1.39.0)", "mypy-boto3-autoscaling-plans (>=1.38.0,<1.39.0)", "mypy-boto3-b2bi (>=1.38.0,<1.39.0)", "mypy-boto3-backup (>=1.38.0,<1.39.0)", "mypy-boto3-backup-gateway (>=1.38.0,<1.39.0)", "mypy-boto3-backupsearch (>=1.38.0,<1.39.0)", "mypy-boto3-batch (>=1.38.0,<1.39.0)", "mypy-boto3-bcm-data-exports (>=1.38.0,<1.39.0)", "mypy-boto3-bcm-pricing-calculator (>=1.38.0,<1.39.0)", "mypy-boto3-bedrock (>=1.38.0,<1.39.0)", "mypy-boto3-bedrock-agent (>=1.38.0,<1.39.0)", "mypy-boto3-bedrock-agent-runtime (>=1.38.0,<1.39.0)", "mypy-boto3-bedrock-data-automation (>=1.38.0,<1.39.0)", "mypy-boto3-bedrock-data-automation-runtime (>=1.38.0,<1.39.0)", "mypy-boto3-bedrock-runtime (>=1.38.0,<1.39.0)", "mypy-boto3-billing (>=1.38.0,<1.39.0)", "mypy-boto3-billingconductor (>=1.38.0,<1.39.0)", "mypy-boto3-braket (>=1.38.0,<1.39.0)", "mypy-boto3-budgets (>=1.38.0,<1.39.0)", "mypy-boto3-ce (>=1.38.0,<1.39.0)", "mypy-boto3-chatbot (>=1.38.0,<1.39.0)", "mypy-boto3-chime (>=1.38.0,<1.39.0)", "mypy-boto3-chime-sdk-identity (>=1.38.0,<1.39.0)", "mypy-boto3-chime-sdk-media-pipelines (>=1.38.0,<1.39.0)", "mypy-boto3-chime-sdk-meetings (>=1.38.0,<1.39.0)", "mypy-boto3-chime-sdk-messaging (>=1.38.0,<1.39.0)", "mypy-boto3-chime-sdk-voice (>=1.38.0,<1.39.0)", "mypy-boto3-cleanrooms (>=1.38.0,<1.39.0)", "mypy-boto3-cleanroomsml (>=1.38.0,<1.39.0)", "mypy-boto3-cloud9 (>=1.38.0,<1.39.0)", "mypy-boto3-cloudcontrol (>=1.38.0,<1.39.0)", "mypy-boto3-clouddirectory (>=1.38.0,<1.39.0)", "mypy-boto3-cloudformation (>=1.38.0,<1.39.0)", "mypy-boto3-cloudfront (>=1.38.0,<1.39.0)", "mypy-boto3-cloudfront-keyvaluestore (>=1.38.0,<1.39.0)", "mypy-boto3-cloudhsm (>=1.38.0,<1.39.0)", "mypy-boto3-cloudhsmv2 (>=1.38.0,<1.39.0)", "mypy-boto3-cloudsearch (>=1.38.0,<1.39.0)", "mypy-boto3-cloudsearchdomain (>=1.38.0,<1.39.0)", "mypy-boto3-cloudtrail (>=1.38.0,<1.39.0)", "mypy-boto3-cloudtrail-data (>=1.38.0,<1.39.0)", "mypy-boto3-cloudwatch (>=1.38.0,<1.39.0)", "mypy-boto3-codeartifact (>=1.38.0,<1.39.0)", "mypy-boto3-codebuild (>=1.38.0,<1.39.0)", "mypy-boto3-codecatalyst (>=1.38.0,<1.39.0)", "mypy-boto3-codecommit (>=1.38.0,<1.39.0)", "mypy-boto3-codeconnections (>=1.38.0,<1.39.0)", "mypy-boto3-codedeploy (>=1.38.0,<1.39.0)", "mypy-boto3-codeguru-reviewer (>=1.38.0,<1.39.0)", "mypy-boto3-codeguru-security (>=1.38.0,<1.39.0)", "mypy-boto3-codeguruprofiler (>=1.38.0,<1.39.0)", "mypy-boto3-codepipeline (>=1.38.0,<1.39.0)", "mypy-boto3-codestar-connections (>=1.38.0,<1.39.0)", "mypy-boto3-codestar-notifications (>=1.38.0,<1.39.0)", "mypy-boto3-cognito-identity (>=1.38.0,<1.39.0)", "mypy-boto3-cognito-idp (>=1.38.0,<1.39.0)", "mypy-boto3-cognito-sync (>=1.38.0,<1.39.0)", "mypy-boto3-comprehend (>=1.38.0,<1.39.0)", "mypy-boto3-comprehendmedical (>=1.38.0,<1.39.0)", "mypy-boto3-compute-optimizer (>=1.38.0,<1.39.0)", "mypy-boto3-config (>=1.38.0,<1.39.0)", "mypy-boto3-connect (>=1.38.0,<1.39.0)", "mypy-boto3-connect-contact-lens (>=1.38.0,<1.39.0)", "mypy-boto3-connectcampaigns (>=1.38.0,<1.39.0)", "mypy-boto3-connectcampaignsv2 (>=1.38.0,<1.39.0)", "mypy-boto3-connectcases (>=1.38.0,<1.39.0)", "mypy-boto3-connectparticipant (>=1.38.0,<1.39.0)", "mypy-boto3-controlcatalog (>=1.38.0,<1.39.0)", "mypy-boto3-controltower (>=1.38.0,<1.39.0)", "mypy-boto3-cost-optimization-hub (>=1.38.0,<1.39.0)", "mypy-boto3-cur (>=1.38.0,<1.39.0)", "mypy-boto3-customer-profiles (>=1.38.0,<1.39.0)", "mypy-boto3-databrew (>=1.38.0,<1.39.0)", "mypy-boto3-dataexchange (>=1.38.0,<1.39.0)", "mypy-boto3-datapipeline (>=1.38.0,<1.39.0)", "mypy-boto3-datasync (>=1.38.0,<1.39.0)", "mypy-boto3-datazone (>=1.38.0,<1.39.0)", "mypy-boto3-dax (>=1.38.0,<1.39.0)", "mypy-boto3-deadline (>=1.38.0,<1.39.0)", "mypy-boto3-detective (>=1.38.0,<1.39.0)", "mypy-boto3-devicefarm (>=1.38.0,<1.39.0)", "mypy-boto3-devops-guru (>=1.38.0,<1.39.0)", "mypy-boto3-directconnect (>=1.38.0,<1.39.0)", "mypy-boto3-discovery (>=1.38.0,<1.39.0)", "mypy-boto3-dlm (>=1.38.0,<1.39.0)", "mypy-boto3-dms (>=1.38.0,<1.39.0)", "mypy-boto3-docdb (>=1.38.0,<1.39.0)", "mypy-boto3-docdb-elastic (>=1.38.0,<1.39.0)", "mypy-boto3-drs (>=1.38.0,<1.39.0)", "mypy-boto3-ds (>=1.38.0,<1.39.0)", "mypy-boto3-ds-data (>=1.38.0,<1.39.0)", "mypy-boto3-dsql (>=1.38.0,<1.39.0)", "mypy-boto3-dynamodb (>=1.38.0,<1.39.0)", "mypy-boto3-dynamodbstreams (>=1.38.0,<1.39.0)", "mypy-boto3-ebs (>=1.38.0,<1.39.0)", "mypy-boto3-ec2 (>=1.38.0,<1.39.0)", "mypy-boto3-ec2-instance-connect (>=1.38.0,<1.39.0)", "mypy-boto3-ecr (>=1.38.0,<1.39.0)", "mypy-boto3-ecr-public (>=1.38.0,<1.39.0)", "mypy-boto3-ecs (>=1.38.0,<1.39.0)", "mypy-boto3-efs (>=1.38.0,<1.39.0)", "mypy-boto3-eks (>=1.38.0,<1.39.0)", "mypy-boto3-eks-auth (>=1.38.0,<1.39.0)", "mypy-boto3-elasticache (>=1.38.0,<1.39.0)", "mypy-boto3-elasticbeanstalk (>=1.38.0,<1.39.0)", "mypy-boto3-elastictranscoder (>=1.38.0,<1.39.0)", "mypy-boto3-elb (>=1.38.0,<1.39.0)", "mypy-boto3-elbv2 (>=1.38.0,<1.39.0)", "mypy-boto3-emr (>=1.38.0,<1.39.0)", "mypy-boto3-emr-containers (>=1.38.0,<1.39.0)", "mypy-boto3-emr-serverless (>=1.38.0,<1.39.0)", "mypy-boto3-entityresolution (>=1.38.0,<1.39.0)", "mypy-boto3-es (>=1.38.0,<1.39.0)", "mypy-boto3-events (>=1.38.0,<1.39.0)", "mypy-boto3-evidently (>=1.38.0,<1.39.0)", "mypy-boto3-finspace (>=1.38.0,<1.39.0)", "mypy-boto3-finspace-data (>=1.38.0,<1.39.0)", "mypy-boto3-firehose (>=1.38.0,<1.39.0)", "mypy-boto3-fis (>=1.38.0,<1.39.0)", "mypy-boto3-fms (>=1.38.0,<1.39.0)", "mypy-boto3-forecast (>=1.38.0,<1.39.0)", "mypy-boto3-forecastquery (>=1.38.0,<1.39.0)", "mypy-boto3-frauddetector (>=1.38.0,<1.39.0)", "mypy-boto3-freetier (>=1.38.0,<1.39.0)", "mypy-boto3-fsx (>=1.38.0,<1.39.0)", "mypy-boto3-gamelift (>=1.38.0,<1.39.0)", "mypy-boto3-gameliftstreams (>=1.38.0,<1.39.0)", "mypy-boto3-geo-maps (>=1.38.0,<1.39.0)", "mypy-boto3-geo-places (>=1.38.0,<1.39.0)", "mypy-boto3-geo-routes (>=1.38.0,<1.39.0)", "mypy-boto3-glacier (>=1.38.0,<1.39.0)", "mypy-boto3-globalaccelerator (>=1.38.0,<1.39.0)", "mypy-boto3-glue (>=1.38.0,<1.39.0)", "mypy-boto3-grafana (>=1.38.0,<1.39.0)", "mypy-boto3-greengrass (>=1.38.0,<1.39.0)", "mypy-boto3-greengrassv2 (>=1.38.0,<1.39.0)", "mypy-boto3-groundstation (>=1.38.0,<1.39.0)", "mypy-boto3-guardduty (>=1.38.0,<1.39.0)", "mypy-boto3-health (>=1.38.0,<1.39.0)", "mypy-boto3-healthlake (>=1.38.0,<1.39.0)", "mypy-boto3-iam (>=1.38.0,<1.39.0)", "mypy-boto3-identitystore (>=1.38.0,<1.39.0)", "mypy-boto3-imagebuilder (>=1.38.0,<1.39.0)", "mypy-boto3-importexport (>=1.38.0,<1.39.0)", "mypy-boto3-inspector (>=1.38.0,<1.39.0)", "mypy-boto3-inspector-scan (>=1.38.0,<1.39.0)", "mypy-boto3-inspector2 (>=1.38.0,<1.39.0)", "mypy-boto3-internetmonitor (>=1.38.0,<1.39.0)", "mypy-boto3-invoicing (>=1.38.0,<1.39.0)", "mypy-boto3-iot (>=1.38.0,<1.39.0)", "mypy-boto3-iot-data (>=1.38.0,<1.39.0)", "mypy-boto3-iot-jobs-data (>=1.38.0,<1.39.0)", "mypy-boto3-iot-managed-integrations (>=1.38.0,<1.39.0)", "mypy-boto3-iotanalytics (>=1.38.0,<1.39.0)", "mypy-boto3-iotdeviceadvisor (>=1.38.0,<1.39.0)", "mypy-boto3-iotevents (>=1.38.0,<1.39.0)", "mypy-boto3-iotevents-data (>=1.38.0,<1.39.0)", "mypy-boto3-iotfleethub (>=1.38.0,<1.39.0)", "mypy-boto3-iotfleetwise (>=1.38.0,<1.39.0)", "mypy-boto3-iotsecuretunneling (>=1.38.0,<1.39.0)", "mypy-boto3-iotsitewise (>=1.38.0,<1.39.0)", "mypy-boto3-iotthingsgraph (>=1.38.0,<1.39.0)", "mypy-boto3-iottwinmaker (>=1.38.0,<1.39.0)", "mypy-boto3-iotwireless (>=1.38.0,<1.39.0)", "mypy-boto3-ivs (>=1.38.0,<1.39.0)", "mypy-boto3-ivs-realtime (>=1.38.0,<1.39.0)", "mypy-boto3-ivschat (>=1.38.0,<1.39.0)", "mypy-boto3-kafka (>=1.38.0,<1.39.0)", "mypy-boto3-kafkaconnect (>=1.38.0,<1.39.0)", "mypy-boto3-kendra (>=1.38.0,<1.39.0)", "mypy-boto3-kendra-ranking (>=1.38.0,<1.39.0)", "mypy-boto3-keyspaces (>=1.38.0,<1.39.0)", "mypy-boto3-kinesis (>=1.38.0,<1.39.0)", "mypy-boto3-kinesis-video-archived-media (>=1.38.0,<1.39.0)", "mypy-boto3-kinesis-video-media (>=1.38.0,<1.39.0)", "mypy-boto3-kinesis-video-signaling (>=1.38.0,<1.39.0)", "mypy-boto3-kinesis-video-webrtc-storage (>=1.38.0,<1.39.0)", "mypy-boto3-kinesisanalytics (>=1.38.0,<1.39.0)", "mypy-boto3-kinesisanalyticsv2 (>=1.38.0,<1.39.0)", "mypy-boto3-kinesisvideo (>=1.38.0,<1.39.0)", "mypy-boto3-kms (>=1.38.0,<1.39.0)", "mypy-boto3-lakeformation (>=1.38.0,<1.39.0)", "mypy-boto3-lambda (>=1.38.0,<1.39.0)", "mypy-boto3-launch-wizard (>=1.38.0,<1.39.0)", "mypy-boto3-lex-models (>=1.38.0,<1.39.0)", "mypy-boto3-lex-runtime (>=1.38.0,<1.39.0)", "mypy-boto3-lexv2-models (>=1.38.0,<1.39.0)", "mypy-boto3-lexv2-runtime (>=1.38.0,<1.39.0)", "mypy-boto3-license-manager (>=1.38.0,<1.39.0)", "mypy-boto3-license-manager-linux-subscriptions (>=1.38.0,<1.39.0)", "mypy-boto3-license-manager-user-subscriptions (>=1.38.0,<1.39.0)", "mypy-boto3-lightsail (>=1.38.0,<1.39.0)", "mypy-boto3-location (>=1.38.0,<1.39.0)", "mypy-boto3-logs (>=1.38.0,<1.39.0)", "mypy-boto3-lookoutequipment (>=1.38.0,<1.39.0)", "mypy-boto3-lookoutmetrics (>=1.38.0,<1.39.0)", "mypy-boto3-lookoutvision (>=1.38.0,<1.39.0)", "mypy-boto3-m2 (>=1.38.0,<1.39.0)", "mypy-boto3-machinelearning (>=1.38.0,<1.39.0)", "mypy-boto3-macie2 (>=1.38.0,<1.39.0)", "mypy-boto3-mailmanager (>=1.38.0,<1.39.0)", "mypy-boto3-managedblockchain (>=1.38.0,<1.39.0)", "mypy-boto3-managedblockchain-query (>=1.38.0,<1.39.0)", "mypy-boto3-marketplace-agreement (>=1.38.0,<1.39.0)", "mypy-boto3-marketplace-catalog (>=1.38.0,<1.39.0)", "mypy-boto3-marketplace-deployment (>=1.38.0,<1.39.0)", "mypy-boto3-marketplace-entitlement (>=1.38.0,<1.39.0)", "mypy-boto3-marketplace-reporting (>=1.38.0,<1.39.0)", "mypy-boto3-marketplacecommerceanalytics (>=1.38.0,<1.39.0)", "mypy-boto3-mediaconnect (>=1.38.0,<1.39.0)", "mypy-boto3-mediaconvert (>=1.38.0,<1.39.0)", "mypy-boto3-medialive (>=1.38.0,<1.39.0)", "mypy-boto3-mediapackage (>=1.38.0,<1.39.0)", "mypy-boto3-mediapackage-vod (>=1.38.0,<1.39.0)", "mypy-boto3-mediapackagev2 (>=1.38.0,<1.39.0)", "mypy-boto3-mediastore (>=1.38.0,<1.39.0)", "mypy-boto3-mediastore-data (>=1.38.0,<1.39.0)", "mypy-boto3-mediatailor (>=1.38.0,<1.39.0)", "mypy-boto3-medical-imaging (>=1.38.0,<1.39.0)", "mypy-boto3-memorydb (>=1.38.0,<1.39.0)", "mypy-boto3-meteringmarketplace (>=1.38.0,<1.39.0)", "mypy-boto3-mgh (>=1.38.0,<1.39.0)", "mypy-boto3-mgn (>=1.38.0,<1.39.0)", "mypy-boto3-migration-hub-refactor-spaces (>=1.38.0,<1.39.0)", "mypy-boto3-migrationhub-config (>=1.38.0,<1.39.0)", "mypy-boto3-migrationhuborchestrator (>=1.38.0,<1.39.0)", "mypy-boto3-migrationhubstrategy (>=1.38.0,<1.39.0)", "mypy-boto3-mq (>=1.38.0,<1.39.0)", "mypy-boto3-mturk (>=1.38.0,<1.39.0)", "mypy-boto3-mwaa (>=1.38.0,<1.39.0)", "mypy-boto3-neptune (>=1.38.0,<1.39.0)", "mypy-boto3-neptune-graph (>=1.38.0,<1.39.0)", "mypy-boto3-neptunedata (>=1.38.0,<1.39.0)", "mypy-boto3-network-firewall (>=1.38.0,<1.39.0)", "mypy-boto3-networkflowmonitor (>=1.38.0,<1.39.0)", "mypy-boto3-networkmanager (>=1.38.0,<1.39.0)", "mypy-boto3-networkmonitor (>=1.38.0,<1.39.0)", "mypy-boto3-notifications (>=1.38.0,<1.39.0)", "mypy-boto3-notificationscontacts (>=1.38.0,<1.39.0)", "mypy-boto3-oam (>=1.38.0,<1.39.0)", "mypy-boto3-observabilityadmin (>=1.38.0,<1.39.0)", "mypy-boto3-omics (>=1.38.0,<1.39.0)", "mypy-boto3-opensearch (>=1.38.0,<1.39.0)", "mypy-boto3-opensearchserverless (>=1.38.0,<1.39.0)", "mypy-boto3-opsworks (>=1.38.0,<1.39.0)", "mypy-boto3-opsworkscm (>=1.38.0,<1.39.0)", "mypy-boto3-organizations (>=1.38.0,<1.39.0)", "mypy-boto3-osis (>=1.38.0,<1.39.0)", "mypy-boto3-outposts (>=1.38.0,<1.39.0)", "mypy-boto3-panorama (>=1.38.0,<1.39.0)", "mypy-boto3-partnercentral-selling (>=1.38.0,<1.39.0)", "mypy-boto3-payment-cryptography (>=1.38.0,<1.39.0)", "mypy-boto3-payment-cryptography-data (>=1.38.0,<1.39.0)", "mypy-boto3-pca-connector-ad (>=1.38.0,<1.39.0)", "mypy-boto3-pca-connector-scep (>=1.38.0,<1.39.0)", "mypy-boto3-pcs (>=1.38.0,<1.39.0)", "mypy-boto3-personalize (>=1.38.0,<1.39.0)", "mypy-boto3-personalize-events (>=1.38.0,<1.39.0)", "mypy-boto3-personalize-runtime (>=1.38.0,<1.39.0)", "mypy-boto3-pi (>=1.38.0,<1.39.0)", "mypy-boto3-pinpoint (>=1.38.0,<1.39.0)", "mypy-boto3-pinpoint-email (>=1.38.0,<1.39.0)", "mypy-boto3-pinpoint-sms-voice (>=1.38.0,<1.39.0)", "mypy-boto3-pinpoint-sms-voice-v2 (>=1.38.0,<1.39.0)", "mypy-boto3-pipes (>=1.38.0,<1.39.0)", "mypy-boto3-polly (>=1.38.0,<1.39.0)", "mypy-boto3-pricing (>=1.38.0,<1.39.0)", "mypy-boto3-proton (>=1.38.0,<1.39.0)", "mypy-boto3-qapps (>=1.38.0,<1.39.0)", "mypy-boto3-qbusiness (>=1.38.0,<1.39.0)", "mypy-boto3-qconnect (>=1.38.0,<1.39.0)", "mypy-boto3-qldb (>=1.38.0,<1.39.0)", "mypy-boto3-qldb-session (>=1.38.0,<1.39.0)", "mypy-boto3-quicksight (>=1.38.0,<1.39.0)", "mypy-boto3-ram (>=1.38.0,<1.39.0)", "mypy-boto3-rbin (>=1.38.0,<1.39.0)", "mypy-boto3-rds (>=1.38.0,<1.39.0)", "mypy-boto3-rds-data (>=1.38.0,<1.39.0)", "mypy-boto3-redshift (>=1.38.0,<1.39.0)", "mypy-boto3-redshift-data (>=1.38.0,<1.39.0)", "mypy-boto3-redshift-serverless (>=1.38.0,<1.39.0)", "mypy-boto3-rekognition (>=1.38.0,<1.39.0)", "mypy-boto3-repostspace (>=1.38.0,<1.39.0)", "mypy-boto3-resiliencehub (>=1.38.0,<1.39.0)", "mypy-boto3-resource-explorer-2 (>=1.38.0,<1.39.0)", "mypy-boto3-resource-groups (>=1.38.0,<1.39.0)", "mypy-boto3-resourcegroupstaggingapi (>=1.38.0,<1.39.0)", "mypy-boto3-robomaker (>=1.38.0,<1.39.0)", "mypy-boto3-rolesanywhere (>=1.38.0,<1.39.0)", "mypy-boto3-route53 (>=1.38.0,<1.39.0)", "mypy-boto3-route53-recovery-cluster (>=1.38.0,<1.39.0)", "mypy-boto3-route53-recovery-control-config (>=1.38.0,<1.39.0)", "mypy-boto3-route53-recovery-readiness (>=1.38.0,<1.39.0)", "mypy-boto3-route53domains (>=1.38.0,<1.39.0)", "mypy-boto3-route53profiles (>=1.38.0,<1.39.0)", "mypy-boto3-route53resolver (>=1.38.0,<1.39.0)", "mypy-boto3-rum (>=1.38.0,<1.39.0)", "mypy-boto3-s3 (>=1.38.0,<1.39.0)", "mypy-boto3-s3control (>=1.38.0,<1.39.0)", "mypy-boto3-s3outposts (>=1.38.0,<1.39.0)", "mypy-boto3-s3tables (>=1.38.0,<1.39.0)", "mypy-boto3-sagemaker (>=1.38.0,<1.39.0)", "mypy-boto3-sagemaker-a2i-runtime (>=1.38.0,<1.39.0)", "mypy-boto3-sagemaker-edge (>=1.38.0,<1.39.0)", "mypy-boto3-sagemaker-featurestore-runtime (>=1.38.0,<1.39.0)", "mypy-boto3-sagemaker-geospatial (>=1.38.0,<1.39.0)", "mypy-boto3-sagemaker-metrics (>=1.38.0,<1.39.0)", "mypy-boto3-sagemaker-runtime (>=1.38.0,<1.39.0)", "mypy-boto3-savingsplans (>=1.38.0,<1.39.0)", "mypy-boto3-scheduler (>=1.38.0,<1.39.0)", "mypy-boto3-schemas (>=1.38.0,<1.39.0)", "mypy-boto3-sdb (>=1.38.0,<1.39.0)", "mypy-boto3-secretsmanager (>=1.38.0,<1.39.0)", "mypy-boto3-security-ir (>=1.38.0,<1.39.0)", "mypy-boto3-securityhub (>=1.38.0,<1.39.0)", "mypy-boto3-securitylake (>=1.38.0,<1.39.0)", "mypy-boto3-serverlessrepo (>=1.38.0,<1.39.0)", "mypy-boto3-service-quotas (>=1.38.0,<1.39.0)", "mypy-boto3-servicecatalog (>=1.38.0,<1.39.0)", "mypy-boto3-servicecatalog-appregistry (>=1.38.0,<1.39.0)", "mypy-boto3-servicediscovery (>=1.38.0,<1.39.0)", "mypy-boto3-ses (>=1.38.0,<1.39.0)", "mypy-boto3-sesv2 (>=1.38.0,<1.39.0)", "mypy-boto3-shield (>=1.38.0,<1.39.0)", "mypy-boto3-signer (>=1.38.0,<1.39.0)", "mypy-boto3-simspaceweaver (>=1.38.0,<1.39.0)", "mypy-boto3-sms (>=1.38.0,<1.39.0)", "mypy-boto3-snow-device-management (>=1.38.0,<1.39.0)", "mypy-boto3-snowball (>=1.38.0,<1.39.0)", "mypy-boto3-sns (>=1.38.0,<1.39.0)", "mypy-boto3-socialmessaging (>=1.38.0,<1.39.0)", "mypy-boto3-sqs (>=1.38.0,<1.39.0)", "mypy-boto3-ssm (>=1.38.0,<1.39.0)", "mypy-boto3-ssm-contacts (>=1.38.0,<1.39.0)", "mypy-boto3-ssm-guiconnect (>=1.38.0,<1.39.0)", "mypy-boto3-ssm-incidents (>=1.38.0,<1.39.0)", "mypy-boto3-ssm-quicksetup (>=1.38.0,<1.39.0)", "mypy-boto3-ssm-sap (>=1.38.0,<1.39.0)", "mypy-boto3-sso (>=1.38.0,<1.39.0)", "mypy-boto3-sso-admin (>=1.38.0,<1.39.0)", "mypy-boto3-sso-oidc (>=1.38.0,<1.39.0)", "mypy-boto3-stepfunctions (>=1.38.0,<1.39.0)", "mypy-boto3-storagegateway (>=1.38.0,<1.39.0)", "mypy-boto3-sts (>=1.38.0,<1.39.0)", "mypy-boto3-supplychain (>=1.38.0,<1.39.0)", "mypy-boto3-support (>=1.38.0,<1.39.0)", "mypy-boto3-support-app (>=1.38.0,<1.39.0)", "mypy-boto3-swf (>=1.38.0,<1.39.0)", "mypy-boto3-synthetics (>=1.38.0,<1.39.0)", "mypy-boto3-taxsettings (>=1.38.0,<1.39.0)", "mypy-boto3-textract (>=1.38.0,<1.39.0)", "mypy-boto3-timestream-influxdb (>=1.38.0,<1.39.0)", "mypy-boto3-timestream-query (>=1.38.0,<1.39.0)", "mypy-boto3-timestream-write (>=1.38.0,<1.39.0)", "mypy-boto3-tnb (>=1.38.0,<1.39.0)", "mypy-boto3-transcribe (>=1.38.0,<1.39.0)", "mypy-boto3-transfer (>=1.38.0,<1.39.0)", "mypy-boto3-translate (>=1.38.0,<1.39.0)", "mypy-boto3-trustedadvisor (>=1.38.0,<1.39.0)", "mypy-boto3-verifiedpermissions (>=1.38.0,<1.39.0)", "mypy-boto3-voice-id (>=1.38.0,<1.39.0)", "mypy-boto3-vpc-lattice (>=1.38.0,<1.39.0)", "mypy-boto3-waf (>=1.38.0,<1.39.0)", "mypy-boto3-waf-regional (>=1.38.0,<1.39.0)", "mypy-boto3-wafv2 (>=1.38.0,<1.39.0)", "mypy-boto3-wellarchitected (>=1.38.0,<1.39.0)", "mypy-boto3-wisdom (>=1.38.0,<1.39.0)", "mypy-boto3-workdocs (>=1.38.0,<1.39.0)", "mypy-boto3-workmail (>=1.38.0,<1.39.0)", "mypy-boto3-workmailmessageflow (>=1.38.0,<1.39.0)", "mypy-boto3-workspaces (>=1.38.0,<1.39.0)", "mypy-boto3-workspaces-thin-client (>=1.38.0,<1.39.0)", "mypy-boto3-workspaces-web (>=1.38.0,<1.39.0)", "mypy-boto3-xray (>=1.38.0,<1.39.0)"]
+amp = ["mypy-boto3-amp (>=1.38.0,<1.39.0)"]
+amplify = ["mypy-boto3-amplify (>=1.38.0,<1.39.0)"]
+amplifybackend = ["mypy-boto3-amplifybackend (>=1.38.0,<1.39.0)"]
+amplifyuibuilder = ["mypy-boto3-amplifyuibuilder (>=1.38.0,<1.39.0)"]
+apigateway = ["mypy-boto3-apigateway (>=1.38.0,<1.39.0)"]
+apigatewaymanagementapi = ["mypy-boto3-apigatewaymanagementapi (>=1.38.0,<1.39.0)"]
+apigatewayv2 = ["mypy-boto3-apigatewayv2 (>=1.38.0,<1.39.0)"]
+appconfig = ["mypy-boto3-appconfig (>=1.38.0,<1.39.0)"]
+appconfigdata = ["mypy-boto3-appconfigdata (>=1.38.0,<1.39.0)"]
+appfabric = ["mypy-boto3-appfabric (>=1.38.0,<1.39.0)"]
+appflow = ["mypy-boto3-appflow (>=1.38.0,<1.39.0)"]
+appintegrations = ["mypy-boto3-appintegrations (>=1.38.0,<1.39.0)"]
+application-autoscaling = ["mypy-boto3-application-autoscaling (>=1.38.0,<1.39.0)"]
+application-insights = ["mypy-boto3-application-insights (>=1.38.0,<1.39.0)"]
+application-signals = ["mypy-boto3-application-signals (>=1.38.0,<1.39.0)"]
+applicationcostprofiler = ["mypy-boto3-applicationcostprofiler (>=1.38.0,<1.39.0)"]
+appmesh = ["mypy-boto3-appmesh (>=1.38.0,<1.39.0)"]
+apprunner = ["mypy-boto3-apprunner (>=1.38.0,<1.39.0)"]
+appstream = ["mypy-boto3-appstream (>=1.38.0,<1.39.0)"]
+appsync = ["mypy-boto3-appsync (>=1.38.0,<1.39.0)"]
+apptest = ["mypy-boto3-apptest (>=1.38.0,<1.39.0)"]
+arc-zonal-shift = ["mypy-boto3-arc-zonal-shift (>=1.38.0,<1.39.0)"]
+artifact = ["mypy-boto3-artifact (>=1.38.0,<1.39.0)"]
+athena = ["mypy-boto3-athena (>=1.38.0,<1.39.0)"]
+auditmanager = ["mypy-boto3-auditmanager (>=1.38.0,<1.39.0)"]
+autoscaling = ["mypy-boto3-autoscaling (>=1.38.0,<1.39.0)"]
+autoscaling-plans = ["mypy-boto3-autoscaling-plans (>=1.38.0,<1.39.0)"]
+b2bi = ["mypy-boto3-b2bi (>=1.38.0,<1.39.0)"]
+backup = ["mypy-boto3-backup (>=1.38.0,<1.39.0)"]
+backup-gateway = ["mypy-boto3-backup-gateway (>=1.38.0,<1.39.0)"]
+backupsearch = ["mypy-boto3-backupsearch (>=1.38.0,<1.39.0)"]
+batch = ["mypy-boto3-batch (>=1.38.0,<1.39.0)"]
+bcm-data-exports = ["mypy-boto3-bcm-data-exports (>=1.38.0,<1.39.0)"]
+bcm-pricing-calculator = ["mypy-boto3-bcm-pricing-calculator (>=1.38.0,<1.39.0)"]
+bedrock = ["mypy-boto3-bedrock (>=1.38.0,<1.39.0)"]
+bedrock-agent = ["mypy-boto3-bedrock-agent (>=1.38.0,<1.39.0)"]
+bedrock-agent-runtime = ["mypy-boto3-bedrock-agent-runtime (>=1.38.0,<1.39.0)"]
+bedrock-data-automation = ["mypy-boto3-bedrock-data-automation (>=1.38.0,<1.39.0)"]
+bedrock-data-automation-runtime = ["mypy-boto3-bedrock-data-automation-runtime (>=1.38.0,<1.39.0)"]
+bedrock-runtime = ["mypy-boto3-bedrock-runtime (>=1.38.0,<1.39.0)"]
+billing = ["mypy-boto3-billing (>=1.38.0,<1.39.0)"]
+billingconductor = ["mypy-boto3-billingconductor (>=1.38.0,<1.39.0)"]
+boto3 = ["boto3 (==1.38.23)"]
+braket = ["mypy-boto3-braket (>=1.38.0,<1.39.0)"]
+budgets = ["mypy-boto3-budgets (>=1.38.0,<1.39.0)"]
+ce = ["mypy-boto3-ce (>=1.38.0,<1.39.0)"]
+chatbot = ["mypy-boto3-chatbot (>=1.38.0,<1.39.0)"]
+chime = ["mypy-boto3-chime (>=1.38.0,<1.39.0)"]
+chime-sdk-identity = ["mypy-boto3-chime-sdk-identity (>=1.38.0,<1.39.0)"]
+chime-sdk-media-pipelines = ["mypy-boto3-chime-sdk-media-pipelines (>=1.38.0,<1.39.0)"]
+chime-sdk-meetings = ["mypy-boto3-chime-sdk-meetings (>=1.38.0,<1.39.0)"]
+chime-sdk-messaging = ["mypy-boto3-chime-sdk-messaging (>=1.38.0,<1.39.0)"]
+chime-sdk-voice = ["mypy-boto3-chime-sdk-voice (>=1.38.0,<1.39.0)"]
+cleanrooms = ["mypy-boto3-cleanrooms (>=1.38.0,<1.39.0)"]
+cleanroomsml = ["mypy-boto3-cleanroomsml (>=1.38.0,<1.39.0)"]
+cloud9 = ["mypy-boto3-cloud9 (>=1.38.0,<1.39.0)"]
+cloudcontrol = ["mypy-boto3-cloudcontrol (>=1.38.0,<1.39.0)"]
+clouddirectory = ["mypy-boto3-clouddirectory (>=1.38.0,<1.39.0)"]
+cloudformation = ["mypy-boto3-cloudformation (>=1.38.0,<1.39.0)"]
+cloudfront = ["mypy-boto3-cloudfront (>=1.38.0,<1.39.0)"]
+cloudfront-keyvaluestore = ["mypy-boto3-cloudfront-keyvaluestore (>=1.38.0,<1.39.0)"]
+cloudhsm = ["mypy-boto3-cloudhsm (>=1.38.0,<1.39.0)"]
+cloudhsmv2 = ["mypy-boto3-cloudhsmv2 (>=1.38.0,<1.39.0)"]
+cloudsearch = ["mypy-boto3-cloudsearch (>=1.38.0,<1.39.0)"]
+cloudsearchdomain = ["mypy-boto3-cloudsearchdomain (>=1.38.0,<1.39.0)"]
+cloudtrail = ["mypy-boto3-cloudtrail (>=1.38.0,<1.39.0)"]
+cloudtrail-data = ["mypy-boto3-cloudtrail-data (>=1.38.0,<1.39.0)"]
+cloudwatch = ["mypy-boto3-cloudwatch (>=1.38.0,<1.39.0)"]
+codeartifact = ["mypy-boto3-codeartifact (>=1.38.0,<1.39.0)"]
+codebuild = ["mypy-boto3-codebuild (>=1.38.0,<1.39.0)"]
+codecatalyst = ["mypy-boto3-codecatalyst (>=1.38.0,<1.39.0)"]
+codecommit = ["mypy-boto3-codecommit (>=1.38.0,<1.39.0)"]
+codeconnections = ["mypy-boto3-codeconnections (>=1.38.0,<1.39.0)"]
+codedeploy = ["mypy-boto3-codedeploy (>=1.38.0,<1.39.0)"]
+codeguru-reviewer = ["mypy-boto3-codeguru-reviewer (>=1.38.0,<1.39.0)"]
+codeguru-security = ["mypy-boto3-codeguru-security (>=1.38.0,<1.39.0)"]
+codeguruprofiler = ["mypy-boto3-codeguruprofiler (>=1.38.0,<1.39.0)"]
+codepipeline = ["mypy-boto3-codepipeline (>=1.38.0,<1.39.0)"]
+codestar-connections = ["mypy-boto3-codestar-connections (>=1.38.0,<1.39.0)"]
+codestar-notifications = ["mypy-boto3-codestar-notifications (>=1.38.0,<1.39.0)"]
+cognito-identity = ["mypy-boto3-cognito-identity (>=1.38.0,<1.39.0)"]
+cognito-idp = ["mypy-boto3-cognito-idp (>=1.38.0,<1.39.0)"]
+cognito-sync = ["mypy-boto3-cognito-sync (>=1.38.0,<1.39.0)"]
+comprehend = ["mypy-boto3-comprehend (>=1.38.0,<1.39.0)"]
+comprehendmedical = ["mypy-boto3-comprehendmedical (>=1.38.0,<1.39.0)"]
+compute-optimizer = ["mypy-boto3-compute-optimizer (>=1.38.0,<1.39.0)"]
+config = ["mypy-boto3-config (>=1.38.0,<1.39.0)"]
+connect = ["mypy-boto3-connect (>=1.38.0,<1.39.0)"]
+connect-contact-lens = ["mypy-boto3-connect-contact-lens (>=1.38.0,<1.39.0)"]
+connectcampaigns = ["mypy-boto3-connectcampaigns (>=1.38.0,<1.39.0)"]
+connectcampaignsv2 = ["mypy-boto3-connectcampaignsv2 (>=1.38.0,<1.39.0)"]
+connectcases = ["mypy-boto3-connectcases (>=1.38.0,<1.39.0)"]
+connectparticipant = ["mypy-boto3-connectparticipant (>=1.38.0,<1.39.0)"]
+controlcatalog = ["mypy-boto3-controlcatalog (>=1.38.0,<1.39.0)"]
+controltower = ["mypy-boto3-controltower (>=1.38.0,<1.39.0)"]
+cost-optimization-hub = ["mypy-boto3-cost-optimization-hub (>=1.38.0,<1.39.0)"]
+cur = ["mypy-boto3-cur (>=1.38.0,<1.39.0)"]
+customer-profiles = ["mypy-boto3-customer-profiles (>=1.38.0,<1.39.0)"]
+databrew = ["mypy-boto3-databrew (>=1.38.0,<1.39.0)"]
+dataexchange = ["mypy-boto3-dataexchange (>=1.38.0,<1.39.0)"]
+datapipeline = ["mypy-boto3-datapipeline (>=1.38.0,<1.39.0)"]
+datasync = ["mypy-boto3-datasync (>=1.38.0,<1.39.0)"]
+datazone = ["mypy-boto3-datazone (>=1.38.0,<1.39.0)"]
+dax = ["mypy-boto3-dax (>=1.38.0,<1.39.0)"]
+deadline = ["mypy-boto3-deadline (>=1.38.0,<1.39.0)"]
+detective = ["mypy-boto3-detective (>=1.38.0,<1.39.0)"]
+devicefarm = ["mypy-boto3-devicefarm (>=1.38.0,<1.39.0)"]
+devops-guru = ["mypy-boto3-devops-guru (>=1.38.0,<1.39.0)"]
+directconnect = ["mypy-boto3-directconnect (>=1.38.0,<1.39.0)"]
+discovery = ["mypy-boto3-discovery (>=1.38.0,<1.39.0)"]
+dlm = ["mypy-boto3-dlm (>=1.38.0,<1.39.0)"]
+dms = ["mypy-boto3-dms (>=1.38.0,<1.39.0)"]
+docdb = ["mypy-boto3-docdb (>=1.38.0,<1.39.0)"]
+docdb-elastic = ["mypy-boto3-docdb-elastic (>=1.38.0,<1.39.0)"]
+drs = ["mypy-boto3-drs (>=1.38.0,<1.39.0)"]
+ds = ["mypy-boto3-ds (>=1.38.0,<1.39.0)"]
+ds-data = ["mypy-boto3-ds-data (>=1.38.0,<1.39.0)"]
+dsql = ["mypy-boto3-dsql (>=1.38.0,<1.39.0)"]
+dynamodb = ["mypy-boto3-dynamodb (>=1.38.0,<1.39.0)"]
+dynamodbstreams = ["mypy-boto3-dynamodbstreams (>=1.38.0,<1.39.0)"]
+ebs = ["mypy-boto3-ebs (>=1.38.0,<1.39.0)"]
+ec2 = ["mypy-boto3-ec2 (>=1.38.0,<1.39.0)"]
+ec2-instance-connect = ["mypy-boto3-ec2-instance-connect (>=1.38.0,<1.39.0)"]
+ecr = ["mypy-boto3-ecr (>=1.38.0,<1.39.0)"]
+ecr-public = ["mypy-boto3-ecr-public (>=1.38.0,<1.39.0)"]
+ecs = ["mypy-boto3-ecs (>=1.38.0,<1.39.0)"]
+efs = ["mypy-boto3-efs (>=1.38.0,<1.39.0)"]
+eks = ["mypy-boto3-eks (>=1.38.0,<1.39.0)"]
+eks-auth = ["mypy-boto3-eks-auth (>=1.38.0,<1.39.0)"]
+elasticache = ["mypy-boto3-elasticache (>=1.38.0,<1.39.0)"]
+elasticbeanstalk = ["mypy-boto3-elasticbeanstalk (>=1.38.0,<1.39.0)"]
+elastictranscoder = ["mypy-boto3-elastictranscoder (>=1.38.0,<1.39.0)"]
+elb = ["mypy-boto3-elb (>=1.38.0,<1.39.0)"]
+elbv2 = ["mypy-boto3-elbv2 (>=1.38.0,<1.39.0)"]
+emr = ["mypy-boto3-emr (>=1.38.0,<1.39.0)"]
+emr-containers = ["mypy-boto3-emr-containers (>=1.38.0,<1.39.0)"]
+emr-serverless = ["mypy-boto3-emr-serverless (>=1.38.0,<1.39.0)"]
+entityresolution = ["mypy-boto3-entityresolution (>=1.38.0,<1.39.0)"]
+es = ["mypy-boto3-es (>=1.38.0,<1.39.0)"]
+essential = ["mypy-boto3-cloudformation (>=1.38.0,<1.39.0)", "mypy-boto3-dynamodb (>=1.38.0,<1.39.0)", "mypy-boto3-ec2 (>=1.38.0,<1.39.0)", "mypy-boto3-lambda (>=1.38.0,<1.39.0)", "mypy-boto3-rds (>=1.38.0,<1.39.0)", "mypy-boto3-s3 (>=1.38.0,<1.39.0)", "mypy-boto3-sqs (>=1.38.0,<1.39.0)"]
+events = ["mypy-boto3-events (>=1.38.0,<1.39.0)"]
+evidently = ["mypy-boto3-evidently (>=1.38.0,<1.39.0)"]
+finspace = ["mypy-boto3-finspace (>=1.38.0,<1.39.0)"]
+finspace-data = ["mypy-boto3-finspace-data (>=1.38.0,<1.39.0)"]
+firehose = ["mypy-boto3-firehose (>=1.38.0,<1.39.0)"]
+fis = ["mypy-boto3-fis (>=1.38.0,<1.39.0)"]
+fms = ["mypy-boto3-fms (>=1.38.0,<1.39.0)"]
+forecast = ["mypy-boto3-forecast (>=1.38.0,<1.39.0)"]
+forecastquery = ["mypy-boto3-forecastquery (>=1.38.0,<1.39.0)"]
+frauddetector = ["mypy-boto3-frauddetector (>=1.38.0,<1.39.0)"]
+freetier = ["mypy-boto3-freetier (>=1.38.0,<1.39.0)"]
+fsx = ["mypy-boto3-fsx (>=1.38.0,<1.39.0)"]
+full = ["boto3-stubs-full (>=1.38.0,<1.39.0)"]
+gamelift = ["mypy-boto3-gamelift (>=1.38.0,<1.39.0)"]
+gameliftstreams = ["mypy-boto3-gameliftstreams (>=1.38.0,<1.39.0)"]
+geo-maps = ["mypy-boto3-geo-maps (>=1.38.0,<1.39.0)"]
+geo-places = ["mypy-boto3-geo-places (>=1.38.0,<1.39.0)"]
+geo-routes = ["mypy-boto3-geo-routes (>=1.38.0,<1.39.0)"]
+glacier = ["mypy-boto3-glacier (>=1.38.0,<1.39.0)"]
+globalaccelerator = ["mypy-boto3-globalaccelerator (>=1.38.0,<1.39.0)"]
+glue = ["mypy-boto3-glue (>=1.38.0,<1.39.0)"]
+grafana = ["mypy-boto3-grafana (>=1.38.0,<1.39.0)"]
+greengrass = ["mypy-boto3-greengrass (>=1.38.0,<1.39.0)"]
+greengrassv2 = ["mypy-boto3-greengrassv2 (>=1.38.0,<1.39.0)"]
+groundstation = ["mypy-boto3-groundstation (>=1.38.0,<1.39.0)"]
+guardduty = ["mypy-boto3-guardduty (>=1.38.0,<1.39.0)"]
+health = ["mypy-boto3-health (>=1.38.0,<1.39.0)"]
+healthlake = ["mypy-boto3-healthlake (>=1.38.0,<1.39.0)"]
+iam = ["mypy-boto3-iam (>=1.38.0,<1.39.0)"]
+identitystore = ["mypy-boto3-identitystore (>=1.38.0,<1.39.0)"]
+imagebuilder = ["mypy-boto3-imagebuilder (>=1.38.0,<1.39.0)"]
+importexport = ["mypy-boto3-importexport (>=1.38.0,<1.39.0)"]
+inspector = ["mypy-boto3-inspector (>=1.38.0,<1.39.0)"]
+inspector-scan = ["mypy-boto3-inspector-scan (>=1.38.0,<1.39.0)"]
+inspector2 = ["mypy-boto3-inspector2 (>=1.38.0,<1.39.0)"]
+internetmonitor = ["mypy-boto3-internetmonitor (>=1.38.0,<1.39.0)"]
+invoicing = ["mypy-boto3-invoicing (>=1.38.0,<1.39.0)"]
+iot = ["mypy-boto3-iot (>=1.38.0,<1.39.0)"]
+iot-data = ["mypy-boto3-iot-data (>=1.38.0,<1.39.0)"]
+iot-jobs-data = ["mypy-boto3-iot-jobs-data (>=1.38.0,<1.39.0)"]
+iot-managed-integrations = ["mypy-boto3-iot-managed-integrations (>=1.38.0,<1.39.0)"]
+iotanalytics = ["mypy-boto3-iotanalytics (>=1.38.0,<1.39.0)"]
+iotdeviceadvisor = ["mypy-boto3-iotdeviceadvisor (>=1.38.0,<1.39.0)"]
+iotevents = ["mypy-boto3-iotevents (>=1.38.0,<1.39.0)"]
+iotevents-data = ["mypy-boto3-iotevents-data (>=1.38.0,<1.39.0)"]
+iotfleethub = ["mypy-boto3-iotfleethub (>=1.38.0,<1.39.0)"]
+iotfleetwise = ["mypy-boto3-iotfleetwise (>=1.38.0,<1.39.0)"]
+iotsecuretunneling = ["mypy-boto3-iotsecuretunneling (>=1.38.0,<1.39.0)"]
+iotsitewise = ["mypy-boto3-iotsitewise (>=1.38.0,<1.39.0)"]
+iotthingsgraph = ["mypy-boto3-iotthingsgraph (>=1.38.0,<1.39.0)"]
+iottwinmaker = ["mypy-boto3-iottwinmaker (>=1.38.0,<1.39.0)"]
+iotwireless = ["mypy-boto3-iotwireless (>=1.38.0,<1.39.0)"]
+ivs = ["mypy-boto3-ivs (>=1.38.0,<1.39.0)"]
+ivs-realtime = ["mypy-boto3-ivs-realtime (>=1.38.0,<1.39.0)"]
+ivschat = ["mypy-boto3-ivschat (>=1.38.0,<1.39.0)"]
+kafka = ["mypy-boto3-kafka (>=1.38.0,<1.39.0)"]
+kafkaconnect = ["mypy-boto3-kafkaconnect (>=1.38.0,<1.39.0)"]
+kendra = ["mypy-boto3-kendra (>=1.38.0,<1.39.0)"]
+kendra-ranking = ["mypy-boto3-kendra-ranking (>=1.38.0,<1.39.0)"]
+keyspaces = ["mypy-boto3-keyspaces (>=1.38.0,<1.39.0)"]
+kinesis = ["mypy-boto3-kinesis (>=1.38.0,<1.39.0)"]
+kinesis-video-archived-media = ["mypy-boto3-kinesis-video-archived-media (>=1.38.0,<1.39.0)"]
+kinesis-video-media = ["mypy-boto3-kinesis-video-media (>=1.38.0,<1.39.0)"]
+kinesis-video-signaling = ["mypy-boto3-kinesis-video-signaling (>=1.38.0,<1.39.0)"]
+kinesis-video-webrtc-storage = ["mypy-boto3-kinesis-video-webrtc-storage (>=1.38.0,<1.39.0)"]
+kinesisanalytics = ["mypy-boto3-kinesisanalytics (>=1.38.0,<1.39.0)"]
+kinesisanalyticsv2 = ["mypy-boto3-kinesisanalyticsv2 (>=1.38.0,<1.39.0)"]
+kinesisvideo = ["mypy-boto3-kinesisvideo (>=1.38.0,<1.39.0)"]
+kms = ["mypy-boto3-kms (>=1.38.0,<1.39.0)"]
+lakeformation = ["mypy-boto3-lakeformation (>=1.38.0,<1.39.0)"]
+lambda = ["mypy-boto3-lambda (>=1.38.0,<1.39.0)"]
+launch-wizard = ["mypy-boto3-launch-wizard (>=1.38.0,<1.39.0)"]
+lex-models = ["mypy-boto3-lex-models (>=1.38.0,<1.39.0)"]
+lex-runtime = ["mypy-boto3-lex-runtime (>=1.38.0,<1.39.0)"]
+lexv2-models = ["mypy-boto3-lexv2-models (>=1.38.0,<1.39.0)"]
+lexv2-runtime = ["mypy-boto3-lexv2-runtime (>=1.38.0,<1.39.0)"]
+license-manager = ["mypy-boto3-license-manager (>=1.38.0,<1.39.0)"]
+license-manager-linux-subscriptions = ["mypy-boto3-license-manager-linux-subscriptions (>=1.38.0,<1.39.0)"]
+license-manager-user-subscriptions = ["mypy-boto3-license-manager-user-subscriptions (>=1.38.0,<1.39.0)"]
+lightsail = ["mypy-boto3-lightsail (>=1.38.0,<1.39.0)"]
+location = ["mypy-boto3-location (>=1.38.0,<1.39.0)"]
+logs = ["mypy-boto3-logs (>=1.38.0,<1.39.0)"]
+lookoutequipment = ["mypy-boto3-lookoutequipment (>=1.38.0,<1.39.0)"]
+lookoutmetrics = ["mypy-boto3-lookoutmetrics (>=1.38.0,<1.39.0)"]
+lookoutvision = ["mypy-boto3-lookoutvision (>=1.38.0,<1.39.0)"]
+m2 = ["mypy-boto3-m2 (>=1.38.0,<1.39.0)"]
+machinelearning = ["mypy-boto3-machinelearning (>=1.38.0,<1.39.0)"]
+macie2 = ["mypy-boto3-macie2 (>=1.38.0,<1.39.0)"]
+mailmanager = ["mypy-boto3-mailmanager (>=1.38.0,<1.39.0)"]
+managedblockchain = ["mypy-boto3-managedblockchain (>=1.38.0,<1.39.0)"]
+managedblockchain-query = ["mypy-boto3-managedblockchain-query (>=1.38.0,<1.39.0)"]
+marketplace-agreement = ["mypy-boto3-marketplace-agreement (>=1.38.0,<1.39.0)"]
+marketplace-catalog = ["mypy-boto3-marketplace-catalog (>=1.38.0,<1.39.0)"]
+marketplace-deployment = ["mypy-boto3-marketplace-deployment (>=1.38.0,<1.39.0)"]
+marketplace-entitlement = ["mypy-boto3-marketplace-entitlement (>=1.38.0,<1.39.0)"]
+marketplace-reporting = ["mypy-boto3-marketplace-reporting (>=1.38.0,<1.39.0)"]
+marketplacecommerceanalytics = ["mypy-boto3-marketplacecommerceanalytics (>=1.38.0,<1.39.0)"]
+mediaconnect = ["mypy-boto3-mediaconnect (>=1.38.0,<1.39.0)"]
+mediaconvert = ["mypy-boto3-mediaconvert (>=1.38.0,<1.39.0)"]
+medialive = ["mypy-boto3-medialive (>=1.38.0,<1.39.0)"]
+mediapackage = ["mypy-boto3-mediapackage (>=1.38.0,<1.39.0)"]
+mediapackage-vod = ["mypy-boto3-mediapackage-vod (>=1.38.0,<1.39.0)"]
+mediapackagev2 = ["mypy-boto3-mediapackagev2 (>=1.38.0,<1.39.0)"]
+mediastore = ["mypy-boto3-mediastore (>=1.38.0,<1.39.0)"]
+mediastore-data = ["mypy-boto3-mediastore-data (>=1.38.0,<1.39.0)"]
+mediatailor = ["mypy-boto3-mediatailor (>=1.38.0,<1.39.0)"]
+medical-imaging = ["mypy-boto3-medical-imaging (>=1.38.0,<1.39.0)"]
+memorydb = ["mypy-boto3-memorydb (>=1.38.0,<1.39.0)"]
+meteringmarketplace = ["mypy-boto3-meteringmarketplace (>=1.38.0,<1.39.0)"]
+mgh = ["mypy-boto3-mgh (>=1.38.0,<1.39.0)"]
+mgn = ["mypy-boto3-mgn (>=1.38.0,<1.39.0)"]
+migration-hub-refactor-spaces = ["mypy-boto3-migration-hub-refactor-spaces (>=1.38.0,<1.39.0)"]
+migrationhub-config = ["mypy-boto3-migrationhub-config (>=1.38.0,<1.39.0)"]
+migrationhuborchestrator = ["mypy-boto3-migrationhuborchestrator (>=1.38.0,<1.39.0)"]
+migrationhubstrategy = ["mypy-boto3-migrationhubstrategy (>=1.38.0,<1.39.0)"]
+mq = ["mypy-boto3-mq (>=1.38.0,<1.39.0)"]
+mturk = ["mypy-boto3-mturk (>=1.38.0,<1.39.0)"]
+mwaa = ["mypy-boto3-mwaa (>=1.38.0,<1.39.0)"]
+neptune = ["mypy-boto3-neptune (>=1.38.0,<1.39.0)"]
+neptune-graph = ["mypy-boto3-neptune-graph (>=1.38.0,<1.39.0)"]
+neptunedata = ["mypy-boto3-neptunedata (>=1.38.0,<1.39.0)"]
+network-firewall = ["mypy-boto3-network-firewall (>=1.38.0,<1.39.0)"]
+networkflowmonitor = ["mypy-boto3-networkflowmonitor (>=1.38.0,<1.39.0)"]
+networkmanager = ["mypy-boto3-networkmanager (>=1.38.0,<1.39.0)"]
+networkmonitor = ["mypy-boto3-networkmonitor (>=1.38.0,<1.39.0)"]
+notifications = ["mypy-boto3-notifications (>=1.38.0,<1.39.0)"]
+notificationscontacts = ["mypy-boto3-notificationscontacts (>=1.38.0,<1.39.0)"]
+oam = ["mypy-boto3-oam (>=1.38.0,<1.39.0)"]
+observabilityadmin = ["mypy-boto3-observabilityadmin (>=1.38.0,<1.39.0)"]
+omics = ["mypy-boto3-omics (>=1.38.0,<1.39.0)"]
+opensearch = ["mypy-boto3-opensearch (>=1.38.0,<1.39.0)"]
+opensearchserverless = ["mypy-boto3-opensearchserverless (>=1.38.0,<1.39.0)"]
+opsworks = ["mypy-boto3-opsworks (>=1.38.0,<1.39.0)"]
+opsworkscm = ["mypy-boto3-opsworkscm (>=1.38.0,<1.39.0)"]
+organizations = ["mypy-boto3-organizations (>=1.38.0,<1.39.0)"]
+osis = ["mypy-boto3-osis (>=1.38.0,<1.39.0)"]
+outposts = ["mypy-boto3-outposts (>=1.38.0,<1.39.0)"]
+panorama = ["mypy-boto3-panorama (>=1.38.0,<1.39.0)"]
+partnercentral-selling = ["mypy-boto3-partnercentral-selling (>=1.38.0,<1.39.0)"]
+payment-cryptography = ["mypy-boto3-payment-cryptography (>=1.38.0,<1.39.0)"]
+payment-cryptography-data = ["mypy-boto3-payment-cryptography-data (>=1.38.0,<1.39.0)"]
+pca-connector-ad = ["mypy-boto3-pca-connector-ad (>=1.38.0,<1.39.0)"]
+pca-connector-scep = ["mypy-boto3-pca-connector-scep (>=1.38.0,<1.39.0)"]
+pcs = ["mypy-boto3-pcs (>=1.38.0,<1.39.0)"]
+personalize = ["mypy-boto3-personalize (>=1.38.0,<1.39.0)"]
+personalize-events = ["mypy-boto3-personalize-events (>=1.38.0,<1.39.0)"]
+personalize-runtime = ["mypy-boto3-personalize-runtime (>=1.38.0,<1.39.0)"]
+pi = ["mypy-boto3-pi (>=1.38.0,<1.39.0)"]
+pinpoint = ["mypy-boto3-pinpoint (>=1.38.0,<1.39.0)"]
+pinpoint-email = ["mypy-boto3-pinpoint-email (>=1.38.0,<1.39.0)"]
+pinpoint-sms-voice = ["mypy-boto3-pinpoint-sms-voice (>=1.38.0,<1.39.0)"]
+pinpoint-sms-voice-v2 = ["mypy-boto3-pinpoint-sms-voice-v2 (>=1.38.0,<1.39.0)"]
+pipes = ["mypy-boto3-pipes (>=1.38.0,<1.39.0)"]
+polly = ["mypy-boto3-polly (>=1.38.0,<1.39.0)"]
+pricing = ["mypy-boto3-pricing (>=1.38.0,<1.39.0)"]
+proton = ["mypy-boto3-proton (>=1.38.0,<1.39.0)"]
+qapps = ["mypy-boto3-qapps (>=1.38.0,<1.39.0)"]
+qbusiness = ["mypy-boto3-qbusiness (>=1.38.0,<1.39.0)"]
+qconnect = ["mypy-boto3-qconnect (>=1.38.0,<1.39.0)"]
+qldb = ["mypy-boto3-qldb (>=1.38.0,<1.39.0)"]
+qldb-session = ["mypy-boto3-qldb-session (>=1.38.0,<1.39.0)"]
+quicksight = ["mypy-boto3-quicksight (>=1.38.0,<1.39.0)"]
+ram = ["mypy-boto3-ram (>=1.38.0,<1.39.0)"]
+rbin = ["mypy-boto3-rbin (>=1.38.0,<1.39.0)"]
+rds = ["mypy-boto3-rds (>=1.38.0,<1.39.0)"]
+rds-data = ["mypy-boto3-rds-data (>=1.38.0,<1.39.0)"]
+redshift = ["mypy-boto3-redshift (>=1.38.0,<1.39.0)"]
+redshift-data = ["mypy-boto3-redshift-data (>=1.38.0,<1.39.0)"]
+redshift-serverless = ["mypy-boto3-redshift-serverless (>=1.38.0,<1.39.0)"]
+rekognition = ["mypy-boto3-rekognition (>=1.38.0,<1.39.0)"]
+repostspace = ["mypy-boto3-repostspace (>=1.38.0,<1.39.0)"]
+resiliencehub = ["mypy-boto3-resiliencehub (>=1.38.0,<1.39.0)"]
+resource-explorer-2 = ["mypy-boto3-resource-explorer-2 (>=1.38.0,<1.39.0)"]
+resource-groups = ["mypy-boto3-resource-groups (>=1.38.0,<1.39.0)"]
+resourcegroupstaggingapi = ["mypy-boto3-resourcegroupstaggingapi (>=1.38.0,<1.39.0)"]
+robomaker = ["mypy-boto3-robomaker (>=1.38.0,<1.39.0)"]
+rolesanywhere = ["mypy-boto3-rolesanywhere (>=1.38.0,<1.39.0)"]
+route53 = ["mypy-boto3-route53 (>=1.38.0,<1.39.0)"]
+route53-recovery-cluster = ["mypy-boto3-route53-recovery-cluster (>=1.38.0,<1.39.0)"]
+route53-recovery-control-config = ["mypy-boto3-route53-recovery-control-config (>=1.38.0,<1.39.0)"]
+route53-recovery-readiness = ["mypy-boto3-route53-recovery-readiness (>=1.38.0,<1.39.0)"]
+route53domains = ["mypy-boto3-route53domains (>=1.38.0,<1.39.0)"]
+route53profiles = ["mypy-boto3-route53profiles (>=1.38.0,<1.39.0)"]
+route53resolver = ["mypy-boto3-route53resolver (>=1.38.0,<1.39.0)"]
+rum = ["mypy-boto3-rum (>=1.38.0,<1.39.0)"]
+s3 = ["mypy-boto3-s3 (>=1.38.0,<1.39.0)"]
+s3control = ["mypy-boto3-s3control (>=1.38.0,<1.39.0)"]
+s3outposts = ["mypy-boto3-s3outposts (>=1.38.0,<1.39.0)"]
+s3tables = ["mypy-boto3-s3tables (>=1.38.0,<1.39.0)"]
+sagemaker = ["mypy-boto3-sagemaker (>=1.38.0,<1.39.0)"]
+sagemaker-a2i-runtime = ["mypy-boto3-sagemaker-a2i-runtime (>=1.38.0,<1.39.0)"]
+sagemaker-edge = ["mypy-boto3-sagemaker-edge (>=1.38.0,<1.39.0)"]
+sagemaker-featurestore-runtime = ["mypy-boto3-sagemaker-featurestore-runtime (>=1.38.0,<1.39.0)"]
+sagemaker-geospatial = ["mypy-boto3-sagemaker-geospatial (>=1.38.0,<1.39.0)"]
+sagemaker-metrics = ["mypy-boto3-sagemaker-metrics (>=1.38.0,<1.39.0)"]
+sagemaker-runtime = ["mypy-boto3-sagemaker-runtime (>=1.38.0,<1.39.0)"]
+savingsplans = ["mypy-boto3-savingsplans (>=1.38.0,<1.39.0)"]
+scheduler = ["mypy-boto3-scheduler (>=1.38.0,<1.39.0)"]
+schemas = ["mypy-boto3-schemas (>=1.38.0,<1.39.0)"]
+sdb = ["mypy-boto3-sdb (>=1.38.0,<1.39.0)"]
+secretsmanager = ["mypy-boto3-secretsmanager (>=1.38.0,<1.39.0)"]
+security-ir = ["mypy-boto3-security-ir (>=1.38.0,<1.39.0)"]
+securityhub = ["mypy-boto3-securityhub (>=1.38.0,<1.39.0)"]
+securitylake = ["mypy-boto3-securitylake (>=1.38.0,<1.39.0)"]
+serverlessrepo = ["mypy-boto3-serverlessrepo (>=1.38.0,<1.39.0)"]
+service-quotas = ["mypy-boto3-service-quotas (>=1.38.0,<1.39.0)"]
+servicecatalog = ["mypy-boto3-servicecatalog (>=1.38.0,<1.39.0)"]
+servicecatalog-appregistry = ["mypy-boto3-servicecatalog-appregistry (>=1.38.0,<1.39.0)"]
+servicediscovery = ["mypy-boto3-servicediscovery (>=1.38.0,<1.39.0)"]
+ses = ["mypy-boto3-ses (>=1.38.0,<1.39.0)"]
+sesv2 = ["mypy-boto3-sesv2 (>=1.38.0,<1.39.0)"]
+shield = ["mypy-boto3-shield (>=1.38.0,<1.39.0)"]
+signer = ["mypy-boto3-signer (>=1.38.0,<1.39.0)"]
+simspaceweaver = ["mypy-boto3-simspaceweaver (>=1.38.0,<1.39.0)"]
+sms = ["mypy-boto3-sms (>=1.38.0,<1.39.0)"]
+snow-device-management = ["mypy-boto3-snow-device-management (>=1.38.0,<1.39.0)"]
+snowball = ["mypy-boto3-snowball (>=1.38.0,<1.39.0)"]
+sns = ["mypy-boto3-sns (>=1.38.0,<1.39.0)"]
+socialmessaging = ["mypy-boto3-socialmessaging (>=1.38.0,<1.39.0)"]
+sqs = ["mypy-boto3-sqs (>=1.38.0,<1.39.0)"]
+ssm = ["mypy-boto3-ssm (>=1.38.0,<1.39.0)"]
+ssm-contacts = ["mypy-boto3-ssm-contacts (>=1.38.0,<1.39.0)"]
+ssm-guiconnect = ["mypy-boto3-ssm-guiconnect (>=1.38.0,<1.39.0)"]
+ssm-incidents = ["mypy-boto3-ssm-incidents (>=1.38.0,<1.39.0)"]
+ssm-quicksetup = ["mypy-boto3-ssm-quicksetup (>=1.38.0,<1.39.0)"]
+ssm-sap = ["mypy-boto3-ssm-sap (>=1.38.0,<1.39.0)"]
+sso = ["mypy-boto3-sso (>=1.38.0,<1.39.0)"]
+sso-admin = ["mypy-boto3-sso-admin (>=1.38.0,<1.39.0)"]
+sso-oidc = ["mypy-boto3-sso-oidc (>=1.38.0,<1.39.0)"]
+stepfunctions = ["mypy-boto3-stepfunctions (>=1.38.0,<1.39.0)"]
+storagegateway = ["mypy-boto3-storagegateway (>=1.38.0,<1.39.0)"]
+sts = ["mypy-boto3-sts (>=1.38.0,<1.39.0)"]
+supplychain = ["mypy-boto3-supplychain (>=1.38.0,<1.39.0)"]
+support = ["mypy-boto3-support (>=1.38.0,<1.39.0)"]
+support-app = ["mypy-boto3-support-app (>=1.38.0,<1.39.0)"]
+swf = ["mypy-boto3-swf (>=1.38.0,<1.39.0)"]
+synthetics = ["mypy-boto3-synthetics (>=1.38.0,<1.39.0)"]
+taxsettings = ["mypy-boto3-taxsettings (>=1.38.0,<1.39.0)"]
+textract = ["mypy-boto3-textract (>=1.38.0,<1.39.0)"]
+timestream-influxdb = ["mypy-boto3-timestream-influxdb (>=1.38.0,<1.39.0)"]
+timestream-query = ["mypy-boto3-timestream-query (>=1.38.0,<1.39.0)"]
+timestream-write = ["mypy-boto3-timestream-write (>=1.38.0,<1.39.0)"]
+tnb = ["mypy-boto3-tnb (>=1.38.0,<1.39.0)"]
+transcribe = ["mypy-boto3-transcribe (>=1.38.0,<1.39.0)"]
+transfer = ["mypy-boto3-transfer (>=1.38.0,<1.39.0)"]
+translate = ["mypy-boto3-translate (>=1.38.0,<1.39.0)"]
+trustedadvisor = ["mypy-boto3-trustedadvisor (>=1.38.0,<1.39.0)"]
+verifiedpermissions = ["mypy-boto3-verifiedpermissions (>=1.38.0,<1.39.0)"]
+voice-id = ["mypy-boto3-voice-id (>=1.38.0,<1.39.0)"]
+vpc-lattice = ["mypy-boto3-vpc-lattice (>=1.38.0,<1.39.0)"]
+waf = ["mypy-boto3-waf (>=1.38.0,<1.39.0)"]
+waf-regional = ["mypy-boto3-waf-regional (>=1.38.0,<1.39.0)"]
+wafv2 = ["mypy-boto3-wafv2 (>=1.38.0,<1.39.0)"]
+wellarchitected = ["mypy-boto3-wellarchitected (>=1.38.0,<1.39.0)"]
+wisdom = ["mypy-boto3-wisdom (>=1.38.0,<1.39.0)"]
+workdocs = ["mypy-boto3-workdocs (>=1.38.0,<1.39.0)"]
+workmail = ["mypy-boto3-workmail (>=1.38.0,<1.39.0)"]
+workmailmessageflow = ["mypy-boto3-workmailmessageflow (>=1.38.0,<1.39.0)"]
+workspaces = ["mypy-boto3-workspaces (>=1.38.0,<1.39.0)"]
+workspaces-thin-client = ["mypy-boto3-workspaces-thin-client (>=1.38.0,<1.39.0)"]
+workspaces-web = ["mypy-boto3-workspaces-web (>=1.38.0,<1.39.0)"]
+xray = ["mypy-boto3-xray (>=1.38.0,<1.39.0)"]
+
+[[package]]
+name = "botocore"
+version = "1.36.1"
+description = "Low-level, data-driven core of boto 3."
+optional = true
+python-versions = ">=3.8"
+groups = ["main"]
+markers = "extra == \"bedrock\""
+files = [
+ {file = "botocore-1.36.1-py3-none-any.whl", hash = "sha256:dec513b4eb8a847d79bbefdcdd07040ed9d44c20b0001136f0890a03d595705a"},
+ {file = "botocore-1.36.1.tar.gz", hash = "sha256:f789a6f272b5b3d8f8756495019785e33868e5e00dd9662a3ee7959ac939bb12"},
+]
+
+[package.dependencies]
+jmespath = ">=0.7.1,<2.0.0"
+python-dateutil = ">=2.1,<3.0.0"
+urllib3 = {version = ">=1.25.4,<2.2.0 || >2.2.0,<3", markers = "python_version >= \"3.10\""}
+
+[package.extras]
+crt = ["awscrt (==0.23.4)"]
+
+[[package]]
+name = "botocore-stubs"
+version = "1.38.19"
+description = "Type annotations and code completion for botocore"
+optional = false
+python-versions = ">=3.8"
+groups = ["dev"]
+files = [
+ {file = "botocore_stubs-1.38.19-py3-none-any.whl", hash = "sha256:66fd7d231c21134a12acbe313ef7a6b152cbf9bfd7bfa12a62f8c33e94737e26"},
+ {file = "botocore_stubs-1.38.19.tar.gz", hash = "sha256:84f67a42bb240a8ea0c5fe4f05d497cc411177db600bc7012182e499ac24bf19"},
+]
+
+[package.dependencies]
+types-awscrt = "*"
+
+[package.extras]
+botocore = ["botocore"]
+
+[[package]]
+name = "cachetools"
+version = "5.5.2"
+description = "Extensible memoizing collections and decorators"
+optional = true
+python-versions = ">=3.7"
+groups = ["main"]
+markers = "extra == \"google\""
+files = [
+ {file = "cachetools-5.5.2-py3-none-any.whl", hash = "sha256:d26a22bcc62eb95c3beabd9f1ee5e820d3d2704fe2967cbe350e20c8ffcd3f0a"},
+ {file = "cachetools-5.5.2.tar.gz", hash = "sha256:1a661caa9175d26759571b2e19580f9d6393969e5dfca11fdb1f947a23e640d4"},
+]
+
+[[package]]
+name = "certifi"
+version = "2025.4.26"
+description = "Python package for providing Mozilla's CA Bundle."
+optional = false
+python-versions = ">=3.6"
+groups = ["main"]
+files = [
+ {file = "certifi-2025.4.26-py3-none-any.whl", hash = "sha256:30350364dfe371162649852c63336a15c70c6510c2ad5015b21c2345311805f3"},
+ {file = "certifi-2025.4.26.tar.gz", hash = "sha256:0a816057ea3cdefcef70270d2c515e4506bbc954f417fa5ade2021213bb8f0c6"},
+]
+
+[[package]]
+name = "charset-normalizer"
+version = "3.4.2"
+description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet."
+optional = false
+python-versions = ">=3.7"
+groups = ["main"]
+files = [
+ {file = "charset_normalizer-3.4.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:7c48ed483eb946e6c04ccbe02c6b4d1d48e51944b6db70f697e089c193404941"},
+ {file = "charset_normalizer-3.4.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b2d318c11350e10662026ad0eb71bb51c7812fc8590825304ae0bdd4ac283acd"},
+ {file = "charset_normalizer-3.4.2-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:9cbfacf36cb0ec2897ce0ebc5d08ca44213af24265bd56eca54bee7923c48fd6"},
+ {file = "charset_normalizer-3.4.2-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:18dd2e350387c87dabe711b86f83c9c78af772c748904d372ade190b5c7c9d4d"},
+ {file = "charset_normalizer-3.4.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8075c35cd58273fee266c58c0c9b670947c19df5fb98e7b66710e04ad4e9ff86"},
+ {file = "charset_normalizer-3.4.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:5bf4545e3b962767e5c06fe1738f951f77d27967cb2caa64c28be7c4563e162c"},
+ {file = "charset_normalizer-3.4.2-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:7a6ab32f7210554a96cd9e33abe3ddd86732beeafc7a28e9955cdf22ffadbab0"},
+ {file = "charset_normalizer-3.4.2-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:b33de11b92e9f75a2b545d6e9b6f37e398d86c3e9e9653c4864eb7e89c5773ef"},
+ {file = "charset_normalizer-3.4.2-cp310-cp310-musllinux_1_2_ppc64le.whl", hash = "sha256:8755483f3c00d6c9a77f490c17e6ab0c8729e39e6390328e42521ef175380ae6"},
+ {file = "charset_normalizer-3.4.2-cp310-cp310-musllinux_1_2_s390x.whl", hash = "sha256:68a328e5f55ec37c57f19ebb1fdc56a248db2e3e9ad769919a58672958e8f366"},
+ {file = "charset_normalizer-3.4.2-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:21b2899062867b0e1fde9b724f8aecb1af14f2778d69aacd1a5a1853a597a5db"},
+ {file = "charset_normalizer-3.4.2-cp310-cp310-win32.whl", hash = "sha256:e8082b26888e2f8b36a042a58307d5b917ef2b1cacab921ad3323ef91901c71a"},
+ {file = "charset_normalizer-3.4.2-cp310-cp310-win_amd64.whl", hash = "sha256:f69a27e45c43520f5487f27627059b64aaf160415589230992cec34c5e18a509"},
+ {file = "charset_normalizer-3.4.2-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:be1e352acbe3c78727a16a455126d9ff83ea2dfdcbc83148d2982305a04714c2"},
+ {file = "charset_normalizer-3.4.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:aa88ca0b1932e93f2d961bf3addbb2db902198dca337d88c89e1559e066e7645"},
+ {file = "charset_normalizer-3.4.2-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d524ba3f1581b35c03cb42beebab4a13e6cdad7b36246bd22541fa585a56cccd"},
+ {file = "charset_normalizer-3.4.2-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:28a1005facc94196e1fb3e82a3d442a9d9110b8434fc1ded7a24a2983c9888d8"},
+ {file = "charset_normalizer-3.4.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:fdb20a30fe1175ecabed17cbf7812f7b804b8a315a25f24678bcdf120a90077f"},
+ {file = "charset_normalizer-3.4.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0f5d9ed7f254402c9e7d35d2f5972c9bbea9040e99cd2861bd77dc68263277c7"},
+ {file = "charset_normalizer-3.4.2-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:efd387a49825780ff861998cd959767800d54f8308936b21025326de4b5a42b9"},
+ {file = "charset_normalizer-3.4.2-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:f0aa37f3c979cf2546b73e8222bbfa3dc07a641585340179d768068e3455e544"},
+ {file = "charset_normalizer-3.4.2-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:e70e990b2137b29dc5564715de1e12701815dacc1d056308e2b17e9095372a82"},
+ {file = "charset_normalizer-3.4.2-cp311-cp311-musllinux_1_2_s390x.whl", hash = "sha256:0c8c57f84ccfc871a48a47321cfa49ae1df56cd1d965a09abe84066f6853b9c0"},
+ {file = "charset_normalizer-3.4.2-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:6b66f92b17849b85cad91259efc341dce9c1af48e2173bf38a85c6329f1033e5"},
+ {file = "charset_normalizer-3.4.2-cp311-cp311-win32.whl", hash = "sha256:daac4765328a919a805fa5e2720f3e94767abd632ae410a9062dff5412bae65a"},
+ {file = "charset_normalizer-3.4.2-cp311-cp311-win_amd64.whl", hash = "sha256:e53efc7c7cee4c1e70661e2e112ca46a575f90ed9ae3fef200f2a25e954f4b28"},
+ {file = "charset_normalizer-3.4.2-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:0c29de6a1a95f24b9a1aa7aefd27d2487263f00dfd55a77719b530788f75cff7"},
+ {file = "charset_normalizer-3.4.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cddf7bd982eaa998934a91f69d182aec997c6c468898efe6679af88283b498d3"},
+ {file = "charset_normalizer-3.4.2-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:fcbe676a55d7445b22c10967bceaaf0ee69407fbe0ece4d032b6eb8d4565982a"},
+ {file = "charset_normalizer-3.4.2-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d41c4d287cfc69060fa91cae9683eacffad989f1a10811995fa309df656ec214"},
+ {file = "charset_normalizer-3.4.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4e594135de17ab3866138f496755f302b72157d115086d100c3f19370839dd3a"},
+ {file = "charset_normalizer-3.4.2-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:cf713fe9a71ef6fd5adf7a79670135081cd4431c2943864757f0fa3a65b1fafd"},
+ {file = "charset_normalizer-3.4.2-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:a370b3e078e418187da8c3674eddb9d983ec09445c99a3a263c2011993522981"},
+ {file = "charset_normalizer-3.4.2-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:a955b438e62efdf7e0b7b52a64dc5c3396e2634baa62471768a64bc2adb73d5c"},
+ {file = "charset_normalizer-3.4.2-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:7222ffd5e4de8e57e03ce2cef95a4c43c98fcb72ad86909abdfc2c17d227fc1b"},
+ {file = "charset_normalizer-3.4.2-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:bee093bf902e1d8fc0ac143c88902c3dfc8941f7ea1d6a8dd2bcb786d33db03d"},
+ {file = "charset_normalizer-3.4.2-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:dedb8adb91d11846ee08bec4c8236c8549ac721c245678282dcb06b221aab59f"},
+ {file = "charset_normalizer-3.4.2-cp312-cp312-win32.whl", hash = "sha256:db4c7bf0e07fc3b7d89ac2a5880a6a8062056801b83ff56d8464b70f65482b6c"},
+ {file = "charset_normalizer-3.4.2-cp312-cp312-win_amd64.whl", hash = "sha256:5a9979887252a82fefd3d3ed2a8e3b937a7a809f65dcb1e068b090e165bbe99e"},
+ {file = "charset_normalizer-3.4.2-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:926ca93accd5d36ccdabd803392ddc3e03e6d4cd1cf17deff3b989ab8e9dbcf0"},
+ {file = "charset_normalizer-3.4.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:eba9904b0f38a143592d9fc0e19e2df0fa2e41c3c3745554761c5f6447eedabf"},
+ {file = "charset_normalizer-3.4.2-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3fddb7e2c84ac87ac3a947cb4e66d143ca5863ef48e4a5ecb83bd48619e4634e"},
+ {file = "charset_normalizer-3.4.2-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:98f862da73774290f251b9df8d11161b6cf25b599a66baf087c1ffe340e9bfd1"},
+ {file = "charset_normalizer-3.4.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c9379d65defcab82d07b2a9dfbfc2e95bc8fe0ebb1b176a3190230a3ef0e07c"},
+ {file = "charset_normalizer-3.4.2-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e635b87f01ebc977342e2697d05b56632f5f879a4f15955dfe8cef2448b51691"},
+ {file = "charset_normalizer-3.4.2-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:1c95a1e2902a8b722868587c0e1184ad5c55631de5afc0eb96bc4b0d738092c0"},
+ {file = "charset_normalizer-3.4.2-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:ef8de666d6179b009dce7bcb2ad4c4a779f113f12caf8dc77f0162c29d20490b"},
+ {file = "charset_normalizer-3.4.2-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:32fc0341d72e0f73f80acb0a2c94216bd704f4f0bce10aedea38f30502b271ff"},
+ {file = "charset_normalizer-3.4.2-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:289200a18fa698949d2b39c671c2cc7a24d44096784e76614899a7ccf2574b7b"},
+ {file = "charset_normalizer-3.4.2-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:4a476b06fbcf359ad25d34a057b7219281286ae2477cc5ff5e3f70a246971148"},
+ {file = "charset_normalizer-3.4.2-cp313-cp313-win32.whl", hash = "sha256:aaeeb6a479c7667fbe1099af9617c83aaca22182d6cf8c53966491a0f1b7ffb7"},
+ {file = "charset_normalizer-3.4.2-cp313-cp313-win_amd64.whl", hash = "sha256:aa6af9e7d59f9c12b33ae4e9450619cf2488e2bbe9b44030905877f0b2324980"},
+ {file = "charset_normalizer-3.4.2-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1cad5f45b3146325bb38d6855642f6fd609c3f7cad4dbaf75549bf3b904d3184"},
+ {file = "charset_normalizer-3.4.2-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:b2680962a4848b3c4f155dc2ee64505a9c57186d0d56b43123b17ca3de18f0fa"},
+ {file = "charset_normalizer-3.4.2-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:36b31da18b8890a76ec181c3cf44326bf2c48e36d393ca1b72b3f484113ea344"},
+ {file = "charset_normalizer-3.4.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f4074c5a429281bf056ddd4c5d3b740ebca4d43ffffe2ef4bf4d2d05114299da"},
+ {file = "charset_normalizer-3.4.2-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c9e36a97bee9b86ef9a1cf7bb96747eb7a15c2f22bdb5b516434b00f2a599f02"},
+ {file = "charset_normalizer-3.4.2-cp37-cp37m-musllinux_1_2_aarch64.whl", hash = "sha256:1b1bde144d98e446b056ef98e59c256e9294f6b74d7af6846bf5ffdafd687a7d"},
+ {file = "charset_normalizer-3.4.2-cp37-cp37m-musllinux_1_2_i686.whl", hash = "sha256:915f3849a011c1f593ab99092f3cecfcb4d65d8feb4a64cf1bf2d22074dc0ec4"},
+ {file = "charset_normalizer-3.4.2-cp37-cp37m-musllinux_1_2_ppc64le.whl", hash = "sha256:fb707f3e15060adf5b7ada797624a6c6e0138e2a26baa089df64c68ee98e040f"},
+ {file = "charset_normalizer-3.4.2-cp37-cp37m-musllinux_1_2_s390x.whl", hash = "sha256:25a23ea5c7edc53e0f29bae2c44fcb5a1aa10591aae107f2a2b2583a9c5cbc64"},
+ {file = "charset_normalizer-3.4.2-cp37-cp37m-musllinux_1_2_x86_64.whl", hash = "sha256:770cab594ecf99ae64c236bc9ee3439c3f46be49796e265ce0cc8bc17b10294f"},
+ {file = "charset_normalizer-3.4.2-cp37-cp37m-win32.whl", hash = "sha256:6a0289e4589e8bdfef02a80478f1dfcb14f0ab696b5a00e1f4b8a14a307a3c58"},
+ {file = "charset_normalizer-3.4.2-cp37-cp37m-win_amd64.whl", hash = "sha256:6fc1f5b51fa4cecaa18f2bd7a003f3dd039dd615cd69a2afd6d3b19aed6775f2"},
+ {file = "charset_normalizer-3.4.2-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:76af085e67e56c8816c3ccf256ebd136def2ed9654525348cfa744b6802b69eb"},
+ {file = "charset_normalizer-3.4.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e45ba65510e2647721e35323d6ef54c7974959f6081b58d4ef5d87c60c84919a"},
+ {file = "charset_normalizer-3.4.2-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:046595208aae0120559a67693ecc65dd75d46f7bf687f159127046628178dc45"},
+ {file = "charset_normalizer-3.4.2-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:75d10d37a47afee94919c4fab4c22b9bc2a8bf7d4f46f87363bcf0573f3ff4f5"},
+ {file = "charset_normalizer-3.4.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6333b3aa5a12c26b2a4d4e7335a28f1475e0e5e17d69d55141ee3cab736f66d1"},
+ {file = "charset_normalizer-3.4.2-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e8323a9b031aa0393768b87f04b4164a40037fb2a3c11ac06a03ffecd3618027"},
+ {file = "charset_normalizer-3.4.2-cp38-cp38-musllinux_1_2_aarch64.whl", hash = "sha256:24498ba8ed6c2e0b56d4acbf83f2d989720a93b41d712ebd4f4979660db4417b"},
+ {file = "charset_normalizer-3.4.2-cp38-cp38-musllinux_1_2_i686.whl", hash = "sha256:844da2b5728b5ce0e32d863af26f32b5ce61bc4273a9c720a9f3aa9df73b1455"},
+ {file = "charset_normalizer-3.4.2-cp38-cp38-musllinux_1_2_ppc64le.whl", hash = "sha256:65c981bdbd3f57670af8b59777cbfae75364b483fa8a9f420f08094531d54a01"},
+ {file = "charset_normalizer-3.4.2-cp38-cp38-musllinux_1_2_s390x.whl", hash = "sha256:3c21d4fca343c805a52c0c78edc01e3477f6dd1ad7c47653241cf2a206d4fc58"},
+ {file = "charset_normalizer-3.4.2-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:dc7039885fa1baf9be153a0626e337aa7ec8bf96b0128605fb0d77788ddc1681"},
+ {file = "charset_normalizer-3.4.2-cp38-cp38-win32.whl", hash = "sha256:8272b73e1c5603666618805fe821edba66892e2870058c94c53147602eab29c7"},
+ {file = "charset_normalizer-3.4.2-cp38-cp38-win_amd64.whl", hash = "sha256:70f7172939fdf8790425ba31915bfbe8335030f05b9913d7ae00a87d4395620a"},
+ {file = "charset_normalizer-3.4.2-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:005fa3432484527f9732ebd315da8da8001593e2cf46a3d817669f062c3d9ed4"},
+ {file = "charset_normalizer-3.4.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e92fca20c46e9f5e1bb485887d074918b13543b1c2a1185e69bb8d17ab6236a7"},
+ {file = "charset_normalizer-3.4.2-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:50bf98d5e563b83cc29471fa114366e6806bc06bc7a25fd59641e41445327836"},
+ {file = "charset_normalizer-3.4.2-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:721c76e84fe669be19c5791da68232ca2e05ba5185575086e384352e2c309597"},
+ {file = "charset_normalizer-3.4.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:82d8fd25b7f4675d0c47cf95b594d4e7b158aca33b76aa63d07186e13c0e0ab7"},
+ {file = "charset_normalizer-3.4.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b3daeac64d5b371dea99714f08ffc2c208522ec6b06fbc7866a450dd446f5c0f"},
+ {file = "charset_normalizer-3.4.2-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:dccab8d5fa1ef9bfba0590ecf4d46df048d18ffe3eec01eeb73a42e0d9e7a8ba"},
+ {file = "charset_normalizer-3.4.2-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:aaf27faa992bfee0264dc1f03f4c75e9fcdda66a519db6b957a3f826e285cf12"},
+ {file = "charset_normalizer-3.4.2-cp39-cp39-musllinux_1_2_ppc64le.whl", hash = "sha256:eb30abc20df9ab0814b5a2524f23d75dcf83cde762c161917a2b4b7b55b1e518"},
+ {file = "charset_normalizer-3.4.2-cp39-cp39-musllinux_1_2_s390x.whl", hash = "sha256:c72fbbe68c6f32f251bdc08b8611c7b3060612236e960ef848e0a517ddbe76c5"},
+ {file = "charset_normalizer-3.4.2-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:982bb1e8b4ffda883b3d0a521e23abcd6fd17418f6d2c4118d257a10199c0ce3"},
+ {file = "charset_normalizer-3.4.2-cp39-cp39-win32.whl", hash = "sha256:43e0933a0eff183ee85833f341ec567c0980dae57c464d8a508e1b2ceb336471"},
+ {file = "charset_normalizer-3.4.2-cp39-cp39-win_amd64.whl", hash = "sha256:d11b54acf878eef558599658b0ffca78138c8c3655cf4f3a4a673c437e67732e"},
+ {file = "charset_normalizer-3.4.2-py3-none-any.whl", hash = "sha256:7f56930ab0abd1c45cd15be65cc741c28b1c9a34876ce8c17a2fa107810c0af0"},
+ {file = "charset_normalizer-3.4.2.tar.gz", hash = "sha256:5baececa9ecba31eff645232d59845c07aa030f0c81ee70184a90d35099a0e63"},
+]
+
+[[package]]
+name = "click"
+version = "8.2.1"
+description = "Composable command line interface toolkit"
+optional = false
+python-versions = ">=3.10"
+groups = ["main"]
+files = [
+ {file = "click-8.2.1-py3-none-any.whl", hash = "sha256:61a3265b914e850b85317d0b3109c7f8cd35a670f963866005d6ef1d5175a12b"},
+ {file = "click-8.2.1.tar.gz", hash = "sha256:27c491cc05d968d271d5a1db13e3b5a184636d9d930f148c50b038f0d0646202"},
+]
+
+[package.dependencies]
+colorama = {version = "*", markers = "platform_system == \"Windows\""}
+
+[[package]]
+name = "colorama"
+version = "0.4.6"
+description = "Cross-platform colored terminal text."
+optional = false
+python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7"
+groups = ["main", "dev"]
+files = [
+ {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"},
+ {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"},
+]
+markers = {main = "platform_system == \"Windows\"", dev = "sys_platform == \"win32\""}
+
+[[package]]
+name = "coverage"
+version = "7.8.2"
+description = "Code coverage measurement for Python"
+optional = false
+python-versions = ">=3.9"
+groups = ["dev"]
+files = [
+ {file = "coverage-7.8.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:bd8ec21e1443fd7a447881332f7ce9d35b8fbd2849e761bb290b584535636b0a"},
+ {file = "coverage-7.8.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:4c26c2396674816deaeae7ded0e2b42c26537280f8fe313335858ffff35019be"},
+ {file = "coverage-7.8.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1aec326ed237e5880bfe69ad41616d333712c7937bcefc1343145e972938f9b3"},
+ {file = "coverage-7.8.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:5e818796f71702d7a13e50c70de2a1924f729228580bcba1607cccf32eea46e6"},
+ {file = "coverage-7.8.2-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:546e537d9e24efc765c9c891328f30f826e3e4808e31f5d0f87c4ba12bbd1622"},
+ {file = "coverage-7.8.2-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:ab9b09a2349f58e73f8ebc06fac546dd623e23b063e5398343c5270072e3201c"},
+ {file = "coverage-7.8.2-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:fd51355ab8a372d89fb0e6a31719e825cf8df8b6724bee942fb5b92c3f016ba3"},
+ {file = "coverage-7.8.2-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:0774df1e093acb6c9e4d58bce7f86656aeed6c132a16e2337692c12786b32404"},
+ {file = "coverage-7.8.2-cp310-cp310-win32.whl", hash = "sha256:00f2e2f2e37f47e5f54423aeefd6c32a7dbcedc033fcd3928a4f4948e8b96af7"},
+ {file = "coverage-7.8.2-cp310-cp310-win_amd64.whl", hash = "sha256:145b07bea229821d51811bf15eeab346c236d523838eda395ea969d120d13347"},
+ {file = "coverage-7.8.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:b99058eef42e6a8dcd135afb068b3d53aff3921ce699e127602efff9956457a9"},
+ {file = "coverage-7.8.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:5feb7f2c3e6ea94d3b877def0270dff0947b8d8c04cfa34a17be0a4dc1836879"},
+ {file = "coverage-7.8.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:670a13249b957bb9050fab12d86acef7bf8f6a879b9d1a883799276e0d4c674a"},
+ {file = "coverage-7.8.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0bdc8bf760459a4a4187b452213e04d039990211f98644c7292adf1e471162b5"},
+ {file = "coverage-7.8.2-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:07a989c867986c2a75f158f03fdb413128aad29aca9d4dbce5fc755672d96f11"},
+ {file = "coverage-7.8.2-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:2db10dedeb619a771ef0e2949ccba7b75e33905de959c2643a4607bef2f3fb3a"},
+ {file = "coverage-7.8.2-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:e6ea7dba4e92926b7b5f0990634b78ea02f208d04af520c73a7c876d5a8d36cb"},
+ {file = "coverage-7.8.2-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:ef2f22795a7aca99fc3c84393a55a53dd18ab8c93fb431004e4d8f0774150f54"},
+ {file = "coverage-7.8.2-cp311-cp311-win32.whl", hash = "sha256:641988828bc18a6368fe72355df5f1703e44411adbe49bba5644b941ce6f2e3a"},
+ {file = "coverage-7.8.2-cp311-cp311-win_amd64.whl", hash = "sha256:8ab4a51cb39dc1933ba627e0875046d150e88478dbe22ce145a68393e9652975"},
+ {file = "coverage-7.8.2-cp311-cp311-win_arm64.whl", hash = "sha256:8966a821e2083c74d88cca5b7dcccc0a3a888a596a04c0b9668a891de3a0cc53"},
+ {file = "coverage-7.8.2-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:e2f6fe3654468d061942591aef56686131335b7a8325684eda85dacdf311356c"},
+ {file = "coverage-7.8.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:76090fab50610798cc05241bf83b603477c40ee87acd358b66196ab0ca44ffa1"},
+ {file = "coverage-7.8.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2bd0a0a5054be160777a7920b731a0570284db5142abaaf81bcbb282b8d99279"},
+ {file = "coverage-7.8.2-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:da23ce9a3d356d0affe9c7036030b5c8f14556bd970c9b224f9c8205505e3b99"},
+ {file = "coverage-7.8.2-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c9392773cffeb8d7e042a7b15b82a414011e9d2b5fdbbd3f7e6a6b17d5e21b20"},
+ {file = "coverage-7.8.2-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:876cbfd0b09ce09d81585d266c07a32657beb3eaec896f39484b631555be0fe2"},
+ {file = "coverage-7.8.2-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:3da9b771c98977a13fbc3830f6caa85cae6c9c83911d24cb2d218e9394259c57"},
+ {file = "coverage-7.8.2-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:9a990f6510b3292686713bfef26d0049cd63b9c7bb17e0864f133cbfd2e6167f"},
+ {file = "coverage-7.8.2-cp312-cp312-win32.whl", hash = "sha256:bf8111cddd0f2b54d34e96613e7fbdd59a673f0cf5574b61134ae75b6f5a33b8"},
+ {file = "coverage-7.8.2-cp312-cp312-win_amd64.whl", hash = "sha256:86a323a275e9e44cdf228af9b71c5030861d4d2610886ab920d9945672a81223"},
+ {file = "coverage-7.8.2-cp312-cp312-win_arm64.whl", hash = "sha256:820157de3a589e992689ffcda8639fbabb313b323d26388d02e154164c57b07f"},
+ {file = "coverage-7.8.2-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:ea561010914ec1c26ab4188aef8b1567272ef6de096312716f90e5baa79ef8ca"},
+ {file = "coverage-7.8.2-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:cb86337a4fcdd0e598ff2caeb513ac604d2f3da6d53df2c8e368e07ee38e277d"},
+ {file = "coverage-7.8.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:26a4636ddb666971345541b59899e969f3b301143dd86b0ddbb570bd591f1e85"},
+ {file = "coverage-7.8.2-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:5040536cf9b13fb033f76bcb5e1e5cb3b57c4807fef37db9e0ed129c6a094257"},
+ {file = "coverage-7.8.2-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dc67994df9bcd7e0150a47ef41278b9e0a0ea187caba72414b71dc590b99a108"},
+ {file = "coverage-7.8.2-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:6e6c86888fd076d9e0fe848af0a2142bf606044dc5ceee0aa9eddb56e26895a0"},
+ {file = "coverage-7.8.2-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:684ca9f58119b8e26bef860db33524ae0365601492e86ba0b71d513f525e7050"},
+ {file = "coverage-7.8.2-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:8165584ddedb49204c4e18da083913bdf6a982bfb558632a79bdaadcdafd0d48"},
+ {file = "coverage-7.8.2-cp313-cp313-win32.whl", hash = "sha256:34759ee2c65362163699cc917bdb2a54114dd06d19bab860725f94ef45a3d9b7"},
+ {file = "coverage-7.8.2-cp313-cp313-win_amd64.whl", hash = "sha256:2f9bc608fbafaee40eb60a9a53dbfb90f53cc66d3d32c2849dc27cf5638a21e3"},
+ {file = "coverage-7.8.2-cp313-cp313-win_arm64.whl", hash = "sha256:9fe449ee461a3b0c7105690419d0b0aba1232f4ff6d120a9e241e58a556733f7"},
+ {file = "coverage-7.8.2-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:8369a7c8ef66bded2b6484053749ff220dbf83cba84f3398c84c51a6f748a008"},
+ {file = "coverage-7.8.2-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:159b81df53a5fcbc7d45dae3adad554fdbde9829a994e15227b3f9d816d00b36"},
+ {file = "coverage-7.8.2-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e6fcbbd35a96192d042c691c9e0c49ef54bd7ed865846a3c9d624c30bb67ce46"},
+ {file = "coverage-7.8.2-cp313-cp313t-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:05364b9cc82f138cc86128dc4e2e1251c2981a2218bfcd556fe6b0fbaa3501be"},
+ {file = "coverage-7.8.2-cp313-cp313t-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:46d532db4e5ff3979ce47d18e2fe8ecad283eeb7367726da0e5ef88e4fe64740"},
+ {file = "coverage-7.8.2-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:4000a31c34932e7e4fa0381a3d6deb43dc0c8f458e3e7ea6502e6238e10be625"},
+ {file = "coverage-7.8.2-cp313-cp313t-musllinux_1_2_i686.whl", hash = "sha256:43ff5033d657cd51f83015c3b7a443287250dc14e69910577c3e03bd2e06f27b"},
+ {file = "coverage-7.8.2-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:94316e13f0981cbbba132c1f9f365cac1d26716aaac130866ca812006f662199"},
+ {file = "coverage-7.8.2-cp313-cp313t-win32.whl", hash = "sha256:3f5673888d3676d0a745c3d0e16da338c5eea300cb1f4ada9c872981265e76d8"},
+ {file = "coverage-7.8.2-cp313-cp313t-win_amd64.whl", hash = "sha256:2c08b05ee8d7861e45dc5a2cc4195c8c66dca5ac613144eb6ebeaff2d502e73d"},
+ {file = "coverage-7.8.2-cp313-cp313t-win_arm64.whl", hash = "sha256:1e1448bb72b387755e1ff3ef1268a06617afd94188164960dba8d0245a46004b"},
+ {file = "coverage-7.8.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:496948261eaac5ac9cf43f5d0a9f6eb7a6d4cb3bedb2c5d294138142f5c18f2a"},
+ {file = "coverage-7.8.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:eacd2de0d30871eff893bab0b67840a96445edcb3c8fd915e6b11ac4b2f3fa6d"},
+ {file = "coverage-7.8.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b039ffddc99ad65d5078ef300e0c7eed08c270dc26570440e3ef18beb816c1ca"},
+ {file = "coverage-7.8.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0e49824808d4375ede9dd84e9961a59c47f9113039f1a525e6be170aa4f5c34d"},
+ {file = "coverage-7.8.2-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b069938961dfad881dc2f8d02b47645cd2f455d3809ba92a8a687bf513839787"},
+ {file = "coverage-7.8.2-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:de77c3ba8bb686d1c411e78ee1b97e6e0b963fb98b1637658dd9ad2c875cf9d7"},
+ {file = "coverage-7.8.2-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:1676628065a498943bd3f64f099bb573e08cf1bc6088bbe33cf4424e0876f4b3"},
+ {file = "coverage-7.8.2-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:8e1a26e7e50076e35f7afafde570ca2b4d7900a491174ca357d29dece5aacee7"},
+ {file = "coverage-7.8.2-cp39-cp39-win32.whl", hash = "sha256:6782a12bf76fa61ad9350d5a6ef5f3f020b57f5e6305cbc663803f2ebd0f270a"},
+ {file = "coverage-7.8.2-cp39-cp39-win_amd64.whl", hash = "sha256:1efa4166ba75ccefd647f2d78b64f53f14fb82622bc94c5a5cb0a622f50f1c9e"},
+ {file = "coverage-7.8.2-pp39.pp310.pp311-none-any.whl", hash = "sha256:ec455eedf3ba0bbdf8f5a570012617eb305c63cb9f03428d39bf544cb2b94837"},
+ {file = "coverage-7.8.2-py3-none-any.whl", hash = "sha256:726f32ee3713f7359696331a18daf0c3b3a70bb0ae71141b9d3c52be7c595e32"},
+ {file = "coverage-7.8.2.tar.gz", hash = "sha256:a886d531373a1f6ff9fad2a2ba4a045b68467b779ae729ee0b3b10ac20033b27"},
+]
+
+[package.extras]
+toml = ["tomli"]
+
+[[package]]
+name = "distro"
+version = "1.9.0"
+description = "Distro - an OS platform information API"
+optional = false
+python-versions = ">=3.6"
+groups = ["main"]
+files = [
+ {file = "distro-1.9.0-py3-none-any.whl", hash = "sha256:7bffd925d65168f85027d8da9af6bddab658135b840670a223589bc0c8ef02b2"},
+ {file = "distro-1.9.0.tar.gz", hash = "sha256:2fa77c6fd8940f116ee1d6b94a2f90b13b5ea8d019b98bc8bafdcabcdd9bdbed"},
+]
+
+[[package]]
+name = "docstring-parser"
+version = "0.16"
+description = "Parse Python docstrings in reST, Google and Numpydoc format"
+optional = false
+python-versions = ">=3.6,<4.0"
+groups = ["main"]
+files = [
+ {file = "docstring_parser-0.16-py3-none-any.whl", hash = "sha256:bf0a1387354d3691d102edef7ec124f219ef639982d096e26e3b60aeffa90637"},
+ {file = "docstring_parser-0.16.tar.gz", hash = "sha256:538beabd0af1e2db0146b6bd3caa526c35a34d61af9fd2887f3a8a27a739aa6e"},
+]
+
+[[package]]
+name = "et-xmlfile"
+version = "2.0.0"
+description = "An implementation of lxml.xmlfile for the standard library"
+optional = false
+python-versions = ">=3.8"
+groups = ["main"]
+files = [
+ {file = "et_xmlfile-2.0.0-py3-none-any.whl", hash = "sha256:7a91720bc756843502c3b7504c77b8fe44217c85c537d85037f0f536151b2caa"},
+ {file = "et_xmlfile-2.0.0.tar.gz", hash = "sha256:dab3f4764309081ce75662649be815c4c9081e88f0837825f90fd28317d4da54"},
+]
+
+[[package]]
+name = "eval-type-backport"
+version = "0.2.2"
+description = "Like `typing._eval_type`, but lets older Python versions use newer typing features."
+optional = true
+python-versions = ">=3.8"
+groups = ["main"]
+markers = "extra == \"mistralai\""
+files = [
+ {file = "eval_type_backport-0.2.2-py3-none-any.whl", hash = "sha256:cb6ad7c393517f476f96d456d0412ea80f0a8cf96f6892834cd9340149111b0a"},
+ {file = "eval_type_backport-0.2.2.tar.gz", hash = "sha256:f0576b4cf01ebb5bd358d02314d31846af5e07678387486e2c798af0e7d849c1"},
+]
+
+[package.extras]
+tests = ["pytest"]
+
+[[package]]
+name = "fal-client"
+version = "0.4.2"
+description = "Python client for fal.ai"
+optional = true
+python-versions = ">=3.8"
+groups = ["main"]
+markers = "extra == \"fal\""
+files = [
+ {file = "fal_client-0.4.2-py3-none-any.whl", hash = "sha256:1a7c6ae2e50ed6631b85847f76df9e4e0d24e53d182b9306c4501387def699b4"},
+ {file = "fal_client-0.4.2.tar.gz", hash = "sha256:010e2cfccd4d02eeaf3ea22eec114eb713808f86a1dde5165ecfc270455b8c70"},
+]
+
+[package.dependencies]
+httpx = ">=0.21.0,<1"
+httpx-sse = ">=0.4.0,<0.5"
+
+[package.extras]
+dev = ["fal-client[docs,test]"]
+docs = ["sphinx", "sphinx-autodoc-typehints", "sphinx-rtd-theme"]
+test = ["pillow", "pytest", "pytest-asyncio"]
+
+[[package]]
+name = "filetype"
+version = "1.2.0"
+description = "Infer file type and MIME type of any file/buffer. No external dependencies."
+optional = false
+python-versions = "*"
+groups = ["main"]
+files = [
+ {file = "filetype-1.2.0-py2.py3-none-any.whl", hash = "sha256:7ce71b6880181241cf7ac8697a2f1eb6a8bd9b429f7ad6d27b8db9ba5f1c2d25"},
+ {file = "filetype-1.2.0.tar.gz", hash = "sha256:66b56cd6474bf41d8c54660347d37afcc3f7d1970648de365c102ef77548aadb"},
+]
+
+[[package]]
+name = "frozenlist"
+version = "1.6.0"
+description = "A list-like structure which implements collections.abc.MutableSequence"
+optional = false
+python-versions = ">=3.9"
+groups = ["main"]
+files = [
+ {file = "frozenlist-1.6.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:e6e558ea1e47fd6fa8ac9ccdad403e5dd5ecc6ed8dda94343056fa4277d5c65e"},
+ {file = "frozenlist-1.6.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:f4b3cd7334a4bbc0c472164f3744562cb72d05002cc6fcf58adb104630bbc352"},
+ {file = "frozenlist-1.6.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:9799257237d0479736e2b4c01ff26b5c7f7694ac9692a426cb717f3dc02fff9b"},
+ {file = "frozenlist-1.6.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f3a7bb0fe1f7a70fb5c6f497dc32619db7d2cdd53164af30ade2f34673f8b1fc"},
+ {file = "frozenlist-1.6.0-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:36d2fc099229f1e4237f563b2a3e0ff7ccebc3999f729067ce4e64a97a7f2869"},
+ {file = "frozenlist-1.6.0-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f27a9f9a86dcf00708be82359db8de86b80d029814e6693259befe82bb58a106"},
+ {file = "frozenlist-1.6.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:75ecee69073312951244f11b8627e3700ec2bfe07ed24e3a685a5979f0412d24"},
+ {file = "frozenlist-1.6.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f2c7d5aa19714b1b01a0f515d078a629e445e667b9da869a3cd0e6fe7dec78bd"},
+ {file = "frozenlist-1.6.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:69bbd454f0fb23b51cadc9bdba616c9678e4114b6f9fa372d462ff2ed9323ec8"},
+ {file = "frozenlist-1.6.0-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:7daa508e75613809c7a57136dec4871a21bca3080b3a8fc347c50b187df4f00c"},
+ {file = "frozenlist-1.6.0-cp310-cp310-musllinux_1_2_armv7l.whl", hash = "sha256:89ffdb799154fd4d7b85c56d5fa9d9ad48946619e0eb95755723fffa11022d75"},
+ {file = "frozenlist-1.6.0-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:920b6bd77d209931e4c263223381d63f76828bec574440f29eb497cf3394c249"},
+ {file = "frozenlist-1.6.0-cp310-cp310-musllinux_1_2_ppc64le.whl", hash = "sha256:d3ceb265249fb401702fce3792e6b44c1166b9319737d21495d3611028d95769"},
+ {file = "frozenlist-1.6.0-cp310-cp310-musllinux_1_2_s390x.whl", hash = "sha256:52021b528f1571f98a7d4258c58aa8d4b1a96d4f01d00d51f1089f2e0323cb02"},
+ {file = "frozenlist-1.6.0-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:0f2ca7810b809ed0f1917293050163c7654cefc57a49f337d5cd9de717b8fad3"},
+ {file = "frozenlist-1.6.0-cp310-cp310-win32.whl", hash = "sha256:0e6f8653acb82e15e5443dba415fb62a8732b68fe09936bb6d388c725b57f812"},
+ {file = "frozenlist-1.6.0-cp310-cp310-win_amd64.whl", hash = "sha256:f1a39819a5a3e84304cd286e3dc62a549fe60985415851b3337b6f5cc91907f1"},
+ {file = "frozenlist-1.6.0-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:ae8337990e7a45683548ffb2fee1af2f1ed08169284cd829cdd9a7fa7470530d"},
+ {file = "frozenlist-1.6.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:8c952f69dd524558694818a461855f35d36cc7f5c0adddce37e962c85d06eac0"},
+ {file = "frozenlist-1.6.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:8f5fef13136c4e2dee91bfb9a44e236fff78fc2cd9f838eddfc470c3d7d90afe"},
+ {file = "frozenlist-1.6.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:716bbba09611b4663ecbb7cd022f640759af8259e12a6ca939c0a6acd49eedba"},
+ {file = "frozenlist-1.6.0-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:7b8c4dc422c1a3ffc550b465090e53b0bf4839047f3e436a34172ac67c45d595"},
+ {file = "frozenlist-1.6.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:b11534872256e1666116f6587a1592ef395a98b54476addb5e8d352925cb5d4a"},
+ {file = "frozenlist-1.6.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:1c6eceb88aaf7221f75be6ab498dc622a151f5f88d536661af3ffc486245a626"},
+ {file = "frozenlist-1.6.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:62c828a5b195570eb4b37369fcbbd58e96c905768d53a44d13044355647838ff"},
+ {file = "frozenlist-1.6.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e1c6bd2c6399920c9622362ce95a7d74e7f9af9bfec05fff91b8ce4b9647845a"},
+ {file = "frozenlist-1.6.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:49ba23817781e22fcbd45fd9ff2b9b8cdb7b16a42a4851ab8025cae7b22e96d0"},
+ {file = "frozenlist-1.6.0-cp311-cp311-musllinux_1_2_armv7l.whl", hash = "sha256:431ef6937ae0f853143e2ca67d6da76c083e8b1fe3df0e96f3802fd37626e606"},
+ {file = "frozenlist-1.6.0-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:9d124b38b3c299ca68433597ee26b7819209cb8a3a9ea761dfe9db3a04bba584"},
+ {file = "frozenlist-1.6.0-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:118e97556306402e2b010da1ef21ea70cb6d6122e580da64c056b96f524fbd6a"},
+ {file = "frozenlist-1.6.0-cp311-cp311-musllinux_1_2_s390x.whl", hash = "sha256:fb3b309f1d4086b5533cf7bbcf3f956f0ae6469664522f1bde4feed26fba60f1"},
+ {file = "frozenlist-1.6.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:54dece0d21dce4fdb188a1ffc555926adf1d1c516e493c2914d7c370e454bc9e"},
+ {file = "frozenlist-1.6.0-cp311-cp311-win32.whl", hash = "sha256:654e4ba1d0b2154ca2f096bed27461cf6160bc7f504a7f9a9ef447c293caf860"},
+ {file = "frozenlist-1.6.0-cp311-cp311-win_amd64.whl", hash = "sha256:3e911391bffdb806001002c1f860787542f45916c3baf764264a52765d5a5603"},
+ {file = "frozenlist-1.6.0-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:c5b9e42ace7d95bf41e19b87cec8f262c41d3510d8ad7514ab3862ea2197bfb1"},
+ {file = "frozenlist-1.6.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:ca9973735ce9f770d24d5484dcb42f68f135351c2fc81a7a9369e48cf2998a29"},
+ {file = "frozenlist-1.6.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:6ac40ec76041c67b928ca8aaffba15c2b2ee3f5ae8d0cb0617b5e63ec119ca25"},
+ {file = "frozenlist-1.6.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:95b7a8a3180dfb280eb044fdec562f9b461614c0ef21669aea6f1d3dac6ee576"},
+ {file = "frozenlist-1.6.0-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:c444d824e22da6c9291886d80c7d00c444981a72686e2b59d38b285617cb52c8"},
+ {file = "frozenlist-1.6.0-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:bb52c8166499a8150bfd38478248572c924c003cbb45fe3bcd348e5ac7c000f9"},
+ {file = "frozenlist-1.6.0-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b35298b2db9c2468106278537ee529719228950a5fdda686582f68f247d1dc6e"},
+ {file = "frozenlist-1.6.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d108e2d070034f9d57210f22fefd22ea0d04609fc97c5f7f5a686b3471028590"},
+ {file = "frozenlist-1.6.0-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4e1be9111cb6756868ac242b3c2bd1f09d9aea09846e4f5c23715e7afb647103"},
+ {file = "frozenlist-1.6.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:94bb451c664415f02f07eef4ece976a2c65dcbab9c2f1705b7031a3a75349d8c"},
+ {file = "frozenlist-1.6.0-cp312-cp312-musllinux_1_2_armv7l.whl", hash = "sha256:d1a686d0b0949182b8faddea596f3fc11f44768d1f74d4cad70213b2e139d821"},
+ {file = "frozenlist-1.6.0-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:ea8e59105d802c5a38bdbe7362822c522230b3faba2aa35c0fa1765239b7dd70"},
+ {file = "frozenlist-1.6.0-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:abc4e880a9b920bc5020bf6a431a6bb40589d9bca3975c980495f63632e8382f"},
+ {file = "frozenlist-1.6.0-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:9a79713adfe28830f27a3c62f6b5406c37376c892b05ae070906f07ae4487046"},
+ {file = "frozenlist-1.6.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:9a0318c2068e217a8f5e3b85e35899f5a19e97141a45bb925bb357cfe1daf770"},
+ {file = "frozenlist-1.6.0-cp312-cp312-win32.whl", hash = "sha256:853ac025092a24bb3bf09ae87f9127de9fe6e0c345614ac92536577cf956dfcc"},
+ {file = "frozenlist-1.6.0-cp312-cp312-win_amd64.whl", hash = "sha256:2bdfe2d7e6c9281c6e55523acd6c2bf77963cb422fdc7d142fb0cb6621b66878"},
+ {file = "frozenlist-1.6.0-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:1d7fb014fe0fbfee3efd6a94fc635aeaa68e5e1720fe9e57357f2e2c6e1a647e"},
+ {file = "frozenlist-1.6.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:01bcaa305a0fdad12745502bfd16a1c75b14558dabae226852f9159364573117"},
+ {file = "frozenlist-1.6.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:8b314faa3051a6d45da196a2c495e922f987dc848e967d8cfeaee8a0328b1cd4"},
+ {file = "frozenlist-1.6.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:da62fecac21a3ee10463d153549d8db87549a5e77eefb8c91ac84bb42bb1e4e3"},
+ {file = "frozenlist-1.6.0-cp313-cp313-manylinux_2_17_armv7l.manylinux2014_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:d1eb89bf3454e2132e046f9599fbcf0a4483ed43b40f545551a39316d0201cd1"},
+ {file = "frozenlist-1.6.0-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d18689b40cb3936acd971f663ccb8e2589c45db5e2c5f07e0ec6207664029a9c"},
+ {file = "frozenlist-1.6.0-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e67ddb0749ed066b1a03fba812e2dcae791dd50e5da03be50b6a14d0c1a9ee45"},
+ {file = "frozenlist-1.6.0-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:fc5e64626e6682638d6e44398c9baf1d6ce6bc236d40b4b57255c9d3f9761f1f"},
+ {file = "frozenlist-1.6.0-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:437cfd39564744ae32ad5929e55b18ebd88817f9180e4cc05e7d53b75f79ce85"},
+ {file = "frozenlist-1.6.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:62dd7df78e74d924952e2feb7357d826af8d2f307557a779d14ddf94d7311be8"},
+ {file = "frozenlist-1.6.0-cp313-cp313-musllinux_1_2_armv7l.whl", hash = "sha256:a66781d7e4cddcbbcfd64de3d41a61d6bdde370fc2e38623f30b2bd539e84a9f"},
+ {file = "frozenlist-1.6.0-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:482fe06e9a3fffbcd41950f9d890034b4a54395c60b5e61fae875d37a699813f"},
+ {file = "frozenlist-1.6.0-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:e4f9373c500dfc02feea39f7a56e4f543e670212102cc2eeb51d3a99c7ffbde6"},
+ {file = "frozenlist-1.6.0-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:e69bb81de06827147b7bfbaeb284d85219fa92d9f097e32cc73675f279d70188"},
+ {file = "frozenlist-1.6.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:7613d9977d2ab4a9141dde4a149f4357e4065949674c5649f920fec86ecb393e"},
+ {file = "frozenlist-1.6.0-cp313-cp313-win32.whl", hash = "sha256:4def87ef6d90429f777c9d9de3961679abf938cb6b7b63d4a7eb8a268babfce4"},
+ {file = "frozenlist-1.6.0-cp313-cp313-win_amd64.whl", hash = "sha256:37a8a52c3dfff01515e9bbbee0e6063181362f9de3db2ccf9bc96189b557cbfd"},
+ {file = "frozenlist-1.6.0-cp313-cp313t-macosx_10_13_universal2.whl", hash = "sha256:46138f5a0773d064ff663d273b309b696293d7a7c00a0994c5c13a5078134b64"},
+ {file = "frozenlist-1.6.0-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:f88bc0a2b9c2a835cb888b32246c27cdab5740059fb3688852bf91e915399b91"},
+ {file = "frozenlist-1.6.0-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:777704c1d7655b802c7850255639672e90e81ad6fa42b99ce5ed3fbf45e338dd"},
+ {file = "frozenlist-1.6.0-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:85ef8d41764c7de0dcdaf64f733a27352248493a85a80661f3c678acd27e31f2"},
+ {file = "frozenlist-1.6.0-cp313-cp313t-manylinux_2_17_armv7l.manylinux2014_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:da5cb36623f2b846fb25009d9d9215322318ff1c63403075f812b3b2876c8506"},
+ {file = "frozenlist-1.6.0-cp313-cp313t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:cbb56587a16cf0fb8acd19e90ff9924979ac1431baea8681712716a8337577b0"},
+ {file = "frozenlist-1.6.0-cp313-cp313t-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c6154c3ba59cda3f954c6333025369e42c3acd0c6e8b6ce31eb5c5b8116c07e0"},
+ {file = "frozenlist-1.6.0-cp313-cp313t-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2e8246877afa3f1ae5c979fe85f567d220f86a50dc6c493b9b7d8191181ae01e"},
+ {file = "frozenlist-1.6.0-cp313-cp313t-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7b0f6cce16306d2e117cf9db71ab3a9e8878a28176aeaf0dbe35248d97b28d0c"},
+ {file = "frozenlist-1.6.0-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:1b8e8cd8032ba266f91136d7105706ad57770f3522eac4a111d77ac126a25a9b"},
+ {file = "frozenlist-1.6.0-cp313-cp313t-musllinux_1_2_armv7l.whl", hash = "sha256:e2ada1d8515d3ea5378c018a5f6d14b4994d4036591a52ceaf1a1549dec8e1ad"},
+ {file = "frozenlist-1.6.0-cp313-cp313t-musllinux_1_2_i686.whl", hash = "sha256:cdb2c7f071e4026c19a3e32b93a09e59b12000751fc9b0b7758da899e657d215"},
+ {file = "frozenlist-1.6.0-cp313-cp313t-musllinux_1_2_ppc64le.whl", hash = "sha256:03572933a1969a6d6ab509d509e5af82ef80d4a5d4e1e9f2e1cdd22c77a3f4d2"},
+ {file = "frozenlist-1.6.0-cp313-cp313t-musllinux_1_2_s390x.whl", hash = "sha256:77effc978947548b676c54bbd6a08992759ea6f410d4987d69feea9cd0919911"},
+ {file = "frozenlist-1.6.0-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:a2bda8be77660ad4089caf2223fdbd6db1858462c4b85b67fbfa22102021e497"},
+ {file = "frozenlist-1.6.0-cp313-cp313t-win32.whl", hash = "sha256:a4d96dc5bcdbd834ec6b0f91027817214216b5b30316494d2b1aebffb87c534f"},
+ {file = "frozenlist-1.6.0-cp313-cp313t-win_amd64.whl", hash = "sha256:e18036cb4caa17ea151fd5f3d70be9d354c99eb8cf817a3ccde8a7873b074348"},
+ {file = "frozenlist-1.6.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:536a1236065c29980c15c7229fbb830dedf809708c10e159b8136534233545f0"},
+ {file = "frozenlist-1.6.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:ed5e3a4462ff25ca84fb09e0fada8ea267df98a450340ead4c91b44857267d70"},
+ {file = "frozenlist-1.6.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:e19c0fc9f4f030fcae43b4cdec9e8ab83ffe30ec10c79a4a43a04d1af6c5e1ad"},
+ {file = "frozenlist-1.6.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c7c608f833897501dac548585312d73a7dca028bf3b8688f0d712b7acfaf7fb3"},
+ {file = "frozenlist-1.6.0-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:0dbae96c225d584f834b8d3cc688825911960f003a85cb0fd20b6e5512468c42"},
+ {file = "frozenlist-1.6.0-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:625170a91dd7261a1d1c2a0c1a353c9e55d21cd67d0852185a5fef86587e6f5f"},
+ {file = "frozenlist-1.6.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:1db8b2fc7ee8a940b547a14c10e56560ad3ea6499dc6875c354e2335812f739d"},
+ {file = "frozenlist-1.6.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:4da6fc43048b648275a220e3a61c33b7fff65d11bdd6dcb9d9c145ff708b804c"},
+ {file = "frozenlist-1.6.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6ef8e7e8f2f3820c5f175d70fdd199b79e417acf6c72c5d0aa8f63c9f721646f"},
+ {file = "frozenlist-1.6.0-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:aa733d123cc78245e9bb15f29b44ed9e5780dc6867cfc4e544717b91f980af3b"},
+ {file = "frozenlist-1.6.0-cp39-cp39-musllinux_1_2_armv7l.whl", hash = "sha256:ba7f8d97152b61f22d7f59491a781ba9b177dd9f318486c5fbc52cde2db12189"},
+ {file = "frozenlist-1.6.0-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:56a0b8dd6d0d3d971c91f1df75e824986667ccce91e20dca2023683814344791"},
+ {file = "frozenlist-1.6.0-cp39-cp39-musllinux_1_2_ppc64le.whl", hash = "sha256:5c9e89bf19ca148efcc9e3c44fd4c09d5af85c8a7dd3dbd0da1cb83425ef4983"},
+ {file = "frozenlist-1.6.0-cp39-cp39-musllinux_1_2_s390x.whl", hash = "sha256:1330f0a4376587face7637dfd245380a57fe21ae8f9d360c1c2ef8746c4195fa"},
+ {file = "frozenlist-1.6.0-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:2187248203b59625566cac53572ec8c2647a140ee2738b4e36772930377a533c"},
+ {file = "frozenlist-1.6.0-cp39-cp39-win32.whl", hash = "sha256:2b8cf4cfea847d6c12af06091561a89740f1f67f331c3fa8623391905e878530"},
+ {file = "frozenlist-1.6.0-cp39-cp39-win_amd64.whl", hash = "sha256:1255d5d64328c5a0d066ecb0f02034d086537925f1f04b50b1ae60d37afbf572"},
+ {file = "frozenlist-1.6.0-py3-none-any.whl", hash = "sha256:535eec9987adb04701266b92745d6cdcef2e77669299359c3009c3404dd5d191"},
+ {file = "frozenlist-1.6.0.tar.gz", hash = "sha256:b99655c32c1c8e06d111e7f41c06c29a5318cb1835df23a45518e02a47c63b68"},
+]
+
+[[package]]
+name = "google-auth"
+version = "2.40.2"
+description = "Google Authentication Library"
+optional = true
+python-versions = ">=3.7"
+groups = ["main"]
+markers = "extra == \"google\""
+files = [
+ {file = "google_auth-2.40.2-py2.py3-none-any.whl", hash = "sha256:f7e568d42eedfded58734f6a60c58321896a621f7c116c411550a4b4a13da90b"},
+ {file = "google_auth-2.40.2.tar.gz", hash = "sha256:a33cde547a2134273226fa4b853883559947ebe9207521f7afc707efbf690f58"},
+]
+
+[package.dependencies]
+cachetools = ">=2.0.0,<6.0"
+pyasn1-modules = ">=0.2.1"
+rsa = ">=3.1.4,<5"
+
+[package.extras]
+aiohttp = ["aiohttp (>=3.6.2,<4.0.0)", "requests (>=2.20.0,<3.0.0)"]
+enterprise-cert = ["cryptography", "pyopenssl"]
+pyjwt = ["cryptography (<39.0.0)", "cryptography (>=38.0.3)", "pyjwt (>=2.0)"]
+pyopenssl = ["cryptography (<39.0.0)", "cryptography (>=38.0.3)", "pyopenssl (>=20.0.0)"]
+reauth = ["pyu2f (>=0.1.5)"]
+requests = ["requests (>=2.20.0,<3.0.0)"]
+testing = ["aiohttp (<3.10.0)", "aiohttp (>=3.6.2,<4.0.0)", "aioresponses", "cryptography (<39.0.0)", "cryptography (>=38.0.3)", "flask", "freezegun", "grpcio", "mock", "oauth2client", "packaging", "pyjwt (>=2.0)", "pyopenssl (<24.3.0)", "pyopenssl (>=20.0.0)", "pytest", "pytest-asyncio", "pytest-cov", "pytest-localserver", "pyu2f (>=0.1.5)", "requests (>=2.20.0,<3.0.0)", "responses", "urllib3"]
+urllib3 = ["packaging", "urllib3"]
+
+[[package]]
+name = "google-auth-oauthlib"
+version = "1.2.2"
+description = "Google Authentication Library"
+optional = true
+python-versions = ">=3.6"
+groups = ["main"]
+markers = "extra == \"google\""
+files = [
+ {file = "google_auth_oauthlib-1.2.2-py3-none-any.whl", hash = "sha256:fd619506f4b3908b5df17b65f39ca8d66ea56986e5472eb5978fd8f3786f00a2"},
+ {file = "google_auth_oauthlib-1.2.2.tar.gz", hash = "sha256:11046fb8d3348b296302dd939ace8af0a724042e8029c1b872d87fabc9f41684"},
+]
+
+[package.dependencies]
+google-auth = ">=2.15.0"
+requests-oauthlib = ">=0.7.0"
+
+[package.extras]
+tool = ["click (>=6.0.0)"]
+
+[[package]]
+name = "h11"
+version = "0.16.0"
+description = "A pure-Python, bring-your-own-I/O implementation of HTTP/1.1"
+optional = false
+python-versions = ">=3.8"
+groups = ["main"]
+files = [
+ {file = "h11-0.16.0-py3-none-any.whl", hash = "sha256:63cf8bbe7522de3bf65932fda1d9c2772064ffb3dae62d55932da54b31cb6c86"},
+ {file = "h11-0.16.0.tar.gz", hash = "sha256:4e35b956cf45792e4caa5885e69fba00bdbc6ffafbfa020300e549b208ee5ff1"},
+]
+
+[[package]]
+name = "httpcore"
+version = "1.0.9"
+description = "A minimal low-level HTTP client."
+optional = false
+python-versions = ">=3.8"
+groups = ["main"]
+files = [
+ {file = "httpcore-1.0.9-py3-none-any.whl", hash = "sha256:2d400746a40668fc9dec9810239072b40b4484b640a8c38fd654a024c7a1bf55"},
+ {file = "httpcore-1.0.9.tar.gz", hash = "sha256:6e34463af53fd2ab5d807f399a9b45ea31c3dfa2276f15a2c3f00afff6e176e8"},
+]
+
+[package.dependencies]
+certifi = "*"
+h11 = ">=0.16"
+
+[package.extras]
+asyncio = ["anyio (>=4.0,<5.0)"]
+http2 = ["h2 (>=3,<5)"]
+socks = ["socksio (==1.*)"]
+trio = ["trio (>=0.22.0,<1.0)"]
+
+[[package]]
+name = "httpx"
+version = "0.27.2"
+description = "The next generation HTTP client."
+optional = false
+python-versions = ">=3.8"
+groups = ["main"]
+files = [
+ {file = "httpx-0.27.2-py3-none-any.whl", hash = "sha256:7bb2708e112d8fdd7829cd4243970f0c223274051cb35ee80c03301ee29a3df0"},
+ {file = "httpx-0.27.2.tar.gz", hash = "sha256:f7c2be1d2f3c3c3160d441802406b206c2b76f5947b11115e6df10c6c65e66c2"},
+]
+
+[package.dependencies]
+anyio = "*"
+certifi = "*"
+httpcore = "==1.*"
+idna = "*"
+sniffio = "*"
+
+[package.extras]
+brotli = ["brotli", "brotlicffi"]
+cli = ["click (==8.*)", "pygments (==2.*)", "rich (>=10,<14)"]
+http2 = ["h2 (>=3,<5)"]
+socks = ["socksio (==1.*)"]
+zstd = ["zstandard (>=0.18.0)"]
+
+[[package]]
+name = "httpx-sse"
+version = "0.4.0"
+description = "Consume Server-Sent Event (SSE) messages with HTTPX."
+optional = true
+python-versions = ">=3.8"
+groups = ["main"]
+markers = "extra == \"fal\""
+files = [
+ {file = "httpx-sse-0.4.0.tar.gz", hash = "sha256:1e81a3a3070ce322add1d3529ed42eb5f70817f45ed6ec915ab753f961139721"},
+ {file = "httpx_sse-0.4.0-py3-none-any.whl", hash = "sha256:f329af6eae57eaa2bdfd962b42524764af68075ea87370a2de920af5341e318f"},
+]
+
+[[package]]
+name = "idna"
+version = "3.10"
+description = "Internationalized Domain Names in Applications (IDNA)"
+optional = false
+python-versions = ">=3.6"
+groups = ["main"]
+files = [
+ {file = "idna-3.10-py3-none-any.whl", hash = "sha256:946d195a0d259cbba61165e88e65941f16e9b36ea6ddb97f00452bae8b1287d3"},
+ {file = "idna-3.10.tar.gz", hash = "sha256:12f65c9b470abda6dc35cf8e63cc574b1c52b11df2c86030af0ac09b01b13ea9"},
+]
+
+[package.extras]
+all = ["flake8 (>=7.1.1)", "mypy (>=1.11.2)", "pytest (>=8.3.2)", "ruff (>=0.6.2)"]
+
+[[package]]
+name = "iniconfig"
+version = "2.1.0"
+description = "brain-dead simple config-ini parsing"
+optional = false
+python-versions = ">=3.8"
+groups = ["dev"]
+files = [
+ {file = "iniconfig-2.1.0-py3-none-any.whl", hash = "sha256:9deba5723312380e77435581c6bf4935c94cbfab9b1ed33ef8d238ea168eb760"},
+ {file = "iniconfig-2.1.0.tar.gz", hash = "sha256:3abbd2e30b36733fee78f9c7f7308f2d0050e88f0087fd25c2645f63c773e1c7"},
+]
+
+[[package]]
+name = "instructor"
+version = "1.7.2"
+description = "structured outputs for llm"
+optional = false
+python-versions = "<4.0,>=3.9"
+groups = ["main"]
+files = [
+ {file = "instructor-1.7.2-py3-none-any.whl", hash = "sha256:cb43d27f6d7631c31762b936b2fcb44d2a3f9d8a020430a0f4d3484604ffb95b"},
+ {file = "instructor-1.7.2.tar.gz", hash = "sha256:6c01b2b159766df24865dc81f7bf8457cbda88a3c0bbc810da3467d19b185ed2"},
+]
+
+[package.dependencies]
+aiohttp = ">=3.9.1,<4.0.0"
+docstring-parser = ">=0.16,<1.0"
+jinja2 = ">=3.1.4,<4.0.0"
+jiter = ">=0.6.1,<0.9"
+openai = ">=1.52.0,<2.0.0"
+pydantic = ">=2.8.0,<3.0.0"
+pydantic-core = ">=2.18.0,<3.0.0"
+requests = ">=2.32.3,<3.0.0"
+rich = ">=13.7.0,<14.0.0"
+tenacity = ">=9.0.0,<10.0.0"
+typer = ">=0.9.0,<1.0.0"
+
+[package.extras]
+anthropic = ["anthropic (==0.42.0)", "xmltodict (>=0.13,<0.15)"]
+cerebras-cloud-sdk = ["cerebras-cloud-sdk (>=1.5.0,<2.0.0)"]
+cohere = ["cohere (>=5.1.8,<6.0.0)"]
+fireworks-ai = ["fireworks-ai (>=0.15.4,<1.0.0)"]
+google-generativeai = ["google-generativeai (>=0.8.2,<1.0.0)", "jsonref (>=1.1.0,<2.0.0)"]
+groq = ["groq (>=0.4.2,<0.14.0)"]
+test-docs = ["diskcache (>=5.6.3,<6.0.0)", "fastapi (>=0.109.2,<0.116.0)", "litellm (>=1.35.31,<2.0.0)", "mistralai (>=1.0.3,<2.0.0)", "pandas (>=2.2.0,<3.0.0)", "pydantic-extra-types (>=2.6.0,<3.0.0)", "redis (>=5.0.1,<6.0.0)", "tabulate (>=0.9.0,<1.0.0)"]
+vertexai = ["google-cloud-aiplatform (>=1.53.0,<2.0.0)", "jsonref (>=1.1.0,<2.0.0)"]
+writer = ["writer-sdk (>=1.2.0,<2.0.0)"]
+
+[[package]]
+name = "jinja2"
+version = "3.1.6"
+description = "A very fast and expressive template engine."
+optional = false
+python-versions = ">=3.7"
+groups = ["main"]
+files = [
+ {file = "jinja2-3.1.6-py3-none-any.whl", hash = "sha256:85ece4451f492d0c13c5dd7c13a64681a86afae63a5f347908daf103ce6d2f67"},
+ {file = "jinja2-3.1.6.tar.gz", hash = "sha256:0137fb05990d35f1275a587e9aee6d56da821fc83491a0fb838183be43f66d6d"},
+]
+
+[package.dependencies]
+MarkupSafe = ">=2.0"
+
+[package.extras]
+i18n = ["Babel (>=2.7)"]
+
+[[package]]
+name = "jiter"
+version = "0.8.2"
+description = "Fast iterable JSON parser."
+optional = false
+python-versions = ">=3.8"
+groups = ["main"]
+files = [
+ {file = "jiter-0.8.2-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:ca8577f6a413abe29b079bc30f907894d7eb07a865c4df69475e868d73e71c7b"},
+ {file = "jiter-0.8.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:b25bd626bde7fb51534190c7e3cb97cee89ee76b76d7585580e22f34f5e3f393"},
+ {file = "jiter-0.8.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d5c826a221851a8dc028eb6d7d6429ba03184fa3c7e83ae01cd6d3bd1d4bd17d"},
+ {file = "jiter-0.8.2-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:d35c864c2dff13dfd79fb070fc4fc6235d7b9b359efe340e1261deb21b9fcb66"},
+ {file = "jiter-0.8.2-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f557c55bc2b7676e74d39d19bcb8775ca295c7a028246175d6a8b431e70835e5"},
+ {file = "jiter-0.8.2-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:580ccf358539153db147e40751a0b41688a5ceb275e6f3e93d91c9467f42b2e3"},
+ {file = "jiter-0.8.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:af102d3372e917cffce49b521e4c32c497515119dc7bd8a75665e90a718bbf08"},
+ {file = "jiter-0.8.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:cadcc978f82397d515bb2683fc0d50103acff2a180552654bb92d6045dec2c49"},
+ {file = "jiter-0.8.2-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:ba5bdf56969cad2019d4e8ffd3f879b5fdc792624129741d3d83fc832fef8c7d"},
+ {file = "jiter-0.8.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:3b94a33a241bee9e34b8481cdcaa3d5c2116f575e0226e421bed3f7a6ea71cff"},
+ {file = "jiter-0.8.2-cp310-cp310-win32.whl", hash = "sha256:6e5337bf454abddd91bd048ce0dca5134056fc99ca0205258766db35d0a2ea43"},
+ {file = "jiter-0.8.2-cp310-cp310-win_amd64.whl", hash = "sha256:4a9220497ca0cb1fe94e3f334f65b9b5102a0b8147646118f020d8ce1de70105"},
+ {file = "jiter-0.8.2-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:2dd61c5afc88a4fda7d8b2cf03ae5947c6ac7516d32b7a15bf4b49569a5c076b"},
+ {file = "jiter-0.8.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:a6c710d657c8d1d2adbbb5c0b0c6bfcec28fd35bd6b5f016395f9ac43e878a15"},
+ {file = "jiter-0.8.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a9584de0cd306072635fe4b89742bf26feae858a0683b399ad0c2509011b9dc0"},
+ {file = "jiter-0.8.2-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:5a90a923338531b7970abb063cfc087eebae6ef8ec8139762007188f6bc69a9f"},
+ {file = "jiter-0.8.2-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d21974d246ed0181558087cd9f76e84e8321091ebfb3a93d4c341479a736f099"},
+ {file = "jiter-0.8.2-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:32475a42b2ea7b344069dc1e81445cfc00b9d0e3ca837f0523072432332e9f74"},
+ {file = "jiter-0.8.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8b9931fd36ee513c26b5bf08c940b0ac875de175341cbdd4fa3be109f0492586"},
+ {file = "jiter-0.8.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:ce0820f4a3a59ddced7fce696d86a096d5cc48d32a4183483a17671a61edfddc"},
+ {file = "jiter-0.8.2-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:8ffc86ae5e3e6a93765d49d1ab47b6075a9c978a2b3b80f0f32628f39caa0c88"},
+ {file = "jiter-0.8.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:5127dc1abd809431172bc3fbe8168d6b90556a30bb10acd5ded41c3cfd6f43b6"},
+ {file = "jiter-0.8.2-cp311-cp311-win32.whl", hash = "sha256:66227a2c7b575720c1871c8800d3a0122bb8ee94edb43a5685aa9aceb2782d44"},
+ {file = "jiter-0.8.2-cp311-cp311-win_amd64.whl", hash = "sha256:cde031d8413842a1e7501e9129b8e676e62a657f8ec8166e18a70d94d4682855"},
+ {file = "jiter-0.8.2-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:e6ec2be506e7d6f9527dae9ff4b7f54e68ea44a0ef6b098256ddf895218a2f8f"},
+ {file = "jiter-0.8.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:76e324da7b5da060287c54f2fabd3db5f76468006c811831f051942bf68c9d44"},
+ {file = "jiter-0.8.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:180a8aea058f7535d1c84183c0362c710f4750bef66630c05f40c93c2b152a0f"},
+ {file = "jiter-0.8.2-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:025337859077b41548bdcbabe38698bcd93cfe10b06ff66617a48ff92c9aec60"},
+ {file = "jiter-0.8.2-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:ecff0dc14f409599bbcafa7e470c00b80f17abc14d1405d38ab02e4b42e55b57"},
+ {file = "jiter-0.8.2-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:ffd9fee7d0775ebaba131f7ca2e2d83839a62ad65e8e02fe2bd8fc975cedeb9e"},
+ {file = "jiter-0.8.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:14601dcac4889e0a1c75ccf6a0e4baf70dbc75041e51bcf8d0e9274519df6887"},
+ {file = "jiter-0.8.2-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:92249669925bc1c54fcd2ec73f70f2c1d6a817928480ee1c65af5f6b81cdf12d"},
+ {file = "jiter-0.8.2-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:e725edd0929fa79f8349ab4ec7f81c714df51dc4e991539a578e5018fa4a7152"},
+ {file = "jiter-0.8.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:bf55846c7b7a680eebaf9c3c48d630e1bf51bdf76c68a5f654b8524335b0ad29"},
+ {file = "jiter-0.8.2-cp312-cp312-win32.whl", hash = "sha256:7efe4853ecd3d6110301665a5178b9856be7e2a9485f49d91aa4d737ad2ae49e"},
+ {file = "jiter-0.8.2-cp312-cp312-win_amd64.whl", hash = "sha256:83c0efd80b29695058d0fd2fa8a556490dbce9804eac3e281f373bbc99045f6c"},
+ {file = "jiter-0.8.2-cp313-cp313-macosx_10_12_x86_64.whl", hash = "sha256:ca1f08b8e43dc3bd0594c992fb1fd2f7ce87f7bf0d44358198d6da8034afdf84"},
+ {file = "jiter-0.8.2-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:5672a86d55416ccd214c778efccf3266b84f87b89063b582167d803246354be4"},
+ {file = "jiter-0.8.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:58dc9bc9767a1101f4e5e22db1b652161a225874d66f0e5cb8e2c7d1c438b587"},
+ {file = "jiter-0.8.2-cp313-cp313-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:37b2998606d6dadbb5ccda959a33d6a5e853252d921fec1792fc902351bb4e2c"},
+ {file = "jiter-0.8.2-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:4ab9a87f3784eb0e098f84a32670cfe4a79cb6512fd8f42ae3d0709f06405d18"},
+ {file = "jiter-0.8.2-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:79aec8172b9e3c6d05fd4b219d5de1ac616bd8da934107325a6c0d0e866a21b6"},
+ {file = "jiter-0.8.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:711e408732d4e9a0208008e5892c2966b485c783cd2d9a681f3eb147cf36c7ef"},
+ {file = "jiter-0.8.2-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:653cf462db4e8c41995e33d865965e79641ef45369d8a11f54cd30888b7e6ff1"},
+ {file = "jiter-0.8.2-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:9c63eaef32b7bebac8ebebf4dabebdbc6769a09c127294db6babee38e9f405b9"},
+ {file = "jiter-0.8.2-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:eb21aaa9a200d0a80dacc7a81038d2e476ffe473ffdd9c91eb745d623561de05"},
+ {file = "jiter-0.8.2-cp313-cp313-win32.whl", hash = "sha256:789361ed945d8d42850f919342a8665d2dc79e7e44ca1c97cc786966a21f627a"},
+ {file = "jiter-0.8.2-cp313-cp313-win_amd64.whl", hash = "sha256:ab7f43235d71e03b941c1630f4b6e3055d46b6cb8728a17663eaac9d8e83a865"},
+ {file = "jiter-0.8.2-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:b426f72cd77da3fec300ed3bc990895e2dd6b49e3bfe6c438592a3ba660e41ca"},
+ {file = "jiter-0.8.2-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b2dd880785088ff2ad21ffee205e58a8c1ddabc63612444ae41e5e4b321b39c0"},
+ {file = "jiter-0.8.2-cp313-cp313t-win_amd64.whl", hash = "sha256:3ac9f578c46f22405ff7f8b1f5848fb753cc4b8377fbec8470a7dc3997ca7566"},
+ {file = "jiter-0.8.2-cp38-cp38-macosx_10_12_x86_64.whl", hash = "sha256:9e1fa156ee9454642adb7e7234a383884452532bc9d53d5af2d18d98ada1d79c"},
+ {file = "jiter-0.8.2-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:0cf5dfa9956d96ff2efb0f8e9c7d055904012c952539a774305aaaf3abdf3d6c"},
+ {file = "jiter-0.8.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e52bf98c7e727dd44f7c4acb980cb988448faeafed8433c867888268899b298b"},
+ {file = "jiter-0.8.2-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:a2ecaa3c23e7a7cf86d00eda3390c232f4d533cd9ddea4b04f5d0644faf642c5"},
+ {file = "jiter-0.8.2-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:08d4c92bf480e19fc3f2717c9ce2aa31dceaa9163839a311424b6862252c943e"},
+ {file = "jiter-0.8.2-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:99d9a1eded738299ba8e106c6779ce5c3893cffa0e32e4485d680588adae6db8"},
+ {file = "jiter-0.8.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d20be8b7f606df096e08b0b1b4a3c6f0515e8dac296881fe7461dfa0fb5ec817"},
+ {file = "jiter-0.8.2-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:d33f94615fcaf872f7fd8cd98ac3b429e435c77619777e8a449d9d27e01134d1"},
+ {file = "jiter-0.8.2-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:317b25e98a35ffec5c67efe56a4e9970852632c810d35b34ecdd70cc0e47b3b6"},
+ {file = "jiter-0.8.2-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:fc9043259ee430ecd71d178fccabd8c332a3bf1e81e50cae43cc2b28d19e4cb7"},
+ {file = "jiter-0.8.2-cp38-cp38-win32.whl", hash = "sha256:fc5adda618205bd4678b146612ce44c3cbfdee9697951f2c0ffdef1f26d72b63"},
+ {file = "jiter-0.8.2-cp38-cp38-win_amd64.whl", hash = "sha256:cd646c827b4f85ef4a78e4e58f4f5854fae0caf3db91b59f0d73731448a970c6"},
+ {file = "jiter-0.8.2-cp39-cp39-macosx_10_12_x86_64.whl", hash = "sha256:e41e75344acef3fc59ba4765df29f107f309ca9e8eace5baacabd9217e52a5ee"},
+ {file = "jiter-0.8.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:7f22b16b35d5c1df9dfd58843ab2cd25e6bf15191f5a236bed177afade507bfc"},
+ {file = "jiter-0.8.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f7200b8f7619d36aa51c803fd52020a2dfbea36ffec1b5e22cab11fd34d95a6d"},
+ {file = "jiter-0.8.2-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:70bf4c43652cc294040dbb62256c83c8718370c8b93dd93d934b9a7bf6c4f53c"},
+ {file = "jiter-0.8.2-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f9d471356dc16f84ed48768b8ee79f29514295c7295cb41e1133ec0b2b8d637d"},
+ {file = "jiter-0.8.2-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:859e8eb3507894093d01929e12e267f83b1d5f6221099d3ec976f0c995cb6bd9"},
+ {file = "jiter-0.8.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:eaa58399c01db555346647a907b4ef6d4f584b123943be6ed5588c3f2359c9f4"},
+ {file = "jiter-0.8.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:8f2d5ed877f089862f4c7aacf3a542627c1496f972a34d0474ce85ee7d939c27"},
+ {file = "jiter-0.8.2-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:03c9df035d4f8d647f8c210ddc2ae0728387275340668fb30d2421e17d9a0841"},
+ {file = "jiter-0.8.2-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:8bd2a824d08d8977bb2794ea2682f898ad3d8837932e3a74937e93d62ecbb637"},
+ {file = "jiter-0.8.2-cp39-cp39-win32.whl", hash = "sha256:ca29b6371ebc40e496995c94b988a101b9fbbed48a51190a4461fcb0a68b4a36"},
+ {file = "jiter-0.8.2-cp39-cp39-win_amd64.whl", hash = "sha256:1c0dfbd1be3cbefc7510102370d86e35d1d53e5a93d48519688b1bf0f761160a"},
+ {file = "jiter-0.8.2.tar.gz", hash = "sha256:cd73d3e740666d0e639f678adb176fad25c1bcbdae88d8d7b857e1783bb4212d"},
+]
+
+[[package]]
+name = "jmespath"
+version = "1.0.1"
+description = "JSON Matching Expressions"
+optional = true
+python-versions = ">=3.7"
+groups = ["main"]
+markers = "extra == \"bedrock\""
+files = [
+ {file = "jmespath-1.0.1-py3-none-any.whl", hash = "sha256:02e2e4cc71b5bcab88332eebf907519190dd9e6e82107fa7f83b1003a6252980"},
+ {file = "jmespath-1.0.1.tar.gz", hash = "sha256:90261b206d6defd58fdd5e85f478bf633a2901798906be2ad389150c5c60edbe"},
+]
+
+[[package]]
+name = "json2html"
+version = "1.3.0"
+description = "JSON to HTML Table Representation"
+optional = false
+python-versions = "*"
+groups = ["main"]
+files = [
+ {file = "json2html-1.3.0.tar.gz", hash = "sha256:8951a53662ae9cfd812685facdba693fc950ffc1c1fd1a8a2d3cf4c34600689c"},
+]
+
+[[package]]
+name = "jsonpath-python"
+version = "1.0.6"
+description = "A more powerful JSONPath implementation in modern python"
+optional = true
+python-versions = ">=3.6"
+groups = ["main"]
+markers = "extra == \"mistralai\""
+files = [
+ {file = "jsonpath-python-1.0.6.tar.gz", hash = "sha256:dd5be4a72d8a2995c3f583cf82bf3cd1a9544cfdabf2d22595b67aff07349666"},
+ {file = "jsonpath_python-1.0.6-py3-none-any.whl", hash = "sha256:1e3b78df579f5efc23565293612decee04214609208a2335884b3ee3f786b575"},
+]
+
+[[package]]
+name = "kajson"
+version = "0.1.4"
+description = "Powerful universal JSON encoder/decoder for Python objects with support for pydantic v2."
+optional = false
+python-versions = "<3.12,>=3.11"
+groups = ["main"]
+files = [
+ {file = "kajson-0.1.4-py3-none-any.whl", hash = "sha256:fbea1ae670744f91ccd8754adf9fa98315aa2b9bd20d76be753cb86771eaa131"},
+ {file = "kajson-0.1.4.tar.gz", hash = "sha256:61f11fb3452afad9cf9c53febe1f2f28af3d2fe8744fb7cc17fd0732e46fccb0"},
+]
+
+[package.dependencies]
+pydantic = "2.10.6"
+rich = ">=13.8.1,<14.0.0"
+
+[[package]]
+name = "markdown"
+version = "3.8"
+description = "Python implementation of John Gruber's Markdown."
+optional = false
+python-versions = ">=3.9"
+groups = ["main"]
+files = [
+ {file = "markdown-3.8-py3-none-any.whl", hash = "sha256:794a929b79c5af141ef5ab0f2f642d0f7b1872981250230e72682346f7cc90dc"},
+ {file = "markdown-3.8.tar.gz", hash = "sha256:7df81e63f0df5c4b24b7d156eb81e4690595239b7d70937d0409f1b0de319c6f"},
+]
+
+[package.extras]
+docs = ["mdx_gh_links (>=0.2)", "mkdocs (>=1.6)", "mkdocs-gen-files", "mkdocs-literate-nav", "mkdocs-nature (>=0.6)", "mkdocs-section-index", "mkdocstrings[python]"]
+testing = ["coverage", "pyyaml"]
+
+[[package]]
+name = "markdown-it-py"
+version = "3.0.0"
+description = "Python port of markdown-it. Markdown parsing, done right!"
+optional = false
+python-versions = ">=3.8"
+groups = ["main", "dev"]
+files = [
+ {file = "markdown-it-py-3.0.0.tar.gz", hash = "sha256:e3f60a94fa066dc52ec76661e37c851cb232d92f9886b15cb560aaada2df8feb"},
+ {file = "markdown_it_py-3.0.0-py3-none-any.whl", hash = "sha256:355216845c60bd96232cd8d8c40e8f9765cc86f46880e43a8fd22dc1a1a8cab1"},
+]
+
+[package.dependencies]
+mdurl = ">=0.1,<1.0"
+
+[package.extras]
+benchmarking = ["psutil", "pytest", "pytest-benchmark"]
+code-style = ["pre-commit (>=3.0,<4.0)"]
+compare = ["commonmark (>=0.9,<1.0)", "markdown (>=3.4,<4.0)", "mistletoe (>=1.0,<2.0)", "mistune (>=2.0,<3.0)", "panflute (>=2.3,<3.0)"]
+linkify = ["linkify-it-py (>=1,<3)"]
+plugins = ["mdit-py-plugins"]
+profiling = ["gprof2dot"]
+rtd = ["jupyter_sphinx", "mdit-py-plugins", "myst-parser", "pyyaml", "sphinx", "sphinx-copybutton", "sphinx-design", "sphinx_book_theme"]
+testing = ["coverage", "pytest", "pytest-cov", "pytest-regressions"]
+
+[[package]]
+name = "markupsafe"
+version = "3.0.2"
+description = "Safely add untrusted strings to HTML/XML markup."
+optional = false
+python-versions = ">=3.9"
+groups = ["main"]
+files = [
+ {file = "MarkupSafe-3.0.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:7e94c425039cde14257288fd61dcfb01963e658efbc0ff54f5306b06054700f8"},
+ {file = "MarkupSafe-3.0.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:9e2d922824181480953426608b81967de705c3cef4d1af983af849d7bd619158"},
+ {file = "MarkupSafe-3.0.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:38a9ef736c01fccdd6600705b09dc574584b89bea478200c5fbf112a6b0d5579"},
+ {file = "MarkupSafe-3.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bbcb445fa71794da8f178f0f6d66789a28d7319071af7a496d4d507ed566270d"},
+ {file = "MarkupSafe-3.0.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:57cb5a3cf367aeb1d316576250f65edec5bb3be939e9247ae594b4bcbc317dfb"},
+ {file = "MarkupSafe-3.0.2-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:3809ede931876f5b2ec92eef964286840ed3540dadf803dd570c3b7e13141a3b"},
+ {file = "MarkupSafe-3.0.2-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:e07c3764494e3776c602c1e78e298937c3315ccc9043ead7e685b7f2b8d47b3c"},
+ {file = "MarkupSafe-3.0.2-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:b424c77b206d63d500bcb69fa55ed8d0e6a3774056bdc4839fc9298a7edca171"},
+ {file = "MarkupSafe-3.0.2-cp310-cp310-win32.whl", hash = "sha256:fcabf5ff6eea076f859677f5f0b6b5c1a51e70a376b0579e0eadef8db48c6b50"},
+ {file = "MarkupSafe-3.0.2-cp310-cp310-win_amd64.whl", hash = "sha256:6af100e168aa82a50e186c82875a5893c5597a0c1ccdb0d8b40240b1f28b969a"},
+ {file = "MarkupSafe-3.0.2-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:9025b4018f3a1314059769c7bf15441064b2207cb3f065e6ea1e7359cb46db9d"},
+ {file = "MarkupSafe-3.0.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:93335ca3812df2f366e80509ae119189886b0f3c2b81325d39efdb84a1e2ae93"},
+ {file = "MarkupSafe-3.0.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2cb8438c3cbb25e220c2ab33bb226559e7afb3baec11c4f218ffa7308603c832"},
+ {file = "MarkupSafe-3.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a123e330ef0853c6e822384873bef7507557d8e4a082961e1defa947aa59ba84"},
+ {file = "MarkupSafe-3.0.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1e084f686b92e5b83186b07e8a17fc09e38fff551f3602b249881fec658d3eca"},
+ {file = "MarkupSafe-3.0.2-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:d8213e09c917a951de9d09ecee036d5c7d36cb6cb7dbaece4c71a60d79fb9798"},
+ {file = "MarkupSafe-3.0.2-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:5b02fb34468b6aaa40dfc198d813a641e3a63b98c2b05a16b9f80b7ec314185e"},
+ {file = "MarkupSafe-3.0.2-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:0bff5e0ae4ef2e1ae4fdf2dfd5b76c75e5c2fa4132d05fc1b0dabcd20c7e28c4"},
+ {file = "MarkupSafe-3.0.2-cp311-cp311-win32.whl", hash = "sha256:6c89876f41da747c8d3677a2b540fb32ef5715f97b66eeb0c6b66f5e3ef6f59d"},
+ {file = "MarkupSafe-3.0.2-cp311-cp311-win_amd64.whl", hash = "sha256:70a87b411535ccad5ef2f1df5136506a10775d267e197e4cf531ced10537bd6b"},
+ {file = "MarkupSafe-3.0.2-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:9778bd8ab0a994ebf6f84c2b949e65736d5575320a17ae8984a77fab08db94cf"},
+ {file = "MarkupSafe-3.0.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:846ade7b71e3536c4e56b386c2a47adf5741d2d8b94ec9dc3e92e5e1ee1e2225"},
+ {file = "MarkupSafe-3.0.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1c99d261bd2d5f6b59325c92c73df481e05e57f19837bdca8413b9eac4bd8028"},
+ {file = "MarkupSafe-3.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e17c96c14e19278594aa4841ec148115f9c7615a47382ecb6b82bd8fea3ab0c8"},
+ {file = "MarkupSafe-3.0.2-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:88416bd1e65dcea10bc7569faacb2c20ce071dd1f87539ca2ab364bf6231393c"},
+ {file = "MarkupSafe-3.0.2-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:2181e67807fc2fa785d0592dc2d6206c019b9502410671cc905d132a92866557"},
+ {file = "MarkupSafe-3.0.2-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:52305740fe773d09cffb16f8ed0427942901f00adedac82ec8b67752f58a1b22"},
+ {file = "MarkupSafe-3.0.2-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:ad10d3ded218f1039f11a75f8091880239651b52e9bb592ca27de44eed242a48"},
+ {file = "MarkupSafe-3.0.2-cp312-cp312-win32.whl", hash = "sha256:0f4ca02bea9a23221c0182836703cbf8930c5e9454bacce27e767509fa286a30"},
+ {file = "MarkupSafe-3.0.2-cp312-cp312-win_amd64.whl", hash = "sha256:8e06879fc22a25ca47312fbe7c8264eb0b662f6db27cb2d3bbbc74b1df4b9b87"},
+ {file = "MarkupSafe-3.0.2-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:ba9527cdd4c926ed0760bc301f6728ef34d841f405abf9d4f959c478421e4efd"},
+ {file = "MarkupSafe-3.0.2-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:f8b3d067f2e40fe93e1ccdd6b2e1d16c43140e76f02fb1319a05cf2b79d99430"},
+ {file = "MarkupSafe-3.0.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:569511d3b58c8791ab4c2e1285575265991e6d8f8700c7be0e88f86cb0672094"},
+ {file = "MarkupSafe-3.0.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:15ab75ef81add55874e7ab7055e9c397312385bd9ced94920f2802310c930396"},
+ {file = "MarkupSafe-3.0.2-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f3818cb119498c0678015754eba762e0d61e5b52d34c8b13d770f0719f7b1d79"},
+ {file = "MarkupSafe-3.0.2-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:cdb82a876c47801bb54a690c5ae105a46b392ac6099881cdfb9f6e95e4014c6a"},
+ {file = "MarkupSafe-3.0.2-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:cabc348d87e913db6ab4aa100f01b08f481097838bdddf7c7a84b7575b7309ca"},
+ {file = "MarkupSafe-3.0.2-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:444dcda765c8a838eaae23112db52f1efaf750daddb2d9ca300bcae1039adc5c"},
+ {file = "MarkupSafe-3.0.2-cp313-cp313-win32.whl", hash = "sha256:bcf3e58998965654fdaff38e58584d8937aa3096ab5354d493c77d1fdd66d7a1"},
+ {file = "MarkupSafe-3.0.2-cp313-cp313-win_amd64.whl", hash = "sha256:e6a2a455bd412959b57a172ce6328d2dd1f01cb2135efda2e4576e8a23fa3b0f"},
+ {file = "MarkupSafe-3.0.2-cp313-cp313t-macosx_10_13_universal2.whl", hash = "sha256:b5a6b3ada725cea8a5e634536b1b01c30bcdcd7f9c6fff4151548d5bf6b3a36c"},
+ {file = "MarkupSafe-3.0.2-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:a904af0a6162c73e3edcb969eeeb53a63ceeb5d8cf642fade7d39e7963a22ddb"},
+ {file = "MarkupSafe-3.0.2-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4aa4e5faecf353ed117801a068ebab7b7e09ffb6e1d5e412dc852e0da018126c"},
+ {file = "MarkupSafe-3.0.2-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c0ef13eaeee5b615fb07c9a7dadb38eac06a0608b41570d8ade51c56539e509d"},
+ {file = "MarkupSafe-3.0.2-cp313-cp313t-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d16a81a06776313e817c951135cf7340a3e91e8c1ff2fac444cfd75fffa04afe"},
+ {file = "MarkupSafe-3.0.2-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:6381026f158fdb7c72a168278597a5e3a5222e83ea18f543112b2662a9b699c5"},
+ {file = "MarkupSafe-3.0.2-cp313-cp313t-musllinux_1_2_i686.whl", hash = "sha256:3d79d162e7be8f996986c064d1c7c817f6df3a77fe3d6859f6f9e7be4b8c213a"},
+ {file = "MarkupSafe-3.0.2-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:131a3c7689c85f5ad20f9f6fb1b866f402c445b220c19fe4308c0b147ccd2ad9"},
+ {file = "MarkupSafe-3.0.2-cp313-cp313t-win32.whl", hash = "sha256:ba8062ed2cf21c07a9e295d5b8a2a5ce678b913b45fdf68c32d95d6c1291e0b6"},
+ {file = "MarkupSafe-3.0.2-cp313-cp313t-win_amd64.whl", hash = "sha256:e444a31f8db13eb18ada366ab3cf45fd4b31e4db1236a4448f68778c1d1a5a2f"},
+ {file = "MarkupSafe-3.0.2-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:eaa0a10b7f72326f1372a713e73c3f739b524b3af41feb43e4921cb529f5929a"},
+ {file = "MarkupSafe-3.0.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:48032821bbdf20f5799ff537c7ac3d1fba0ba032cfc06194faffa8cda8b560ff"},
+ {file = "MarkupSafe-3.0.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1a9d3f5f0901fdec14d8d2f66ef7d035f2157240a433441719ac9a3fba440b13"},
+ {file = "MarkupSafe-3.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:88b49a3b9ff31e19998750c38e030fc7bb937398b1f78cfa599aaef92d693144"},
+ {file = "MarkupSafe-3.0.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:cfad01eed2c2e0c01fd0ecd2ef42c492f7f93902e39a42fc9ee1692961443a29"},
+ {file = "MarkupSafe-3.0.2-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:1225beacc926f536dc82e45f8a4d68502949dc67eea90eab715dea3a21c1b5f0"},
+ {file = "MarkupSafe-3.0.2-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:3169b1eefae027567d1ce6ee7cae382c57fe26e82775f460f0b2778beaad66c0"},
+ {file = "MarkupSafe-3.0.2-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:eb7972a85c54febfb25b5c4b4f3af4dcc731994c7da0d8a0b4a6eb0640e1d178"},
+ {file = "MarkupSafe-3.0.2-cp39-cp39-win32.whl", hash = "sha256:8c4e8c3ce11e1f92f6536ff07154f9d49677ebaaafc32db9db4620bc11ed480f"},
+ {file = "MarkupSafe-3.0.2-cp39-cp39-win_amd64.whl", hash = "sha256:6e296a513ca3d94054c2c881cc913116e90fd030ad1c656b3869762b754f5f8a"},
+ {file = "markupsafe-3.0.2.tar.gz", hash = "sha256:ee55d3edf80167e48ea11a923c7386f4669df67d7994554387f84e7d8b0a2bf0"},
+]
+
+[[package]]
+name = "mdurl"
+version = "0.1.2"
+description = "Markdown URL utilities"
+optional = false
+python-versions = ">=3.7"
+groups = ["main", "dev"]
+files = [
+ {file = "mdurl-0.1.2-py3-none-any.whl", hash = "sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8"},
+ {file = "mdurl-0.1.2.tar.gz", hash = "sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba"},
+]
+
+[[package]]
+name = "mistralai"
+version = "1.5.2"
+description = "Python Client SDK for the Mistral AI API."
+optional = true
+python-versions = ">=3.8"
+groups = ["main"]
+markers = "extra == \"mistralai\""
+files = [
+ {file = "mistralai-1.5.2-py3-none-any.whl", hash = "sha256:5b1112acebbcad1afd7732ce0bd60614975b64999801c555c54768ac41f506ae"},
+ {file = "mistralai-1.5.2.tar.gz", hash = "sha256:f39e6e51e8939aac2602e4badcb18712cbee2df33d86100c559333e609b92d17"},
+]
+
+[package.dependencies]
+eval-type-backport = ">=0.2.0"
+httpx = ">=0.27.0"
+jsonpath-python = ">=1.0.6"
+pydantic = ">=2.9.0"
+python-dateutil = ">=2.8.2"
+typing-inspect = ">=0.9.0"
+
+[package.extras]
+gcp = ["google-auth (>=2.27.0)", "requests (>=2.32.3)"]
+
+[[package]]
+name = "multidict"
+version = "6.4.4"
+description = "multidict implementation"
+optional = false
+python-versions = ">=3.9"
+groups = ["main"]
+files = [
+ {file = "multidict-6.4.4-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:8adee3ac041145ffe4488ea73fa0a622b464cc25340d98be76924d0cda8545ff"},
+ {file = "multidict-6.4.4-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:b61e98c3e2a861035aaccd207da585bdcacef65fe01d7a0d07478efac005e028"},
+ {file = "multidict-6.4.4-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:75493f28dbadecdbb59130e74fe935288813301a8554dc32f0c631b6bdcdf8b0"},
+ {file = "multidict-6.4.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4ffc3c6a37e048b5395ee235e4a2a0d639c2349dffa32d9367a42fc20d399772"},
+ {file = "multidict-6.4.4-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:87cb72263946b301570b0f63855569a24ee8758aaae2cd182aae7d95fbc92ca7"},
+ {file = "multidict-6.4.4-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:9bbf7bd39822fd07e3609b6b4467af4c404dd2b88ee314837ad1830a7f4a8299"},
+ {file = "multidict-6.4.4-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d1f7cbd4f1f44ddf5fd86a8675b7679176eae770f2fc88115d6dddb6cefb59bc"},
+ {file = "multidict-6.4.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bb5ac9e5bfce0e6282e7f59ff7b7b9a74aa8e5c60d38186a4637f5aa764046ad"},
+ {file = "multidict-6.4.4-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:4efc31dfef8c4eeb95b6b17d799eedad88c4902daba39ce637e23a17ea078915"},
+ {file = "multidict-6.4.4-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:9fcad2945b1b91c29ef2b4050f590bfcb68d8ac8e0995a74e659aa57e8d78e01"},
+ {file = "multidict-6.4.4-cp310-cp310-musllinux_1_2_armv7l.whl", hash = "sha256:d877447e7368c7320832acb7159557e49b21ea10ffeb135c1077dbbc0816b598"},
+ {file = "multidict-6.4.4-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:33a12ebac9f380714c298cbfd3e5b9c0c4e89c75fe612ae496512ee51028915f"},
+ {file = "multidict-6.4.4-cp310-cp310-musllinux_1_2_ppc64le.whl", hash = "sha256:0f14ea68d29b43a9bf37953881b1e3eb75b2739e896ba4a6aa4ad4c5b9ffa145"},
+ {file = "multidict-6.4.4-cp310-cp310-musllinux_1_2_s390x.whl", hash = "sha256:0327ad2c747a6600e4797d115d3c38a220fdb28e54983abe8964fd17e95ae83c"},
+ {file = "multidict-6.4.4-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:d1a20707492db9719a05fc62ee215fd2c29b22b47c1b1ba347f9abc831e26683"},
+ {file = "multidict-6.4.4-cp310-cp310-win32.whl", hash = "sha256:d83f18315b9fca5db2452d1881ef20f79593c4aa824095b62cb280019ef7aa3d"},
+ {file = "multidict-6.4.4-cp310-cp310-win_amd64.whl", hash = "sha256:9c17341ee04545fd962ae07330cb5a39977294c883485c8d74634669b1f7fe04"},
+ {file = "multidict-6.4.4-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:4f5f29794ac0e73d2a06ac03fd18870adc0135a9d384f4a306a951188ed02f95"},
+ {file = "multidict-6.4.4-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:c04157266344158ebd57b7120d9b0b35812285d26d0e78193e17ef57bfe2979a"},
+ {file = "multidict-6.4.4-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:bb61ffd3ab8310d93427e460f565322c44ef12769f51f77277b4abad7b6f7223"},
+ {file = "multidict-6.4.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5e0ba18a9afd495f17c351d08ebbc4284e9c9f7971d715f196b79636a4d0de44"},
+ {file = "multidict-6.4.4-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:9faf1b1dcaadf9f900d23a0e6d6c8eadd6a95795a0e57fcca73acce0eb912065"},
+ {file = "multidict-6.4.4-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a4d1cb1327c6082c4fce4e2a438483390964c02213bc6b8d782cf782c9b1471f"},
+ {file = "multidict-6.4.4-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:941f1bec2f5dbd51feeb40aea654c2747f811ab01bdd3422a48a4e4576b7d76a"},
+ {file = "multidict-6.4.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e5f8a146184da7ea12910a4cec51ef85e44f6268467fb489c3caf0cd512f29c2"},
+ {file = "multidict-6.4.4-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:232b7237e57ec3c09be97206bfb83a0aa1c5d7d377faa019c68a210fa35831f1"},
+ {file = "multidict-6.4.4-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:55ae0721c1513e5e3210bca4fc98456b980b0c2c016679d3d723119b6b202c42"},
+ {file = "multidict-6.4.4-cp311-cp311-musllinux_1_2_armv7l.whl", hash = "sha256:51d662c072579f63137919d7bb8fc250655ce79f00c82ecf11cab678f335062e"},
+ {file = "multidict-6.4.4-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:0e05c39962baa0bb19a6b210e9b1422c35c093b651d64246b6c2e1a7e242d9fd"},
+ {file = "multidict-6.4.4-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:d5b1cc3ab8c31d9ebf0faa6e3540fb91257590da330ffe6d2393d4208e638925"},
+ {file = "multidict-6.4.4-cp311-cp311-musllinux_1_2_s390x.whl", hash = "sha256:93ec84488a384cd7b8a29c2c7f467137d8a73f6fe38bb810ecf29d1ade011a7c"},
+ {file = "multidict-6.4.4-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:b308402608493638763abc95f9dc0030bbd6ac6aff784512e8ac3da73a88af08"},
+ {file = "multidict-6.4.4-cp311-cp311-win32.whl", hash = "sha256:343892a27d1a04d6ae455ecece12904d242d299ada01633d94c4f431d68a8c49"},
+ {file = "multidict-6.4.4-cp311-cp311-win_amd64.whl", hash = "sha256:73484a94f55359780c0f458bbd3c39cb9cf9c182552177d2136e828269dee529"},
+ {file = "multidict-6.4.4-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:dc388f75a1c00000824bf28b7633e40854f4127ede80512b44c3cfeeea1839a2"},
+ {file = "multidict-6.4.4-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:98af87593a666f739d9dba5d0ae86e01b0e1a9cfcd2e30d2d361fbbbd1a9162d"},
+ {file = "multidict-6.4.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:aff4cafea2d120327d55eadd6b7f1136a8e5a0ecf6fb3b6863e8aca32cd8e50a"},
+ {file = "multidict-6.4.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:169c4ba7858176b797fe551d6e99040c531c775d2d57b31bcf4de6d7a669847f"},
+ {file = "multidict-6.4.4-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:b9eb4c59c54421a32b3273d4239865cb14ead53a606db066d7130ac80cc8ec93"},
+ {file = "multidict-6.4.4-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:7cf3bd54c56aa16fdb40028d545eaa8d051402b61533c21e84046e05513d5780"},
+ {file = "multidict-6.4.4-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:f682c42003c7264134bfe886376299db4cc0c6cd06a3295b41b347044bcb5482"},
+ {file = "multidict-6.4.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a920f9cf2abdf6e493c519492d892c362007f113c94da4c239ae88429835bad1"},
+ {file = "multidict-6.4.4-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:530d86827a2df6504526106b4c104ba19044594f8722d3e87714e847c74a0275"},
+ {file = "multidict-6.4.4-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:ecde56ea2439b96ed8a8d826b50c57364612ddac0438c39e473fafad7ae1c23b"},
+ {file = "multidict-6.4.4-cp312-cp312-musllinux_1_2_armv7l.whl", hash = "sha256:dc8c9736d8574b560634775ac0def6bdc1661fc63fa27ffdfc7264c565bcb4f2"},
+ {file = "multidict-6.4.4-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:7f3d3b3c34867579ea47cbd6c1f2ce23fbfd20a273b6f9e3177e256584f1eacc"},
+ {file = "multidict-6.4.4-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:87a728af265e08f96b6318ebe3c0f68b9335131f461efab2fc64cc84a44aa6ed"},
+ {file = "multidict-6.4.4-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:9f193eeda1857f8e8d3079a4abd258f42ef4a4bc87388452ed1e1c4d2b0c8740"},
+ {file = "multidict-6.4.4-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:be06e73c06415199200e9a2324a11252a3d62030319919cde5e6950ffeccf72e"},
+ {file = "multidict-6.4.4-cp312-cp312-win32.whl", hash = "sha256:622f26ea6a7e19b7c48dd9228071f571b2fbbd57a8cd71c061e848f281550e6b"},
+ {file = "multidict-6.4.4-cp312-cp312-win_amd64.whl", hash = "sha256:5e2bcda30d5009996ff439e02a9f2b5c3d64a20151d34898c000a6281faa3781"},
+ {file = "multidict-6.4.4-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:82ffabefc8d84c2742ad19c37f02cde5ec2a1ee172d19944d380f920a340e4b9"},
+ {file = "multidict-6.4.4-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:6a2f58a66fe2c22615ad26156354005391e26a2f3721c3621504cd87c1ea87bf"},
+ {file = "multidict-6.4.4-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:5883d6ee0fd9d8a48e9174df47540b7545909841ac82354c7ae4cbe9952603bd"},
+ {file = "multidict-6.4.4-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9abcf56a9511653fa1d052bfc55fbe53dbee8f34e68bd6a5a038731b0ca42d15"},
+ {file = "multidict-6.4.4-cp313-cp313-manylinux_2_17_armv7l.manylinux2014_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:6ed5ae5605d4ad5a049fad2a28bb7193400700ce2f4ae484ab702d1e3749c3f9"},
+ {file = "multidict-6.4.4-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:bbfcb60396f9bcfa63e017a180c3105b8c123a63e9d1428a36544e7d37ca9e20"},
+ {file = "multidict-6.4.4-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b0f1987787f5f1e2076b59692352ab29a955b09ccc433c1f6b8e8e18666f608b"},
+ {file = "multidict-6.4.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1d0121ccce8c812047d8d43d691a1ad7641f72c4f730474878a5aeae1b8ead8c"},
+ {file = "multidict-6.4.4-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:83ec4967114295b8afd120a8eec579920c882831a3e4c3331d591a8e5bfbbc0f"},
+ {file = "multidict-6.4.4-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:995f985e2e268deaf17867801b859a282e0448633f1310e3704b30616d269d69"},
+ {file = "multidict-6.4.4-cp313-cp313-musllinux_1_2_armv7l.whl", hash = "sha256:d832c608f94b9f92a0ec8b7e949be7792a642b6e535fcf32f3e28fab69eeb046"},
+ {file = "multidict-6.4.4-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:d21c1212171cf7da703c5b0b7a0e85be23b720818aef502ad187d627316d5645"},
+ {file = "multidict-6.4.4-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:cbebaa076aaecad3d4bb4c008ecc73b09274c952cf6a1b78ccfd689e51f5a5b0"},
+ {file = "multidict-6.4.4-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:c93a6fb06cc8e5d3628b2b5fda215a5db01e8f08fc15fadd65662d9b857acbe4"},
+ {file = "multidict-6.4.4-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:8cd8f81f1310182362fb0c7898145ea9c9b08a71081c5963b40ee3e3cac589b1"},
+ {file = "multidict-6.4.4-cp313-cp313-win32.whl", hash = "sha256:3e9f1cd61a0ab857154205fb0b1f3d3ace88d27ebd1409ab7af5096e409614cd"},
+ {file = "multidict-6.4.4-cp313-cp313-win_amd64.whl", hash = "sha256:8ffb40b74400e4455785c2fa37eba434269149ec525fc8329858c862e4b35373"},
+ {file = "multidict-6.4.4-cp313-cp313t-macosx_10_13_universal2.whl", hash = "sha256:6a602151dbf177be2450ef38966f4be3467d41a86c6a845070d12e17c858a156"},
+ {file = "multidict-6.4.4-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:0d2b9712211b860d123815a80b859075d86a4d54787e247d7fbee9db6832cf1c"},
+ {file = "multidict-6.4.4-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:d2fa86af59f8fc1972e121ade052145f6da22758f6996a197d69bb52f8204e7e"},
+ {file = "multidict-6.4.4-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:50855d03e9e4d66eab6947ba688ffb714616f985838077bc4b490e769e48da51"},
+ {file = "multidict-6.4.4-cp313-cp313t-manylinux_2_17_armv7l.manylinux2014_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:5bce06b83be23225be1905dcdb6b789064fae92499fbc458f59a8c0e68718601"},
+ {file = "multidict-6.4.4-cp313-cp313t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:66ed0731f8e5dfd8369a883b6e564aca085fb9289aacabd9decd70568b9a30de"},
+ {file = "multidict-6.4.4-cp313-cp313t-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:329ae97fc2f56f44d91bc47fe0972b1f52d21c4b7a2ac97040da02577e2daca2"},
+ {file = "multidict-6.4.4-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c27e5dcf520923d6474d98b96749e6805f7677e93aaaf62656005b8643f907ab"},
+ {file = "multidict-6.4.4-cp313-cp313t-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:058cc59b9e9b143cc56715e59e22941a5d868c322242278d28123a5d09cdf6b0"},
+ {file = "multidict-6.4.4-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:69133376bc9a03f8c47343d33f91f74a99c339e8b58cea90433d8e24bb298031"},
+ {file = "multidict-6.4.4-cp313-cp313t-musllinux_1_2_armv7l.whl", hash = "sha256:d6b15c55721b1b115c5ba178c77104123745b1417527ad9641a4c5e2047450f0"},
+ {file = "multidict-6.4.4-cp313-cp313t-musllinux_1_2_i686.whl", hash = "sha256:a887b77f51d3d41e6e1a63cf3bc7ddf24de5939d9ff69441387dfefa58ac2e26"},
+ {file = "multidict-6.4.4-cp313-cp313t-musllinux_1_2_ppc64le.whl", hash = "sha256:632a3bf8f1787f7ef7d3c2f68a7bde5be2f702906f8b5842ad6da9d974d0aab3"},
+ {file = "multidict-6.4.4-cp313-cp313t-musllinux_1_2_s390x.whl", hash = "sha256:a145c550900deb7540973c5cdb183b0d24bed6b80bf7bddf33ed8f569082535e"},
+ {file = "multidict-6.4.4-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:cc5d83c6619ca5c9672cb78b39ed8542f1975a803dee2cda114ff73cbb076edd"},
+ {file = "multidict-6.4.4-cp313-cp313t-win32.whl", hash = "sha256:3312f63261b9df49be9d57aaa6abf53a6ad96d93b24f9cc16cf979956355ce6e"},
+ {file = "multidict-6.4.4-cp313-cp313t-win_amd64.whl", hash = "sha256:ba852168d814b2c73333073e1c7116d9395bea69575a01b0b3c89d2d5a87c8fb"},
+ {file = "multidict-6.4.4-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:603f39bd1cf85705c6c1ba59644b480dfe495e6ee2b877908de93322705ad7cf"},
+ {file = "multidict-6.4.4-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:fc60f91c02e11dfbe3ff4e1219c085695c339af72d1641800fe6075b91850c8f"},
+ {file = "multidict-6.4.4-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:496bcf01c76a70a31c3d746fd39383aad8d685ce6331e4c709e9af4ced5fa221"},
+ {file = "multidict-6.4.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4219390fb5bf8e548e77b428bb36a21d9382960db5321b74d9d9987148074d6b"},
+ {file = "multidict-6.4.4-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:3ef4e9096ff86dfdcbd4a78253090ba13b1d183daa11b973e842465d94ae1772"},
+ {file = "multidict-6.4.4-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:49a29d7133b1fc214e818bbe025a77cc6025ed9a4f407d2850373ddde07fd04a"},
+ {file = "multidict-6.4.4-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e32053d6d3a8b0dfe49fde05b496731a0e6099a4df92154641c00aa76786aef5"},
+ {file = "multidict-6.4.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8cc403092a49509e8ef2d2fd636a8ecefc4698cc57bbe894606b14579bc2a955"},
+ {file = "multidict-6.4.4-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:5363f9b2a7f3910e5c87d8b1855c478c05a2dc559ac57308117424dfaad6805c"},
+ {file = "multidict-6.4.4-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:2e543a40e4946cf70a88a3be87837a3ae0aebd9058ba49e91cacb0b2cd631e2b"},
+ {file = "multidict-6.4.4-cp39-cp39-musllinux_1_2_armv7l.whl", hash = "sha256:60d849912350da557fe7de20aa8cf394aada6980d0052cc829eeda4a0db1c1db"},
+ {file = "multidict-6.4.4-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:19d08b4f22eae45bb018b9f06e2838c1e4b853c67628ef8ae126d99de0da6395"},
+ {file = "multidict-6.4.4-cp39-cp39-musllinux_1_2_ppc64le.whl", hash = "sha256:d693307856d1ef08041e8b6ff01d5b4618715007d288490ce2c7e29013c12b9a"},
+ {file = "multidict-6.4.4-cp39-cp39-musllinux_1_2_s390x.whl", hash = "sha256:fad6daaed41021934917f4fb03ca2db8d8a4d79bf89b17ebe77228eb6710c003"},
+ {file = "multidict-6.4.4-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:c10d17371bff801af0daf8b073c30b6cf14215784dc08cd5c43ab5b7b8029bbc"},
+ {file = "multidict-6.4.4-cp39-cp39-win32.whl", hash = "sha256:7e23f2f841fcb3ebd4724a40032d32e0892fbba4143e43d2a9e7695c5e50e6bd"},
+ {file = "multidict-6.4.4-cp39-cp39-win_amd64.whl", hash = "sha256:4d7b50b673ffb4ff4366e7ab43cf1f0aef4bd3608735c5fbdf0bdb6f690da411"},
+ {file = "multidict-6.4.4-py3-none-any.whl", hash = "sha256:bd4557071b561a8b3b6075c3ce93cf9bfb6182cb241805c3d66ced3b75eff4ac"},
+ {file = "multidict-6.4.4.tar.gz", hash = "sha256:69ee9e6ba214b5245031b76233dd95408a0fd57fdb019ddcc1ead4790932a8e8"},
+]
+
+[[package]]
+name = "mypy"
+version = "1.15.0"
+description = "Optional static typing for Python"
+optional = false
+python-versions = ">=3.9"
+groups = ["dev"]
+files = [
+ {file = "mypy-1.15.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:979e4e1a006511dacf628e36fadfecbcc0160a8af6ca7dad2f5025529e082c13"},
+ {file = "mypy-1.15.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:c4bb0e1bd29f7d34efcccd71cf733580191e9a264a2202b0239da95984c5b559"},
+ {file = "mypy-1.15.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:be68172e9fd9ad8fb876c6389f16d1c1b5f100ffa779f77b1fb2176fcc9ab95b"},
+ {file = "mypy-1.15.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c7be1e46525adfa0d97681432ee9fcd61a3964c2446795714699a998d193f1a3"},
+ {file = "mypy-1.15.0-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:2e2c2e6d3593f6451b18588848e66260ff62ccca522dd231cd4dd59b0160668b"},
+ {file = "mypy-1.15.0-cp310-cp310-win_amd64.whl", hash = "sha256:6983aae8b2f653e098edb77f893f7b6aca69f6cffb19b2cc7443f23cce5f4828"},
+ {file = "mypy-1.15.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:2922d42e16d6de288022e5ca321cd0618b238cfc5570e0263e5ba0a77dbef56f"},
+ {file = "mypy-1.15.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:2ee2d57e01a7c35de00f4634ba1bbf015185b219e4dc5909e281016df43f5ee5"},
+ {file = "mypy-1.15.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:973500e0774b85d9689715feeffcc980193086551110fd678ebe1f4342fb7c5e"},
+ {file = "mypy-1.15.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:5a95fb17c13e29d2d5195869262f8125dfdb5c134dc8d9a9d0aecf7525b10c2c"},
+ {file = "mypy-1.15.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:1905f494bfd7d85a23a88c5d97840888a7bd516545fc5aaedff0267e0bb54e2f"},
+ {file = "mypy-1.15.0-cp311-cp311-win_amd64.whl", hash = "sha256:c9817fa23833ff189db061e6d2eff49b2f3b6ed9856b4a0a73046e41932d744f"},
+ {file = "mypy-1.15.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:aea39e0583d05124836ea645f412e88a5c7d0fd77a6d694b60d9b6b2d9f184fd"},
+ {file = "mypy-1.15.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:2f2147ab812b75e5b5499b01ade1f4a81489a147c01585cda36019102538615f"},
+ {file = "mypy-1.15.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:ce436f4c6d218a070048ed6a44c0bbb10cd2cc5e272b29e7845f6a2f57ee4464"},
+ {file = "mypy-1.15.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:8023ff13985661b50a5928fc7a5ca15f3d1affb41e5f0a9952cb68ef090b31ee"},
+ {file = "mypy-1.15.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:1124a18bc11a6a62887e3e137f37f53fbae476dc36c185d549d4f837a2a6a14e"},
+ {file = "mypy-1.15.0-cp312-cp312-win_amd64.whl", hash = "sha256:171a9ca9a40cd1843abeca0e405bc1940cd9b305eaeea2dda769ba096932bb22"},
+ {file = "mypy-1.15.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:93faf3fdb04768d44bf28693293f3904bbb555d076b781ad2530214ee53e3445"},
+ {file = "mypy-1.15.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:811aeccadfb730024c5d3e326b2fbe9249bb7413553f15499a4050f7c30e801d"},
+ {file = "mypy-1.15.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:98b7b9b9aedb65fe628c62a6dc57f6d5088ef2dfca37903a7d9ee374d03acca5"},
+ {file = "mypy-1.15.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c43a7682e24b4f576d93072216bf56eeff70d9140241f9edec0c104d0c515036"},
+ {file = "mypy-1.15.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:baefc32840a9f00babd83251560e0ae1573e2f9d1b067719479bfb0e987c6357"},
+ {file = "mypy-1.15.0-cp313-cp313-win_amd64.whl", hash = "sha256:b9378e2c00146c44793c98b8d5a61039a048e31f429fb0eb546d93f4b000bedf"},
+ {file = "mypy-1.15.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:e601a7fa172c2131bff456bb3ee08a88360760d0d2f8cbd7a75a65497e2df078"},
+ {file = "mypy-1.15.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:712e962a6357634fef20412699a3655c610110e01cdaa6180acec7fc9f8513ba"},
+ {file = "mypy-1.15.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:f95579473af29ab73a10bada2f9722856792a36ec5af5399b653aa28360290a5"},
+ {file = "mypy-1.15.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:8f8722560a14cde92fdb1e31597760dc35f9f5524cce17836c0d22841830fd5b"},
+ {file = "mypy-1.15.0-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:1fbb8da62dc352133d7d7ca90ed2fb0e9d42bb1a32724c287d3c76c58cbaa9c2"},
+ {file = "mypy-1.15.0-cp39-cp39-win_amd64.whl", hash = "sha256:d10d994b41fb3497719bbf866f227b3489048ea4bbbb5015357db306249f7980"},
+ {file = "mypy-1.15.0-py3-none-any.whl", hash = "sha256:5469affef548bd1895d86d3bf10ce2b44e33d86923c29e4d675b3e323437ea3e"},
+ {file = "mypy-1.15.0.tar.gz", hash = "sha256:404534629d51d3efea5c800ee7c42b72a6554d6c400e6a79eafe15d11341fd43"},
+]
+
+[package.dependencies]
+mypy_extensions = ">=1.0.0"
+typing_extensions = ">=4.6.0"
+
+[package.extras]
+dmypy = ["psutil (>=4.0)"]
+faster-cache = ["orjson"]
+install-types = ["pip"]
+mypyc = ["setuptools (>=50)"]
+reports = ["lxml"]
+
+[[package]]
+name = "mypy-extensions"
+version = "1.1.0"
+description = "Type system extensions for programs checked with the mypy type checker."
+optional = false
+python-versions = ">=3.8"
+groups = ["main", "dev"]
+files = [
+ {file = "mypy_extensions-1.1.0-py3-none-any.whl", hash = "sha256:1be4cccdb0f2482337c4743e60421de3a356cd97508abadd57d47403e94f5505"},
+ {file = "mypy_extensions-1.1.0.tar.gz", hash = "sha256:52e68efc3284861e772bbcd66823fde5ae21fd2fdb51c62a211403730b916558"},
+]
+markers = {main = "extra == \"mistralai\""}
+
+[[package]]
+name = "networkx"
+version = "3.4.2"
+description = "Python package for creating and manipulating graphs and networks"
+optional = false
+python-versions = ">=3.10"
+groups = ["main"]
+files = [
+ {file = "networkx-3.4.2-py3-none-any.whl", hash = "sha256:df5d4365b724cf81b8c6a7312509d0c22386097011ad1abe274afd5e9d3bbc5f"},
+ {file = "networkx-3.4.2.tar.gz", hash = "sha256:307c3669428c5362aab27c8a1260aa8f47c4e91d3891f48be0141738d8d053e1"},
+]
+
+[package.extras]
+default = ["matplotlib (>=3.7)", "numpy (>=1.24)", "pandas (>=2.0)", "scipy (>=1.10,!=1.11.0,!=1.11.1)"]
+developer = ["changelist (==0.5)", "mypy (>=1.1)", "pre-commit (>=3.2)", "rtoml"]
+doc = ["intersphinx-registry", "myst-nb (>=1.1)", "numpydoc (>=1.8.0)", "pillow (>=9.4)", "pydata-sphinx-theme (>=0.15)", "sphinx (>=7.3)", "sphinx-gallery (>=0.16)", "texext (>=0.6.7)"]
+example = ["cairocffi (>=1.7)", "contextily (>=1.6)", "igraph (>=0.11)", "momepy (>=0.7.2)", "osmnx (>=1.9)", "scikit-learn (>=1.5)", "seaborn (>=0.13)"]
+extra = ["lxml (>=4.6)", "pydot (>=3.0.1)", "pygraphviz (>=1.14)", "sympy (>=1.10)"]
+test = ["pytest (>=7.2)", "pytest-cov (>=4.0)"]
+
+[[package]]
+name = "nodeenv"
+version = "1.9.1"
+description = "Node.js virtual environment builder"
+optional = false
+python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7"
+groups = ["dev"]
+files = [
+ {file = "nodeenv-1.9.1-py2.py3-none-any.whl", hash = "sha256:ba11c9782d29c27c70ffbdda2d7415098754709be8a7056d79a737cd901155c9"},
+ {file = "nodeenv-1.9.1.tar.gz", hash = "sha256:6ec12890a2dab7946721edbfbcd91f3319c6ccc9aec47be7c7e6b7011ee6645f"},
+]
+
+[[package]]
+name = "numpy"
+version = "2.2.6"
+description = "Fundamental package for array computing in Python"
+optional = false
+python-versions = ">=3.10"
+groups = ["main", "dev"]
+files = [
+ {file = "numpy-2.2.6-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:b412caa66f72040e6d268491a59f2c43bf03eb6c96dd8f0307829feb7fa2b6fb"},
+ {file = "numpy-2.2.6-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:8e41fd67c52b86603a91c1a505ebaef50b3314de0213461c7a6e99c9a3beff90"},
+ {file = "numpy-2.2.6-cp310-cp310-macosx_14_0_arm64.whl", hash = "sha256:37e990a01ae6ec7fe7fa1c26c55ecb672dd98b19c3d0e1d1f326fa13cb38d163"},
+ {file = "numpy-2.2.6-cp310-cp310-macosx_14_0_x86_64.whl", hash = "sha256:5a6429d4be8ca66d889b7cf70f536a397dc45ba6faeb5f8c5427935d9592e9cf"},
+ {file = "numpy-2.2.6-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:efd28d4e9cd7d7a8d39074a4d44c63eda73401580c5c76acda2ce969e0a38e83"},
+ {file = "numpy-2.2.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:fc7b73d02efb0e18c000e9ad8b83480dfcd5dfd11065997ed4c6747470ae8915"},
+ {file = "numpy-2.2.6-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:74d4531beb257d2c3f4b261bfb0fc09e0f9ebb8842d82a7b4209415896adc680"},
+ {file = "numpy-2.2.6-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:8fc377d995680230e83241d8a96def29f204b5782f371c532579b4f20607a289"},
+ {file = "numpy-2.2.6-cp310-cp310-win32.whl", hash = "sha256:b093dd74e50a8cba3e873868d9e93a85b78e0daf2e98c6797566ad8044e8363d"},
+ {file = "numpy-2.2.6-cp310-cp310-win_amd64.whl", hash = "sha256:f0fd6321b839904e15c46e0d257fdd101dd7f530fe03fd6359c1ea63738703f3"},
+ {file = "numpy-2.2.6-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:f9f1adb22318e121c5c69a09142811a201ef17ab257a1e66ca3025065b7f53ae"},
+ {file = "numpy-2.2.6-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:c820a93b0255bc360f53eca31a0e676fd1101f673dda8da93454a12e23fc5f7a"},
+ {file = "numpy-2.2.6-cp311-cp311-macosx_14_0_arm64.whl", hash = "sha256:3d70692235e759f260c3d837193090014aebdf026dfd167834bcba43e30c2a42"},
+ {file = "numpy-2.2.6-cp311-cp311-macosx_14_0_x86_64.whl", hash = "sha256:481b49095335f8eed42e39e8041327c05b0f6f4780488f61286ed3c01368d491"},
+ {file = "numpy-2.2.6-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b64d8d4d17135e00c8e346e0a738deb17e754230d7e0810ac5012750bbd85a5a"},
+ {file = "numpy-2.2.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ba10f8411898fc418a521833e014a77d3ca01c15b0c6cdcce6a0d2897e6dbbdf"},
+ {file = "numpy-2.2.6-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:bd48227a919f1bafbdda0583705e547892342c26fb127219d60a5c36882609d1"},
+ {file = "numpy-2.2.6-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:9551a499bf125c1d4f9e250377c1ee2eddd02e01eac6644c080162c0c51778ab"},
+ {file = "numpy-2.2.6-cp311-cp311-win32.whl", hash = "sha256:0678000bb9ac1475cd454c6b8c799206af8107e310843532b04d49649c717a47"},
+ {file = "numpy-2.2.6-cp311-cp311-win_amd64.whl", hash = "sha256:e8213002e427c69c45a52bbd94163084025f533a55a59d6f9c5b820774ef3303"},
+ {file = "numpy-2.2.6-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:41c5a21f4a04fa86436124d388f6ed60a9343a6f767fced1a8a71c3fbca038ff"},
+ {file = "numpy-2.2.6-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:de749064336d37e340f640b05f24e9e3dd678c57318c7289d222a8a2f543e90c"},
+ {file = "numpy-2.2.6-cp312-cp312-macosx_14_0_arm64.whl", hash = "sha256:894b3a42502226a1cac872f840030665f33326fc3dac8e57c607905773cdcde3"},
+ {file = "numpy-2.2.6-cp312-cp312-macosx_14_0_x86_64.whl", hash = "sha256:71594f7c51a18e728451bb50cc60a3ce4e6538822731b2933209a1f3614e9282"},
+ {file = "numpy-2.2.6-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f2618db89be1b4e05f7a1a847a9c1c0abd63e63a1607d892dd54668dd92faf87"},
+ {file = "numpy-2.2.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:fd83c01228a688733f1ded5201c678f0c53ecc1006ffbc404db9f7a899ac6249"},
+ {file = "numpy-2.2.6-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:37c0ca431f82cd5fa716eca9506aefcabc247fb27ba69c5062a6d3ade8cf8f49"},
+ {file = "numpy-2.2.6-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:fe27749d33bb772c80dcd84ae7e8df2adc920ae8297400dabec45f0dedb3f6de"},
+ {file = "numpy-2.2.6-cp312-cp312-win32.whl", hash = "sha256:4eeaae00d789f66c7a25ac5f34b71a7035bb474e679f410e5e1a94deb24cf2d4"},
+ {file = "numpy-2.2.6-cp312-cp312-win_amd64.whl", hash = "sha256:c1f9540be57940698ed329904db803cf7a402f3fc200bfe599334c9bd84a40b2"},
+ {file = "numpy-2.2.6-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:0811bb762109d9708cca4d0b13c4f67146e3c3b7cf8d34018c722adb2d957c84"},
+ {file = "numpy-2.2.6-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:287cc3162b6f01463ccd86be154f284d0893d2b3ed7292439ea97eafa8170e0b"},
+ {file = "numpy-2.2.6-cp313-cp313-macosx_14_0_arm64.whl", hash = "sha256:f1372f041402e37e5e633e586f62aa53de2eac8d98cbfb822806ce4bbefcb74d"},
+ {file = "numpy-2.2.6-cp313-cp313-macosx_14_0_x86_64.whl", hash = "sha256:55a4d33fa519660d69614a9fad433be87e5252f4b03850642f88993f7b2ca566"},
+ {file = "numpy-2.2.6-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f92729c95468a2f4f15e9bb94c432a9229d0d50de67304399627a943201baa2f"},
+ {file = "numpy-2.2.6-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1bc23a79bfabc5d056d106f9befb8d50c31ced2fbc70eedb8155aec74a45798f"},
+ {file = "numpy-2.2.6-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:e3143e4451880bed956e706a3220b4e5cf6172ef05fcc397f6f36a550b1dd868"},
+ {file = "numpy-2.2.6-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:b4f13750ce79751586ae2eb824ba7e1e8dba64784086c98cdbbcc6a42112ce0d"},
+ {file = "numpy-2.2.6-cp313-cp313-win32.whl", hash = "sha256:5beb72339d9d4fa36522fc63802f469b13cdbe4fdab4a288f0c441b74272ebfd"},
+ {file = "numpy-2.2.6-cp313-cp313-win_amd64.whl", hash = "sha256:b0544343a702fa80c95ad5d3d608ea3599dd54d4632df855e4c8d24eb6ecfa1c"},
+ {file = "numpy-2.2.6-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:0bca768cd85ae743b2affdc762d617eddf3bcf8724435498a1e80132d04879e6"},
+ {file = "numpy-2.2.6-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:fc0c5673685c508a142ca65209b4e79ed6740a4ed6b2267dbba90f34b0b3cfda"},
+ {file = "numpy-2.2.6-cp313-cp313t-macosx_14_0_arm64.whl", hash = "sha256:5bd4fc3ac8926b3819797a7c0e2631eb889b4118a9898c84f585a54d475b7e40"},
+ {file = "numpy-2.2.6-cp313-cp313t-macosx_14_0_x86_64.whl", hash = "sha256:fee4236c876c4e8369388054d02d0e9bb84821feb1a64dd59e137e6511a551f8"},
+ {file = "numpy-2.2.6-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e1dda9c7e08dc141e0247a5b8f49cf05984955246a327d4c48bda16821947b2f"},
+ {file = "numpy-2.2.6-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f447e6acb680fd307f40d3da4852208af94afdfab89cf850986c3ca00562f4fa"},
+ {file = "numpy-2.2.6-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:389d771b1623ec92636b0786bc4ae56abafad4a4c513d36a55dce14bd9ce8571"},
+ {file = "numpy-2.2.6-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:8e9ace4a37db23421249ed236fdcdd457d671e25146786dfc96835cd951aa7c1"},
+ {file = "numpy-2.2.6-cp313-cp313t-win32.whl", hash = "sha256:038613e9fb8c72b0a41f025a7e4c3f0b7a1b5d768ece4796b674c8f3fe13efff"},
+ {file = "numpy-2.2.6-cp313-cp313t-win_amd64.whl", hash = "sha256:6031dd6dfecc0cf9f668681a37648373bddd6421fff6c66ec1624eed0180ee06"},
+ {file = "numpy-2.2.6-pp310-pypy310_pp73-macosx_10_15_x86_64.whl", hash = "sha256:0b605b275d7bd0c640cad4e5d30fa701a8d59302e127e5f79138ad62762c3e3d"},
+ {file = "numpy-2.2.6-pp310-pypy310_pp73-macosx_14_0_x86_64.whl", hash = "sha256:7befc596a7dc9da8a337f79802ee8adb30a552a94f792b9c9d18c840055907db"},
+ {file = "numpy-2.2.6-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ce47521a4754c8f4593837384bd3424880629f718d87c5d44f8ed763edd63543"},
+ {file = "numpy-2.2.6-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:d042d24c90c41b54fd506da306759e06e568864df8ec17ccc17e9e884634fd00"},
+ {file = "numpy-2.2.6.tar.gz", hash = "sha256:e29554e2bef54a90aa5cc07da6ce955accb83f21ab5de01a62c8478897b264fd"},
+]
+markers = {main = "python_version == \"3.11\""}
+
+[[package]]
+name = "oauthlib"
+version = "3.2.2"
+description = "A generic, spec-compliant, thorough implementation of the OAuth request-signing logic"
+optional = true
+python-versions = ">=3.6"
+groups = ["main"]
+markers = "extra == \"google\""
+files = [
+ {file = "oauthlib-3.2.2-py3-none-any.whl", hash = "sha256:8139f29aac13e25d502680e9e19963e83f16838d48a0d71c287fe40e7067fbca"},
+ {file = "oauthlib-3.2.2.tar.gz", hash = "sha256:9859c40929662bec5d64f34d01c99e093149682a3f38915dc0655d5a633dd918"},
+]
+
+[package.extras]
+rsa = ["cryptography (>=3.0.0)"]
+signals = ["blinker (>=1.4.0)"]
+signedtoken = ["cryptography (>=3.0.0)", "pyjwt (>=2.0.0,<3)"]
+
+[[package]]
+name = "openai"
+version = "1.82.0"
+description = "The official Python library for the openai API"
+optional = false
+python-versions = ">=3.8"
+groups = ["main"]
+files = [
+ {file = "openai-1.82.0-py3-none-any.whl", hash = "sha256:8c40647fea1816516cb3de5189775b30b5f4812777e40b8768f361f232b61b30"},
+ {file = "openai-1.82.0.tar.gz", hash = "sha256:b0a009b9a58662d598d07e91e4219ab4b1e3d8ba2db3f173896a92b9b874d1a7"},
+]
+
+[package.dependencies]
+anyio = ">=3.5.0,<5"
+distro = ">=1.7.0,<2"
+httpx = ">=0.23.0,<1"
+jiter = ">=0.4.0,<1"
+pydantic = ">=1.9.0,<3"
+sniffio = "*"
+tqdm = ">4"
+typing-extensions = ">=4.11,<5"
+
+[package.extras]
+datalib = ["numpy (>=1)", "pandas (>=1.2.3)", "pandas-stubs (>=1.1.0.11)"]
+realtime = ["websockets (>=13,<16)"]
+voice-helpers = ["numpy (>=2.0.2)", "sounddevice (>=0.5.1)"]
+
+[[package]]
+name = "openpyxl"
+version = "3.1.5"
+description = "A Python library to read/write Excel 2010 xlsx/xlsm files"
+optional = false
+python-versions = ">=3.8"
+groups = ["main"]
+files = [
+ {file = "openpyxl-3.1.5-py2.py3-none-any.whl", hash = "sha256:5282c12b107bffeef825f4617dc029afaf41d0ea60823bbb665ef3079dc79de2"},
+ {file = "openpyxl-3.1.5.tar.gz", hash = "sha256:cf0e3cf56142039133628b5acffe8ef0c12bc902d2aadd3e0fe5878dc08d1050"},
+]
+
+[package.dependencies]
+et-xmlfile = "*"
+
+[[package]]
+name = "packaging"
+version = "25.0"
+description = "Core utilities for Python packages"
+optional = false
+python-versions = ">=3.8"
+groups = ["dev"]
+files = [
+ {file = "packaging-25.0-py3-none-any.whl", hash = "sha256:29572ef2b1f17581046b3a2227d5c611fb25ec70ca1ba8554b24b0e69331a484"},
+ {file = "packaging-25.0.tar.gz", hash = "sha256:d443872c98d677bf60f6a1f2f8c1cb748e8fe762d2bf9d3148b5599295b0fc4f"},
+]
+
+[[package]]
+name = "pandas"
+version = "2.2.3"
+description = "Powerful data structures for data analysis, time series, and statistics"
+optional = false
+python-versions = ">=3.9"
+groups = ["main"]
+files = [
+ {file = "pandas-2.2.3-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:1948ddde24197a0f7add2bdc4ca83bf2b1ef84a1bc8ccffd95eda17fd836ecb5"},
+ {file = "pandas-2.2.3-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:381175499d3802cde0eabbaf6324cce0c4f5d52ca6f8c377c29ad442f50f6348"},
+ {file = "pandas-2.2.3-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:d9c45366def9a3dd85a6454c0e7908f2b3b8e9c138f5dc38fed7ce720d8453ed"},
+ {file = "pandas-2.2.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:86976a1c5b25ae3f8ccae3a5306e443569ee3c3faf444dfd0f41cda24667ad57"},
+ {file = "pandas-2.2.3-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:b8661b0238a69d7aafe156b7fa86c44b881387509653fdf857bebc5e4008ad42"},
+ {file = "pandas-2.2.3-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:37e0aced3e8f539eccf2e099f65cdb9c8aa85109b0be6e93e2baff94264bdc6f"},
+ {file = "pandas-2.2.3-cp310-cp310-win_amd64.whl", hash = "sha256:56534ce0746a58afaf7942ba4863e0ef81c9c50d3f0ae93e9497d6a41a057645"},
+ {file = "pandas-2.2.3-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:66108071e1b935240e74525006034333f98bcdb87ea116de573a6a0dccb6c039"},
+ {file = "pandas-2.2.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:7c2875855b0ff77b2a64a0365e24455d9990730d6431b9e0ee18ad8acee13dbd"},
+ {file = "pandas-2.2.3-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:cd8d0c3be0515c12fed0bdbae072551c8b54b7192c7b1fda0ba56059a0179698"},
+ {file = "pandas-2.2.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c124333816c3a9b03fbeef3a9f230ba9a737e9e5bb4060aa2107a86cc0a497fc"},
+ {file = "pandas-2.2.3-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:63cc132e40a2e084cf01adf0775b15ac515ba905d7dcca47e9a251819c575ef3"},
+ {file = "pandas-2.2.3-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:29401dbfa9ad77319367d36940cd8a0b3a11aba16063e39632d98b0e931ddf32"},
+ {file = "pandas-2.2.3-cp311-cp311-win_amd64.whl", hash = "sha256:3fc6873a41186404dad67245896a6e440baacc92f5b716ccd1bc9ed2995ab2c5"},
+ {file = "pandas-2.2.3-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:b1d432e8d08679a40e2a6d8b2f9770a5c21793a6f9f47fdd52c5ce1948a5a8a9"},
+ {file = "pandas-2.2.3-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:a5a1595fe639f5988ba6a8e5bc9649af3baf26df3998a0abe56c02609392e0a4"},
+ {file = "pandas-2.2.3-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:5de54125a92bb4d1c051c0659e6fcb75256bf799a732a87184e5ea503965bce3"},
+ {file = "pandas-2.2.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:fffb8ae78d8af97f849404f21411c95062db1496aeb3e56f146f0355c9989319"},
+ {file = "pandas-2.2.3-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:6dfcb5ee8d4d50c06a51c2fffa6cff6272098ad6540aed1a76d15fb9318194d8"},
+ {file = "pandas-2.2.3-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:062309c1b9ea12a50e8ce661145c6aab431b1e99530d3cd60640e255778bd43a"},
+ {file = "pandas-2.2.3-cp312-cp312-win_amd64.whl", hash = "sha256:59ef3764d0fe818125a5097d2ae867ca3fa64df032331b7e0917cf5d7bf66b13"},
+ {file = "pandas-2.2.3-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:f00d1345d84d8c86a63e476bb4955e46458b304b9575dcf71102b5c705320015"},
+ {file = "pandas-2.2.3-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:3508d914817e153ad359d7e069d752cdd736a247c322d932eb89e6bc84217f28"},
+ {file = "pandas-2.2.3-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:22a9d949bfc9a502d320aa04e5d02feab689d61da4e7764b62c30b991c42c5f0"},
+ {file = "pandas-2.2.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f3a255b2c19987fbbe62a9dfd6cff7ff2aa9ccab3fc75218fd4b7530f01efa24"},
+ {file = "pandas-2.2.3-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:800250ecdadb6d9c78eae4990da62743b857b470883fa27f652db8bdde7f6659"},
+ {file = "pandas-2.2.3-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:6374c452ff3ec675a8f46fd9ab25c4ad0ba590b71cf0656f8b6daa5202bca3fb"},
+ {file = "pandas-2.2.3-cp313-cp313-win_amd64.whl", hash = "sha256:61c5ad4043f791b61dd4752191d9f07f0ae412515d59ba8f005832a532f8736d"},
+ {file = "pandas-2.2.3-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:3b71f27954685ee685317063bf13c7709a7ba74fc996b84fc6821c59b0f06468"},
+ {file = "pandas-2.2.3-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:38cf8125c40dae9d5acc10fa66af8ea6fdf760b2714ee482ca691fc66e6fcb18"},
+ {file = "pandas-2.2.3-cp313-cp313t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:ba96630bc17c875161df3818780af30e43be9b166ce51c9a18c1feae342906c2"},
+ {file = "pandas-2.2.3-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1db71525a1538b30142094edb9adc10be3f3e176748cd7acc2240c2f2e5aa3a4"},
+ {file = "pandas-2.2.3-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:15c0e1e02e93116177d29ff83e8b1619c93ddc9c49083f237d4312337a61165d"},
+ {file = "pandas-2.2.3-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:ad5b65698ab28ed8d7f18790a0dc58005c7629f227be9ecc1072aa74c0c1d43a"},
+ {file = "pandas-2.2.3-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:bc6b93f9b966093cb0fd62ff1a7e4c09e6d546ad7c1de191767baffc57628f39"},
+ {file = "pandas-2.2.3-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:5dbca4c1acd72e8eeef4753eeca07de9b1db4f398669d5994086f788a5d7cc30"},
+ {file = "pandas-2.2.3-cp39-cp39-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:8cd6d7cc958a3910f934ea8dbdf17b2364827bb4dafc38ce6eef6bb3d65ff09c"},
+ {file = "pandas-2.2.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:99df71520d25fade9db7c1076ac94eb994f4d2673ef2aa2e86ee039b6746d20c"},
+ {file = "pandas-2.2.3-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:31d0ced62d4ea3e231a9f228366919a5ea0b07440d9d4dac345376fd8e1477ea"},
+ {file = "pandas-2.2.3-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:7eee9e7cea6adf3e3d24e304ac6b8300646e2a5d1cd3a3c2abed9101b0846761"},
+ {file = "pandas-2.2.3-cp39-cp39-win_amd64.whl", hash = "sha256:4850ba03528b6dd51d6c5d273c46f183f39a9baf3f0143e566b89450965b105e"},
+ {file = "pandas-2.2.3.tar.gz", hash = "sha256:4f18ba62b61d7e192368b84517265a99b4d7ee8912f8708660fb4a366cc82667"},
+]
+
+[package.dependencies]
+numpy = {version = ">=1.23.2", markers = "python_version == \"3.11\""}
+python-dateutil = ">=2.8.2"
+pytz = ">=2020.1"
+tzdata = ">=2022.7"
+
+[package.extras]
+all = ["PyQt5 (>=5.15.9)", "SQLAlchemy (>=2.0.0)", "adbc-driver-postgresql (>=0.8.0)", "adbc-driver-sqlite (>=0.8.0)", "beautifulsoup4 (>=4.11.2)", "bottleneck (>=1.3.6)", "dataframe-api-compat (>=0.1.7)", "fastparquet (>=2022.12.0)", "fsspec (>=2022.11.0)", "gcsfs (>=2022.11.0)", "html5lib (>=1.1)", "hypothesis (>=6.46.1)", "jinja2 (>=3.1.2)", "lxml (>=4.9.2)", "matplotlib (>=3.6.3)", "numba (>=0.56.4)", "numexpr (>=2.8.4)", "odfpy (>=1.4.1)", "openpyxl (>=3.1.0)", "pandas-gbq (>=0.19.0)", "psycopg2 (>=2.9.6)", "pyarrow (>=10.0.1)", "pymysql (>=1.0.2)", "pyreadstat (>=1.2.0)", "pytest (>=7.3.2)", "pytest-xdist (>=2.2.0)", "python-calamine (>=0.1.7)", "pyxlsb (>=1.0.10)", "qtpy (>=2.3.0)", "s3fs (>=2022.11.0)", "scipy (>=1.10.0)", "tables (>=3.8.0)", "tabulate (>=0.9.0)", "xarray (>=2022.12.0)", "xlrd (>=2.0.1)", "xlsxwriter (>=3.0.5)", "zstandard (>=0.19.0)"]
+aws = ["s3fs (>=2022.11.0)"]
+clipboard = ["PyQt5 (>=5.15.9)", "qtpy (>=2.3.0)"]
+compression = ["zstandard (>=0.19.0)"]
+computation = ["scipy (>=1.10.0)", "xarray (>=2022.12.0)"]
+consortium-standard = ["dataframe-api-compat (>=0.1.7)"]
+excel = ["odfpy (>=1.4.1)", "openpyxl (>=3.1.0)", "python-calamine (>=0.1.7)", "pyxlsb (>=1.0.10)", "xlrd (>=2.0.1)", "xlsxwriter (>=3.0.5)"]
+feather = ["pyarrow (>=10.0.1)"]
+fss = ["fsspec (>=2022.11.0)"]
+gcp = ["gcsfs (>=2022.11.0)", "pandas-gbq (>=0.19.0)"]
+hdf5 = ["tables (>=3.8.0)"]
+html = ["beautifulsoup4 (>=4.11.2)", "html5lib (>=1.1)", "lxml (>=4.9.2)"]
+mysql = ["SQLAlchemy (>=2.0.0)", "pymysql (>=1.0.2)"]
+output-formatting = ["jinja2 (>=3.1.2)", "tabulate (>=0.9.0)"]
+parquet = ["pyarrow (>=10.0.1)"]
+performance = ["bottleneck (>=1.3.6)", "numba (>=0.56.4)", "numexpr (>=2.8.4)"]
+plot = ["matplotlib (>=3.6.3)"]
+postgresql = ["SQLAlchemy (>=2.0.0)", "adbc-driver-postgresql (>=0.8.0)", "psycopg2 (>=2.9.6)"]
+pyarrow = ["pyarrow (>=10.0.1)"]
+spss = ["pyreadstat (>=1.2.0)"]
+sql-other = ["SQLAlchemy (>=2.0.0)", "adbc-driver-postgresql (>=0.8.0)", "adbc-driver-sqlite (>=0.8.0)"]
+test = ["hypothesis (>=6.46.1)", "pytest (>=7.3.2)", "pytest-xdist (>=2.2.0)"]
+xml = ["lxml (>=4.9.2)"]
+
+[[package]]
+name = "pandas-stubs"
+version = "2.2.3.250308"
+description = "Type annotations for pandas"
+optional = false
+python-versions = ">=3.10"
+groups = ["dev"]
+files = [
+ {file = "pandas_stubs-2.2.3.250308-py3-none-any.whl", hash = "sha256:a377edff3b61f8b268c82499fdbe7c00fdeed13235b8b71d6a1dc347aeddc74d"},
+ {file = "pandas_stubs-2.2.3.250308.tar.gz", hash = "sha256:3a6e9daf161f00b85c83772ed3d5cff9522028f07a94817472c07b91f46710fd"},
+]
+
+[package.dependencies]
+numpy = ">=1.23.5"
+types-pytz = ">=2022.1.1"
+
+[[package]]
+name = "pillow"
+version = "11.2.1"
+description = "Python Imaging Library (Fork)"
+optional = false
+python-versions = ">=3.9"
+groups = ["main"]
+files = [
+ {file = "pillow-11.2.1-cp310-cp310-macosx_10_10_x86_64.whl", hash = "sha256:d57a75d53922fc20c165016a20d9c44f73305e67c351bbc60d1adaf662e74047"},
+ {file = "pillow-11.2.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:127bf6ac4a5b58b3d32fc8289656f77f80567d65660bc46f72c0d77e6600cc95"},
+ {file = "pillow-11.2.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b4ba4be812c7a40280629e55ae0b14a0aafa150dd6451297562e1764808bbe61"},
+ {file = "pillow-11.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c8bd62331e5032bc396a93609982a9ab6b411c05078a52f5fe3cc59234a3abd1"},
+ {file = "pillow-11.2.1-cp310-cp310-manylinux_2_28_aarch64.whl", hash = "sha256:562d11134c97a62fe3af29581f083033179f7ff435f78392565a1ad2d1c2c45c"},
+ {file = "pillow-11.2.1-cp310-cp310-manylinux_2_28_x86_64.whl", hash = "sha256:c97209e85b5be259994eb5b69ff50c5d20cca0f458ef9abd835e262d9d88b39d"},
+ {file = "pillow-11.2.1-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:0c3e6d0f59171dfa2e25d7116217543310908dfa2770aa64b8f87605f8cacc97"},
+ {file = "pillow-11.2.1-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:cc1c3bc53befb6096b84165956e886b1729634a799e9d6329a0c512ab651e579"},
+ {file = "pillow-11.2.1-cp310-cp310-win32.whl", hash = "sha256:312c77b7f07ab2139924d2639860e084ec2a13e72af54d4f08ac843a5fc9c79d"},
+ {file = "pillow-11.2.1-cp310-cp310-win_amd64.whl", hash = "sha256:9bc7ae48b8057a611e5fe9f853baa88093b9a76303937449397899385da06fad"},
+ {file = "pillow-11.2.1-cp310-cp310-win_arm64.whl", hash = "sha256:2728567e249cdd939f6cc3d1f049595c66e4187f3c34078cbc0a7d21c47482d2"},
+ {file = "pillow-11.2.1-cp311-cp311-macosx_10_10_x86_64.whl", hash = "sha256:35ca289f712ccfc699508c4658a1d14652e8033e9b69839edf83cbdd0ba39e70"},
+ {file = "pillow-11.2.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:e0409af9f829f87a2dfb7e259f78f317a5351f2045158be321fd135973fff7bf"},
+ {file = "pillow-11.2.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d4e5c5edee874dce4f653dbe59db7c73a600119fbea8d31f53423586ee2aafd7"},
+ {file = "pillow-11.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b93a07e76d13bff9444f1a029e0af2964e654bfc2e2c2d46bfd080df5ad5f3d8"},
+ {file = "pillow-11.2.1-cp311-cp311-manylinux_2_28_aarch64.whl", hash = "sha256:e6def7eed9e7fa90fde255afaf08060dc4b343bbe524a8f69bdd2a2f0018f600"},
+ {file = "pillow-11.2.1-cp311-cp311-manylinux_2_28_x86_64.whl", hash = "sha256:8f4f3724c068be008c08257207210c138d5f3731af6c155a81c2b09a9eb3a788"},
+ {file = "pillow-11.2.1-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:a0a6709b47019dff32e678bc12c63008311b82b9327613f534e496dacaefb71e"},
+ {file = "pillow-11.2.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:f6b0c664ccb879109ee3ca702a9272d877f4fcd21e5eb63c26422fd6e415365e"},
+ {file = "pillow-11.2.1-cp311-cp311-win32.whl", hash = "sha256:cc5d875d56e49f112b6def6813c4e3d3036d269c008bf8aef72cd08d20ca6df6"},
+ {file = "pillow-11.2.1-cp311-cp311-win_amd64.whl", hash = "sha256:0f5c7eda47bf8e3c8a283762cab94e496ba977a420868cb819159980b6709193"},
+ {file = "pillow-11.2.1-cp311-cp311-win_arm64.whl", hash = "sha256:4d375eb838755f2528ac8cbc926c3e31cc49ca4ad0cf79cff48b20e30634a4a7"},
+ {file = "pillow-11.2.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:78afba22027b4accef10dbd5eed84425930ba41b3ea0a86fa8d20baaf19d807f"},
+ {file = "pillow-11.2.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:78092232a4ab376a35d68c4e6d5e00dfd73454bd12b230420025fbe178ee3b0b"},
+ {file = "pillow-11.2.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:25a5f306095c6780c52e6bbb6109624b95c5b18e40aab1c3041da3e9e0cd3e2d"},
+ {file = "pillow-11.2.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0c7b29dbd4281923a2bfe562acb734cee96bbb129e96e6972d315ed9f232bef4"},
+ {file = "pillow-11.2.1-cp312-cp312-manylinux_2_28_aarch64.whl", hash = "sha256:3e645b020f3209a0181a418bffe7b4a93171eef6c4ef6cc20980b30bebf17b7d"},
+ {file = "pillow-11.2.1-cp312-cp312-manylinux_2_28_x86_64.whl", hash = "sha256:b2dbea1012ccb784a65349f57bbc93730b96e85b42e9bf7b01ef40443db720b4"},
+ {file = "pillow-11.2.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:da3104c57bbd72948d75f6a9389e6727d2ab6333c3617f0a89d72d4940aa0443"},
+ {file = "pillow-11.2.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:598174aef4589af795f66f9caab87ba4ff860ce08cd5bb447c6fc553ffee603c"},
+ {file = "pillow-11.2.1-cp312-cp312-win32.whl", hash = "sha256:1d535df14716e7f8776b9e7fee118576d65572b4aad3ed639be9e4fa88a1cad3"},
+ {file = "pillow-11.2.1-cp312-cp312-win_amd64.whl", hash = "sha256:14e33b28bf17c7a38eede290f77db7c664e4eb01f7869e37fa98a5aa95978941"},
+ {file = "pillow-11.2.1-cp312-cp312-win_arm64.whl", hash = "sha256:21e1470ac9e5739ff880c211fc3af01e3ae505859392bf65458c224d0bf283eb"},
+ {file = "pillow-11.2.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:fdec757fea0b793056419bca3e9932eb2b0ceec90ef4813ea4c1e072c389eb28"},
+ {file = "pillow-11.2.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:b0e130705d568e2f43a17bcbe74d90958e8a16263868a12c3e0d9c8162690830"},
+ {file = "pillow-11.2.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7bdb5e09068332578214cadd9c05e3d64d99e0e87591be22a324bdbc18925be0"},
+ {file = "pillow-11.2.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d189ba1bebfbc0c0e529159631ec72bb9e9bc041f01ec6d3233d6d82eb823bc1"},
+ {file = "pillow-11.2.1-cp313-cp313-manylinux_2_28_aarch64.whl", hash = "sha256:191955c55d8a712fab8934a42bfefbf99dd0b5875078240943f913bb66d46d9f"},
+ {file = "pillow-11.2.1-cp313-cp313-manylinux_2_28_x86_64.whl", hash = "sha256:ad275964d52e2243430472fc5d2c2334b4fc3ff9c16cb0a19254e25efa03a155"},
+ {file = "pillow-11.2.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:750f96efe0597382660d8b53e90dd1dd44568a8edb51cb7f9d5d918b80d4de14"},
+ {file = "pillow-11.2.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:fe15238d3798788d00716637b3d4e7bb6bde18b26e5d08335a96e88564a36b6b"},
+ {file = "pillow-11.2.1-cp313-cp313-win32.whl", hash = "sha256:3fe735ced9a607fee4f481423a9c36701a39719252a9bb251679635f99d0f7d2"},
+ {file = "pillow-11.2.1-cp313-cp313-win_amd64.whl", hash = "sha256:74ee3d7ecb3f3c05459ba95eed5efa28d6092d751ce9bf20e3e253a4e497e691"},
+ {file = "pillow-11.2.1-cp313-cp313-win_arm64.whl", hash = "sha256:5119225c622403afb4b44bad4c1ca6c1f98eed79db8d3bc6e4e160fc6339d66c"},
+ {file = "pillow-11.2.1-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:8ce2e8411c7aaef53e6bb29fe98f28cd4fbd9a1d9be2eeea434331aac0536b22"},
+ {file = "pillow-11.2.1-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:9ee66787e095127116d91dea2143db65c7bb1e232f617aa5957c0d9d2a3f23a7"},
+ {file = "pillow-11.2.1-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9622e3b6c1d8b551b6e6f21873bdcc55762b4b2126633014cea1803368a9aa16"},
+ {file = "pillow-11.2.1-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:63b5dff3a68f371ea06025a1a6966c9a1e1ee452fc8020c2cd0ea41b83e9037b"},
+ {file = "pillow-11.2.1-cp313-cp313t-manylinux_2_28_aarch64.whl", hash = "sha256:31df6e2d3d8fc99f993fd253e97fae451a8db2e7207acf97859732273e108406"},
+ {file = "pillow-11.2.1-cp313-cp313t-manylinux_2_28_x86_64.whl", hash = "sha256:062b7a42d672c45a70fa1f8b43d1d38ff76b63421cbbe7f88146b39e8a558d91"},
+ {file = "pillow-11.2.1-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:4eb92eca2711ef8be42fd3f67533765d9fd043b8c80db204f16c8ea62ee1a751"},
+ {file = "pillow-11.2.1-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:f91ebf30830a48c825590aede79376cb40f110b387c17ee9bd59932c961044f9"},
+ {file = "pillow-11.2.1-cp313-cp313t-win32.whl", hash = "sha256:e0b55f27f584ed623221cfe995c912c61606be8513bfa0e07d2c674b4516d9dd"},
+ {file = "pillow-11.2.1-cp313-cp313t-win_amd64.whl", hash = "sha256:36d6b82164c39ce5482f649b437382c0fb2395eabc1e2b1702a6deb8ad647d6e"},
+ {file = "pillow-11.2.1-cp313-cp313t-win_arm64.whl", hash = "sha256:225c832a13326e34f212d2072982bb1adb210e0cc0b153e688743018c94a2681"},
+ {file = "pillow-11.2.1-cp39-cp39-macosx_10_10_x86_64.whl", hash = "sha256:7491cf8a79b8eb867d419648fff2f83cb0b3891c8b36da92cc7f1931d46108c8"},
+ {file = "pillow-11.2.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:8b02d8f9cb83c52578a0b4beadba92e37d83a4ef11570a8688bbf43f4ca50909"},
+ {file = "pillow-11.2.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:014ca0050c85003620526b0ac1ac53f56fc93af128f7546623cc8e31875ab928"},
+ {file = "pillow-11.2.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3692b68c87096ac6308296d96354eddd25f98740c9d2ab54e1549d6c8aea9d79"},
+ {file = "pillow-11.2.1-cp39-cp39-manylinux_2_28_aarch64.whl", hash = "sha256:f781dcb0bc9929adc77bad571b8621ecb1e4cdef86e940fe2e5b5ee24fd33b35"},
+ {file = "pillow-11.2.1-cp39-cp39-manylinux_2_28_x86_64.whl", hash = "sha256:2b490402c96f907a166615e9a5afacf2519e28295f157ec3a2bb9bd57de638cb"},
+ {file = "pillow-11.2.1-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:dd6b20b93b3ccc9c1b597999209e4bc5cf2853f9ee66e3fc9a400a78733ffc9a"},
+ {file = "pillow-11.2.1-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:4b835d89c08a6c2ee7781b8dd0a30209a8012b5f09c0a665b65b0eb3560b6f36"},
+ {file = "pillow-11.2.1-cp39-cp39-win32.whl", hash = "sha256:b10428b3416d4f9c61f94b494681280be7686bda15898a3a9e08eb66a6d92d67"},
+ {file = "pillow-11.2.1-cp39-cp39-win_amd64.whl", hash = "sha256:6ebce70c3f486acf7591a3d73431fa504a4e18a9b97ff27f5f47b7368e4b9dd1"},
+ {file = "pillow-11.2.1-cp39-cp39-win_arm64.whl", hash = "sha256:c27476257b2fdcd7872d54cfd119b3a9ce4610fb85c8e32b70b42e3680a29a1e"},
+ {file = "pillow-11.2.1-pp310-pypy310_pp73-macosx_10_15_x86_64.whl", hash = "sha256:9b7b0d4fd2635f54ad82785d56bc0d94f147096493a79985d0ab57aedd563156"},
+ {file = "pillow-11.2.1-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:aa442755e31c64037aa7c1cb186e0b369f8416c567381852c63444dd666fb772"},
+ {file = "pillow-11.2.1-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f0d3348c95b766f54b76116d53d4cb171b52992a1027e7ca50c81b43b9d9e363"},
+ {file = "pillow-11.2.1-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:85d27ea4c889342f7e35f6d56e7e1cb345632ad592e8c51b693d7b7556043ce0"},
+ {file = "pillow-11.2.1-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:bf2c33d6791c598142f00c9c4c7d47f6476731c31081331664eb26d6ab583e01"},
+ {file = "pillow-11.2.1-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:e616e7154c37669fc1dfc14584f11e284e05d1c650e1c0f972f281c4ccc53193"},
+ {file = "pillow-11.2.1-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:39ad2e0f424394e3aebc40168845fee52df1394a4673a6ee512d840d14ab3013"},
+ {file = "pillow-11.2.1-pp311-pypy311_pp73-macosx_10_15_x86_64.whl", hash = "sha256:80f1df8dbe9572b4b7abdfa17eb5d78dd620b1d55d9e25f834efdbee872d3aed"},
+ {file = "pillow-11.2.1-pp311-pypy311_pp73-macosx_11_0_arm64.whl", hash = "sha256:ea926cfbc3957090becbcbbb65ad177161a2ff2ad578b5a6ec9bb1e1cd78753c"},
+ {file = "pillow-11.2.1-pp311-pypy311_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:738db0e0941ca0376804d4de6a782c005245264edaa253ffce24e5a15cbdc7bd"},
+ {file = "pillow-11.2.1-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9db98ab6565c69082ec9b0d4e40dd9f6181dab0dd236d26f7a50b8b9bfbd5076"},
+ {file = "pillow-11.2.1-pp311-pypy311_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:036e53f4170e270ddb8797d4c590e6dd14d28e15c7da375c18978045f7e6c37b"},
+ {file = "pillow-11.2.1-pp311-pypy311_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:14f73f7c291279bd65fda51ee87affd7c1e097709f7fdd0188957a16c264601f"},
+ {file = "pillow-11.2.1-pp311-pypy311_pp73-win_amd64.whl", hash = "sha256:208653868d5c9ecc2b327f9b9ef34e0e42a4cdd172c2988fd81d62d2bc9bc044"},
+ {file = "pillow-11.2.1.tar.gz", hash = "sha256:a64dd61998416367b7ef979b73d3a85853ba9bec4c2925f74e588879a58716b6"},
+]
+
+[package.extras]
+docs = ["furo", "olefile", "sphinx (>=8.2)", "sphinx-copybutton", "sphinx-inline-tabs", "sphinxext-opengraph"]
+fpx = ["olefile"]
+mic = ["olefile"]
+test-arrow = ["pyarrow"]
+tests = ["check-manifest", "coverage (>=7.4.2)", "defusedxml", "markdown2", "olefile", "packaging", "pyroma", "pytest", "pytest-cov", "pytest-timeout", "trove-classifiers (>=2024.10.12)"]
+typing = ["typing-extensions"]
+xmp = ["defusedxml"]
+
+[[package]]
+name = "pluggy"
+version = "1.6.0"
+description = "plugin and hook calling mechanisms for python"
+optional = false
+python-versions = ">=3.9"
+groups = ["dev"]
+files = [
+ {file = "pluggy-1.6.0-py3-none-any.whl", hash = "sha256:e920276dd6813095e9377c0bc5566d94c932c33b27a3e3945d8389c374dd4746"},
+ {file = "pluggy-1.6.0.tar.gz", hash = "sha256:7dcc130b76258d33b90f61b658791dede3486c3e6bfb003ee5c9bfb396dd22f3"},
+]
+
+[package.extras]
+dev = ["pre-commit", "tox"]
+testing = ["coverage", "pytest", "pytest-benchmark"]
+
+[[package]]
+name = "propcache"
+version = "0.3.1"
+description = "Accelerated property cache"
+optional = false
+python-versions = ">=3.9"
+groups = ["main"]
+files = [
+ {file = "propcache-0.3.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:f27785888d2fdd918bc36de8b8739f2d6c791399552333721b58193f68ea3e98"},
+ {file = "propcache-0.3.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d4e89cde74154c7b5957f87a355bb9c8ec929c167b59c83d90654ea36aeb6180"},
+ {file = "propcache-0.3.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:730178f476ef03d3d4d255f0c9fa186cb1d13fd33ffe89d39f2cda4da90ceb71"},
+ {file = "propcache-0.3.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:967a8eec513dbe08330f10137eacb427b2ca52118769e82ebcfcab0fba92a649"},
+ {file = "propcache-0.3.1-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:5b9145c35cc87313b5fd480144f8078716007656093d23059e8993d3a8fa730f"},
+ {file = "propcache-0.3.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9e64e948ab41411958670f1093c0a57acfdc3bee5cf5b935671bbd5313bcf229"},
+ {file = "propcache-0.3.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:319fa8765bfd6a265e5fa661547556da381e53274bc05094fc9ea50da51bfd46"},
+ {file = "propcache-0.3.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c66d8ccbc902ad548312b96ed8d5d266d0d2c6d006fd0f66323e9d8f2dd49be7"},
+ {file = "propcache-0.3.1-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:2d219b0dbabe75e15e581fc1ae796109b07c8ba7d25b9ae8d650da582bed01b0"},
+ {file = "propcache-0.3.1-cp310-cp310-musllinux_1_2_armv7l.whl", hash = "sha256:cd6a55f65241c551eb53f8cf4d2f4af33512c39da5d9777694e9d9c60872f519"},
+ {file = "propcache-0.3.1-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:9979643ffc69b799d50d3a7b72b5164a2e97e117009d7af6dfdd2ab906cb72cd"},
+ {file = "propcache-0.3.1-cp310-cp310-musllinux_1_2_ppc64le.whl", hash = "sha256:4cf9e93a81979f1424f1a3d155213dc928f1069d697e4353edb8a5eba67c6259"},
+ {file = "propcache-0.3.1-cp310-cp310-musllinux_1_2_s390x.whl", hash = "sha256:2fce1df66915909ff6c824bbb5eb403d2d15f98f1518e583074671a30fe0c21e"},
+ {file = "propcache-0.3.1-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:4d0dfdd9a2ebc77b869a0b04423591ea8823f791293b527dc1bb896c1d6f1136"},
+ {file = "propcache-0.3.1-cp310-cp310-win32.whl", hash = "sha256:1f6cc0ad7b4560e5637eb2c994e97b4fa41ba8226069c9277eb5ea7101845b42"},
+ {file = "propcache-0.3.1-cp310-cp310-win_amd64.whl", hash = "sha256:47ef24aa6511e388e9894ec16f0fbf3313a53ee68402bc428744a367ec55b833"},
+ {file = "propcache-0.3.1-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:7f30241577d2fef2602113b70ef7231bf4c69a97e04693bde08ddab913ba0ce5"},
+ {file = "propcache-0.3.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:43593c6772aa12abc3af7784bff4a41ffa921608dd38b77cf1dfd7f5c4e71371"},
+ {file = "propcache-0.3.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:a75801768bbe65499495660b777e018cbe90c7980f07f8aa57d6be79ea6f71da"},
+ {file = "propcache-0.3.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f6f1324db48f001c2ca26a25fa25af60711e09b9aaf4b28488602776f4f9a744"},
+ {file = "propcache-0.3.1-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:5cdb0f3e1eb6dfc9965d19734d8f9c481b294b5274337a8cb5cb01b462dcb7e0"},
+ {file = "propcache-0.3.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:1eb34d90aac9bfbced9a58b266f8946cb5935869ff01b164573a7634d39fbcb5"},
+ {file = "propcache-0.3.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f35c7070eeec2cdaac6fd3fe245226ed2a6292d3ee8c938e5bb645b434c5f256"},
+ {file = "propcache-0.3.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b23c11c2c9e6d4e7300c92e022046ad09b91fd00e36e83c44483df4afa990073"},
+ {file = "propcache-0.3.1-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:3e19ea4ea0bf46179f8a3652ac1426e6dcbaf577ce4b4f65be581e237340420d"},
+ {file = "propcache-0.3.1-cp311-cp311-musllinux_1_2_armv7l.whl", hash = "sha256:bd39c92e4c8f6cbf5f08257d6360123af72af9f4da75a690bef50da77362d25f"},
+ {file = "propcache-0.3.1-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:b0313e8b923b3814d1c4a524c93dfecea5f39fa95601f6a9b1ac96cd66f89ea0"},
+ {file = "propcache-0.3.1-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:e861ad82892408487be144906a368ddbe2dc6297074ade2d892341b35c59844a"},
+ {file = "propcache-0.3.1-cp311-cp311-musllinux_1_2_s390x.whl", hash = "sha256:61014615c1274df8da5991a1e5da85a3ccb00c2d4701ac6f3383afd3ca47ab0a"},
+ {file = "propcache-0.3.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:71ebe3fe42656a2328ab08933d420df5f3ab121772eef78f2dc63624157f0ed9"},
+ {file = "propcache-0.3.1-cp311-cp311-win32.whl", hash = "sha256:58aa11f4ca8b60113d4b8e32d37e7e78bd8af4d1a5b5cb4979ed856a45e62005"},
+ {file = "propcache-0.3.1-cp311-cp311-win_amd64.whl", hash = "sha256:9532ea0b26a401264b1365146c440a6d78269ed41f83f23818d4b79497aeabe7"},
+ {file = "propcache-0.3.1-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:f78eb8422acc93d7b69964012ad7048764bb45a54ba7a39bb9e146c72ea29723"},
+ {file = "propcache-0.3.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:89498dd49c2f9a026ee057965cdf8192e5ae070ce7d7a7bd4b66a8e257d0c976"},
+ {file = "propcache-0.3.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:09400e98545c998d57d10035ff623266927cb784d13dd2b31fd33b8a5316b85b"},
+ {file = "propcache-0.3.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:aa8efd8c5adc5a2c9d3b952815ff8f7710cefdcaf5f2c36d26aff51aeca2f12f"},
+ {file = "propcache-0.3.1-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c2fe5c910f6007e716a06d269608d307b4f36e7babee5f36533722660e8c4a70"},
+ {file = "propcache-0.3.1-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a0ab8cf8cdd2194f8ff979a43ab43049b1df0b37aa64ab7eca04ac14429baeb7"},
+ {file = "propcache-0.3.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:563f9d8c03ad645597b8d010ef4e9eab359faeb11a0a2ac9f7b4bc8c28ebef25"},
+ {file = "propcache-0.3.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:fb6e0faf8cb6b4beea5d6ed7b5a578254c6d7df54c36ccd3d8b3eb00d6770277"},
+ {file = "propcache-0.3.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:1c5c7ab7f2bb3f573d1cb921993006ba2d39e8621019dffb1c5bc94cdbae81e8"},
+ {file = "propcache-0.3.1-cp312-cp312-musllinux_1_2_armv7l.whl", hash = "sha256:050b571b2e96ec942898f8eb46ea4bfbb19bd5502424747e83badc2d4a99a44e"},
+ {file = "propcache-0.3.1-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:e1c4d24b804b3a87e9350f79e2371a705a188d292fd310e663483af6ee6718ee"},
+ {file = "propcache-0.3.1-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:e4fe2a6d5ce975c117a6bb1e8ccda772d1e7029c1cca1acd209f91d30fa72815"},
+ {file = "propcache-0.3.1-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:feccd282de1f6322f56f6845bf1207a537227812f0a9bf5571df52bb418d79d5"},
+ {file = "propcache-0.3.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:ec314cde7314d2dd0510c6787326bbffcbdc317ecee6b7401ce218b3099075a7"},
+ {file = "propcache-0.3.1-cp312-cp312-win32.whl", hash = "sha256:7d2d5a0028d920738372630870e7d9644ce437142197f8c827194fca404bf03b"},
+ {file = "propcache-0.3.1-cp312-cp312-win_amd64.whl", hash = "sha256:88c423efef9d7a59dae0614eaed718449c09a5ac79a5f224a8b9664d603f04a3"},
+ {file = "propcache-0.3.1-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:f1528ec4374617a7a753f90f20e2f551121bb558fcb35926f99e3c42367164b8"},
+ {file = "propcache-0.3.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:dc1915ec523b3b494933b5424980831b636fe483d7d543f7afb7b3bf00f0c10f"},
+ {file = "propcache-0.3.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:a110205022d077da24e60b3df8bcee73971be9575dec5573dd17ae5d81751111"},
+ {file = "propcache-0.3.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d249609e547c04d190e820d0d4c8ca03ed4582bcf8e4e160a6969ddfb57b62e5"},
+ {file = "propcache-0.3.1-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:5ced33d827625d0a589e831126ccb4f5c29dfdf6766cac441d23995a65825dcb"},
+ {file = "propcache-0.3.1-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:4114c4ada8f3181af20808bedb250da6bae56660e4b8dfd9cd95d4549c0962f7"},
+ {file = "propcache-0.3.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:975af16f406ce48f1333ec5e912fe11064605d5c5b3f6746969077cc3adeb120"},
+ {file = "propcache-0.3.1-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a34aa3a1abc50740be6ac0ab9d594e274f59960d3ad253cd318af76b996dd654"},
+ {file = "propcache-0.3.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:9cec3239c85ed15bfaded997773fdad9fb5662b0a7cbc854a43f291eb183179e"},
+ {file = "propcache-0.3.1-cp313-cp313-musllinux_1_2_armv7l.whl", hash = "sha256:05543250deac8e61084234d5fc54f8ebd254e8f2b39a16b1dce48904f45b744b"},
+ {file = "propcache-0.3.1-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:5cb5918253912e088edbf023788de539219718d3b10aef334476b62d2b53de53"},
+ {file = "propcache-0.3.1-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:f3bbecd2f34d0e6d3c543fdb3b15d6b60dd69970c2b4c822379e5ec8f6f621d5"},
+ {file = "propcache-0.3.1-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:aca63103895c7d960a5b9b044a83f544b233c95e0dcff114389d64d762017af7"},
+ {file = "propcache-0.3.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:5a0a9898fdb99bf11786265468571e628ba60af80dc3f6eb89a3545540c6b0ef"},
+ {file = "propcache-0.3.1-cp313-cp313-win32.whl", hash = "sha256:3a02a28095b5e63128bcae98eb59025924f121f048a62393db682f049bf4ac24"},
+ {file = "propcache-0.3.1-cp313-cp313-win_amd64.whl", hash = "sha256:813fbb8b6aea2fc9659815e585e548fe706d6f663fa73dff59a1677d4595a037"},
+ {file = "propcache-0.3.1-cp313-cp313t-macosx_10_13_universal2.whl", hash = "sha256:a444192f20f5ce8a5e52761a031b90f5ea6288b1eef42ad4c7e64fef33540b8f"},
+ {file = "propcache-0.3.1-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:0fbe94666e62ebe36cd652f5fc012abfbc2342de99b523f8267a678e4dfdee3c"},
+ {file = "propcache-0.3.1-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:f011f104db880f4e2166bcdcf7f58250f7a465bc6b068dc84c824a3d4a5c94dc"},
+ {file = "propcache-0.3.1-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3e584b6d388aeb0001d6d5c2bd86b26304adde6d9bb9bfa9c4889805021b96de"},
+ {file = "propcache-0.3.1-cp313-cp313t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:8a17583515a04358b034e241f952f1715243482fc2c2945fd99a1b03a0bd77d6"},
+ {file = "propcache-0.3.1-cp313-cp313t-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:5aed8d8308215089c0734a2af4f2e95eeb360660184ad3912686c181e500b2e7"},
+ {file = "propcache-0.3.1-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6d8e309ff9a0503ef70dc9a0ebd3e69cf7b3894c9ae2ae81fc10943c37762458"},
+ {file = "propcache-0.3.1-cp313-cp313t-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b655032b202028a582d27aeedc2e813299f82cb232f969f87a4fde491a233f11"},
+ {file = "propcache-0.3.1-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:9f64d91b751df77931336b5ff7bafbe8845c5770b06630e27acd5dbb71e1931c"},
+ {file = "propcache-0.3.1-cp313-cp313t-musllinux_1_2_armv7l.whl", hash = "sha256:19a06db789a4bd896ee91ebc50d059e23b3639c25d58eb35be3ca1cbe967c3bf"},
+ {file = "propcache-0.3.1-cp313-cp313t-musllinux_1_2_i686.whl", hash = "sha256:bef100c88d8692864651b5f98e871fb090bd65c8a41a1cb0ff2322db39c96c27"},
+ {file = "propcache-0.3.1-cp313-cp313t-musllinux_1_2_ppc64le.whl", hash = "sha256:87380fb1f3089d2a0b8b00f006ed12bd41bd858fabfa7330c954c70f50ed8757"},
+ {file = "propcache-0.3.1-cp313-cp313t-musllinux_1_2_s390x.whl", hash = "sha256:e474fc718e73ba5ec5180358aa07f6aded0ff5f2abe700e3115c37d75c947e18"},
+ {file = "propcache-0.3.1-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:17d1c688a443355234f3c031349da69444be052613483f3e4158eef751abcd8a"},
+ {file = "propcache-0.3.1-cp313-cp313t-win32.whl", hash = "sha256:359e81a949a7619802eb601d66d37072b79b79c2505e6d3fd8b945538411400d"},
+ {file = "propcache-0.3.1-cp313-cp313t-win_amd64.whl", hash = "sha256:e7fb9a84c9abbf2b2683fa3e7b0d7da4d8ecf139a1c635732a8bda29c5214b0e"},
+ {file = "propcache-0.3.1-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:ed5f6d2edbf349bd8d630e81f474d33d6ae5d07760c44d33cd808e2f5c8f4ae6"},
+ {file = "propcache-0.3.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:668ddddc9f3075af019f784456267eb504cb77c2c4bd46cc8402d723b4d200bf"},
+ {file = "propcache-0.3.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:0c86e7ceea56376216eba345aa1fc6a8a6b27ac236181f840d1d7e6a1ea9ba5c"},
+ {file = "propcache-0.3.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:83be47aa4e35b87c106fc0c84c0fc069d3f9b9b06d3c494cd404ec6747544894"},
+ {file = "propcache-0.3.1-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:27c6ac6aa9fc7bc662f594ef380707494cb42c22786a558d95fcdedb9aa5d035"},
+ {file = "propcache-0.3.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:64a956dff37080b352c1c40b2966b09defb014347043e740d420ca1eb7c9b908"},
+ {file = "propcache-0.3.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:82de5da8c8893056603ac2d6a89eb8b4df49abf1a7c19d536984c8dd63f481d5"},
+ {file = "propcache-0.3.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0c3c3a203c375b08fd06a20da3cf7aac293b834b6f4f4db71190e8422750cca5"},
+ {file = "propcache-0.3.1-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:b303b194c2e6f171cfddf8b8ba30baefccf03d36a4d9cab7fd0bb68ba476a3d7"},
+ {file = "propcache-0.3.1-cp39-cp39-musllinux_1_2_armv7l.whl", hash = "sha256:916cd229b0150129d645ec51614d38129ee74c03293a9f3f17537be0029a9641"},
+ {file = "propcache-0.3.1-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:a461959ead5b38e2581998700b26346b78cd98540b5524796c175722f18b0294"},
+ {file = "propcache-0.3.1-cp39-cp39-musllinux_1_2_ppc64le.whl", hash = "sha256:069e7212890b0bcf9b2be0a03afb0c2d5161d91e1bf51569a64f629acc7defbf"},
+ {file = "propcache-0.3.1-cp39-cp39-musllinux_1_2_s390x.whl", hash = "sha256:ef2e4e91fb3945769e14ce82ed53007195e616a63aa43b40fb7ebaaf907c8d4c"},
+ {file = "propcache-0.3.1-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:8638f99dca15b9dff328fb6273e09f03d1c50d9b6512f3b65a4154588a7595fe"},
+ {file = "propcache-0.3.1-cp39-cp39-win32.whl", hash = "sha256:6f173bbfe976105aaa890b712d1759de339d8a7cef2fc0a1714cc1a1e1c47f64"},
+ {file = "propcache-0.3.1-cp39-cp39-win_amd64.whl", hash = "sha256:603f1fe4144420374f1a69b907494c3acbc867a581c2d49d4175b0de7cc64566"},
+ {file = "propcache-0.3.1-py3-none-any.whl", hash = "sha256:9a8ecf38de50a7f518c21568c80f985e776397b902f1ce0b01f799aba1608b40"},
+ {file = "propcache-0.3.1.tar.gz", hash = "sha256:40d980c33765359098837527e18eddefc9a24cea5b45e078a7f3bb5b032c6ecf"},
+]
+
+[[package]]
+name = "pyasn1"
+version = "0.6.1"
+description = "Pure-Python implementation of ASN.1 types and DER/BER/CER codecs (X.208)"
+optional = true
+python-versions = ">=3.8"
+groups = ["main"]
+markers = "extra == \"google\""
+files = [
+ {file = "pyasn1-0.6.1-py3-none-any.whl", hash = "sha256:0d632f46f2ba09143da3a8afe9e33fb6f92fa2320ab7e886e2d0f7672af84629"},
+ {file = "pyasn1-0.6.1.tar.gz", hash = "sha256:6f580d2bdd84365380830acf45550f2511469f673cb4a5ae3857a3170128b034"},
+]
+
+[[package]]
+name = "pyasn1-modules"
+version = "0.4.2"
+description = "A collection of ASN.1-based protocols modules"
+optional = true
+python-versions = ">=3.8"
+groups = ["main"]
+markers = "extra == \"google\""
+files = [
+ {file = "pyasn1_modules-0.4.2-py3-none-any.whl", hash = "sha256:29253a9207ce32b64c3ac6600edc75368f98473906e8fd1043bd6b5b1de2c14a"},
+ {file = "pyasn1_modules-0.4.2.tar.gz", hash = "sha256:677091de870a80aae844b1ca6134f54652fa2c8c5a52aa396440ac3106e941e6"},
+]
+
+[package.dependencies]
+pyasn1 = ">=0.6.1,<0.7.0"
+
+[[package]]
+name = "pydantic"
+version = "2.10.6"
+description = "Data validation using Python type hints"
+optional = false
+python-versions = ">=3.8"
+groups = ["main"]
+files = [
+ {file = "pydantic-2.10.6-py3-none-any.whl", hash = "sha256:427d664bf0b8a2b34ff5dd0f5a18df00591adcee7198fbd71981054cef37b584"},
+ {file = "pydantic-2.10.6.tar.gz", hash = "sha256:ca5daa827cce33de7a42be142548b0096bf05a7e7b365aebfa5f8eeec7128236"},
+]
+
+[package.dependencies]
+annotated-types = ">=0.6.0"
+pydantic-core = "2.27.2"
+typing-extensions = ">=4.12.2"
+
+[package.extras]
+email = ["email-validator (>=2.0.0)"]
+timezone = ["tzdata"]
+
+[[package]]
+name = "pydantic-core"
+version = "2.27.2"
+description = "Core functionality for Pydantic validation and serialization"
+optional = false
+python-versions = ">=3.8"
+groups = ["main"]
+files = [
+ {file = "pydantic_core-2.27.2-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:2d367ca20b2f14095a8f4fa1210f5a7b78b8a20009ecced6b12818f455b1e9fa"},
+ {file = "pydantic_core-2.27.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:491a2b73db93fab69731eaee494f320faa4e093dbed776be1a829c2eb222c34c"},
+ {file = "pydantic_core-2.27.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7969e133a6f183be60e9f6f56bfae753585680f3b7307a8e555a948d443cc05a"},
+ {file = "pydantic_core-2.27.2-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:3de9961f2a346257caf0aa508a4da705467f53778e9ef6fe744c038119737ef5"},
+ {file = "pydantic_core-2.27.2-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e2bb4d3e5873c37bb3dd58714d4cd0b0e6238cebc4177ac8fe878f8b3aa8e74c"},
+ {file = "pydantic_core-2.27.2-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:280d219beebb0752699480fe8f1dc61ab6615c2046d76b7ab7ee38858de0a4e7"},
+ {file = "pydantic_core-2.27.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:47956ae78b6422cbd46f772f1746799cbb862de838fd8d1fbd34a82e05b0983a"},
+ {file = "pydantic_core-2.27.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:14d4a5c49d2f009d62a2a7140d3064f686d17a5d1a268bc641954ba181880236"},
+ {file = "pydantic_core-2.27.2-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:337b443af21d488716f8d0b6164de833e788aa6bd7e3a39c005febc1284f4962"},
+ {file = "pydantic_core-2.27.2-cp310-cp310-musllinux_1_1_armv7l.whl", hash = "sha256:03d0f86ea3184a12f41a2d23f7ccb79cdb5a18e06993f8a45baa8dfec746f0e9"},
+ {file = "pydantic_core-2.27.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:7041c36f5680c6e0f08d922aed302e98b3745d97fe1589db0a3eebf6624523af"},
+ {file = "pydantic_core-2.27.2-cp310-cp310-win32.whl", hash = "sha256:50a68f3e3819077be2c98110c1f9dcb3817e93f267ba80a2c05bb4f8799e2ff4"},
+ {file = "pydantic_core-2.27.2-cp310-cp310-win_amd64.whl", hash = "sha256:e0fd26b16394ead34a424eecf8a31a1f5137094cabe84a1bcb10fa6ba39d3d31"},
+ {file = "pydantic_core-2.27.2-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:8e10c99ef58cfdf2a66fc15d66b16c4a04f62bca39db589ae8cba08bc55331bc"},
+ {file = "pydantic_core-2.27.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:26f32e0adf166a84d0cb63be85c562ca8a6fa8de28e5f0d92250c6b7e9e2aff7"},
+ {file = "pydantic_core-2.27.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8c19d1ea0673cd13cc2f872f6c9ab42acc4e4f492a7ca9d3795ce2b112dd7e15"},
+ {file = "pydantic_core-2.27.2-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:5e68c4446fe0810e959cdff46ab0a41ce2f2c86d227d96dc3847af0ba7def306"},
+ {file = "pydantic_core-2.27.2-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d9640b0059ff4f14d1f37321b94061c6db164fbe49b334b31643e0528d100d99"},
+ {file = "pydantic_core-2.27.2-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:40d02e7d45c9f8af700f3452f329ead92da4c5f4317ca9b896de7ce7199ea459"},
+ {file = "pydantic_core-2.27.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1c1fd185014191700554795c99b347d64f2bb637966c4cfc16998a0ca700d048"},
+ {file = "pydantic_core-2.27.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:d81d2068e1c1228a565af076598f9e7451712700b673de8f502f0334f281387d"},
+ {file = "pydantic_core-2.27.2-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:1a4207639fb02ec2dbb76227d7c751a20b1a6b4bc52850568e52260cae64ca3b"},
+ {file = "pydantic_core-2.27.2-cp311-cp311-musllinux_1_1_armv7l.whl", hash = "sha256:3de3ce3c9ddc8bbd88f6e0e304dea0e66d843ec9de1b0042b0911c1663ffd474"},
+ {file = "pydantic_core-2.27.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:30c5f68ded0c36466acede341551106821043e9afaad516adfb6e8fa80a4e6a6"},
+ {file = "pydantic_core-2.27.2-cp311-cp311-win32.whl", hash = "sha256:c70c26d2c99f78b125a3459f8afe1aed4d9687c24fd677c6a4436bc042e50d6c"},
+ {file = "pydantic_core-2.27.2-cp311-cp311-win_amd64.whl", hash = "sha256:08e125dbdc505fa69ca7d9c499639ab6407cfa909214d500897d02afb816e7cc"},
+ {file = "pydantic_core-2.27.2-cp311-cp311-win_arm64.whl", hash = "sha256:26f0d68d4b235a2bae0c3fc585c585b4ecc51382db0e3ba402a22cbc440915e4"},
+ {file = "pydantic_core-2.27.2-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:9e0c8cfefa0ef83b4da9588448b6d8d2a2bf1a53c3f1ae5fca39eb3061e2f0b0"},
+ {file = "pydantic_core-2.27.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:83097677b8e3bd7eaa6775720ec8e0405f1575015a463285a92bfdfe254529ef"},
+ {file = "pydantic_core-2.27.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:172fce187655fece0c90d90a678424b013f8fbb0ca8b036ac266749c09438cb7"},
+ {file = "pydantic_core-2.27.2-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:519f29f5213271eeeeb3093f662ba2fd512b91c5f188f3bb7b27bc5973816934"},
+ {file = "pydantic_core-2.27.2-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:05e3a55d124407fffba0dd6b0c0cd056d10e983ceb4e5dbd10dda135c31071d6"},
+ {file = "pydantic_core-2.27.2-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9c3ed807c7b91de05e63930188f19e921d1fe90de6b4f5cd43ee7fcc3525cb8c"},
+ {file = "pydantic_core-2.27.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6fb4aadc0b9a0c063206846d603b92030eb6f03069151a625667f982887153e2"},
+ {file = "pydantic_core-2.27.2-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:28ccb213807e037460326424ceb8b5245acb88f32f3d2777427476e1b32c48c4"},
+ {file = "pydantic_core-2.27.2-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:de3cd1899e2c279b140adde9357c4495ed9d47131b4a4eaff9052f23398076b3"},
+ {file = "pydantic_core-2.27.2-cp312-cp312-musllinux_1_1_armv7l.whl", hash = "sha256:220f892729375e2d736b97d0e51466252ad84c51857d4d15f5e9692f9ef12be4"},
+ {file = "pydantic_core-2.27.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:a0fcd29cd6b4e74fe8ddd2c90330fd8edf2e30cb52acda47f06dd615ae72da57"},
+ {file = "pydantic_core-2.27.2-cp312-cp312-win32.whl", hash = "sha256:1e2cb691ed9834cd6a8be61228471d0a503731abfb42f82458ff27be7b2186fc"},
+ {file = "pydantic_core-2.27.2-cp312-cp312-win_amd64.whl", hash = "sha256:cc3f1a99a4f4f9dd1de4fe0312c114e740b5ddead65bb4102884b384c15d8bc9"},
+ {file = "pydantic_core-2.27.2-cp312-cp312-win_arm64.whl", hash = "sha256:3911ac9284cd8a1792d3cb26a2da18f3ca26c6908cc434a18f730dc0db7bfa3b"},
+ {file = "pydantic_core-2.27.2-cp313-cp313-macosx_10_12_x86_64.whl", hash = "sha256:7d14bd329640e63852364c306f4d23eb744e0f8193148d4044dd3dacdaacbd8b"},
+ {file = "pydantic_core-2.27.2-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:82f91663004eb8ed30ff478d77c4d1179b3563df6cdb15c0817cd1cdaf34d154"},
+ {file = "pydantic_core-2.27.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:71b24c7d61131bb83df10cc7e687433609963a944ccf45190cfc21e0887b08c9"},
+ {file = "pydantic_core-2.27.2-cp313-cp313-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:fa8e459d4954f608fa26116118bb67f56b93b209c39b008277ace29937453dc9"},
+ {file = "pydantic_core-2.27.2-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:ce8918cbebc8da707ba805b7fd0b382816858728ae7fe19a942080c24e5b7cd1"},
+ {file = "pydantic_core-2.27.2-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:eda3f5c2a021bbc5d976107bb302e0131351c2ba54343f8a496dc8783d3d3a6a"},
+ {file = "pydantic_core-2.27.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bd8086fa684c4775c27f03f062cbb9eaa6e17f064307e86b21b9e0abc9c0f02e"},
+ {file = "pydantic_core-2.27.2-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:8d9b3388db186ba0c099a6d20f0604a44eabdeef1777ddd94786cdae158729e4"},
+ {file = "pydantic_core-2.27.2-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:7a66efda2387de898c8f38c0cf7f14fca0b51a8ef0b24bfea5849f1b3c95af27"},
+ {file = "pydantic_core-2.27.2-cp313-cp313-musllinux_1_1_armv7l.whl", hash = "sha256:18a101c168e4e092ab40dbc2503bdc0f62010e95d292b27827871dc85450d7ee"},
+ {file = "pydantic_core-2.27.2-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:ba5dd002f88b78a4215ed2f8ddbdf85e8513382820ba15ad5ad8955ce0ca19a1"},
+ {file = "pydantic_core-2.27.2-cp313-cp313-win32.whl", hash = "sha256:1ebaf1d0481914d004a573394f4be3a7616334be70261007e47c2a6fe7e50130"},
+ {file = "pydantic_core-2.27.2-cp313-cp313-win_amd64.whl", hash = "sha256:953101387ecf2f5652883208769a79e48db18c6df442568a0b5ccd8c2723abee"},
+ {file = "pydantic_core-2.27.2-cp313-cp313-win_arm64.whl", hash = "sha256:ac4dbfd1691affb8f48c2c13241a2e3b60ff23247cbcf981759c768b6633cf8b"},
+ {file = "pydantic_core-2.27.2-cp38-cp38-macosx_10_12_x86_64.whl", hash = "sha256:d3e8d504bdd3f10835468f29008d72fc8359d95c9c415ce6e767203db6127506"},
+ {file = "pydantic_core-2.27.2-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:521eb9b7f036c9b6187f0b47318ab0d7ca14bd87f776240b90b21c1f4f149320"},
+ {file = "pydantic_core-2.27.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:85210c4d99a0114f5a9481b44560d7d1e35e32cc5634c656bc48e590b669b145"},
+ {file = "pydantic_core-2.27.2-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:d716e2e30c6f140d7560ef1538953a5cd1a87264c737643d481f2779fc247fe1"},
+ {file = "pydantic_core-2.27.2-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f66d89ba397d92f840f8654756196d93804278457b5fbede59598a1f9f90b228"},
+ {file = "pydantic_core-2.27.2-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:669e193c1c576a58f132e3158f9dfa9662969edb1a250c54d8fa52590045f046"},
+ {file = "pydantic_core-2.27.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9fdbe7629b996647b99c01b37f11170a57ae675375b14b8c13b8518b8320ced5"},
+ {file = "pydantic_core-2.27.2-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:d262606bf386a5ba0b0af3b97f37c83d7011439e3dc1a9298f21efb292e42f1a"},
+ {file = "pydantic_core-2.27.2-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:cabb9bcb7e0d97f74df8646f34fc76fbf793b7f6dc2438517d7a9e50eee4f14d"},
+ {file = "pydantic_core-2.27.2-cp38-cp38-musllinux_1_1_armv7l.whl", hash = "sha256:d2d63f1215638d28221f664596b1ccb3944f6e25dd18cd3b86b0a4c408d5ebb9"},
+ {file = "pydantic_core-2.27.2-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:bca101c00bff0adb45a833f8451b9105d9df18accb8743b08107d7ada14bd7da"},
+ {file = "pydantic_core-2.27.2-cp38-cp38-win32.whl", hash = "sha256:f6f8e111843bbb0dee4cb6594cdc73e79b3329b526037ec242a3e49012495b3b"},
+ {file = "pydantic_core-2.27.2-cp38-cp38-win_amd64.whl", hash = "sha256:fd1aea04935a508f62e0d0ef1f5ae968774a32afc306fb8545e06f5ff5cdf3ad"},
+ {file = "pydantic_core-2.27.2-cp39-cp39-macosx_10_12_x86_64.whl", hash = "sha256:c10eb4f1659290b523af58fa7cffb452a61ad6ae5613404519aee4bfbf1df993"},
+ {file = "pydantic_core-2.27.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:ef592d4bad47296fb11f96cd7dc898b92e795032b4894dfb4076cfccd43a9308"},
+ {file = "pydantic_core-2.27.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c61709a844acc6bf0b7dce7daae75195a10aac96a596ea1b776996414791ede4"},
+ {file = "pydantic_core-2.27.2-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:42c5f762659e47fdb7b16956c71598292f60a03aa92f8b6351504359dbdba6cf"},
+ {file = "pydantic_core-2.27.2-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:4c9775e339e42e79ec99c441d9730fccf07414af63eac2f0e48e08fd38a64d76"},
+ {file = "pydantic_core-2.27.2-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:57762139821c31847cfb2df63c12f725788bd9f04bc2fb392790959b8f70f118"},
+ {file = "pydantic_core-2.27.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0d1e85068e818c73e048fe28cfc769040bb1f475524f4745a5dc621f75ac7630"},
+ {file = "pydantic_core-2.27.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:097830ed52fd9e427942ff3b9bc17fab52913b2f50f2880dc4a5611446606a54"},
+ {file = "pydantic_core-2.27.2-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:044a50963a614ecfae59bb1eaf7ea7efc4bc62f49ed594e18fa1e5d953c40e9f"},
+ {file = "pydantic_core-2.27.2-cp39-cp39-musllinux_1_1_armv7l.whl", hash = "sha256:4e0b4220ba5b40d727c7f879eac379b822eee5d8fff418e9d3381ee45b3b0362"},
+ {file = "pydantic_core-2.27.2-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:5e4f4bb20d75e9325cc9696c6802657b58bc1dbbe3022f32cc2b2b632c3fbb96"},
+ {file = "pydantic_core-2.27.2-cp39-cp39-win32.whl", hash = "sha256:cca63613e90d001b9f2f9a9ceb276c308bfa2a43fafb75c8031c4f66039e8c6e"},
+ {file = "pydantic_core-2.27.2-cp39-cp39-win_amd64.whl", hash = "sha256:77d1bca19b0f7021b3a982e6f903dcd5b2b06076def36a652e3907f596e29f67"},
+ {file = "pydantic_core-2.27.2-pp310-pypy310_pp73-macosx_10_12_x86_64.whl", hash = "sha256:2bf14caea37e91198329b828eae1618c068dfb8ef17bb33287a7ad4b61ac314e"},
+ {file = "pydantic_core-2.27.2-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:b0cb791f5b45307caae8810c2023a184c74605ec3bcbb67d13846c28ff731ff8"},
+ {file = "pydantic_core-2.27.2-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:688d3fd9fcb71f41c4c015c023d12a79d1c4c0732ec9eb35d96e3388a120dcf3"},
+ {file = "pydantic_core-2.27.2-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3d591580c34f4d731592f0e9fe40f9cc1b430d297eecc70b962e93c5c668f15f"},
+ {file = "pydantic_core-2.27.2-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:82f986faf4e644ffc189a7f1aafc86e46ef70372bb153e7001e8afccc6e54133"},
+ {file = "pydantic_core-2.27.2-pp310-pypy310_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:bec317a27290e2537f922639cafd54990551725fc844249e64c523301d0822fc"},
+ {file = "pydantic_core-2.27.2-pp310-pypy310_pp73-musllinux_1_1_armv7l.whl", hash = "sha256:0296abcb83a797db256b773f45773da397da75a08f5fcaef41f2044adec05f50"},
+ {file = "pydantic_core-2.27.2-pp310-pypy310_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:0d75070718e369e452075a6017fbf187f788e17ed67a3abd47fa934d001863d9"},
+ {file = "pydantic_core-2.27.2-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:7e17b560be3c98a8e3aa66ce828bdebb9e9ac6ad5466fba92eb74c4c95cb1151"},
+ {file = "pydantic_core-2.27.2-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:c33939a82924da9ed65dab5a65d427205a73181d8098e79b6b426bdf8ad4e656"},
+ {file = "pydantic_core-2.27.2-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:00bad2484fa6bda1e216e7345a798bd37c68fb2d97558edd584942aa41b7d278"},
+ {file = "pydantic_core-2.27.2-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c817e2b40aba42bac6f457498dacabc568c3b7a986fc9ba7c8d9d260b71485fb"},
+ {file = "pydantic_core-2.27.2-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:251136cdad0cb722e93732cb45ca5299fb56e1344a833640bf93b2803f8d1bfd"},
+ {file = "pydantic_core-2.27.2-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:d2088237af596f0a524d3afc39ab3b036e8adb054ee57cbb1dcf8e09da5b29cc"},
+ {file = "pydantic_core-2.27.2-pp39-pypy39_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:d4041c0b966a84b4ae7a09832eb691a35aec90910cd2dbe7a208de59be77965b"},
+ {file = "pydantic_core-2.27.2-pp39-pypy39_pp73-musllinux_1_1_armv7l.whl", hash = "sha256:8083d4e875ebe0b864ffef72a4304827015cff328a1be6e22cc850753bfb122b"},
+ {file = "pydantic_core-2.27.2-pp39-pypy39_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:f141ee28a0ad2123b6611b6ceff018039df17f32ada8b534e6aa039545a3efb2"},
+ {file = "pydantic_core-2.27.2-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:7d0c8399fcc1848491f00e0314bd59fb34a9c008761bcb422a057670c3f65e35"},
+ {file = "pydantic_core-2.27.2.tar.gz", hash = "sha256:eb026e5a4c1fee05726072337ff51d1efb6f59090b7da90d30ea58625b1ffb39"},
+]
+
+[package.dependencies]
+typing-extensions = ">=4.6.0,<4.7.0 || >4.7.0"
+
+[[package]]
+name = "pygments"
+version = "2.19.1"
+description = "Pygments is a syntax highlighting package written in Python."
+optional = false
+python-versions = ">=3.8"
+groups = ["main", "dev"]
+files = [
+ {file = "pygments-2.19.1-py3-none-any.whl", hash = "sha256:9ea1544ad55cecf4b8242fab6dd35a93bbce657034b0611ee383099054ab6d8c"},
+ {file = "pygments-2.19.1.tar.gz", hash = "sha256:61c16d2a8576dc0649d9f39e089b5f02bcd27fba10d8fb4dcc28173f7a45151f"},
+]
+
+[package.extras]
+windows-terminal = ["colorama (>=0.4.6)"]
+
+[[package]]
+name = "pypdfium2"
+version = "4.30.1"
+description = "Python bindings to PDFium"
+optional = false
+python-versions = ">=3.6"
+groups = ["main"]
+files = [
+ {file = "pypdfium2-4.30.1-py3-none-macosx_10_13_x86_64.whl", hash = "sha256:e07c47633732cc18d890bb7e965ad28a9c5a932e548acb928596f86be2e5ae37"},
+ {file = "pypdfium2-4.30.1-py3-none-macosx_11_0_arm64.whl", hash = "sha256:5ea2d44e96d361123b67b00f527017aa9c847c871b5714e013c01c3eb36a79fe"},
+ {file = "pypdfium2-4.30.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1de7a3a36803171b3f66911131046d65a732f9e7834438191cb58235e6163c4e"},
+ {file = "pypdfium2-4.30.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:b8a4231efb13170354f568c722d6540b8d5b476b08825586d48ef70c40d16e03"},
+ {file = "pypdfium2-4.30.1-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6f434a4934e8244aa95343ffcf24e9ad9f120dbb4785f631bb40a88c39292493"},
+ {file = "pypdfium2-4.30.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f454032a0bc7681900170f67d8711b3942824531e765f91c2f5ce7937f999794"},
+ {file = "pypdfium2-4.30.1-py3-none-musllinux_1_1_aarch64.whl", hash = "sha256:bbf9130a72370ee9d602e39949b902db669a2a1c24746a91e5586eb829055d9f"},
+ {file = "pypdfium2-4.30.1-py3-none-musllinux_1_1_i686.whl", hash = "sha256:5cb52884b1583b96e94fd78542c63bb42e06df5e8f9e52f8f31f5ad5a1e53367"},
+ {file = "pypdfium2-4.30.1-py3-none-musllinux_1_1_x86_64.whl", hash = "sha256:1a9e372bd4867ff223cc8c338e33fe11055dad12f22885950fc27646cc8d9122"},
+ {file = "pypdfium2-4.30.1-py3-none-win32.whl", hash = "sha256:421f1cf205e213e07c1f2934905779547f4f4a2ff2f59dde29da3d511d3fc806"},
+ {file = "pypdfium2-4.30.1-py3-none-win_amd64.whl", hash = "sha256:598a7f20264ab5113853cba6d86c4566e4356cad037d7d1f849c8c9021007e05"},
+ {file = "pypdfium2-4.30.1-py3-none-win_arm64.whl", hash = "sha256:c2b6d63f6d425d9416c08d2511822b54b8e3ac38e639fc41164b1d75584b3a8c"},
+ {file = "pypdfium2-4.30.1.tar.gz", hash = "sha256:5f5c7c6d03598e107d974f66b220a49436aceb191da34cda5f692be098a814ce"},
+]
+
+[[package]]
+name = "pyright"
+version = "1.1.398"
+description = "Command line wrapper for pyright"
+optional = false
+python-versions = ">=3.7"
+groups = ["dev"]
+files = [
+ {file = "pyright-1.1.398-py3-none-any.whl", hash = "sha256:0a70bfd007d9ea7de1cf9740e1ad1a40a122592cfe22a3f6791b06162ad08753"},
+ {file = "pyright-1.1.398.tar.gz", hash = "sha256:357a13edd9be8082dc73be51190913e475fa41a6efb6ec0d4b7aab3bc11638d8"},
+]
+
+[package.dependencies]
+nodeenv = ">=1.6.0"
+typing-extensions = ">=4.1"
+
+[package.extras]
+all = ["nodejs-wheel-binaries", "twine (>=3.4.1)"]
+dev = ["twine (>=3.4.1)"]
+nodejs = ["nodejs-wheel-binaries"]
+
+[[package]]
+name = "pytest"
+version = "8.3.5"
+description = "pytest: simple powerful testing with Python"
+optional = false
+python-versions = ">=3.8"
+groups = ["dev"]
+files = [
+ {file = "pytest-8.3.5-py3-none-any.whl", hash = "sha256:c69214aa47deac29fad6c2a4f590b9c4a9fdb16a403176fe154b79c0b4d4d820"},
+ {file = "pytest-8.3.5.tar.gz", hash = "sha256:f4efe70cc14e511565ac476b57c279e12a855b11f48f212af1080ef2263d3845"},
+]
+
+[package.dependencies]
+colorama = {version = "*", markers = "sys_platform == \"win32\""}
+iniconfig = "*"
+packaging = "*"
+pluggy = ">=1.5,<2"
+
+[package.extras]
+dev = ["argcomplete", "attrs (>=19.2)", "hypothesis (>=3.56)", "mock", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"]
+
+[[package]]
+name = "pytest-asyncio"
+version = "0.24.0"
+description = "Pytest support for asyncio"
+optional = false
+python-versions = ">=3.8"
+groups = ["dev"]
+files = [
+ {file = "pytest_asyncio-0.24.0-py3-none-any.whl", hash = "sha256:a811296ed596b69bf0b6f3dc40f83bcaf341b155a269052d82efa2b25ac7037b"},
+ {file = "pytest_asyncio-0.24.0.tar.gz", hash = "sha256:d081d828e576d85f875399194281e92bf8a68d60d72d1a2faf2feddb6c46b276"},
+]
+
+[package.dependencies]
+pytest = ">=8.2,<9"
+
+[package.extras]
+docs = ["sphinx (>=5.3)", "sphinx-rtd-theme (>=1.0)"]
+testing = ["coverage (>=6.2)", "hypothesis (>=5.7.1)"]
+
+[[package]]
+name = "pytest-cov"
+version = "6.1.1"
+description = "Pytest plugin for measuring coverage."
+optional = false
+python-versions = ">=3.9"
+groups = ["dev"]
+files = [
+ {file = "pytest_cov-6.1.1-py3-none-any.whl", hash = "sha256:bddf29ed2d0ab6f4df17b4c55b0a657287db8684af9c42ea546b21b1041b3dde"},
+ {file = "pytest_cov-6.1.1.tar.gz", hash = "sha256:46935f7aaefba760e716c2ebfbe1c216240b9592966e7da99ea8292d4d3e2a0a"},
+]
+
+[package.dependencies]
+coverage = {version = ">=7.5", extras = ["toml"]}
+pytest = ">=4.6"
+
+[package.extras]
+testing = ["fields", "hunter", "process-tests", "pytest-xdist", "virtualenv"]
+
+[[package]]
+name = "pytest-pretty"
+version = "1.2.0"
+description = "pytest plugin for printing summary data as I want it"
+optional = false
+python-versions = ">=3.7"
+groups = ["dev"]
+files = [
+ {file = "pytest_pretty-1.2.0-py3-none-any.whl", hash = "sha256:6f79122bf53864ae2951b6c9e94d7a06a87ef753476acd4588aeac018f062036"},
+ {file = "pytest_pretty-1.2.0.tar.gz", hash = "sha256:105a355f128e392860ad2c478ae173ff96d2f03044692f9818ff3d49205d3a60"},
+]
+
+[package.dependencies]
+pytest = ">=7"
+rich = ">=12"
+
+[[package]]
+name = "python-dateutil"
+version = "2.9.0.post0"
+description = "Extensions to the standard Python datetime module"
+optional = false
+python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7"
+groups = ["main"]
+files = [
+ {file = "python-dateutil-2.9.0.post0.tar.gz", hash = "sha256:37dd54208da7e1cd875388217d5e00ebd4179249f90fb72437e91a35459a0ad3"},
+ {file = "python_dateutil-2.9.0.post0-py2.py3-none-any.whl", hash = "sha256:a8b2bc7bffae282281c8140a97d3aa9c14da0b136dfe83f850eea9a5f7470427"},
+]
+
+[package.dependencies]
+six = ">=1.5"
+
+[[package]]
+name = "python-dotenv"
+version = "1.1.0"
+description = "Read key-value pairs from a .env file and set them as environment variables"
+optional = false
+python-versions = ">=3.9"
+groups = ["main"]
+files = [
+ {file = "python_dotenv-1.1.0-py3-none-any.whl", hash = "sha256:d7c01d9e2293916c18baf562d95698754b0dbbb5e74d457c45d4f6561fb9d55d"},
+ {file = "python_dotenv-1.1.0.tar.gz", hash = "sha256:41f90bc6f5f177fb41f53e87666db362025010eb28f60a01c9143bfa33a2b2d5"},
+]
+
+[package.extras]
+cli = ["click (>=5.0)"]
+
+[[package]]
+name = "pytz"
+version = "2025.2"
+description = "World timezone definitions, modern and historical"
+optional = false
+python-versions = "*"
+groups = ["main"]
+files = [
+ {file = "pytz-2025.2-py2.py3-none-any.whl", hash = "sha256:5ddf76296dd8c44c26eb8f4b6f35488f3ccbf6fbbd7adee0b7262d43f0ec2f00"},
+ {file = "pytz-2025.2.tar.gz", hash = "sha256:360b9e3dbb49a209c21ad61809c7fb453643e048b38924c765813546746e81c3"},
+]
+
+[[package]]
+name = "pyyaml"
+version = "6.0.2"
+description = "YAML parser and emitter for Python"
+optional = false
+python-versions = ">=3.8"
+groups = ["main"]
+files = [
+ {file = "PyYAML-6.0.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:0a9a2848a5b7feac301353437eb7d5957887edbf81d56e903999a75a3d743086"},
+ {file = "PyYAML-6.0.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:29717114e51c84ddfba879543fb232a6ed60086602313ca38cce623c1d62cfbf"},
+ {file = "PyYAML-6.0.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8824b5a04a04a047e72eea5cec3bc266db09e35de6bdfe34c9436ac5ee27d237"},
+ {file = "PyYAML-6.0.2-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:7c36280e6fb8385e520936c3cb3b8042851904eba0e58d277dca80a5cfed590b"},
+ {file = "PyYAML-6.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ec031d5d2feb36d1d1a24380e4db6d43695f3748343d99434e6f5f9156aaa2ed"},
+ {file = "PyYAML-6.0.2-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:936d68689298c36b53b29f23c6dbb74de12b4ac12ca6cfe0e047bedceea56180"},
+ {file = "PyYAML-6.0.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:23502f431948090f597378482b4812b0caae32c22213aecf3b55325e049a6c68"},
+ {file = "PyYAML-6.0.2-cp310-cp310-win32.whl", hash = "sha256:2e99c6826ffa974fe6e27cdb5ed0021786b03fc98e5ee3c5bfe1fd5015f42b99"},
+ {file = "PyYAML-6.0.2-cp310-cp310-win_amd64.whl", hash = "sha256:a4d3091415f010369ae4ed1fc6b79def9416358877534caf6a0fdd2146c87a3e"},
+ {file = "PyYAML-6.0.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:cc1c1159b3d456576af7a3e4d1ba7e6924cb39de8f67111c735f6fc832082774"},
+ {file = "PyYAML-6.0.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:1e2120ef853f59c7419231f3bf4e7021f1b936f6ebd222406c3b60212205d2ee"},
+ {file = "PyYAML-6.0.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5d225db5a45f21e78dd9358e58a98702a0302f2659a3c6cd320564b75b86f47c"},
+ {file = "PyYAML-6.0.2-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:5ac9328ec4831237bec75defaf839f7d4564be1e6b25ac710bd1a96321cc8317"},
+ {file = "PyYAML-6.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3ad2a3decf9aaba3d29c8f537ac4b243e36bef957511b4766cb0057d32b0be85"},
+ {file = "PyYAML-6.0.2-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:ff3824dc5261f50c9b0dfb3be22b4567a6f938ccce4587b38952d85fd9e9afe4"},
+ {file = "PyYAML-6.0.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:797b4f722ffa07cc8d62053e4cff1486fa6dc094105d13fea7b1de7d8bf71c9e"},
+ {file = "PyYAML-6.0.2-cp311-cp311-win32.whl", hash = "sha256:11d8f3dd2b9c1207dcaf2ee0bbbfd5991f571186ec9cc78427ba5bd32afae4b5"},
+ {file = "PyYAML-6.0.2-cp311-cp311-win_amd64.whl", hash = "sha256:e10ce637b18caea04431ce14fabcf5c64a1c61ec9c56b071a4b7ca131ca52d44"},
+ {file = "PyYAML-6.0.2-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:c70c95198c015b85feafc136515252a261a84561b7b1d51e3384e0655ddf25ab"},
+ {file = "PyYAML-6.0.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:ce826d6ef20b1bc864f0a68340c8b3287705cae2f8b4b1d932177dcc76721725"},
+ {file = "PyYAML-6.0.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1f71ea527786de97d1a0cc0eacd1defc0985dcf6b3f17bb77dcfc8c34bec4dc5"},
+ {file = "PyYAML-6.0.2-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9b22676e8097e9e22e36d6b7bda33190d0d400f345f23d4065d48f4ca7ae0425"},
+ {file = "PyYAML-6.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:80bab7bfc629882493af4aa31a4cfa43a4c57c83813253626916b8c7ada83476"},
+ {file = "PyYAML-6.0.2-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:0833f8694549e586547b576dcfaba4a6b55b9e96098b36cdc7ebefe667dfed48"},
+ {file = "PyYAML-6.0.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8b9c7197f7cb2738065c481a0461e50ad02f18c78cd75775628afb4d7137fb3b"},
+ {file = "PyYAML-6.0.2-cp312-cp312-win32.whl", hash = "sha256:ef6107725bd54b262d6dedcc2af448a266975032bc85ef0172c5f059da6325b4"},
+ {file = "PyYAML-6.0.2-cp312-cp312-win_amd64.whl", hash = "sha256:7e7401d0de89a9a855c839bc697c079a4af81cf878373abd7dc625847d25cbd8"},
+ {file = "PyYAML-6.0.2-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:efdca5630322a10774e8e98e1af481aad470dd62c3170801852d752aa7a783ba"},
+ {file = "PyYAML-6.0.2-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:50187695423ffe49e2deacb8cd10510bc361faac997de9efef88badc3bb9e2d1"},
+ {file = "PyYAML-6.0.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0ffe8360bab4910ef1b9e87fb812d8bc0a308b0d0eef8c8f44e0254ab3b07133"},
+ {file = "PyYAML-6.0.2-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:17e311b6c678207928d649faa7cb0d7b4c26a0ba73d41e99c4fff6b6c3276484"},
+ {file = "PyYAML-6.0.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:70b189594dbe54f75ab3a1acec5f1e3faa7e8cf2f1e08d9b561cb41b845f69d5"},
+ {file = "PyYAML-6.0.2-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:41e4e3953a79407c794916fa277a82531dd93aad34e29c2a514c2c0c5fe971cc"},
+ {file = "PyYAML-6.0.2-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:68ccc6023a3400877818152ad9a1033e3db8625d899c72eacb5a668902e4d652"},
+ {file = "PyYAML-6.0.2-cp313-cp313-win32.whl", hash = "sha256:bc2fa7c6b47d6bc618dd7fb02ef6fdedb1090ec036abab80d4681424b84c1183"},
+ {file = "PyYAML-6.0.2-cp313-cp313-win_amd64.whl", hash = "sha256:8388ee1976c416731879ac16da0aff3f63b286ffdd57cdeb95f3f2e085687563"},
+ {file = "PyYAML-6.0.2-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:24471b829b3bf607e04e88d79542a9d48bb037c2267d7927a874e6c205ca7e9a"},
+ {file = "PyYAML-6.0.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d7fded462629cfa4b685c5416b949ebad6cec74af5e2d42905d41e257e0869f5"},
+ {file = "PyYAML-6.0.2-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d84a1718ee396f54f3a086ea0a66d8e552b2ab2017ef8b420e92edbc841c352d"},
+ {file = "PyYAML-6.0.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9056c1ecd25795207ad294bcf39f2db3d845767be0ea6e6a34d856f006006083"},
+ {file = "PyYAML-6.0.2-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:82d09873e40955485746739bcb8b4586983670466c23382c19cffecbf1fd8706"},
+ {file = "PyYAML-6.0.2-cp38-cp38-win32.whl", hash = "sha256:43fa96a3ca0d6b1812e01ced1044a003533c47f6ee8aca31724f78e93ccc089a"},
+ {file = "PyYAML-6.0.2-cp38-cp38-win_amd64.whl", hash = "sha256:01179a4a8559ab5de078078f37e5c1a30d76bb88519906844fd7bdea1b7729ff"},
+ {file = "PyYAML-6.0.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:688ba32a1cffef67fd2e9398a2efebaea461578b0923624778664cc1c914db5d"},
+ {file = "PyYAML-6.0.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:a8786accb172bd8afb8be14490a16625cbc387036876ab6ba70912730faf8e1f"},
+ {file = "PyYAML-6.0.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d8e03406cac8513435335dbab54c0d385e4a49e4945d2909a581c83647ca0290"},
+ {file = "PyYAML-6.0.2-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:f753120cb8181e736c57ef7636e83f31b9c0d1722c516f7e86cf15b7aa57ff12"},
+ {file = "PyYAML-6.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3b1fdb9dc17f5a7677423d508ab4f243a726dea51fa5e70992e59a7411c89d19"},
+ {file = "PyYAML-6.0.2-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:0b69e4ce7a131fe56b7e4d770c67429700908fc0752af059838b1cfb41960e4e"},
+ {file = "PyYAML-6.0.2-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:a9f8c2e67970f13b16084e04f134610fd1d374bf477b17ec1599185cf611d725"},
+ {file = "PyYAML-6.0.2-cp39-cp39-win32.whl", hash = "sha256:6395c297d42274772abc367baaa79683958044e5d3835486c16da75d2a694631"},
+ {file = "PyYAML-6.0.2-cp39-cp39-win_amd64.whl", hash = "sha256:39693e1f8320ae4f43943590b49779ffb98acb81f788220ea932a6b6c51004d8"},
+ {file = "pyyaml-6.0.2.tar.gz", hash = "sha256:d584d9ec91ad65861cc08d42e834324ef890a082e591037abe114850ff7bbc3e"},
+]
+
+[[package]]
+name = "requests"
+version = "2.32.3"
+description = "Python HTTP for Humans."
+optional = false
+python-versions = ">=3.8"
+groups = ["main"]
+files = [
+ {file = "requests-2.32.3-py3-none-any.whl", hash = "sha256:70761cfe03c773ceb22aa2f671b4757976145175cdfca038c02654d061d6dcc6"},
+ {file = "requests-2.32.3.tar.gz", hash = "sha256:55365417734eb18255590a9ff9eb97e9e1da868d4ccd6402399eaf68af20a760"},
+]
+
+[package.dependencies]
+certifi = ">=2017.4.17"
+charset-normalizer = ">=2,<4"
+idna = ">=2.5,<4"
+urllib3 = ">=1.21.1,<3"
+
+[package.extras]
+socks = ["PySocks (>=1.5.6,!=1.5.7)"]
+use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"]
+
+[[package]]
+name = "requests-oauthlib"
+version = "2.0.0"
+description = "OAuthlib authentication support for Requests."
+optional = true
+python-versions = ">=3.4"
+groups = ["main"]
+markers = "extra == \"google\""
+files = [
+ {file = "requests-oauthlib-2.0.0.tar.gz", hash = "sha256:b3dffaebd884d8cd778494369603a9e7b58d29111bf6b41bdc2dcd87203af4e9"},
+ {file = "requests_oauthlib-2.0.0-py2.py3-none-any.whl", hash = "sha256:7dd8a5c40426b779b0868c404bdef9768deccf22749cde15852df527e6269b36"},
+]
+
+[package.dependencies]
+oauthlib = ">=3.0.0"
+requests = ">=2.0.0"
+
+[package.extras]
+rsa = ["oauthlib[signedtoken] (>=3.0.0)"]
+
+[[package]]
+name = "rich"
+version = "13.9.4"
+description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal"
+optional = false
+python-versions = ">=3.8.0"
+groups = ["main", "dev"]
+files = [
+ {file = "rich-13.9.4-py3-none-any.whl", hash = "sha256:6049d5e6ec054bf2779ab3358186963bac2ea89175919d699e378b99738c2a90"},
+ {file = "rich-13.9.4.tar.gz", hash = "sha256:439594978a49a09530cff7ebc4b5c7103ef57baf48d5ea3184f21d9a2befa098"},
+]
+
+[package.dependencies]
+markdown-it-py = ">=2.2.0"
+pygments = ">=2.13.0,<3.0.0"
+
+[package.extras]
+jupyter = ["ipywidgets (>=7.5.1,<9)"]
+
+[[package]]
+name = "rsa"
+version = "4.9.1"
+description = "Pure-Python RSA implementation"
+optional = true
+python-versions = "<4,>=3.6"
+groups = ["main"]
+markers = "extra == \"google\""
+files = [
+ {file = "rsa-4.9.1-py3-none-any.whl", hash = "sha256:68635866661c6836b8d39430f97a996acbd61bfa49406748ea243539fe239762"},
+ {file = "rsa-4.9.1.tar.gz", hash = "sha256:e7bdbfdb5497da4c07dfd35530e1a902659db6ff241e39d9953cad06ebd0ae75"},
+]
+
+[package.dependencies]
+pyasn1 = ">=0.1.3"
+
+[[package]]
+name = "ruff"
+version = "0.6.9"
+description = "An extremely fast Python linter and code formatter, written in Rust."
+optional = false
+python-versions = ">=3.7"
+groups = ["dev"]
+files = [
+ {file = "ruff-0.6.9-py3-none-linux_armv6l.whl", hash = "sha256:064df58d84ccc0ac0fcd63bc3090b251d90e2a372558c0f057c3f75ed73e1ccd"},
+ {file = "ruff-0.6.9-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:140d4b5c9f5fc7a7b074908a78ab8d384dd7f6510402267bc76c37195c02a7ec"},
+ {file = "ruff-0.6.9-py3-none-macosx_11_0_arm64.whl", hash = "sha256:53fd8ca5e82bdee8da7f506d7b03a261f24cd43d090ea9db9a1dc59d9313914c"},
+ {file = "ruff-0.6.9-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:645d7d8761f915e48a00d4ecc3686969761df69fb561dd914a773c1a8266e14e"},
+ {file = "ruff-0.6.9-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:eae02b700763e3847595b9d2891488989cac00214da7f845f4bcf2989007d577"},
+ {file = "ruff-0.6.9-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7d5ccc9e58112441de8ad4b29dcb7a86dc25c5f770e3c06a9d57e0e5eba48829"},
+ {file = "ruff-0.6.9-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:417b81aa1c9b60b2f8edc463c58363075412866ae4e2b9ab0f690dc1e87ac1b5"},
+ {file = "ruff-0.6.9-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3c866b631f5fbce896a74a6e4383407ba7507b815ccc52bcedabb6810fdb3ef7"},
+ {file = "ruff-0.6.9-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:7b118afbb3202f5911486ad52da86d1d52305b59e7ef2031cea3425142b97d6f"},
+ {file = "ruff-0.6.9-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a67267654edc23c97335586774790cde402fb6bbdb3c2314f1fc087dee320bfa"},
+ {file = "ruff-0.6.9-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:3ef0cc774b00fec123f635ce5c547dac263f6ee9fb9cc83437c5904183b55ceb"},
+ {file = "ruff-0.6.9-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:12edd2af0c60fa61ff31cefb90aef4288ac4d372b4962c2864aeea3a1a2460c0"},
+ {file = "ruff-0.6.9-py3-none-musllinux_1_2_i686.whl", hash = "sha256:55bb01caeaf3a60b2b2bba07308a02fca6ab56233302406ed5245180a05c5625"},
+ {file = "ruff-0.6.9-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:925d26471fa24b0ce5a6cdfab1bb526fb4159952385f386bdcc643813d472039"},
+ {file = "ruff-0.6.9-py3-none-win32.whl", hash = "sha256:eb61ec9bdb2506cffd492e05ac40e5bc6284873aceb605503d8494180d6fc84d"},
+ {file = "ruff-0.6.9-py3-none-win_amd64.whl", hash = "sha256:785d31851c1ae91f45b3d8fe23b8ae4b5170089021fbb42402d811135f0b7117"},
+ {file = "ruff-0.6.9-py3-none-win_arm64.whl", hash = "sha256:a9641e31476d601f83cd602608739a0840e348bda93fec9f1ee816f8b6798b93"},
+ {file = "ruff-0.6.9.tar.gz", hash = "sha256:b076ef717a8e5bc819514ee1d602bbdca5b4420ae13a9cf61a0c0a4f53a2baa2"},
+]
+
+[[package]]
+name = "s3transfer"
+version = "0.11.3"
+description = "An Amazon S3 Transfer Manager"
+optional = true
+python-versions = ">=3.8"
+groups = ["main"]
+markers = "extra == \"bedrock\""
+files = [
+ {file = "s3transfer-0.11.3-py3-none-any.whl", hash = "sha256:ca855bdeb885174b5ffa95b9913622459d4ad8e331fc98eb01e6d5eb6a30655d"},
+ {file = "s3transfer-0.11.3.tar.gz", hash = "sha256:edae4977e3a122445660c7c114bba949f9d191bae3b34a096f18a1c8c354527a"},
+]
+
+[package.dependencies]
+botocore = ">=1.36.0,<2.0a.0"
+
+[package.extras]
+crt = ["botocore[crt] (>=1.36.0,<2.0a.0)"]
+
+[[package]]
+name = "shellingham"
+version = "1.5.4"
+description = "Tool to Detect Surrounding Shell"
+optional = false
+python-versions = ">=3.7"
+groups = ["main"]
+files = [
+ {file = "shellingham-1.5.4-py2.py3-none-any.whl", hash = "sha256:7ecfff8f2fd72616f7481040475a65b2bf8af90a56c89140852d1120324e8686"},
+ {file = "shellingham-1.5.4.tar.gz", hash = "sha256:8dbca0739d487e5bd35ab3ca4b36e11c4078f3a234bfce294b0a0291363404de"},
+]
+
+[[package]]
+name = "shortuuid"
+version = "1.0.13"
+description = "A generator library for concise, unambiguous and URL-safe UUIDs."
+optional = false
+python-versions = ">=3.6"
+groups = ["main"]
+files = [
+ {file = "shortuuid-1.0.13-py3-none-any.whl", hash = "sha256:a482a497300b49b4953e15108a7913244e1bb0d41f9d332f5e9925dba33a3c5a"},
+ {file = "shortuuid-1.0.13.tar.gz", hash = "sha256:3bb9cf07f606260584b1df46399c0b87dd84773e7b25912b7e391e30797c5e72"},
+]
+
+[[package]]
+name = "six"
+version = "1.17.0"
+description = "Python 2 and 3 compatibility utilities"
+optional = false
+python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7"
+groups = ["main"]
+files = [
+ {file = "six-1.17.0-py2.py3-none-any.whl", hash = "sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274"},
+ {file = "six-1.17.0.tar.gz", hash = "sha256:ff70335d468e7eb6ec65b95b99d3a2836546063f63acc5171de367e834932a81"},
+]
+
+[[package]]
+name = "sniffio"
+version = "1.3.1"
+description = "Sniff out which async library your code is running under"
+optional = false
+python-versions = ">=3.7"
+groups = ["main"]
+files = [
+ {file = "sniffio-1.3.1-py3-none-any.whl", hash = "sha256:2f6da418d1f1e0fddd844478f41680e794e6051915791a034ff65e5f100525a2"},
+ {file = "sniffio-1.3.1.tar.gz", hash = "sha256:f4324edc670a0f49750a81b895f35c3adb843cca46f0530f79fc1babb23789dc"},
+]
+
+[[package]]
+name = "tenacity"
+version = "9.1.2"
+description = "Retry code until it succeeds"
+optional = false
+python-versions = ">=3.9"
+groups = ["main"]
+files = [
+ {file = "tenacity-9.1.2-py3-none-any.whl", hash = "sha256:f77bf36710d8b73a50b2dd155c97b870017ad21afe6ab300326b0371b3b05138"},
+ {file = "tenacity-9.1.2.tar.gz", hash = "sha256:1169d376c297e7de388d18b4481760d478b0e99a777cad3a9c86e556f4b697cb"},
+]
+
+[package.extras]
+doc = ["reno", "sphinx"]
+test = ["pytest", "tornado (>=4.5)", "typeguard"]
+
+[[package]]
+name = "toml"
+version = "0.10.2"
+description = "Python Library for Tom's Obvious, Minimal Language"
+optional = false
+python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*"
+groups = ["main"]
+files = [
+ {file = "toml-0.10.2-py2.py3-none-any.whl", hash = "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"},
+ {file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"},
+]
+
+[[package]]
+name = "tqdm"
+version = "4.67.1"
+description = "Fast, Extensible Progress Meter"
+optional = false
+python-versions = ">=3.7"
+groups = ["main"]
+files = [
+ {file = "tqdm-4.67.1-py3-none-any.whl", hash = "sha256:26445eca388f82e72884e0d580d5464cd801a3ea01e63e5601bdff9ba6a48de2"},
+ {file = "tqdm-4.67.1.tar.gz", hash = "sha256:f8aef9c52c08c13a65f30ea34f4e5aac3fd1a34959879d7e59e63027286627f2"},
+]
+
+[package.dependencies]
+colorama = {version = "*", markers = "platform_system == \"Windows\""}
+
+[package.extras]
+dev = ["nbval", "pytest (>=6)", "pytest-asyncio (>=0.24)", "pytest-cov", "pytest-timeout"]
+discord = ["requests"]
+notebook = ["ipywidgets (>=6)"]
+slack = ["slack-sdk"]
+telegram = ["requests"]
+
+[[package]]
+name = "typer"
+version = "0.12.5"
+description = "Typer, build great CLIs. Easy to code. Based on Python type hints."
+optional = false
+python-versions = ">=3.7"
+groups = ["main"]
+files = [
+ {file = "typer-0.12.5-py3-none-any.whl", hash = "sha256:62fe4e471711b147e3365034133904df3e235698399bc4de2b36c8579298d52b"},
+ {file = "typer-0.12.5.tar.gz", hash = "sha256:f592f089bedcc8ec1b974125d64851029c3b1af145f04aca64d69410f0c9b722"},
+]
+
+[package.dependencies]
+click = ">=8.0.0"
+rich = ">=10.11.0"
+shellingham = ">=1.3.0"
+typing-extensions = ">=3.7.4.3"
+
+[[package]]
+name = "types-aioboto3"
+version = "13.4.0"
+description = "Type annotations for aioboto3 13.4.0 generated with mypy-boto3-builder 8.8.0"
+optional = false
+python-versions = ">=3.8"
+groups = ["dev"]
+files = [
+ {file = "types_aioboto3-13.4.0-py3-none-any.whl", hash = "sha256:73749e313eb3c64523efdefdf2e76d6ea5112298cf3e10074e3981a982ca7f36"},
+ {file = "types_aioboto3-13.4.0.tar.gz", hash = "sha256:c313ff9f02b00b311decdc6d24b34e504b36871ee3b7d8b11a4a7fc15bde1b96"},
+]
+
+[package.dependencies]
+botocore-stubs = "*"
+types-aiobotocore = "*"
+types-aiobotocore-bedrock = {version = ">=2.18.0,<2.19.0", optional = true, markers = "extra == \"bedrock\""}
+types-aiobotocore-bedrock-runtime = {version = ">=2.18.0,<2.19.0", optional = true, markers = "extra == \"bedrock-runtime\""}
+types-s3transfer = "*"
+typing-extensions = {version = ">=4.1.0", markers = "python_version < \"3.12\""}
+
+[package.extras]
+accessanalyzer = ["types-aiobotocore-accessanalyzer (>=2.18.0,<2.19.0)"]
+account = ["types-aiobotocore-account (>=2.18.0,<2.19.0)"]
+acm = ["types-aiobotocore-acm (>=2.18.0,<2.19.0)"]
+acm-pca = ["types-aiobotocore-acm-pca (>=2.18.0,<2.19.0)"]
+aioboto3 = ["aioboto3 (==13.4.0)"]
+all = ["types-aiobotocore-accessanalyzer (>=2.18.0,<2.19.0)", "types-aiobotocore-account (>=2.18.0,<2.19.0)", "types-aiobotocore-acm (>=2.18.0,<2.19.0)", "types-aiobotocore-acm-pca (>=2.18.0,<2.19.0)", "types-aiobotocore-amp (>=2.18.0,<2.19.0)", "types-aiobotocore-amplify (>=2.18.0,<2.19.0)", "types-aiobotocore-amplifybackend (>=2.18.0,<2.19.0)", "types-aiobotocore-amplifyuibuilder (>=2.18.0,<2.19.0)", "types-aiobotocore-apigateway (>=2.18.0,<2.19.0)", "types-aiobotocore-apigatewaymanagementapi (>=2.18.0,<2.19.0)", "types-aiobotocore-apigatewayv2 (>=2.18.0,<2.19.0)", "types-aiobotocore-appconfig (>=2.18.0,<2.19.0)", "types-aiobotocore-appconfigdata (>=2.18.0,<2.19.0)", "types-aiobotocore-appfabric (>=2.18.0,<2.19.0)", "types-aiobotocore-appflow (>=2.18.0,<2.19.0)", "types-aiobotocore-appintegrations (>=2.18.0,<2.19.0)", "types-aiobotocore-application-autoscaling (>=2.18.0,<2.19.0)", "types-aiobotocore-application-insights (>=2.18.0,<2.19.0)", "types-aiobotocore-application-signals (>=2.18.0,<2.19.0)", "types-aiobotocore-applicationcostprofiler (>=2.18.0,<2.19.0)", "types-aiobotocore-appmesh (>=2.18.0,<2.19.0)", "types-aiobotocore-apprunner (>=2.18.0,<2.19.0)", "types-aiobotocore-appstream (>=2.18.0,<2.19.0)", "types-aiobotocore-appsync (>=2.18.0,<2.19.0)", "types-aiobotocore-apptest (>=2.18.0,<2.19.0)", "types-aiobotocore-arc-zonal-shift (>=2.18.0,<2.19.0)", "types-aiobotocore-artifact (>=2.18.0,<2.19.0)", "types-aiobotocore-athena (>=2.18.0,<2.19.0)", "types-aiobotocore-auditmanager (>=2.18.0,<2.19.0)", "types-aiobotocore-autoscaling (>=2.18.0,<2.19.0)", "types-aiobotocore-autoscaling-plans (>=2.18.0,<2.19.0)", "types-aiobotocore-b2bi (>=2.18.0,<2.19.0)", "types-aiobotocore-backup (>=2.18.0,<2.19.0)", "types-aiobotocore-backup-gateway (>=2.18.0,<2.19.0)", "types-aiobotocore-backupsearch (>=2.18.0,<2.19.0)", "types-aiobotocore-batch (>=2.18.0,<2.19.0)", "types-aiobotocore-bcm-data-exports (>=2.18.0,<2.19.0)", "types-aiobotocore-bcm-pricing-calculator (>=2.18.0,<2.19.0)", "types-aiobotocore-bedrock (>=2.18.0,<2.19.0)", "types-aiobotocore-bedrock-agent (>=2.18.0,<2.19.0)", "types-aiobotocore-bedrock-agent-runtime (>=2.18.0,<2.19.0)", "types-aiobotocore-bedrock-data-automation (>=2.18.0,<2.19.0)", "types-aiobotocore-bedrock-data-automation-runtime (>=2.18.0,<2.19.0)", "types-aiobotocore-bedrock-runtime (>=2.18.0,<2.19.0)", "types-aiobotocore-billing (>=2.18.0,<2.19.0)", "types-aiobotocore-billingconductor (>=2.18.0,<2.19.0)", "types-aiobotocore-braket (>=2.18.0,<2.19.0)", "types-aiobotocore-budgets (>=2.18.0,<2.19.0)", "types-aiobotocore-ce (>=2.18.0,<2.19.0)", "types-aiobotocore-chatbot (>=2.18.0,<2.19.0)", "types-aiobotocore-chime (>=2.18.0,<2.19.0)", "types-aiobotocore-chime-sdk-identity (>=2.18.0,<2.19.0)", "types-aiobotocore-chime-sdk-media-pipelines (>=2.18.0,<2.19.0)", "types-aiobotocore-chime-sdk-meetings (>=2.18.0,<2.19.0)", "types-aiobotocore-chime-sdk-messaging (>=2.18.0,<2.19.0)", "types-aiobotocore-chime-sdk-voice (>=2.18.0,<2.19.0)", "types-aiobotocore-cleanrooms (>=2.18.0,<2.19.0)", "types-aiobotocore-cleanroomsml (>=2.18.0,<2.19.0)", "types-aiobotocore-cloud9 (>=2.18.0,<2.19.0)", "types-aiobotocore-cloudcontrol (>=2.18.0,<2.19.0)", "types-aiobotocore-clouddirectory (>=2.18.0,<2.19.0)", "types-aiobotocore-cloudformation (>=2.18.0,<2.19.0)", "types-aiobotocore-cloudfront (>=2.18.0,<2.19.0)", "types-aiobotocore-cloudfront-keyvaluestore (>=2.18.0,<2.19.0)", "types-aiobotocore-cloudhsm (>=2.18.0,<2.19.0)", "types-aiobotocore-cloudhsmv2 (>=2.18.0,<2.19.0)", "types-aiobotocore-cloudsearch (>=2.18.0,<2.19.0)", "types-aiobotocore-cloudsearchdomain (>=2.18.0,<2.19.0)", "types-aiobotocore-cloudtrail (>=2.18.0,<2.19.0)", "types-aiobotocore-cloudtrail-data (>=2.18.0,<2.19.0)", "types-aiobotocore-cloudwatch (>=2.18.0,<2.19.0)", "types-aiobotocore-codeartifact (>=2.18.0,<2.19.0)", "types-aiobotocore-codebuild (>=2.18.0,<2.19.0)", "types-aiobotocore-codecatalyst (>=2.18.0,<2.19.0)", "types-aiobotocore-codecommit (>=2.18.0,<2.19.0)", "types-aiobotocore-codeconnections (>=2.18.0,<2.19.0)", "types-aiobotocore-codedeploy (>=2.18.0,<2.19.0)", "types-aiobotocore-codeguru-reviewer (>=2.18.0,<2.19.0)", "types-aiobotocore-codeguru-security (>=2.18.0,<2.19.0)", "types-aiobotocore-codeguruprofiler (>=2.18.0,<2.19.0)", "types-aiobotocore-codepipeline (>=2.18.0,<2.19.0)", "types-aiobotocore-codestar-connections (>=2.18.0,<2.19.0)", "types-aiobotocore-codestar-notifications (>=2.18.0,<2.19.0)", "types-aiobotocore-cognito-identity (>=2.18.0,<2.19.0)", "types-aiobotocore-cognito-idp (>=2.18.0,<2.19.0)", "types-aiobotocore-cognito-sync (>=2.18.0,<2.19.0)", "types-aiobotocore-comprehend (>=2.18.0,<2.19.0)", "types-aiobotocore-comprehendmedical (>=2.18.0,<2.19.0)", "types-aiobotocore-compute-optimizer (>=2.18.0,<2.19.0)", "types-aiobotocore-config (>=2.18.0,<2.19.0)", "types-aiobotocore-connect (>=2.18.0,<2.19.0)", "types-aiobotocore-connect-contact-lens (>=2.18.0,<2.19.0)", "types-aiobotocore-connectcampaigns (>=2.18.0,<2.19.0)", "types-aiobotocore-connectcampaignsv2 (>=2.18.0,<2.19.0)", "types-aiobotocore-connectcases (>=2.18.0,<2.19.0)", "types-aiobotocore-connectparticipant (>=2.18.0,<2.19.0)", "types-aiobotocore-controlcatalog (>=2.18.0,<2.19.0)", "types-aiobotocore-controltower (>=2.18.0,<2.19.0)", "types-aiobotocore-cost-optimization-hub (>=2.18.0,<2.19.0)", "types-aiobotocore-cur (>=2.18.0,<2.19.0)", "types-aiobotocore-customer-profiles (>=2.18.0,<2.19.0)", "types-aiobotocore-databrew (>=2.18.0,<2.19.0)", "types-aiobotocore-dataexchange (>=2.18.0,<2.19.0)", "types-aiobotocore-datapipeline (>=2.18.0,<2.19.0)", "types-aiobotocore-datasync (>=2.18.0,<2.19.0)", "types-aiobotocore-datazone (>=2.18.0,<2.19.0)", "types-aiobotocore-dax (>=2.18.0,<2.19.0)", "types-aiobotocore-deadline (>=2.18.0,<2.19.0)", "types-aiobotocore-detective (>=2.18.0,<2.19.0)", "types-aiobotocore-devicefarm (>=2.18.0,<2.19.0)", "types-aiobotocore-devops-guru (>=2.18.0,<2.19.0)", "types-aiobotocore-directconnect (>=2.18.0,<2.19.0)", "types-aiobotocore-discovery (>=2.18.0,<2.19.0)", "types-aiobotocore-dlm (>=2.18.0,<2.19.0)", "types-aiobotocore-dms (>=2.18.0,<2.19.0)", "types-aiobotocore-docdb (>=2.18.0,<2.19.0)", "types-aiobotocore-docdb-elastic (>=2.18.0,<2.19.0)", "types-aiobotocore-drs (>=2.18.0,<2.19.0)", "types-aiobotocore-ds (>=2.18.0,<2.19.0)", "types-aiobotocore-ds-data (>=2.18.0,<2.19.0)", "types-aiobotocore-dsql (>=2.18.0,<2.19.0)", "types-aiobotocore-dynamodb (>=2.18.0,<2.19.0)", "types-aiobotocore-dynamodbstreams (>=2.18.0,<2.19.0)", "types-aiobotocore-ebs (>=2.18.0,<2.19.0)", "types-aiobotocore-ec2 (>=2.18.0,<2.19.0)", "types-aiobotocore-ec2-instance-connect (>=2.18.0,<2.19.0)", "types-aiobotocore-ecr (>=2.18.0,<2.19.0)", "types-aiobotocore-ecr-public (>=2.18.0,<2.19.0)", "types-aiobotocore-ecs (>=2.18.0,<2.19.0)", "types-aiobotocore-efs (>=2.18.0,<2.19.0)", "types-aiobotocore-eks (>=2.18.0,<2.19.0)", "types-aiobotocore-eks-auth (>=2.18.0,<2.19.0)", "types-aiobotocore-elastic-inference (>=2.18.0,<2.19.0)", "types-aiobotocore-elasticache (>=2.18.0,<2.19.0)", "types-aiobotocore-elasticbeanstalk (>=2.18.0,<2.19.0)", "types-aiobotocore-elastictranscoder (>=2.18.0,<2.19.0)", "types-aiobotocore-elb (>=2.18.0,<2.19.0)", "types-aiobotocore-elbv2 (>=2.18.0,<2.19.0)", "types-aiobotocore-emr (>=2.18.0,<2.19.0)", "types-aiobotocore-emr-containers (>=2.18.0,<2.19.0)", "types-aiobotocore-emr-serverless (>=2.18.0,<2.19.0)", "types-aiobotocore-entityresolution (>=2.18.0,<2.19.0)", "types-aiobotocore-es (>=2.18.0,<2.19.0)", "types-aiobotocore-events (>=2.18.0,<2.19.0)", "types-aiobotocore-evidently (>=2.18.0,<2.19.0)", "types-aiobotocore-finspace (>=2.18.0,<2.19.0)", "types-aiobotocore-finspace-data (>=2.18.0,<2.19.0)", "types-aiobotocore-firehose (>=2.18.0,<2.19.0)", "types-aiobotocore-fis (>=2.18.0,<2.19.0)", "types-aiobotocore-fms (>=2.18.0,<2.19.0)", "types-aiobotocore-forecast (>=2.18.0,<2.19.0)", "types-aiobotocore-forecastquery (>=2.18.0,<2.19.0)", "types-aiobotocore-frauddetector (>=2.18.0,<2.19.0)", "types-aiobotocore-freetier (>=2.18.0,<2.19.0)", "types-aiobotocore-fsx (>=2.18.0,<2.19.0)", "types-aiobotocore-gamelift (>=2.18.0,<2.19.0)", "types-aiobotocore-geo-maps (>=2.18.0,<2.19.0)", "types-aiobotocore-geo-places (>=2.18.0,<2.19.0)", "types-aiobotocore-geo-routes (>=2.18.0,<2.19.0)", "types-aiobotocore-glacier (>=2.18.0,<2.19.0)", "types-aiobotocore-globalaccelerator (>=2.18.0,<2.19.0)", "types-aiobotocore-glue (>=2.18.0,<2.19.0)", "types-aiobotocore-grafana (>=2.18.0,<2.19.0)", "types-aiobotocore-greengrass (>=2.18.0,<2.19.0)", "types-aiobotocore-greengrassv2 (>=2.18.0,<2.19.0)", "types-aiobotocore-groundstation (>=2.18.0,<2.19.0)", "types-aiobotocore-guardduty (>=2.18.0,<2.19.0)", "types-aiobotocore-health (>=2.18.0,<2.19.0)", "types-aiobotocore-healthlake (>=2.18.0,<2.19.0)", "types-aiobotocore-iam (>=2.18.0,<2.19.0)", "types-aiobotocore-identitystore (>=2.18.0,<2.19.0)", "types-aiobotocore-imagebuilder (>=2.18.0,<2.19.0)", "types-aiobotocore-importexport (>=2.18.0,<2.19.0)", "types-aiobotocore-inspector (>=2.18.0,<2.19.0)", "types-aiobotocore-inspector-scan (>=2.18.0,<2.19.0)", "types-aiobotocore-inspector2 (>=2.18.0,<2.19.0)", "types-aiobotocore-internetmonitor (>=2.18.0,<2.19.0)", "types-aiobotocore-invoicing (>=2.18.0,<2.19.0)", "types-aiobotocore-iot (>=2.18.0,<2.19.0)", "types-aiobotocore-iot-data (>=2.18.0,<2.19.0)", "types-aiobotocore-iot-jobs-data (>=2.18.0,<2.19.0)", "types-aiobotocore-iotanalytics (>=2.18.0,<2.19.0)", "types-aiobotocore-iotdeviceadvisor (>=2.18.0,<2.19.0)", "types-aiobotocore-iotevents (>=2.18.0,<2.19.0)", "types-aiobotocore-iotevents-data (>=2.18.0,<2.19.0)", "types-aiobotocore-iotfleethub (>=2.18.0,<2.19.0)", "types-aiobotocore-iotfleetwise (>=2.18.0,<2.19.0)", "types-aiobotocore-iotsecuretunneling (>=2.18.0,<2.19.0)", "types-aiobotocore-iotsitewise (>=2.18.0,<2.19.0)", "types-aiobotocore-iotthingsgraph (>=2.18.0,<2.19.0)", "types-aiobotocore-iottwinmaker (>=2.18.0,<2.19.0)", "types-aiobotocore-iotwireless (>=2.18.0,<2.19.0)", "types-aiobotocore-ivs (>=2.18.0,<2.19.0)", "types-aiobotocore-ivs-realtime (>=2.18.0,<2.19.0)", "types-aiobotocore-ivschat (>=2.18.0,<2.19.0)", "types-aiobotocore-kafka (>=2.18.0,<2.19.0)", "types-aiobotocore-kafkaconnect (>=2.18.0,<2.19.0)", "types-aiobotocore-kendra (>=2.18.0,<2.19.0)", "types-aiobotocore-kendra-ranking (>=2.18.0,<2.19.0)", "types-aiobotocore-keyspaces (>=2.18.0,<2.19.0)", "types-aiobotocore-kinesis (>=2.18.0,<2.19.0)", "types-aiobotocore-kinesis-video-archived-media (>=2.18.0,<2.19.0)", "types-aiobotocore-kinesis-video-media (>=2.18.0,<2.19.0)", "types-aiobotocore-kinesis-video-signaling (>=2.18.0,<2.19.0)", "types-aiobotocore-kinesis-video-webrtc-storage (>=2.18.0,<2.19.0)", "types-aiobotocore-kinesisanalytics (>=2.18.0,<2.19.0)", "types-aiobotocore-kinesisanalyticsv2 (>=2.18.0,<2.19.0)", "types-aiobotocore-kinesisvideo (>=2.18.0,<2.19.0)", "types-aiobotocore-kms (>=2.18.0,<2.19.0)", "types-aiobotocore-lakeformation (>=2.18.0,<2.19.0)", "types-aiobotocore-lambda (>=2.18.0,<2.19.0)", "types-aiobotocore-launch-wizard (>=2.18.0,<2.19.0)", "types-aiobotocore-lex-models (>=2.18.0,<2.19.0)", "types-aiobotocore-lex-runtime (>=2.18.0,<2.19.0)", "types-aiobotocore-lexv2-models (>=2.18.0,<2.19.0)", "types-aiobotocore-lexv2-runtime (>=2.18.0,<2.19.0)", "types-aiobotocore-license-manager (>=2.18.0,<2.19.0)", "types-aiobotocore-license-manager-linux-subscriptions (>=2.18.0,<2.19.0)", "types-aiobotocore-license-manager-user-subscriptions (>=2.18.0,<2.19.0)", "types-aiobotocore-lightsail (>=2.18.0,<2.19.0)", "types-aiobotocore-location (>=2.18.0,<2.19.0)", "types-aiobotocore-logs (>=2.18.0,<2.19.0)", "types-aiobotocore-lookoutequipment (>=2.18.0,<2.19.0)", "types-aiobotocore-lookoutmetrics (>=2.18.0,<2.19.0)", "types-aiobotocore-lookoutvision (>=2.18.0,<2.19.0)", "types-aiobotocore-m2 (>=2.18.0,<2.19.0)", "types-aiobotocore-machinelearning (>=2.18.0,<2.19.0)", "types-aiobotocore-macie2 (>=2.18.0,<2.19.0)", "types-aiobotocore-mailmanager (>=2.18.0,<2.19.0)", "types-aiobotocore-managedblockchain (>=2.18.0,<2.19.0)", "types-aiobotocore-managedblockchain-query (>=2.18.0,<2.19.0)", "types-aiobotocore-marketplace-agreement (>=2.18.0,<2.19.0)", "types-aiobotocore-marketplace-catalog (>=2.18.0,<2.19.0)", "types-aiobotocore-marketplace-deployment (>=2.18.0,<2.19.0)", "types-aiobotocore-marketplace-entitlement (>=2.18.0,<2.19.0)", "types-aiobotocore-marketplace-reporting (>=2.18.0,<2.19.0)", "types-aiobotocore-marketplacecommerceanalytics (>=2.18.0,<2.19.0)", "types-aiobotocore-mediaconnect (>=2.18.0,<2.19.0)", "types-aiobotocore-mediaconvert (>=2.18.0,<2.19.0)", "types-aiobotocore-medialive (>=2.18.0,<2.19.0)", "types-aiobotocore-mediapackage (>=2.18.0,<2.19.0)", "types-aiobotocore-mediapackage-vod (>=2.18.0,<2.19.0)", "types-aiobotocore-mediapackagev2 (>=2.18.0,<2.19.0)", "types-aiobotocore-mediastore (>=2.18.0,<2.19.0)", "types-aiobotocore-mediastore-data (>=2.18.0,<2.19.0)", "types-aiobotocore-mediatailor (>=2.18.0,<2.19.0)", "types-aiobotocore-medical-imaging (>=2.18.0,<2.19.0)", "types-aiobotocore-memorydb (>=2.18.0,<2.19.0)", "types-aiobotocore-meteringmarketplace (>=2.18.0,<2.19.0)", "types-aiobotocore-mgh (>=2.18.0,<2.19.0)", "types-aiobotocore-mgn (>=2.18.0,<2.19.0)", "types-aiobotocore-migration-hub-refactor-spaces (>=2.18.0,<2.19.0)", "types-aiobotocore-migrationhub-config (>=2.18.0,<2.19.0)", "types-aiobotocore-migrationhuborchestrator (>=2.18.0,<2.19.0)", "types-aiobotocore-migrationhubstrategy (>=2.18.0,<2.19.0)", "types-aiobotocore-mq (>=2.18.0,<2.19.0)", "types-aiobotocore-mturk (>=2.18.0,<2.19.0)", "types-aiobotocore-mwaa (>=2.18.0,<2.19.0)", "types-aiobotocore-neptune (>=2.18.0,<2.19.0)", "types-aiobotocore-neptune-graph (>=2.18.0,<2.19.0)", "types-aiobotocore-neptunedata (>=2.18.0,<2.19.0)", "types-aiobotocore-network-firewall (>=2.18.0,<2.19.0)", "types-aiobotocore-networkflowmonitor (>=2.18.0,<2.19.0)", "types-aiobotocore-networkmanager (>=2.18.0,<2.19.0)", "types-aiobotocore-networkmonitor (>=2.18.0,<2.19.0)", "types-aiobotocore-notifications (>=2.18.0,<2.19.0)", "types-aiobotocore-notificationscontacts (>=2.18.0,<2.19.0)", "types-aiobotocore-oam (>=2.18.0,<2.19.0)", "types-aiobotocore-observabilityadmin (>=2.18.0,<2.19.0)", "types-aiobotocore-omics (>=2.18.0,<2.19.0)", "types-aiobotocore-opensearch (>=2.18.0,<2.19.0)", "types-aiobotocore-opensearchserverless (>=2.18.0,<2.19.0)", "types-aiobotocore-opsworks (>=2.18.0,<2.19.0)", "types-aiobotocore-opsworkscm (>=2.18.0,<2.19.0)", "types-aiobotocore-organizations (>=2.18.0,<2.19.0)", "types-aiobotocore-osis (>=2.18.0,<2.19.0)", "types-aiobotocore-outposts (>=2.18.0,<2.19.0)", "types-aiobotocore-panorama (>=2.18.0,<2.19.0)", "types-aiobotocore-partnercentral-selling (>=2.18.0,<2.19.0)", "types-aiobotocore-payment-cryptography (>=2.18.0,<2.19.0)", "types-aiobotocore-payment-cryptography-data (>=2.18.0,<2.19.0)", "types-aiobotocore-pca-connector-ad (>=2.18.0,<2.19.0)", "types-aiobotocore-pca-connector-scep (>=2.18.0,<2.19.0)", "types-aiobotocore-pcs (>=2.18.0,<2.19.0)", "types-aiobotocore-personalize (>=2.18.0,<2.19.0)", "types-aiobotocore-personalize-events (>=2.18.0,<2.19.0)", "types-aiobotocore-personalize-runtime (>=2.18.0,<2.19.0)", "types-aiobotocore-pi (>=2.18.0,<2.19.0)", "types-aiobotocore-pinpoint (>=2.18.0,<2.19.0)", "types-aiobotocore-pinpoint-email (>=2.18.0,<2.19.0)", "types-aiobotocore-pinpoint-sms-voice (>=2.18.0,<2.19.0)", "types-aiobotocore-pinpoint-sms-voice-v2 (>=2.18.0,<2.19.0)", "types-aiobotocore-pipes (>=2.18.0,<2.19.0)", "types-aiobotocore-polly (>=2.18.0,<2.19.0)", "types-aiobotocore-pricing (>=2.18.0,<2.19.0)", "types-aiobotocore-privatenetworks (>=2.18.0,<2.19.0)", "types-aiobotocore-proton (>=2.18.0,<2.19.0)", "types-aiobotocore-qapps (>=2.18.0,<2.19.0)", "types-aiobotocore-qbusiness (>=2.18.0,<2.19.0)", "types-aiobotocore-qconnect (>=2.18.0,<2.19.0)", "types-aiobotocore-qldb (>=2.18.0,<2.19.0)", "types-aiobotocore-qldb-session (>=2.18.0,<2.19.0)", "types-aiobotocore-quicksight (>=2.18.0,<2.19.0)", "types-aiobotocore-ram (>=2.18.0,<2.19.0)", "types-aiobotocore-rbin (>=2.18.0,<2.19.0)", "types-aiobotocore-rds (>=2.18.0,<2.19.0)", "types-aiobotocore-rds-data (>=2.18.0,<2.19.0)", "types-aiobotocore-redshift (>=2.18.0,<2.19.0)", "types-aiobotocore-redshift-data (>=2.18.0,<2.19.0)", "types-aiobotocore-redshift-serverless (>=2.18.0,<2.19.0)", "types-aiobotocore-rekognition (>=2.18.0,<2.19.0)", "types-aiobotocore-repostspace (>=2.18.0,<2.19.0)", "types-aiobotocore-resiliencehub (>=2.18.0,<2.19.0)", "types-aiobotocore-resource-explorer-2 (>=2.18.0,<2.19.0)", "types-aiobotocore-resource-groups (>=2.18.0,<2.19.0)", "types-aiobotocore-resourcegroupstaggingapi (>=2.18.0,<2.19.0)", "types-aiobotocore-robomaker (>=2.18.0,<2.19.0)", "types-aiobotocore-rolesanywhere (>=2.18.0,<2.19.0)", "types-aiobotocore-route53 (>=2.18.0,<2.19.0)", "types-aiobotocore-route53-recovery-cluster (>=2.18.0,<2.19.0)", "types-aiobotocore-route53-recovery-control-config (>=2.18.0,<2.19.0)", "types-aiobotocore-route53-recovery-readiness (>=2.18.0,<2.19.0)", "types-aiobotocore-route53domains (>=2.18.0,<2.19.0)", "types-aiobotocore-route53profiles (>=2.18.0,<2.19.0)", "types-aiobotocore-route53resolver (>=2.18.0,<2.19.0)", "types-aiobotocore-rum (>=2.18.0,<2.19.0)", "types-aiobotocore-s3 (>=2.18.0,<2.19.0)", "types-aiobotocore-s3control (>=2.18.0,<2.19.0)", "types-aiobotocore-s3outposts (>=2.18.0,<2.19.0)", "types-aiobotocore-s3tables (>=2.18.0,<2.19.0)", "types-aiobotocore-sagemaker (>=2.18.0,<2.19.0)", "types-aiobotocore-sagemaker-a2i-runtime (>=2.18.0,<2.19.0)", "types-aiobotocore-sagemaker-edge (>=2.18.0,<2.19.0)", "types-aiobotocore-sagemaker-featurestore-runtime (>=2.18.0,<2.19.0)", "types-aiobotocore-sagemaker-geospatial (>=2.18.0,<2.19.0)", "types-aiobotocore-sagemaker-metrics (>=2.18.0,<2.19.0)", "types-aiobotocore-sagemaker-runtime (>=2.18.0,<2.19.0)", "types-aiobotocore-savingsplans (>=2.18.0,<2.19.0)", "types-aiobotocore-scheduler (>=2.18.0,<2.19.0)", "types-aiobotocore-schemas (>=2.18.0,<2.19.0)", "types-aiobotocore-sdb (>=2.18.0,<2.19.0)", "types-aiobotocore-secretsmanager (>=2.18.0,<2.19.0)", "types-aiobotocore-security-ir (>=2.18.0,<2.19.0)", "types-aiobotocore-securityhub (>=2.18.0,<2.19.0)", "types-aiobotocore-securitylake (>=2.18.0,<2.19.0)", "types-aiobotocore-serverlessrepo (>=2.18.0,<2.19.0)", "types-aiobotocore-service-quotas (>=2.18.0,<2.19.0)", "types-aiobotocore-servicecatalog (>=2.18.0,<2.19.0)", "types-aiobotocore-servicecatalog-appregistry (>=2.18.0,<2.19.0)", "types-aiobotocore-servicediscovery (>=2.18.0,<2.19.0)", "types-aiobotocore-ses (>=2.18.0,<2.19.0)", "types-aiobotocore-sesv2 (>=2.18.0,<2.19.0)", "types-aiobotocore-shield (>=2.18.0,<2.19.0)", "types-aiobotocore-signer (>=2.18.0,<2.19.0)", "types-aiobotocore-simspaceweaver (>=2.18.0,<2.19.0)", "types-aiobotocore-sms (>=2.18.0,<2.19.0)", "types-aiobotocore-sms-voice (>=2.18.0,<2.19.0)", "types-aiobotocore-snow-device-management (>=2.18.0,<2.19.0)", "types-aiobotocore-snowball (>=2.18.0,<2.19.0)", "types-aiobotocore-sns (>=2.18.0,<2.19.0)", "types-aiobotocore-socialmessaging (>=2.18.0,<2.19.0)", "types-aiobotocore-sqs (>=2.18.0,<2.19.0)", "types-aiobotocore-ssm (>=2.18.0,<2.19.0)", "types-aiobotocore-ssm-contacts (>=2.18.0,<2.19.0)", "types-aiobotocore-ssm-incidents (>=2.18.0,<2.19.0)", "types-aiobotocore-ssm-quicksetup (>=2.18.0,<2.19.0)", "types-aiobotocore-ssm-sap (>=2.18.0,<2.19.0)", "types-aiobotocore-sso (>=2.18.0,<2.19.0)", "types-aiobotocore-sso-admin (>=2.18.0,<2.19.0)", "types-aiobotocore-sso-oidc (>=2.18.0,<2.19.0)", "types-aiobotocore-stepfunctions (>=2.18.0,<2.19.0)", "types-aiobotocore-storagegateway (>=2.18.0,<2.19.0)", "types-aiobotocore-sts (>=2.18.0,<2.19.0)", "types-aiobotocore-supplychain (>=2.18.0,<2.19.0)", "types-aiobotocore-support (>=2.18.0,<2.19.0)", "types-aiobotocore-support-app (>=2.18.0,<2.19.0)", "types-aiobotocore-swf (>=2.18.0,<2.19.0)", "types-aiobotocore-synthetics (>=2.18.0,<2.19.0)", "types-aiobotocore-taxsettings (>=2.18.0,<2.19.0)", "types-aiobotocore-textract (>=2.18.0,<2.19.0)", "types-aiobotocore-timestream-influxdb (>=2.18.0,<2.19.0)", "types-aiobotocore-timestream-query (>=2.18.0,<2.19.0)", "types-aiobotocore-timestream-write (>=2.18.0,<2.19.0)", "types-aiobotocore-tnb (>=2.18.0,<2.19.0)", "types-aiobotocore-transcribe (>=2.18.0,<2.19.0)", "types-aiobotocore-transfer (>=2.18.0,<2.19.0)", "types-aiobotocore-translate (>=2.18.0,<2.19.0)", "types-aiobotocore-trustedadvisor (>=2.18.0,<2.19.0)", "types-aiobotocore-verifiedpermissions (>=2.18.0,<2.19.0)", "types-aiobotocore-voice-id (>=2.18.0,<2.19.0)", "types-aiobotocore-vpc-lattice (>=2.18.0,<2.19.0)", "types-aiobotocore-waf (>=2.18.0,<2.19.0)", "types-aiobotocore-waf-regional (>=2.18.0,<2.19.0)", "types-aiobotocore-wafv2 (>=2.18.0,<2.19.0)", "types-aiobotocore-wellarchitected (>=2.18.0,<2.19.0)", "types-aiobotocore-wisdom (>=2.18.0,<2.19.0)", "types-aiobotocore-workdocs (>=2.18.0,<2.19.0)", "types-aiobotocore-workmail (>=2.18.0,<2.19.0)", "types-aiobotocore-workmailmessageflow (>=2.18.0,<2.19.0)", "types-aiobotocore-workspaces (>=2.18.0,<2.19.0)", "types-aiobotocore-workspaces-thin-client (>=2.18.0,<2.19.0)", "types-aiobotocore-workspaces-web (>=2.18.0,<2.19.0)", "types-aiobotocore-xray (>=2.18.0,<2.19.0)"]
+amp = ["types-aiobotocore-amp (>=2.18.0,<2.19.0)"]
+amplify = ["types-aiobotocore-amplify (>=2.18.0,<2.19.0)"]
+amplifybackend = ["types-aiobotocore-amplifybackend (>=2.18.0,<2.19.0)"]
+amplifyuibuilder = ["types-aiobotocore-amplifyuibuilder (>=2.18.0,<2.19.0)"]
+apigateway = ["types-aiobotocore-apigateway (>=2.18.0,<2.19.0)"]
+apigatewaymanagementapi = ["types-aiobotocore-apigatewaymanagementapi (>=2.18.0,<2.19.0)"]
+apigatewayv2 = ["types-aiobotocore-apigatewayv2 (>=2.18.0,<2.19.0)"]
+appconfig = ["types-aiobotocore-appconfig (>=2.18.0,<2.19.0)"]
+appconfigdata = ["types-aiobotocore-appconfigdata (>=2.18.0,<2.19.0)"]
+appfabric = ["types-aiobotocore-appfabric (>=2.18.0,<2.19.0)"]
+appflow = ["types-aiobotocore-appflow (>=2.18.0,<2.19.0)"]
+appintegrations = ["types-aiobotocore-appintegrations (>=2.18.0,<2.19.0)"]
+application-autoscaling = ["types-aiobotocore-application-autoscaling (>=2.18.0,<2.19.0)"]
+application-insights = ["types-aiobotocore-application-insights (>=2.18.0,<2.19.0)"]
+application-signals = ["types-aiobotocore-application-signals (>=2.18.0,<2.19.0)"]
+applicationcostprofiler = ["types-aiobotocore-applicationcostprofiler (>=2.18.0,<2.19.0)"]
+appmesh = ["types-aiobotocore-appmesh (>=2.18.0,<2.19.0)"]
+apprunner = ["types-aiobotocore-apprunner (>=2.18.0,<2.19.0)"]
+appstream = ["types-aiobotocore-appstream (>=2.18.0,<2.19.0)"]
+appsync = ["types-aiobotocore-appsync (>=2.18.0,<2.19.0)"]
+apptest = ["types-aiobotocore-apptest (>=2.18.0,<2.19.0)"]
+arc-zonal-shift = ["types-aiobotocore-arc-zonal-shift (>=2.18.0,<2.19.0)"]
+artifact = ["types-aiobotocore-artifact (>=2.18.0,<2.19.0)"]
+athena = ["types-aiobotocore-athena (>=2.18.0,<2.19.0)"]
+auditmanager = ["types-aiobotocore-auditmanager (>=2.18.0,<2.19.0)"]
+autoscaling = ["types-aiobotocore-autoscaling (>=2.18.0,<2.19.0)"]
+autoscaling-plans = ["types-aiobotocore-autoscaling-plans (>=2.18.0,<2.19.0)"]
+b2bi = ["types-aiobotocore-b2bi (>=2.18.0,<2.19.0)"]
+backup = ["types-aiobotocore-backup (>=2.18.0,<2.19.0)"]
+backup-gateway = ["types-aiobotocore-backup-gateway (>=2.18.0,<2.19.0)"]
+backupsearch = ["types-aiobotocore-backupsearch (>=2.18.0,<2.19.0)"]
+batch = ["types-aiobotocore-batch (>=2.18.0,<2.19.0)"]
+bcm-data-exports = ["types-aiobotocore-bcm-data-exports (>=2.18.0,<2.19.0)"]
+bcm-pricing-calculator = ["types-aiobotocore-bcm-pricing-calculator (>=2.18.0,<2.19.0)"]
+bedrock = ["types-aiobotocore-bedrock (>=2.18.0,<2.19.0)"]
+bedrock-agent = ["types-aiobotocore-bedrock-agent (>=2.18.0,<2.19.0)"]
+bedrock-agent-runtime = ["types-aiobotocore-bedrock-agent-runtime (>=2.18.0,<2.19.0)"]
+bedrock-data-automation = ["types-aiobotocore-bedrock-data-automation (>=2.18.0,<2.19.0)"]
+bedrock-data-automation-runtime = ["types-aiobotocore-bedrock-data-automation-runtime (>=2.18.0,<2.19.0)"]
+bedrock-runtime = ["types-aiobotocore-bedrock-runtime (>=2.18.0,<2.19.0)"]
+billing = ["types-aiobotocore-billing (>=2.18.0,<2.19.0)"]
+billingconductor = ["types-aiobotocore-billingconductor (>=2.18.0,<2.19.0)"]
+braket = ["types-aiobotocore-braket (>=2.18.0,<2.19.0)"]
+budgets = ["types-aiobotocore-budgets (>=2.18.0,<2.19.0)"]
+ce = ["types-aiobotocore-ce (>=2.18.0,<2.19.0)"]
+chatbot = ["types-aiobotocore-chatbot (>=2.18.0,<2.19.0)"]
+chime = ["types-aiobotocore-chime (>=2.18.0,<2.19.0)"]
+chime-sdk-identity = ["types-aiobotocore-chime-sdk-identity (>=2.18.0,<2.19.0)"]
+chime-sdk-media-pipelines = ["types-aiobotocore-chime-sdk-media-pipelines (>=2.18.0,<2.19.0)"]
+chime-sdk-meetings = ["types-aiobotocore-chime-sdk-meetings (>=2.18.0,<2.19.0)"]
+chime-sdk-messaging = ["types-aiobotocore-chime-sdk-messaging (>=2.18.0,<2.19.0)"]
+chime-sdk-voice = ["types-aiobotocore-chime-sdk-voice (>=2.18.0,<2.19.0)"]
+cleanrooms = ["types-aiobotocore-cleanrooms (>=2.18.0,<2.19.0)"]
+cleanroomsml = ["types-aiobotocore-cleanroomsml (>=2.18.0,<2.19.0)"]
+cloud9 = ["types-aiobotocore-cloud9 (>=2.18.0,<2.19.0)"]
+cloudcontrol = ["types-aiobotocore-cloudcontrol (>=2.18.0,<2.19.0)"]
+clouddirectory = ["types-aiobotocore-clouddirectory (>=2.18.0,<2.19.0)"]
+cloudformation = ["types-aiobotocore-cloudformation (>=2.18.0,<2.19.0)"]
+cloudfront = ["types-aiobotocore-cloudfront (>=2.18.0,<2.19.0)"]
+cloudfront-keyvaluestore = ["types-aiobotocore-cloudfront-keyvaluestore (>=2.18.0,<2.19.0)"]
+cloudhsm = ["types-aiobotocore-cloudhsm (>=2.18.0,<2.19.0)"]
+cloudhsmv2 = ["types-aiobotocore-cloudhsmv2 (>=2.18.0,<2.19.0)"]
+cloudsearch = ["types-aiobotocore-cloudsearch (>=2.18.0,<2.19.0)"]
+cloudsearchdomain = ["types-aiobotocore-cloudsearchdomain (>=2.18.0,<2.19.0)"]
+cloudtrail = ["types-aiobotocore-cloudtrail (>=2.18.0,<2.19.0)"]
+cloudtrail-data = ["types-aiobotocore-cloudtrail-data (>=2.18.0,<2.19.0)"]
+cloudwatch = ["types-aiobotocore-cloudwatch (>=2.18.0,<2.19.0)"]
+codeartifact = ["types-aiobotocore-codeartifact (>=2.18.0,<2.19.0)"]
+codebuild = ["types-aiobotocore-codebuild (>=2.18.0,<2.19.0)"]
+codecatalyst = ["types-aiobotocore-codecatalyst (>=2.18.0,<2.19.0)"]
+codecommit = ["types-aiobotocore-codecommit (>=2.18.0,<2.19.0)"]
+codeconnections = ["types-aiobotocore-codeconnections (>=2.18.0,<2.19.0)"]
+codedeploy = ["types-aiobotocore-codedeploy (>=2.18.0,<2.19.0)"]
+codeguru-reviewer = ["types-aiobotocore-codeguru-reviewer (>=2.18.0,<2.19.0)"]
+codeguru-security = ["types-aiobotocore-codeguru-security (>=2.18.0,<2.19.0)"]
+codeguruprofiler = ["types-aiobotocore-codeguruprofiler (>=2.18.0,<2.19.0)"]
+codepipeline = ["types-aiobotocore-codepipeline (>=2.18.0,<2.19.0)"]
+codestar-connections = ["types-aiobotocore-codestar-connections (>=2.18.0,<2.19.0)"]
+codestar-notifications = ["types-aiobotocore-codestar-notifications (>=2.18.0,<2.19.0)"]
+cognito-identity = ["types-aiobotocore-cognito-identity (>=2.18.0,<2.19.0)"]
+cognito-idp = ["types-aiobotocore-cognito-idp (>=2.18.0,<2.19.0)"]
+cognito-sync = ["types-aiobotocore-cognito-sync (>=2.18.0,<2.19.0)"]
+comprehend = ["types-aiobotocore-comprehend (>=2.18.0,<2.19.0)"]
+comprehendmedical = ["types-aiobotocore-comprehendmedical (>=2.18.0,<2.19.0)"]
+compute-optimizer = ["types-aiobotocore-compute-optimizer (>=2.18.0,<2.19.0)"]
+config = ["types-aiobotocore-config (>=2.18.0,<2.19.0)"]
+connect = ["types-aiobotocore-connect (>=2.18.0,<2.19.0)"]
+connect-contact-lens = ["types-aiobotocore-connect-contact-lens (>=2.18.0,<2.19.0)"]
+connectcampaigns = ["types-aiobotocore-connectcampaigns (>=2.18.0,<2.19.0)"]
+connectcampaignsv2 = ["types-aiobotocore-connectcampaignsv2 (>=2.18.0,<2.19.0)"]
+connectcases = ["types-aiobotocore-connectcases (>=2.18.0,<2.19.0)"]
+connectparticipant = ["types-aiobotocore-connectparticipant (>=2.18.0,<2.19.0)"]
+controlcatalog = ["types-aiobotocore-controlcatalog (>=2.18.0,<2.19.0)"]
+controltower = ["types-aiobotocore-controltower (>=2.18.0,<2.19.0)"]
+cost-optimization-hub = ["types-aiobotocore-cost-optimization-hub (>=2.18.0,<2.19.0)"]
+cur = ["types-aiobotocore-cur (>=2.18.0,<2.19.0)"]
+customer-profiles = ["types-aiobotocore-customer-profiles (>=2.18.0,<2.19.0)"]
+databrew = ["types-aiobotocore-databrew (>=2.18.0,<2.19.0)"]
+dataexchange = ["types-aiobotocore-dataexchange (>=2.18.0,<2.19.0)"]
+datapipeline = ["types-aiobotocore-datapipeline (>=2.18.0,<2.19.0)"]
+datasync = ["types-aiobotocore-datasync (>=2.18.0,<2.19.0)"]
+datazone = ["types-aiobotocore-datazone (>=2.18.0,<2.19.0)"]
+dax = ["types-aiobotocore-dax (>=2.18.0,<2.19.0)"]
+deadline = ["types-aiobotocore-deadline (>=2.18.0,<2.19.0)"]
+detective = ["types-aiobotocore-detective (>=2.18.0,<2.19.0)"]
+devicefarm = ["types-aiobotocore-devicefarm (>=2.18.0,<2.19.0)"]
+devops-guru = ["types-aiobotocore-devops-guru (>=2.18.0,<2.19.0)"]
+directconnect = ["types-aiobotocore-directconnect (>=2.18.0,<2.19.0)"]
+discovery = ["types-aiobotocore-discovery (>=2.18.0,<2.19.0)"]
+dlm = ["types-aiobotocore-dlm (>=2.18.0,<2.19.0)"]
+dms = ["types-aiobotocore-dms (>=2.18.0,<2.19.0)"]
+docdb = ["types-aiobotocore-docdb (>=2.18.0,<2.19.0)"]
+docdb-elastic = ["types-aiobotocore-docdb-elastic (>=2.18.0,<2.19.0)"]
+drs = ["types-aiobotocore-drs (>=2.18.0,<2.19.0)"]
+ds = ["types-aiobotocore-ds (>=2.18.0,<2.19.0)"]
+ds-data = ["types-aiobotocore-ds-data (>=2.18.0,<2.19.0)"]
+dsql = ["types-aiobotocore-dsql (>=2.18.0,<2.19.0)"]
+dynamodb = ["types-aiobotocore-dynamodb (>=2.18.0,<2.19.0)"]
+dynamodbstreams = ["types-aiobotocore-dynamodbstreams (>=2.18.0,<2.19.0)"]
+ebs = ["types-aiobotocore-ebs (>=2.18.0,<2.19.0)"]
+ec2 = ["types-aiobotocore-ec2 (>=2.18.0,<2.19.0)"]
+ec2-instance-connect = ["types-aiobotocore-ec2-instance-connect (>=2.18.0,<2.19.0)"]
+ecr = ["types-aiobotocore-ecr (>=2.18.0,<2.19.0)"]
+ecr-public = ["types-aiobotocore-ecr-public (>=2.18.0,<2.19.0)"]
+ecs = ["types-aiobotocore-ecs (>=2.18.0,<2.19.0)"]
+efs = ["types-aiobotocore-efs (>=2.18.0,<2.19.0)"]
+eks = ["types-aiobotocore-eks (>=2.18.0,<2.19.0)"]
+eks-auth = ["types-aiobotocore-eks-auth (>=2.18.0,<2.19.0)"]
+elastic-inference = ["types-aiobotocore-elastic-inference (>=2.18.0,<2.19.0)"]
+elasticache = ["types-aiobotocore-elasticache (>=2.18.0,<2.19.0)"]
+elasticbeanstalk = ["types-aiobotocore-elasticbeanstalk (>=2.18.0,<2.19.0)"]
+elastictranscoder = ["types-aiobotocore-elastictranscoder (>=2.18.0,<2.19.0)"]
+elb = ["types-aiobotocore-elb (>=2.18.0,<2.19.0)"]
+elbv2 = ["types-aiobotocore-elbv2 (>=2.18.0,<2.19.0)"]
+emr = ["types-aiobotocore-emr (>=2.18.0,<2.19.0)"]
+emr-containers = ["types-aiobotocore-emr-containers (>=2.18.0,<2.19.0)"]
+emr-serverless = ["types-aiobotocore-emr-serverless (>=2.18.0,<2.19.0)"]
+entityresolution = ["types-aiobotocore-entityresolution (>=2.18.0,<2.19.0)"]
+es = ["types-aiobotocore-es (>=2.18.0,<2.19.0)"]
+essential = ["types-aiobotocore-cloudformation (>=2.18.0,<2.19.0)", "types-aiobotocore-dynamodb (>=2.18.0,<2.19.0)", "types-aiobotocore-ec2 (>=2.18.0,<2.19.0)", "types-aiobotocore-lambda (>=2.18.0,<2.19.0)", "types-aiobotocore-rds (>=2.18.0,<2.19.0)", "types-aiobotocore-s3 (>=2.18.0,<2.19.0)", "types-aiobotocore-sqs (>=2.18.0,<2.19.0)"]
+events = ["types-aiobotocore-events (>=2.18.0,<2.19.0)"]
+evidently = ["types-aiobotocore-evidently (>=2.18.0,<2.19.0)"]
+finspace = ["types-aiobotocore-finspace (>=2.18.0,<2.19.0)"]
+finspace-data = ["types-aiobotocore-finspace-data (>=2.18.0,<2.19.0)"]
+firehose = ["types-aiobotocore-firehose (>=2.18.0,<2.19.0)"]
+fis = ["types-aiobotocore-fis (>=2.18.0,<2.19.0)"]
+fms = ["types-aiobotocore-fms (>=2.18.0,<2.19.0)"]
+forecast = ["types-aiobotocore-forecast (>=2.18.0,<2.19.0)"]
+forecastquery = ["types-aiobotocore-forecastquery (>=2.18.0,<2.19.0)"]
+frauddetector = ["types-aiobotocore-frauddetector (>=2.18.0,<2.19.0)"]
+freetier = ["types-aiobotocore-freetier (>=2.18.0,<2.19.0)"]
+fsx = ["types-aiobotocore-fsx (>=2.18.0,<2.19.0)"]
+full = ["types-aiobotocore-full (>=2.18.0,<2.19.0)"]
+gamelift = ["types-aiobotocore-gamelift (>=2.18.0,<2.19.0)"]
+geo-maps = ["types-aiobotocore-geo-maps (>=2.18.0,<2.19.0)"]
+geo-places = ["types-aiobotocore-geo-places (>=2.18.0,<2.19.0)"]
+geo-routes = ["types-aiobotocore-geo-routes (>=2.18.0,<2.19.0)"]
+glacier = ["types-aiobotocore-glacier (>=2.18.0,<2.19.0)"]
+globalaccelerator = ["types-aiobotocore-globalaccelerator (>=2.18.0,<2.19.0)"]
+glue = ["types-aiobotocore-glue (>=2.18.0,<2.19.0)"]
+grafana = ["types-aiobotocore-grafana (>=2.18.0,<2.19.0)"]
+greengrass = ["types-aiobotocore-greengrass (>=2.18.0,<2.19.0)"]
+greengrassv2 = ["types-aiobotocore-greengrassv2 (>=2.18.0,<2.19.0)"]
+groundstation = ["types-aiobotocore-groundstation (>=2.18.0,<2.19.0)"]
+guardduty = ["types-aiobotocore-guardduty (>=2.18.0,<2.19.0)"]
+health = ["types-aiobotocore-health (>=2.18.0,<2.19.0)"]
+healthlake = ["types-aiobotocore-healthlake (>=2.18.0,<2.19.0)"]
+iam = ["types-aiobotocore-iam (>=2.18.0,<2.19.0)"]
+identitystore = ["types-aiobotocore-identitystore (>=2.18.0,<2.19.0)"]
+imagebuilder = ["types-aiobotocore-imagebuilder (>=2.18.0,<2.19.0)"]
+importexport = ["types-aiobotocore-importexport (>=2.18.0,<2.19.0)"]
+inspector = ["types-aiobotocore-inspector (>=2.18.0,<2.19.0)"]
+inspector-scan = ["types-aiobotocore-inspector-scan (>=2.18.0,<2.19.0)"]
+inspector2 = ["types-aiobotocore-inspector2 (>=2.18.0,<2.19.0)"]
+internetmonitor = ["types-aiobotocore-internetmonitor (>=2.18.0,<2.19.0)"]
+invoicing = ["types-aiobotocore-invoicing (>=2.18.0,<2.19.0)"]
+iot = ["types-aiobotocore-iot (>=2.18.0,<2.19.0)"]
+iot-data = ["types-aiobotocore-iot-data (>=2.18.0,<2.19.0)"]
+iot-jobs-data = ["types-aiobotocore-iot-jobs-data (>=2.18.0,<2.19.0)"]
+iotanalytics = ["types-aiobotocore-iotanalytics (>=2.18.0,<2.19.0)"]
+iotdeviceadvisor = ["types-aiobotocore-iotdeviceadvisor (>=2.18.0,<2.19.0)"]
+iotevents = ["types-aiobotocore-iotevents (>=2.18.0,<2.19.0)"]
+iotevents-data = ["types-aiobotocore-iotevents-data (>=2.18.0,<2.19.0)"]
+iotfleethub = ["types-aiobotocore-iotfleethub (>=2.18.0,<2.19.0)"]
+iotfleetwise = ["types-aiobotocore-iotfleetwise (>=2.18.0,<2.19.0)"]
+iotsecuretunneling = ["types-aiobotocore-iotsecuretunneling (>=2.18.0,<2.19.0)"]
+iotsitewise = ["types-aiobotocore-iotsitewise (>=2.18.0,<2.19.0)"]
+iotthingsgraph = ["types-aiobotocore-iotthingsgraph (>=2.18.0,<2.19.0)"]
+iottwinmaker = ["types-aiobotocore-iottwinmaker (>=2.18.0,<2.19.0)"]
+iotwireless = ["types-aiobotocore-iotwireless (>=2.18.0,<2.19.0)"]
+ivs = ["types-aiobotocore-ivs (>=2.18.0,<2.19.0)"]
+ivs-realtime = ["types-aiobotocore-ivs-realtime (>=2.18.0,<2.19.0)"]
+ivschat = ["types-aiobotocore-ivschat (>=2.18.0,<2.19.0)"]
+kafka = ["types-aiobotocore-kafka (>=2.18.0,<2.19.0)"]
+kafkaconnect = ["types-aiobotocore-kafkaconnect (>=2.18.0,<2.19.0)"]
+kendra = ["types-aiobotocore-kendra (>=2.18.0,<2.19.0)"]
+kendra-ranking = ["types-aiobotocore-kendra-ranking (>=2.18.0,<2.19.0)"]
+keyspaces = ["types-aiobotocore-keyspaces (>=2.18.0,<2.19.0)"]
+kinesis = ["types-aiobotocore-kinesis (>=2.18.0,<2.19.0)"]
+kinesis-video-archived-media = ["types-aiobotocore-kinesis-video-archived-media (>=2.18.0,<2.19.0)"]
+kinesis-video-media = ["types-aiobotocore-kinesis-video-media (>=2.18.0,<2.19.0)"]
+kinesis-video-signaling = ["types-aiobotocore-kinesis-video-signaling (>=2.18.0,<2.19.0)"]
+kinesis-video-webrtc-storage = ["types-aiobotocore-kinesis-video-webrtc-storage (>=2.18.0,<2.19.0)"]
+kinesisanalytics = ["types-aiobotocore-kinesisanalytics (>=2.18.0,<2.19.0)"]
+kinesisanalyticsv2 = ["types-aiobotocore-kinesisanalyticsv2 (>=2.18.0,<2.19.0)"]
+kinesisvideo = ["types-aiobotocore-kinesisvideo (>=2.18.0,<2.19.0)"]
+kms = ["types-aiobotocore-kms (>=2.18.0,<2.19.0)"]
+lakeformation = ["types-aiobotocore-lakeformation (>=2.18.0,<2.19.0)"]
+lambda = ["types-aiobotocore-lambda (>=2.18.0,<2.19.0)"]
+launch-wizard = ["types-aiobotocore-launch-wizard (>=2.18.0,<2.19.0)"]
+lex-models = ["types-aiobotocore-lex-models (>=2.18.0,<2.19.0)"]
+lex-runtime = ["types-aiobotocore-lex-runtime (>=2.18.0,<2.19.0)"]
+lexv2-models = ["types-aiobotocore-lexv2-models (>=2.18.0,<2.19.0)"]
+lexv2-runtime = ["types-aiobotocore-lexv2-runtime (>=2.18.0,<2.19.0)"]
+license-manager = ["types-aiobotocore-license-manager (>=2.18.0,<2.19.0)"]
+license-manager-linux-subscriptions = ["types-aiobotocore-license-manager-linux-subscriptions (>=2.18.0,<2.19.0)"]
+license-manager-user-subscriptions = ["types-aiobotocore-license-manager-user-subscriptions (>=2.18.0,<2.19.0)"]
+lightsail = ["types-aiobotocore-lightsail (>=2.18.0,<2.19.0)"]
+location = ["types-aiobotocore-location (>=2.18.0,<2.19.0)"]
+logs = ["types-aiobotocore-logs (>=2.18.0,<2.19.0)"]
+lookoutequipment = ["types-aiobotocore-lookoutequipment (>=2.18.0,<2.19.0)"]
+lookoutmetrics = ["types-aiobotocore-lookoutmetrics (>=2.18.0,<2.19.0)"]
+lookoutvision = ["types-aiobotocore-lookoutvision (>=2.18.0,<2.19.0)"]
+m2 = ["types-aiobotocore-m2 (>=2.18.0,<2.19.0)"]
+machinelearning = ["types-aiobotocore-machinelearning (>=2.18.0,<2.19.0)"]
+macie2 = ["types-aiobotocore-macie2 (>=2.18.0,<2.19.0)"]
+mailmanager = ["types-aiobotocore-mailmanager (>=2.18.0,<2.19.0)"]
+managedblockchain = ["types-aiobotocore-managedblockchain (>=2.18.0,<2.19.0)"]
+managedblockchain-query = ["types-aiobotocore-managedblockchain-query (>=2.18.0,<2.19.0)"]
+marketplace-agreement = ["types-aiobotocore-marketplace-agreement (>=2.18.0,<2.19.0)"]
+marketplace-catalog = ["types-aiobotocore-marketplace-catalog (>=2.18.0,<2.19.0)"]
+marketplace-deployment = ["types-aiobotocore-marketplace-deployment (>=2.18.0,<2.19.0)"]
+marketplace-entitlement = ["types-aiobotocore-marketplace-entitlement (>=2.18.0,<2.19.0)"]
+marketplace-reporting = ["types-aiobotocore-marketplace-reporting (>=2.18.0,<2.19.0)"]
+marketplacecommerceanalytics = ["types-aiobotocore-marketplacecommerceanalytics (>=2.18.0,<2.19.0)"]
+mediaconnect = ["types-aiobotocore-mediaconnect (>=2.18.0,<2.19.0)"]
+mediaconvert = ["types-aiobotocore-mediaconvert (>=2.18.0,<2.19.0)"]
+medialive = ["types-aiobotocore-medialive (>=2.18.0,<2.19.0)"]
+mediapackage = ["types-aiobotocore-mediapackage (>=2.18.0,<2.19.0)"]
+mediapackage-vod = ["types-aiobotocore-mediapackage-vod (>=2.18.0,<2.19.0)"]
+mediapackagev2 = ["types-aiobotocore-mediapackagev2 (>=2.18.0,<2.19.0)"]
+mediastore = ["types-aiobotocore-mediastore (>=2.18.0,<2.19.0)"]
+mediastore-data = ["types-aiobotocore-mediastore-data (>=2.18.0,<2.19.0)"]
+mediatailor = ["types-aiobotocore-mediatailor (>=2.18.0,<2.19.0)"]
+medical-imaging = ["types-aiobotocore-medical-imaging (>=2.18.0,<2.19.0)"]
+memorydb = ["types-aiobotocore-memorydb (>=2.18.0,<2.19.0)"]
+meteringmarketplace = ["types-aiobotocore-meteringmarketplace (>=2.18.0,<2.19.0)"]
+mgh = ["types-aiobotocore-mgh (>=2.18.0,<2.19.0)"]
+mgn = ["types-aiobotocore-mgn (>=2.18.0,<2.19.0)"]
+migration-hub-refactor-spaces = ["types-aiobotocore-migration-hub-refactor-spaces (>=2.18.0,<2.19.0)"]
+migrationhub-config = ["types-aiobotocore-migrationhub-config (>=2.18.0,<2.19.0)"]
+migrationhuborchestrator = ["types-aiobotocore-migrationhuborchestrator (>=2.18.0,<2.19.0)"]
+migrationhubstrategy = ["types-aiobotocore-migrationhubstrategy (>=2.18.0,<2.19.0)"]
+mq = ["types-aiobotocore-mq (>=2.18.0,<2.19.0)"]
+mturk = ["types-aiobotocore-mturk (>=2.18.0,<2.19.0)"]
+mwaa = ["types-aiobotocore-mwaa (>=2.18.0,<2.19.0)"]
+neptune = ["types-aiobotocore-neptune (>=2.18.0,<2.19.0)"]
+neptune-graph = ["types-aiobotocore-neptune-graph (>=2.18.0,<2.19.0)"]
+neptunedata = ["types-aiobotocore-neptunedata (>=2.18.0,<2.19.0)"]
+network-firewall = ["types-aiobotocore-network-firewall (>=2.18.0,<2.19.0)"]
+networkflowmonitor = ["types-aiobotocore-networkflowmonitor (>=2.18.0,<2.19.0)"]
+networkmanager = ["types-aiobotocore-networkmanager (>=2.18.0,<2.19.0)"]
+networkmonitor = ["types-aiobotocore-networkmonitor (>=2.18.0,<2.19.0)"]
+notifications = ["types-aiobotocore-notifications (>=2.18.0,<2.19.0)"]
+notificationscontacts = ["types-aiobotocore-notificationscontacts (>=2.18.0,<2.19.0)"]
+oam = ["types-aiobotocore-oam (>=2.18.0,<2.19.0)"]
+observabilityadmin = ["types-aiobotocore-observabilityadmin (>=2.18.0,<2.19.0)"]
+omics = ["types-aiobotocore-omics (>=2.18.0,<2.19.0)"]
+opensearch = ["types-aiobotocore-opensearch (>=2.18.0,<2.19.0)"]
+opensearchserverless = ["types-aiobotocore-opensearchserverless (>=2.18.0,<2.19.0)"]
+opsworks = ["types-aiobotocore-opsworks (>=2.18.0,<2.19.0)"]
+opsworkscm = ["types-aiobotocore-opsworkscm (>=2.18.0,<2.19.0)"]
+organizations = ["types-aiobotocore-organizations (>=2.18.0,<2.19.0)"]
+osis = ["types-aiobotocore-osis (>=2.18.0,<2.19.0)"]
+outposts = ["types-aiobotocore-outposts (>=2.18.0,<2.19.0)"]
+panorama = ["types-aiobotocore-panorama (>=2.18.0,<2.19.0)"]
+partnercentral-selling = ["types-aiobotocore-partnercentral-selling (>=2.18.0,<2.19.0)"]
+payment-cryptography = ["types-aiobotocore-payment-cryptography (>=2.18.0,<2.19.0)"]
+payment-cryptography-data = ["types-aiobotocore-payment-cryptography-data (>=2.18.0,<2.19.0)"]
+pca-connector-ad = ["types-aiobotocore-pca-connector-ad (>=2.18.0,<2.19.0)"]
+pca-connector-scep = ["types-aiobotocore-pca-connector-scep (>=2.18.0,<2.19.0)"]
+pcs = ["types-aiobotocore-pcs (>=2.18.0,<2.19.0)"]
+personalize = ["types-aiobotocore-personalize (>=2.18.0,<2.19.0)"]
+personalize-events = ["types-aiobotocore-personalize-events (>=2.18.0,<2.19.0)"]
+personalize-runtime = ["types-aiobotocore-personalize-runtime (>=2.18.0,<2.19.0)"]
+pi = ["types-aiobotocore-pi (>=2.18.0,<2.19.0)"]
+pinpoint = ["types-aiobotocore-pinpoint (>=2.18.0,<2.19.0)"]
+pinpoint-email = ["types-aiobotocore-pinpoint-email (>=2.18.0,<2.19.0)"]
+pinpoint-sms-voice = ["types-aiobotocore-pinpoint-sms-voice (>=2.18.0,<2.19.0)"]
+pinpoint-sms-voice-v2 = ["types-aiobotocore-pinpoint-sms-voice-v2 (>=2.18.0,<2.19.0)"]
+pipes = ["types-aiobotocore-pipes (>=2.18.0,<2.19.0)"]
+polly = ["types-aiobotocore-polly (>=2.18.0,<2.19.0)"]
+pricing = ["types-aiobotocore-pricing (>=2.18.0,<2.19.0)"]
+privatenetworks = ["types-aiobotocore-privatenetworks (>=2.18.0,<2.19.0)"]
+proton = ["types-aiobotocore-proton (>=2.18.0,<2.19.0)"]
+qapps = ["types-aiobotocore-qapps (>=2.18.0,<2.19.0)"]
+qbusiness = ["types-aiobotocore-qbusiness (>=2.18.0,<2.19.0)"]
+qconnect = ["types-aiobotocore-qconnect (>=2.18.0,<2.19.0)"]
+qldb = ["types-aiobotocore-qldb (>=2.18.0,<2.19.0)"]
+qldb-session = ["types-aiobotocore-qldb-session (>=2.18.0,<2.19.0)"]
+quicksight = ["types-aiobotocore-quicksight (>=2.18.0,<2.19.0)"]
+ram = ["types-aiobotocore-ram (>=2.18.0,<2.19.0)"]
+rbin = ["types-aiobotocore-rbin (>=2.18.0,<2.19.0)"]
+rds = ["types-aiobotocore-rds (>=2.18.0,<2.19.0)"]
+rds-data = ["types-aiobotocore-rds-data (>=2.18.0,<2.19.0)"]
+redshift = ["types-aiobotocore-redshift (>=2.18.0,<2.19.0)"]
+redshift-data = ["types-aiobotocore-redshift-data (>=2.18.0,<2.19.0)"]
+redshift-serverless = ["types-aiobotocore-redshift-serverless (>=2.18.0,<2.19.0)"]
+rekognition = ["types-aiobotocore-rekognition (>=2.18.0,<2.19.0)"]
+repostspace = ["types-aiobotocore-repostspace (>=2.18.0,<2.19.0)"]
+resiliencehub = ["types-aiobotocore-resiliencehub (>=2.18.0,<2.19.0)"]
+resource-explorer-2 = ["types-aiobotocore-resource-explorer-2 (>=2.18.0,<2.19.0)"]
+resource-groups = ["types-aiobotocore-resource-groups (>=2.18.0,<2.19.0)"]
+resourcegroupstaggingapi = ["types-aiobotocore-resourcegroupstaggingapi (>=2.18.0,<2.19.0)"]
+robomaker = ["types-aiobotocore-robomaker (>=2.18.0,<2.19.0)"]
+rolesanywhere = ["types-aiobotocore-rolesanywhere (>=2.18.0,<2.19.0)"]
+route53 = ["types-aiobotocore-route53 (>=2.18.0,<2.19.0)"]
+route53-recovery-cluster = ["types-aiobotocore-route53-recovery-cluster (>=2.18.0,<2.19.0)"]
+route53-recovery-control-config = ["types-aiobotocore-route53-recovery-control-config (>=2.18.0,<2.19.0)"]
+route53-recovery-readiness = ["types-aiobotocore-route53-recovery-readiness (>=2.18.0,<2.19.0)"]
+route53domains = ["types-aiobotocore-route53domains (>=2.18.0,<2.19.0)"]
+route53profiles = ["types-aiobotocore-route53profiles (>=2.18.0,<2.19.0)"]
+route53resolver = ["types-aiobotocore-route53resolver (>=2.18.0,<2.19.0)"]
+rum = ["types-aiobotocore-rum (>=2.18.0,<2.19.0)"]
+s3 = ["types-aiobotocore-s3 (>=2.18.0,<2.19.0)"]
+s3control = ["types-aiobotocore-s3control (>=2.18.0,<2.19.0)"]
+s3outposts = ["types-aiobotocore-s3outposts (>=2.18.0,<2.19.0)"]
+s3tables = ["types-aiobotocore-s3tables (>=2.18.0,<2.19.0)"]
+sagemaker = ["types-aiobotocore-sagemaker (>=2.18.0,<2.19.0)"]
+sagemaker-a2i-runtime = ["types-aiobotocore-sagemaker-a2i-runtime (>=2.18.0,<2.19.0)"]
+sagemaker-edge = ["types-aiobotocore-sagemaker-edge (>=2.18.0,<2.19.0)"]
+sagemaker-featurestore-runtime = ["types-aiobotocore-sagemaker-featurestore-runtime (>=2.18.0,<2.19.0)"]
+sagemaker-geospatial = ["types-aiobotocore-sagemaker-geospatial (>=2.18.0,<2.19.0)"]
+sagemaker-metrics = ["types-aiobotocore-sagemaker-metrics (>=2.18.0,<2.19.0)"]
+sagemaker-runtime = ["types-aiobotocore-sagemaker-runtime (>=2.18.0,<2.19.0)"]
+savingsplans = ["types-aiobotocore-savingsplans (>=2.18.0,<2.19.0)"]
+scheduler = ["types-aiobotocore-scheduler (>=2.18.0,<2.19.0)"]
+schemas = ["types-aiobotocore-schemas (>=2.18.0,<2.19.0)"]
+sdb = ["types-aiobotocore-sdb (>=2.18.0,<2.19.0)"]
+secretsmanager = ["types-aiobotocore-secretsmanager (>=2.18.0,<2.19.0)"]
+security-ir = ["types-aiobotocore-security-ir (>=2.18.0,<2.19.0)"]
+securityhub = ["types-aiobotocore-securityhub (>=2.18.0,<2.19.0)"]
+securitylake = ["types-aiobotocore-securitylake (>=2.18.0,<2.19.0)"]
+serverlessrepo = ["types-aiobotocore-serverlessrepo (>=2.18.0,<2.19.0)"]
+service-quotas = ["types-aiobotocore-service-quotas (>=2.18.0,<2.19.0)"]
+servicecatalog = ["types-aiobotocore-servicecatalog (>=2.18.0,<2.19.0)"]
+servicecatalog-appregistry = ["types-aiobotocore-servicecatalog-appregistry (>=2.18.0,<2.19.0)"]
+servicediscovery = ["types-aiobotocore-servicediscovery (>=2.18.0,<2.19.0)"]
+ses = ["types-aiobotocore-ses (>=2.18.0,<2.19.0)"]
+sesv2 = ["types-aiobotocore-sesv2 (>=2.18.0,<2.19.0)"]
+shield = ["types-aiobotocore-shield (>=2.18.0,<2.19.0)"]
+signer = ["types-aiobotocore-signer (>=2.18.0,<2.19.0)"]
+simspaceweaver = ["types-aiobotocore-simspaceweaver (>=2.18.0,<2.19.0)"]
+sms = ["types-aiobotocore-sms (>=2.18.0,<2.19.0)"]
+sms-voice = ["types-aiobotocore-sms-voice (>=2.18.0,<2.19.0)"]
+snow-device-management = ["types-aiobotocore-snow-device-management (>=2.18.0,<2.19.0)"]
+snowball = ["types-aiobotocore-snowball (>=2.18.0,<2.19.0)"]
+sns = ["types-aiobotocore-sns (>=2.18.0,<2.19.0)"]
+socialmessaging = ["types-aiobotocore-socialmessaging (>=2.18.0,<2.19.0)"]
+sqs = ["types-aiobotocore-sqs (>=2.18.0,<2.19.0)"]
+ssm = ["types-aiobotocore-ssm (>=2.18.0,<2.19.0)"]
+ssm-contacts = ["types-aiobotocore-ssm-contacts (>=2.18.0,<2.19.0)"]
+ssm-incidents = ["types-aiobotocore-ssm-incidents (>=2.18.0,<2.19.0)"]
+ssm-quicksetup = ["types-aiobotocore-ssm-quicksetup (>=2.18.0,<2.19.0)"]
+ssm-sap = ["types-aiobotocore-ssm-sap (>=2.18.0,<2.19.0)"]
+sso = ["types-aiobotocore-sso (>=2.18.0,<2.19.0)"]
+sso-admin = ["types-aiobotocore-sso-admin (>=2.18.0,<2.19.0)"]
+sso-oidc = ["types-aiobotocore-sso-oidc (>=2.18.0,<2.19.0)"]
+stepfunctions = ["types-aiobotocore-stepfunctions (>=2.18.0,<2.19.0)"]
+storagegateway = ["types-aiobotocore-storagegateway (>=2.18.0,<2.19.0)"]
+sts = ["types-aiobotocore-sts (>=2.18.0,<2.19.0)"]
+supplychain = ["types-aiobotocore-supplychain (>=2.18.0,<2.19.0)"]
+support = ["types-aiobotocore-support (>=2.18.0,<2.19.0)"]
+support-app = ["types-aiobotocore-support-app (>=2.18.0,<2.19.0)"]
+swf = ["types-aiobotocore-swf (>=2.18.0,<2.19.0)"]
+synthetics = ["types-aiobotocore-synthetics (>=2.18.0,<2.19.0)"]
+taxsettings = ["types-aiobotocore-taxsettings (>=2.18.0,<2.19.0)"]
+textract = ["types-aiobotocore-textract (>=2.18.0,<2.19.0)"]
+timestream-influxdb = ["types-aiobotocore-timestream-influxdb (>=2.18.0,<2.19.0)"]
+timestream-query = ["types-aiobotocore-timestream-query (>=2.18.0,<2.19.0)"]
+timestream-write = ["types-aiobotocore-timestream-write (>=2.18.0,<2.19.0)"]
+tnb = ["types-aiobotocore-tnb (>=2.18.0,<2.19.0)"]
+transcribe = ["types-aiobotocore-transcribe (>=2.18.0,<2.19.0)"]
+transfer = ["types-aiobotocore-transfer (>=2.18.0,<2.19.0)"]
+translate = ["types-aiobotocore-translate (>=2.18.0,<2.19.0)"]
+trustedadvisor = ["types-aiobotocore-trustedadvisor (>=2.18.0,<2.19.0)"]
+verifiedpermissions = ["types-aiobotocore-verifiedpermissions (>=2.18.0,<2.19.0)"]
+voice-id = ["types-aiobotocore-voice-id (>=2.18.0,<2.19.0)"]
+vpc-lattice = ["types-aiobotocore-vpc-lattice (>=2.18.0,<2.19.0)"]
+waf = ["types-aiobotocore-waf (>=2.18.0,<2.19.0)"]
+waf-regional = ["types-aiobotocore-waf-regional (>=2.18.0,<2.19.0)"]
+wafv2 = ["types-aiobotocore-wafv2 (>=2.18.0,<2.19.0)"]
+wellarchitected = ["types-aiobotocore-wellarchitected (>=2.18.0,<2.19.0)"]
+wisdom = ["types-aiobotocore-wisdom (>=2.18.0,<2.19.0)"]
+workdocs = ["types-aiobotocore-workdocs (>=2.18.0,<2.19.0)"]
+workmail = ["types-aiobotocore-workmail (>=2.18.0,<2.19.0)"]
+workmailmessageflow = ["types-aiobotocore-workmailmessageflow (>=2.18.0,<2.19.0)"]
+workspaces = ["types-aiobotocore-workspaces (>=2.18.0,<2.19.0)"]
+workspaces-thin-client = ["types-aiobotocore-workspaces-thin-client (>=2.18.0,<2.19.0)"]
+workspaces-web = ["types-aiobotocore-workspaces-web (>=2.18.0,<2.19.0)"]
+xray = ["types-aiobotocore-xray (>=2.18.0,<2.19.0)"]
+
+[[package]]
+name = "types-aiobotocore"
+version = "2.22.0"
+description = "Type annotations for aiobotocore 2.22.0 generated with mypy-boto3-builder 8.10.1"
+optional = false
+python-versions = ">=3.8"
+groups = ["dev"]
+files = [
+ {file = "types_aiobotocore-2.22.0-py3-none-any.whl", hash = "sha256:54ffcf8d0144d71fa8b540f3997ae1a555ff3a61200d0c13b3db1c29dec730e5"},
+ {file = "types_aiobotocore-2.22.0.tar.gz", hash = "sha256:04c6acd984f9a37d22db2ebf670ff84e55f6f227d3cc71e9b297720d4a71b718"},
+]
+
+[package.dependencies]
+botocore-stubs = "*"
+typing-extensions = {version = ">=4.1.0", markers = "python_version < \"3.12\""}
+
+[package.extras]
+accessanalyzer = ["types-aiobotocore-accessanalyzer (>=2.22.0,<2.23.0)"]
+account = ["types-aiobotocore-account (>=2.22.0,<2.23.0)"]
+acm = ["types-aiobotocore-acm (>=2.22.0,<2.23.0)"]
+acm-pca = ["types-aiobotocore-acm-pca (>=2.22.0,<2.23.0)"]
+aiobotocore = ["aiobotocore (==2.22.0)"]
+all = ["types-aiobotocore-accessanalyzer (>=2.22.0,<2.23.0)", "types-aiobotocore-account (>=2.22.0,<2.23.0)", "types-aiobotocore-acm (>=2.22.0,<2.23.0)", "types-aiobotocore-acm-pca (>=2.22.0,<2.23.0)", "types-aiobotocore-amp (>=2.22.0,<2.23.0)", "types-aiobotocore-amplify (>=2.22.0,<2.23.0)", "types-aiobotocore-amplifybackend (>=2.22.0,<2.23.0)", "types-aiobotocore-amplifyuibuilder (>=2.22.0,<2.23.0)", "types-aiobotocore-apigateway (>=2.22.0,<2.23.0)", "types-aiobotocore-apigatewaymanagementapi (>=2.22.0,<2.23.0)", "types-aiobotocore-apigatewayv2 (>=2.22.0,<2.23.0)", "types-aiobotocore-appconfig (>=2.22.0,<2.23.0)", "types-aiobotocore-appconfigdata (>=2.22.0,<2.23.0)", "types-aiobotocore-appfabric (>=2.22.0,<2.23.0)", "types-aiobotocore-appflow (>=2.22.0,<2.23.0)", "types-aiobotocore-appintegrations (>=2.22.0,<2.23.0)", "types-aiobotocore-application-autoscaling (>=2.22.0,<2.23.0)", "types-aiobotocore-application-insights (>=2.22.0,<2.23.0)", "types-aiobotocore-application-signals (>=2.22.0,<2.23.0)", "types-aiobotocore-applicationcostprofiler (>=2.22.0,<2.23.0)", "types-aiobotocore-appmesh (>=2.22.0,<2.23.0)", "types-aiobotocore-apprunner (>=2.22.0,<2.23.0)", "types-aiobotocore-appstream (>=2.22.0,<2.23.0)", "types-aiobotocore-appsync (>=2.22.0,<2.23.0)", "types-aiobotocore-apptest (>=2.22.0,<2.23.0)", "types-aiobotocore-arc-zonal-shift (>=2.22.0,<2.23.0)", "types-aiobotocore-artifact (>=2.22.0,<2.23.0)", "types-aiobotocore-athena (>=2.22.0,<2.23.0)", "types-aiobotocore-auditmanager (>=2.22.0,<2.23.0)", "types-aiobotocore-autoscaling (>=2.22.0,<2.23.0)", "types-aiobotocore-autoscaling-plans (>=2.22.0,<2.23.0)", "types-aiobotocore-b2bi (>=2.22.0,<2.23.0)", "types-aiobotocore-backup (>=2.22.0,<2.23.0)", "types-aiobotocore-backup-gateway (>=2.22.0,<2.23.0)", "types-aiobotocore-backupsearch (>=2.22.0,<2.23.0)", "types-aiobotocore-batch (>=2.22.0,<2.23.0)", "types-aiobotocore-bcm-data-exports (>=2.22.0,<2.23.0)", "types-aiobotocore-bcm-pricing-calculator (>=2.22.0,<2.23.0)", "types-aiobotocore-bedrock (>=2.22.0,<2.23.0)", "types-aiobotocore-bedrock-agent (>=2.22.0,<2.23.0)", "types-aiobotocore-bedrock-agent-runtime (>=2.22.0,<2.23.0)", "types-aiobotocore-bedrock-data-automation (>=2.22.0,<2.23.0)", "types-aiobotocore-bedrock-data-automation-runtime (>=2.22.0,<2.23.0)", "types-aiobotocore-bedrock-runtime (>=2.22.0,<2.23.0)", "types-aiobotocore-billing (>=2.22.0,<2.23.0)", "types-aiobotocore-billingconductor (>=2.22.0,<2.23.0)", "types-aiobotocore-braket (>=2.22.0,<2.23.0)", "types-aiobotocore-budgets (>=2.22.0,<2.23.0)", "types-aiobotocore-ce (>=2.22.0,<2.23.0)", "types-aiobotocore-chatbot (>=2.22.0,<2.23.0)", "types-aiobotocore-chime (>=2.22.0,<2.23.0)", "types-aiobotocore-chime-sdk-identity (>=2.22.0,<2.23.0)", "types-aiobotocore-chime-sdk-media-pipelines (>=2.22.0,<2.23.0)", "types-aiobotocore-chime-sdk-meetings (>=2.22.0,<2.23.0)", "types-aiobotocore-chime-sdk-messaging (>=2.22.0,<2.23.0)", "types-aiobotocore-chime-sdk-voice (>=2.22.0,<2.23.0)", "types-aiobotocore-cleanrooms (>=2.22.0,<2.23.0)", "types-aiobotocore-cleanroomsml (>=2.22.0,<2.23.0)", "types-aiobotocore-cloud9 (>=2.22.0,<2.23.0)", "types-aiobotocore-cloudcontrol (>=2.22.0,<2.23.0)", "types-aiobotocore-clouddirectory (>=2.22.0,<2.23.0)", "types-aiobotocore-cloudformation (>=2.22.0,<2.23.0)", "types-aiobotocore-cloudfront (>=2.22.0,<2.23.0)", "types-aiobotocore-cloudfront-keyvaluestore (>=2.22.0,<2.23.0)", "types-aiobotocore-cloudhsm (>=2.22.0,<2.23.0)", "types-aiobotocore-cloudhsmv2 (>=2.22.0,<2.23.0)", "types-aiobotocore-cloudsearch (>=2.22.0,<2.23.0)", "types-aiobotocore-cloudsearchdomain (>=2.22.0,<2.23.0)", "types-aiobotocore-cloudtrail (>=2.22.0,<2.23.0)", "types-aiobotocore-cloudtrail-data (>=2.22.0,<2.23.0)", "types-aiobotocore-cloudwatch (>=2.22.0,<2.23.0)", "types-aiobotocore-codeartifact (>=2.22.0,<2.23.0)", "types-aiobotocore-codebuild (>=2.22.0,<2.23.0)", "types-aiobotocore-codecatalyst (>=2.22.0,<2.23.0)", "types-aiobotocore-codecommit (>=2.22.0,<2.23.0)", "types-aiobotocore-codeconnections (>=2.22.0,<2.23.0)", "types-aiobotocore-codedeploy (>=2.22.0,<2.23.0)", "types-aiobotocore-codeguru-reviewer (>=2.22.0,<2.23.0)", "types-aiobotocore-codeguru-security (>=2.22.0,<2.23.0)", "types-aiobotocore-codeguruprofiler (>=2.22.0,<2.23.0)", "types-aiobotocore-codepipeline (>=2.22.0,<2.23.0)", "types-aiobotocore-codestar-connections (>=2.22.0,<2.23.0)", "types-aiobotocore-codestar-notifications (>=2.22.0,<2.23.0)", "types-aiobotocore-cognito-identity (>=2.22.0,<2.23.0)", "types-aiobotocore-cognito-idp (>=2.22.0,<2.23.0)", "types-aiobotocore-cognito-sync (>=2.22.0,<2.23.0)", "types-aiobotocore-comprehend (>=2.22.0,<2.23.0)", "types-aiobotocore-comprehendmedical (>=2.22.0,<2.23.0)", "types-aiobotocore-compute-optimizer (>=2.22.0,<2.23.0)", "types-aiobotocore-config (>=2.22.0,<2.23.0)", "types-aiobotocore-connect (>=2.22.0,<2.23.0)", "types-aiobotocore-connect-contact-lens (>=2.22.0,<2.23.0)", "types-aiobotocore-connectcampaigns (>=2.22.0,<2.23.0)", "types-aiobotocore-connectcampaignsv2 (>=2.22.0,<2.23.0)", "types-aiobotocore-connectcases (>=2.22.0,<2.23.0)", "types-aiobotocore-connectparticipant (>=2.22.0,<2.23.0)", "types-aiobotocore-controlcatalog (>=2.22.0,<2.23.0)", "types-aiobotocore-controltower (>=2.22.0,<2.23.0)", "types-aiobotocore-cost-optimization-hub (>=2.22.0,<2.23.0)", "types-aiobotocore-cur (>=2.22.0,<2.23.0)", "types-aiobotocore-customer-profiles (>=2.22.0,<2.23.0)", "types-aiobotocore-databrew (>=2.22.0,<2.23.0)", "types-aiobotocore-dataexchange (>=2.22.0,<2.23.0)", "types-aiobotocore-datapipeline (>=2.22.0,<2.23.0)", "types-aiobotocore-datasync (>=2.22.0,<2.23.0)", "types-aiobotocore-datazone (>=2.22.0,<2.23.0)", "types-aiobotocore-dax (>=2.22.0,<2.23.0)", "types-aiobotocore-deadline (>=2.22.0,<2.23.0)", "types-aiobotocore-detective (>=2.22.0,<2.23.0)", "types-aiobotocore-devicefarm (>=2.22.0,<2.23.0)", "types-aiobotocore-devops-guru (>=2.22.0,<2.23.0)", "types-aiobotocore-directconnect (>=2.22.0,<2.23.0)", "types-aiobotocore-discovery (>=2.22.0,<2.23.0)", "types-aiobotocore-dlm (>=2.22.0,<2.23.0)", "types-aiobotocore-dms (>=2.22.0,<2.23.0)", "types-aiobotocore-docdb (>=2.22.0,<2.23.0)", "types-aiobotocore-docdb-elastic (>=2.22.0,<2.23.0)", "types-aiobotocore-drs (>=2.22.0,<2.23.0)", "types-aiobotocore-ds (>=2.22.0,<2.23.0)", "types-aiobotocore-ds-data (>=2.22.0,<2.23.0)", "types-aiobotocore-dsql (>=2.22.0,<2.23.0)", "types-aiobotocore-dynamodb (>=2.22.0,<2.23.0)", "types-aiobotocore-dynamodbstreams (>=2.22.0,<2.23.0)", "types-aiobotocore-ebs (>=2.22.0,<2.23.0)", "types-aiobotocore-ec2 (>=2.22.0,<2.23.0)", "types-aiobotocore-ec2-instance-connect (>=2.22.0,<2.23.0)", "types-aiobotocore-ecr (>=2.22.0,<2.23.0)", "types-aiobotocore-ecr-public (>=2.22.0,<2.23.0)", "types-aiobotocore-ecs (>=2.22.0,<2.23.0)", "types-aiobotocore-efs (>=2.22.0,<2.23.0)", "types-aiobotocore-eks (>=2.22.0,<2.23.0)", "types-aiobotocore-eks-auth (>=2.22.0,<2.23.0)", "types-aiobotocore-elasticache (>=2.22.0,<2.23.0)", "types-aiobotocore-elasticbeanstalk (>=2.22.0,<2.23.0)", "types-aiobotocore-elastictranscoder (>=2.22.0,<2.23.0)", "types-aiobotocore-elb (>=2.22.0,<2.23.0)", "types-aiobotocore-elbv2 (>=2.22.0,<2.23.0)", "types-aiobotocore-emr (>=2.22.0,<2.23.0)", "types-aiobotocore-emr-containers (>=2.22.0,<2.23.0)", "types-aiobotocore-emr-serverless (>=2.22.0,<2.23.0)", "types-aiobotocore-entityresolution (>=2.22.0,<2.23.0)", "types-aiobotocore-es (>=2.22.0,<2.23.0)", "types-aiobotocore-events (>=2.22.0,<2.23.0)", "types-aiobotocore-evidently (>=2.22.0,<2.23.0)", "types-aiobotocore-finspace (>=2.22.0,<2.23.0)", "types-aiobotocore-finspace-data (>=2.22.0,<2.23.0)", "types-aiobotocore-firehose (>=2.22.0,<2.23.0)", "types-aiobotocore-fis (>=2.22.0,<2.23.0)", "types-aiobotocore-fms (>=2.22.0,<2.23.0)", "types-aiobotocore-forecast (>=2.22.0,<2.23.0)", "types-aiobotocore-forecastquery (>=2.22.0,<2.23.0)", "types-aiobotocore-frauddetector (>=2.22.0,<2.23.0)", "types-aiobotocore-freetier (>=2.22.0,<2.23.0)", "types-aiobotocore-fsx (>=2.22.0,<2.23.0)", "types-aiobotocore-gamelift (>=2.22.0,<2.23.0)", "types-aiobotocore-geo-maps (>=2.22.0,<2.23.0)", "types-aiobotocore-geo-places (>=2.22.0,<2.23.0)", "types-aiobotocore-geo-routes (>=2.22.0,<2.23.0)", "types-aiobotocore-glacier (>=2.22.0,<2.23.0)", "types-aiobotocore-globalaccelerator (>=2.22.0,<2.23.0)", "types-aiobotocore-glue (>=2.22.0,<2.23.0)", "types-aiobotocore-grafana (>=2.22.0,<2.23.0)", "types-aiobotocore-greengrass (>=2.22.0,<2.23.0)", "types-aiobotocore-greengrassv2 (>=2.22.0,<2.23.0)", "types-aiobotocore-groundstation (>=2.22.0,<2.23.0)", "types-aiobotocore-guardduty (>=2.22.0,<2.23.0)", "types-aiobotocore-health (>=2.22.0,<2.23.0)", "types-aiobotocore-healthlake (>=2.22.0,<2.23.0)", "types-aiobotocore-iam (>=2.22.0,<2.23.0)", "types-aiobotocore-identitystore (>=2.22.0,<2.23.0)", "types-aiobotocore-imagebuilder (>=2.22.0,<2.23.0)", "types-aiobotocore-importexport (>=2.22.0,<2.23.0)", "types-aiobotocore-inspector (>=2.22.0,<2.23.0)", "types-aiobotocore-inspector-scan (>=2.22.0,<2.23.0)", "types-aiobotocore-inspector2 (>=2.22.0,<2.23.0)", "types-aiobotocore-internetmonitor (>=2.22.0,<2.23.0)", "types-aiobotocore-invoicing (>=2.22.0,<2.23.0)", "types-aiobotocore-iot (>=2.22.0,<2.23.0)", "types-aiobotocore-iot-data (>=2.22.0,<2.23.0)", "types-aiobotocore-iot-jobs-data (>=2.22.0,<2.23.0)", "types-aiobotocore-iotanalytics (>=2.22.0,<2.23.0)", "types-aiobotocore-iotdeviceadvisor (>=2.22.0,<2.23.0)", "types-aiobotocore-iotevents (>=2.22.0,<2.23.0)", "types-aiobotocore-iotevents-data (>=2.22.0,<2.23.0)", "types-aiobotocore-iotfleethub (>=2.22.0,<2.23.0)", "types-aiobotocore-iotfleetwise (>=2.22.0,<2.23.0)", "types-aiobotocore-iotsecuretunneling (>=2.22.0,<2.23.0)", "types-aiobotocore-iotsitewise (>=2.22.0,<2.23.0)", "types-aiobotocore-iotthingsgraph (>=2.22.0,<2.23.0)", "types-aiobotocore-iottwinmaker (>=2.22.0,<2.23.0)", "types-aiobotocore-iotwireless (>=2.22.0,<2.23.0)", "types-aiobotocore-ivs (>=2.22.0,<2.23.0)", "types-aiobotocore-ivs-realtime (>=2.22.0,<2.23.0)", "types-aiobotocore-ivschat (>=2.22.0,<2.23.0)", "types-aiobotocore-kafka (>=2.22.0,<2.23.0)", "types-aiobotocore-kafkaconnect (>=2.22.0,<2.23.0)", "types-aiobotocore-kendra (>=2.22.0,<2.23.0)", "types-aiobotocore-kendra-ranking (>=2.22.0,<2.23.0)", "types-aiobotocore-keyspaces (>=2.22.0,<2.23.0)", "types-aiobotocore-kinesis (>=2.22.0,<2.23.0)", "types-aiobotocore-kinesis-video-archived-media (>=2.22.0,<2.23.0)", "types-aiobotocore-kinesis-video-media (>=2.22.0,<2.23.0)", "types-aiobotocore-kinesis-video-signaling (>=2.22.0,<2.23.0)", "types-aiobotocore-kinesis-video-webrtc-storage (>=2.22.0,<2.23.0)", "types-aiobotocore-kinesisanalytics (>=2.22.0,<2.23.0)", "types-aiobotocore-kinesisanalyticsv2 (>=2.22.0,<2.23.0)", "types-aiobotocore-kinesisvideo (>=2.22.0,<2.23.0)", "types-aiobotocore-kms (>=2.22.0,<2.23.0)", "types-aiobotocore-lakeformation (>=2.22.0,<2.23.0)", "types-aiobotocore-lambda (>=2.22.0,<2.23.0)", "types-aiobotocore-launch-wizard (>=2.22.0,<2.23.0)", "types-aiobotocore-lex-models (>=2.22.0,<2.23.0)", "types-aiobotocore-lex-runtime (>=2.22.0,<2.23.0)", "types-aiobotocore-lexv2-models (>=2.22.0,<2.23.0)", "types-aiobotocore-lexv2-runtime (>=2.22.0,<2.23.0)", "types-aiobotocore-license-manager (>=2.22.0,<2.23.0)", "types-aiobotocore-license-manager-linux-subscriptions (>=2.22.0,<2.23.0)", "types-aiobotocore-license-manager-user-subscriptions (>=2.22.0,<2.23.0)", "types-aiobotocore-lightsail (>=2.22.0,<2.23.0)", "types-aiobotocore-location (>=2.22.0,<2.23.0)", "types-aiobotocore-logs (>=2.22.0,<2.23.0)", "types-aiobotocore-lookoutequipment (>=2.22.0,<2.23.0)", "types-aiobotocore-lookoutmetrics (>=2.22.0,<2.23.0)", "types-aiobotocore-lookoutvision (>=2.22.0,<2.23.0)", "types-aiobotocore-m2 (>=2.22.0,<2.23.0)", "types-aiobotocore-machinelearning (>=2.22.0,<2.23.0)", "types-aiobotocore-macie2 (>=2.22.0,<2.23.0)", "types-aiobotocore-mailmanager (>=2.22.0,<2.23.0)", "types-aiobotocore-managedblockchain (>=2.22.0,<2.23.0)", "types-aiobotocore-managedblockchain-query (>=2.22.0,<2.23.0)", "types-aiobotocore-marketplace-agreement (>=2.22.0,<2.23.0)", "types-aiobotocore-marketplace-catalog (>=2.22.0,<2.23.0)", "types-aiobotocore-marketplace-deployment (>=2.22.0,<2.23.0)", "types-aiobotocore-marketplace-entitlement (>=2.22.0,<2.23.0)", "types-aiobotocore-marketplace-reporting (>=2.22.0,<2.23.0)", "types-aiobotocore-marketplacecommerceanalytics (>=2.22.0,<2.23.0)", "types-aiobotocore-mediaconnect (>=2.22.0,<2.23.0)", "types-aiobotocore-mediaconvert (>=2.22.0,<2.23.0)", "types-aiobotocore-medialive (>=2.22.0,<2.23.0)", "types-aiobotocore-mediapackage (>=2.22.0,<2.23.0)", "types-aiobotocore-mediapackage-vod (>=2.22.0,<2.23.0)", "types-aiobotocore-mediapackagev2 (>=2.22.0,<2.23.0)", "types-aiobotocore-mediastore (>=2.22.0,<2.23.0)", "types-aiobotocore-mediastore-data (>=2.22.0,<2.23.0)", "types-aiobotocore-mediatailor (>=2.22.0,<2.23.0)", "types-aiobotocore-medical-imaging (>=2.22.0,<2.23.0)", "types-aiobotocore-memorydb (>=2.22.0,<2.23.0)", "types-aiobotocore-meteringmarketplace (>=2.22.0,<2.23.0)", "types-aiobotocore-mgh (>=2.22.0,<2.23.0)", "types-aiobotocore-mgn (>=2.22.0,<2.23.0)", "types-aiobotocore-migration-hub-refactor-spaces (>=2.22.0,<2.23.0)", "types-aiobotocore-migrationhub-config (>=2.22.0,<2.23.0)", "types-aiobotocore-migrationhuborchestrator (>=2.22.0,<2.23.0)", "types-aiobotocore-migrationhubstrategy (>=2.22.0,<2.23.0)", "types-aiobotocore-mq (>=2.22.0,<2.23.0)", "types-aiobotocore-mturk (>=2.22.0,<2.23.0)", "types-aiobotocore-mwaa (>=2.22.0,<2.23.0)", "types-aiobotocore-neptune (>=2.22.0,<2.23.0)", "types-aiobotocore-neptune-graph (>=2.22.0,<2.23.0)", "types-aiobotocore-neptunedata (>=2.22.0,<2.23.0)", "types-aiobotocore-network-firewall (>=2.22.0,<2.23.0)", "types-aiobotocore-networkflowmonitor (>=2.22.0,<2.23.0)", "types-aiobotocore-networkmanager (>=2.22.0,<2.23.0)", "types-aiobotocore-networkmonitor (>=2.22.0,<2.23.0)", "types-aiobotocore-notifications (>=2.22.0,<2.23.0)", "types-aiobotocore-notificationscontacts (>=2.22.0,<2.23.0)", "types-aiobotocore-oam (>=2.22.0,<2.23.0)", "types-aiobotocore-observabilityadmin (>=2.22.0,<2.23.0)", "types-aiobotocore-omics (>=2.22.0,<2.23.0)", "types-aiobotocore-opensearch (>=2.22.0,<2.23.0)", "types-aiobotocore-opensearchserverless (>=2.22.0,<2.23.0)", "types-aiobotocore-opsworks (>=2.22.0,<2.23.0)", "types-aiobotocore-opsworkscm (>=2.22.0,<2.23.0)", "types-aiobotocore-organizations (>=2.22.0,<2.23.0)", "types-aiobotocore-osis (>=2.22.0,<2.23.0)", "types-aiobotocore-outposts (>=2.22.0,<2.23.0)", "types-aiobotocore-panorama (>=2.22.0,<2.23.0)", "types-aiobotocore-partnercentral-selling (>=2.22.0,<2.23.0)", "types-aiobotocore-payment-cryptography (>=2.22.0,<2.23.0)", "types-aiobotocore-payment-cryptography-data (>=2.22.0,<2.23.0)", "types-aiobotocore-pca-connector-ad (>=2.22.0,<2.23.0)", "types-aiobotocore-pca-connector-scep (>=2.22.0,<2.23.0)", "types-aiobotocore-pcs (>=2.22.0,<2.23.0)", "types-aiobotocore-personalize (>=2.22.0,<2.23.0)", "types-aiobotocore-personalize-events (>=2.22.0,<2.23.0)", "types-aiobotocore-personalize-runtime (>=2.22.0,<2.23.0)", "types-aiobotocore-pi (>=2.22.0,<2.23.0)", "types-aiobotocore-pinpoint (>=2.22.0,<2.23.0)", "types-aiobotocore-pinpoint-email (>=2.22.0,<2.23.0)", "types-aiobotocore-pinpoint-sms-voice (>=2.22.0,<2.23.0)", "types-aiobotocore-pinpoint-sms-voice-v2 (>=2.22.0,<2.23.0)", "types-aiobotocore-pipes (>=2.22.0,<2.23.0)", "types-aiobotocore-polly (>=2.22.0,<2.23.0)", "types-aiobotocore-pricing (>=2.22.0,<2.23.0)", "types-aiobotocore-privatenetworks (>=2.22.0,<2.23.0)", "types-aiobotocore-proton (>=2.22.0,<2.23.0)", "types-aiobotocore-qapps (>=2.22.0,<2.23.0)", "types-aiobotocore-qbusiness (>=2.22.0,<2.23.0)", "types-aiobotocore-qconnect (>=2.22.0,<2.23.0)", "types-aiobotocore-qldb (>=2.22.0,<2.23.0)", "types-aiobotocore-qldb-session (>=2.22.0,<2.23.0)", "types-aiobotocore-quicksight (>=2.22.0,<2.23.0)", "types-aiobotocore-ram (>=2.22.0,<2.23.0)", "types-aiobotocore-rbin (>=2.22.0,<2.23.0)", "types-aiobotocore-rds (>=2.22.0,<2.23.0)", "types-aiobotocore-rds-data (>=2.22.0,<2.23.0)", "types-aiobotocore-redshift (>=2.22.0,<2.23.0)", "types-aiobotocore-redshift-data (>=2.22.0,<2.23.0)", "types-aiobotocore-redshift-serverless (>=2.22.0,<2.23.0)", "types-aiobotocore-rekognition (>=2.22.0,<2.23.0)", "types-aiobotocore-repostspace (>=2.22.0,<2.23.0)", "types-aiobotocore-resiliencehub (>=2.22.0,<2.23.0)", "types-aiobotocore-resource-explorer-2 (>=2.22.0,<2.23.0)", "types-aiobotocore-resource-groups (>=2.22.0,<2.23.0)", "types-aiobotocore-resourcegroupstaggingapi (>=2.22.0,<2.23.0)", "types-aiobotocore-robomaker (>=2.22.0,<2.23.0)", "types-aiobotocore-rolesanywhere (>=2.22.0,<2.23.0)", "types-aiobotocore-route53 (>=2.22.0,<2.23.0)", "types-aiobotocore-route53-recovery-cluster (>=2.22.0,<2.23.0)", "types-aiobotocore-route53-recovery-control-config (>=2.22.0,<2.23.0)", "types-aiobotocore-route53-recovery-readiness (>=2.22.0,<2.23.0)", "types-aiobotocore-route53domains (>=2.22.0,<2.23.0)", "types-aiobotocore-route53profiles (>=2.22.0,<2.23.0)", "types-aiobotocore-route53resolver (>=2.22.0,<2.23.0)", "types-aiobotocore-rum (>=2.22.0,<2.23.0)", "types-aiobotocore-s3 (>=2.22.0,<2.23.0)", "types-aiobotocore-s3control (>=2.22.0,<2.23.0)", "types-aiobotocore-s3outposts (>=2.22.0,<2.23.0)", "types-aiobotocore-s3tables (>=2.22.0,<2.23.0)", "types-aiobotocore-sagemaker (>=2.22.0,<2.23.0)", "types-aiobotocore-sagemaker-a2i-runtime (>=2.22.0,<2.23.0)", "types-aiobotocore-sagemaker-edge (>=2.22.0,<2.23.0)", "types-aiobotocore-sagemaker-featurestore-runtime (>=2.22.0,<2.23.0)", "types-aiobotocore-sagemaker-geospatial (>=2.22.0,<2.23.0)", "types-aiobotocore-sagemaker-metrics (>=2.22.0,<2.23.0)", "types-aiobotocore-sagemaker-runtime (>=2.22.0,<2.23.0)", "types-aiobotocore-savingsplans (>=2.22.0,<2.23.0)", "types-aiobotocore-scheduler (>=2.22.0,<2.23.0)", "types-aiobotocore-schemas (>=2.22.0,<2.23.0)", "types-aiobotocore-sdb (>=2.22.0,<2.23.0)", "types-aiobotocore-secretsmanager (>=2.22.0,<2.23.0)", "types-aiobotocore-security-ir (>=2.22.0,<2.23.0)", "types-aiobotocore-securityhub (>=2.22.0,<2.23.0)", "types-aiobotocore-securitylake (>=2.22.0,<2.23.0)", "types-aiobotocore-serverlessrepo (>=2.22.0,<2.23.0)", "types-aiobotocore-service-quotas (>=2.22.0,<2.23.0)", "types-aiobotocore-servicecatalog (>=2.22.0,<2.23.0)", "types-aiobotocore-servicecatalog-appregistry (>=2.22.0,<2.23.0)", "types-aiobotocore-servicediscovery (>=2.22.0,<2.23.0)", "types-aiobotocore-ses (>=2.22.0,<2.23.0)", "types-aiobotocore-sesv2 (>=2.22.0,<2.23.0)", "types-aiobotocore-shield (>=2.22.0,<2.23.0)", "types-aiobotocore-signer (>=2.22.0,<2.23.0)", "types-aiobotocore-simspaceweaver (>=2.22.0,<2.23.0)", "types-aiobotocore-sms (>=2.22.0,<2.23.0)", "types-aiobotocore-sms-voice (>=2.22.0,<2.23.0)", "types-aiobotocore-snow-device-management (>=2.22.0,<2.23.0)", "types-aiobotocore-snowball (>=2.22.0,<2.23.0)", "types-aiobotocore-sns (>=2.22.0,<2.23.0)", "types-aiobotocore-socialmessaging (>=2.22.0,<2.23.0)", "types-aiobotocore-sqs (>=2.22.0,<2.23.0)", "types-aiobotocore-ssm (>=2.22.0,<2.23.0)", "types-aiobotocore-ssm-contacts (>=2.22.0,<2.23.0)", "types-aiobotocore-ssm-incidents (>=2.22.0,<2.23.0)", "types-aiobotocore-ssm-quicksetup (>=2.22.0,<2.23.0)", "types-aiobotocore-ssm-sap (>=2.22.0,<2.23.0)", "types-aiobotocore-sso (>=2.22.0,<2.23.0)", "types-aiobotocore-sso-admin (>=2.22.0,<2.23.0)", "types-aiobotocore-sso-oidc (>=2.22.0,<2.23.0)", "types-aiobotocore-stepfunctions (>=2.22.0,<2.23.0)", "types-aiobotocore-storagegateway (>=2.22.0,<2.23.0)", "types-aiobotocore-sts (>=2.22.0,<2.23.0)", "types-aiobotocore-supplychain (>=2.22.0,<2.23.0)", "types-aiobotocore-support (>=2.22.0,<2.23.0)", "types-aiobotocore-support-app (>=2.22.0,<2.23.0)", "types-aiobotocore-swf (>=2.22.0,<2.23.0)", "types-aiobotocore-synthetics (>=2.22.0,<2.23.0)", "types-aiobotocore-taxsettings (>=2.22.0,<2.23.0)", "types-aiobotocore-textract (>=2.22.0,<2.23.0)", "types-aiobotocore-timestream-influxdb (>=2.22.0,<2.23.0)", "types-aiobotocore-timestream-query (>=2.22.0,<2.23.0)", "types-aiobotocore-timestream-write (>=2.22.0,<2.23.0)", "types-aiobotocore-tnb (>=2.22.0,<2.23.0)", "types-aiobotocore-transcribe (>=2.22.0,<2.23.0)", "types-aiobotocore-transfer (>=2.22.0,<2.23.0)", "types-aiobotocore-translate (>=2.22.0,<2.23.0)", "types-aiobotocore-trustedadvisor (>=2.22.0,<2.23.0)", "types-aiobotocore-verifiedpermissions (>=2.22.0,<2.23.0)", "types-aiobotocore-voice-id (>=2.22.0,<2.23.0)", "types-aiobotocore-vpc-lattice (>=2.22.0,<2.23.0)", "types-aiobotocore-waf (>=2.22.0,<2.23.0)", "types-aiobotocore-waf-regional (>=2.22.0,<2.23.0)", "types-aiobotocore-wafv2 (>=2.22.0,<2.23.0)", "types-aiobotocore-wellarchitected (>=2.22.0,<2.23.0)", "types-aiobotocore-wisdom (>=2.22.0,<2.23.0)", "types-aiobotocore-workdocs (>=2.22.0,<2.23.0)", "types-aiobotocore-workmail (>=2.22.0,<2.23.0)", "types-aiobotocore-workmailmessageflow (>=2.22.0,<2.23.0)", "types-aiobotocore-workspaces (>=2.22.0,<2.23.0)", "types-aiobotocore-workspaces-thin-client (>=2.22.0,<2.23.0)", "types-aiobotocore-workspaces-web (>=2.22.0,<2.23.0)", "types-aiobotocore-xray (>=2.22.0,<2.23.0)"]
+amp = ["types-aiobotocore-amp (>=2.22.0,<2.23.0)"]
+amplify = ["types-aiobotocore-amplify (>=2.22.0,<2.23.0)"]
+amplifybackend = ["types-aiobotocore-amplifybackend (>=2.22.0,<2.23.0)"]
+amplifyuibuilder = ["types-aiobotocore-amplifyuibuilder (>=2.22.0,<2.23.0)"]
+apigateway = ["types-aiobotocore-apigateway (>=2.22.0,<2.23.0)"]
+apigatewaymanagementapi = ["types-aiobotocore-apigatewaymanagementapi (>=2.22.0,<2.23.0)"]
+apigatewayv2 = ["types-aiobotocore-apigatewayv2 (>=2.22.0,<2.23.0)"]
+appconfig = ["types-aiobotocore-appconfig (>=2.22.0,<2.23.0)"]
+appconfigdata = ["types-aiobotocore-appconfigdata (>=2.22.0,<2.23.0)"]
+appfabric = ["types-aiobotocore-appfabric (>=2.22.0,<2.23.0)"]
+appflow = ["types-aiobotocore-appflow (>=2.22.0,<2.23.0)"]
+appintegrations = ["types-aiobotocore-appintegrations (>=2.22.0,<2.23.0)"]
+application-autoscaling = ["types-aiobotocore-application-autoscaling (>=2.22.0,<2.23.0)"]
+application-insights = ["types-aiobotocore-application-insights (>=2.22.0,<2.23.0)"]
+application-signals = ["types-aiobotocore-application-signals (>=2.22.0,<2.23.0)"]
+applicationcostprofiler = ["types-aiobotocore-applicationcostprofiler (>=2.22.0,<2.23.0)"]
+appmesh = ["types-aiobotocore-appmesh (>=2.22.0,<2.23.0)"]
+apprunner = ["types-aiobotocore-apprunner (>=2.22.0,<2.23.0)"]
+appstream = ["types-aiobotocore-appstream (>=2.22.0,<2.23.0)"]
+appsync = ["types-aiobotocore-appsync (>=2.22.0,<2.23.0)"]
+apptest = ["types-aiobotocore-apptest (>=2.22.0,<2.23.0)"]
+arc-zonal-shift = ["types-aiobotocore-arc-zonal-shift (>=2.22.0,<2.23.0)"]
+artifact = ["types-aiobotocore-artifact (>=2.22.0,<2.23.0)"]
+athena = ["types-aiobotocore-athena (>=2.22.0,<2.23.0)"]
+auditmanager = ["types-aiobotocore-auditmanager (>=2.22.0,<2.23.0)"]
+autoscaling = ["types-aiobotocore-autoscaling (>=2.22.0,<2.23.0)"]
+autoscaling-plans = ["types-aiobotocore-autoscaling-plans (>=2.22.0,<2.23.0)"]
+b2bi = ["types-aiobotocore-b2bi (>=2.22.0,<2.23.0)"]
+backup = ["types-aiobotocore-backup (>=2.22.0,<2.23.0)"]
+backup-gateway = ["types-aiobotocore-backup-gateway (>=2.22.0,<2.23.0)"]
+backupsearch = ["types-aiobotocore-backupsearch (>=2.22.0,<2.23.0)"]
+batch = ["types-aiobotocore-batch (>=2.22.0,<2.23.0)"]
+bcm-data-exports = ["types-aiobotocore-bcm-data-exports (>=2.22.0,<2.23.0)"]
+bcm-pricing-calculator = ["types-aiobotocore-bcm-pricing-calculator (>=2.22.0,<2.23.0)"]
+bedrock = ["types-aiobotocore-bedrock (>=2.22.0,<2.23.0)"]
+bedrock-agent = ["types-aiobotocore-bedrock-agent (>=2.22.0,<2.23.0)"]
+bedrock-agent-runtime = ["types-aiobotocore-bedrock-agent-runtime (>=2.22.0,<2.23.0)"]
+bedrock-data-automation = ["types-aiobotocore-bedrock-data-automation (>=2.22.0,<2.23.0)"]
+bedrock-data-automation-runtime = ["types-aiobotocore-bedrock-data-automation-runtime (>=2.22.0,<2.23.0)"]
+bedrock-runtime = ["types-aiobotocore-bedrock-runtime (>=2.22.0,<2.23.0)"]
+billing = ["types-aiobotocore-billing (>=2.22.0,<2.23.0)"]
+billingconductor = ["types-aiobotocore-billingconductor (>=2.22.0,<2.23.0)"]
+braket = ["types-aiobotocore-braket (>=2.22.0,<2.23.0)"]
+budgets = ["types-aiobotocore-budgets (>=2.22.0,<2.23.0)"]
+ce = ["types-aiobotocore-ce (>=2.22.0,<2.23.0)"]
+chatbot = ["types-aiobotocore-chatbot (>=2.22.0,<2.23.0)"]
+chime = ["types-aiobotocore-chime (>=2.22.0,<2.23.0)"]
+chime-sdk-identity = ["types-aiobotocore-chime-sdk-identity (>=2.22.0,<2.23.0)"]
+chime-sdk-media-pipelines = ["types-aiobotocore-chime-sdk-media-pipelines (>=2.22.0,<2.23.0)"]
+chime-sdk-meetings = ["types-aiobotocore-chime-sdk-meetings (>=2.22.0,<2.23.0)"]
+chime-sdk-messaging = ["types-aiobotocore-chime-sdk-messaging (>=2.22.0,<2.23.0)"]
+chime-sdk-voice = ["types-aiobotocore-chime-sdk-voice (>=2.22.0,<2.23.0)"]
+cleanrooms = ["types-aiobotocore-cleanrooms (>=2.22.0,<2.23.0)"]
+cleanroomsml = ["types-aiobotocore-cleanroomsml (>=2.22.0,<2.23.0)"]
+cloud9 = ["types-aiobotocore-cloud9 (>=2.22.0,<2.23.0)"]
+cloudcontrol = ["types-aiobotocore-cloudcontrol (>=2.22.0,<2.23.0)"]
+clouddirectory = ["types-aiobotocore-clouddirectory (>=2.22.0,<2.23.0)"]
+cloudformation = ["types-aiobotocore-cloudformation (>=2.22.0,<2.23.0)"]
+cloudfront = ["types-aiobotocore-cloudfront (>=2.22.0,<2.23.0)"]
+cloudfront-keyvaluestore = ["types-aiobotocore-cloudfront-keyvaluestore (>=2.22.0,<2.23.0)"]
+cloudhsm = ["types-aiobotocore-cloudhsm (>=2.22.0,<2.23.0)"]
+cloudhsmv2 = ["types-aiobotocore-cloudhsmv2 (>=2.22.0,<2.23.0)"]
+cloudsearch = ["types-aiobotocore-cloudsearch (>=2.22.0,<2.23.0)"]
+cloudsearchdomain = ["types-aiobotocore-cloudsearchdomain (>=2.22.0,<2.23.0)"]
+cloudtrail = ["types-aiobotocore-cloudtrail (>=2.22.0,<2.23.0)"]
+cloudtrail-data = ["types-aiobotocore-cloudtrail-data (>=2.22.0,<2.23.0)"]
+cloudwatch = ["types-aiobotocore-cloudwatch (>=2.22.0,<2.23.0)"]
+codeartifact = ["types-aiobotocore-codeartifact (>=2.22.0,<2.23.0)"]
+codebuild = ["types-aiobotocore-codebuild (>=2.22.0,<2.23.0)"]
+codecatalyst = ["types-aiobotocore-codecatalyst (>=2.22.0,<2.23.0)"]
+codecommit = ["types-aiobotocore-codecommit (>=2.22.0,<2.23.0)"]
+codeconnections = ["types-aiobotocore-codeconnections (>=2.22.0,<2.23.0)"]
+codedeploy = ["types-aiobotocore-codedeploy (>=2.22.0,<2.23.0)"]
+codeguru-reviewer = ["types-aiobotocore-codeguru-reviewer (>=2.22.0,<2.23.0)"]
+codeguru-security = ["types-aiobotocore-codeguru-security (>=2.22.0,<2.23.0)"]
+codeguruprofiler = ["types-aiobotocore-codeguruprofiler (>=2.22.0,<2.23.0)"]
+codepipeline = ["types-aiobotocore-codepipeline (>=2.22.0,<2.23.0)"]
+codestar-connections = ["types-aiobotocore-codestar-connections (>=2.22.0,<2.23.0)"]
+codestar-notifications = ["types-aiobotocore-codestar-notifications (>=2.22.0,<2.23.0)"]
+cognito-identity = ["types-aiobotocore-cognito-identity (>=2.22.0,<2.23.0)"]
+cognito-idp = ["types-aiobotocore-cognito-idp (>=2.22.0,<2.23.0)"]
+cognito-sync = ["types-aiobotocore-cognito-sync (>=2.22.0,<2.23.0)"]
+comprehend = ["types-aiobotocore-comprehend (>=2.22.0,<2.23.0)"]
+comprehendmedical = ["types-aiobotocore-comprehendmedical (>=2.22.0,<2.23.0)"]
+compute-optimizer = ["types-aiobotocore-compute-optimizer (>=2.22.0,<2.23.0)"]
+config = ["types-aiobotocore-config (>=2.22.0,<2.23.0)"]
+connect = ["types-aiobotocore-connect (>=2.22.0,<2.23.0)"]
+connect-contact-lens = ["types-aiobotocore-connect-contact-lens (>=2.22.0,<2.23.0)"]
+connectcampaigns = ["types-aiobotocore-connectcampaigns (>=2.22.0,<2.23.0)"]
+connectcampaignsv2 = ["types-aiobotocore-connectcampaignsv2 (>=2.22.0,<2.23.0)"]
+connectcases = ["types-aiobotocore-connectcases (>=2.22.0,<2.23.0)"]
+connectparticipant = ["types-aiobotocore-connectparticipant (>=2.22.0,<2.23.0)"]
+controlcatalog = ["types-aiobotocore-controlcatalog (>=2.22.0,<2.23.0)"]
+controltower = ["types-aiobotocore-controltower (>=2.22.0,<2.23.0)"]
+cost-optimization-hub = ["types-aiobotocore-cost-optimization-hub (>=2.22.0,<2.23.0)"]
+cur = ["types-aiobotocore-cur (>=2.22.0,<2.23.0)"]
+customer-profiles = ["types-aiobotocore-customer-profiles (>=2.22.0,<2.23.0)"]
+databrew = ["types-aiobotocore-databrew (>=2.22.0,<2.23.0)"]
+dataexchange = ["types-aiobotocore-dataexchange (>=2.22.0,<2.23.0)"]
+datapipeline = ["types-aiobotocore-datapipeline (>=2.22.0,<2.23.0)"]
+datasync = ["types-aiobotocore-datasync (>=2.22.0,<2.23.0)"]
+datazone = ["types-aiobotocore-datazone (>=2.22.0,<2.23.0)"]
+dax = ["types-aiobotocore-dax (>=2.22.0,<2.23.0)"]
+deadline = ["types-aiobotocore-deadline (>=2.22.0,<2.23.0)"]
+detective = ["types-aiobotocore-detective (>=2.22.0,<2.23.0)"]
+devicefarm = ["types-aiobotocore-devicefarm (>=2.22.0,<2.23.0)"]
+devops-guru = ["types-aiobotocore-devops-guru (>=2.22.0,<2.23.0)"]
+directconnect = ["types-aiobotocore-directconnect (>=2.22.0,<2.23.0)"]
+discovery = ["types-aiobotocore-discovery (>=2.22.0,<2.23.0)"]
+dlm = ["types-aiobotocore-dlm (>=2.22.0,<2.23.0)"]
+dms = ["types-aiobotocore-dms (>=2.22.0,<2.23.0)"]
+docdb = ["types-aiobotocore-docdb (>=2.22.0,<2.23.0)"]
+docdb-elastic = ["types-aiobotocore-docdb-elastic (>=2.22.0,<2.23.0)"]
+drs = ["types-aiobotocore-drs (>=2.22.0,<2.23.0)"]
+ds = ["types-aiobotocore-ds (>=2.22.0,<2.23.0)"]
+ds-data = ["types-aiobotocore-ds-data (>=2.22.0,<2.23.0)"]
+dsql = ["types-aiobotocore-dsql (>=2.22.0,<2.23.0)"]
+dynamodb = ["types-aiobotocore-dynamodb (>=2.22.0,<2.23.0)"]
+dynamodbstreams = ["types-aiobotocore-dynamodbstreams (>=2.22.0,<2.23.0)"]
+ebs = ["types-aiobotocore-ebs (>=2.22.0,<2.23.0)"]
+ec2 = ["types-aiobotocore-ec2 (>=2.22.0,<2.23.0)"]
+ec2-instance-connect = ["types-aiobotocore-ec2-instance-connect (>=2.22.0,<2.23.0)"]
+ecr = ["types-aiobotocore-ecr (>=2.22.0,<2.23.0)"]
+ecr-public = ["types-aiobotocore-ecr-public (>=2.22.0,<2.23.0)"]
+ecs = ["types-aiobotocore-ecs (>=2.22.0,<2.23.0)"]
+efs = ["types-aiobotocore-efs (>=2.22.0,<2.23.0)"]
+eks = ["types-aiobotocore-eks (>=2.22.0,<2.23.0)"]
+eks-auth = ["types-aiobotocore-eks-auth (>=2.22.0,<2.23.0)"]
+elasticache = ["types-aiobotocore-elasticache (>=2.22.0,<2.23.0)"]
+elasticbeanstalk = ["types-aiobotocore-elasticbeanstalk (>=2.22.0,<2.23.0)"]
+elastictranscoder = ["types-aiobotocore-elastictranscoder (>=2.22.0,<2.23.0)"]
+elb = ["types-aiobotocore-elb (>=2.22.0,<2.23.0)"]
+elbv2 = ["types-aiobotocore-elbv2 (>=2.22.0,<2.23.0)"]
+emr = ["types-aiobotocore-emr (>=2.22.0,<2.23.0)"]
+emr-containers = ["types-aiobotocore-emr-containers (>=2.22.0,<2.23.0)"]
+emr-serverless = ["types-aiobotocore-emr-serverless (>=2.22.0,<2.23.0)"]
+entityresolution = ["types-aiobotocore-entityresolution (>=2.22.0,<2.23.0)"]
+es = ["types-aiobotocore-es (>=2.22.0,<2.23.0)"]
+essential = ["types-aiobotocore-cloudformation (>=2.22.0,<2.23.0)", "types-aiobotocore-dynamodb (>=2.22.0,<2.23.0)", "types-aiobotocore-ec2 (>=2.22.0,<2.23.0)", "types-aiobotocore-lambda (>=2.22.0,<2.23.0)", "types-aiobotocore-rds (>=2.22.0,<2.23.0)", "types-aiobotocore-s3 (>=2.22.0,<2.23.0)", "types-aiobotocore-sqs (>=2.22.0,<2.23.0)"]
+events = ["types-aiobotocore-events (>=2.22.0,<2.23.0)"]
+evidently = ["types-aiobotocore-evidently (>=2.22.0,<2.23.0)"]
+finspace = ["types-aiobotocore-finspace (>=2.22.0,<2.23.0)"]
+finspace-data = ["types-aiobotocore-finspace-data (>=2.22.0,<2.23.0)"]
+firehose = ["types-aiobotocore-firehose (>=2.22.0,<2.23.0)"]
+fis = ["types-aiobotocore-fis (>=2.22.0,<2.23.0)"]
+fms = ["types-aiobotocore-fms (>=2.22.0,<2.23.0)"]
+forecast = ["types-aiobotocore-forecast (>=2.22.0,<2.23.0)"]
+forecastquery = ["types-aiobotocore-forecastquery (>=2.22.0,<2.23.0)"]
+frauddetector = ["types-aiobotocore-frauddetector (>=2.22.0,<2.23.0)"]
+freetier = ["types-aiobotocore-freetier (>=2.22.0,<2.23.0)"]
+fsx = ["types-aiobotocore-fsx (>=2.22.0,<2.23.0)"]
+full = ["types-aiobotocore-full (>=2.22.0,<2.23.0)"]
+gamelift = ["types-aiobotocore-gamelift (>=2.22.0,<2.23.0)"]
+geo-maps = ["types-aiobotocore-geo-maps (>=2.22.0,<2.23.0)"]
+geo-places = ["types-aiobotocore-geo-places (>=2.22.0,<2.23.0)"]
+geo-routes = ["types-aiobotocore-geo-routes (>=2.22.0,<2.23.0)"]
+glacier = ["types-aiobotocore-glacier (>=2.22.0,<2.23.0)"]
+globalaccelerator = ["types-aiobotocore-globalaccelerator (>=2.22.0,<2.23.0)"]
+glue = ["types-aiobotocore-glue (>=2.22.0,<2.23.0)"]
+grafana = ["types-aiobotocore-grafana (>=2.22.0,<2.23.0)"]
+greengrass = ["types-aiobotocore-greengrass (>=2.22.0,<2.23.0)"]
+greengrassv2 = ["types-aiobotocore-greengrassv2 (>=2.22.0,<2.23.0)"]
+groundstation = ["types-aiobotocore-groundstation (>=2.22.0,<2.23.0)"]
+guardduty = ["types-aiobotocore-guardduty (>=2.22.0,<2.23.0)"]
+health = ["types-aiobotocore-health (>=2.22.0,<2.23.0)"]
+healthlake = ["types-aiobotocore-healthlake (>=2.22.0,<2.23.0)"]
+iam = ["types-aiobotocore-iam (>=2.22.0,<2.23.0)"]
+identitystore = ["types-aiobotocore-identitystore (>=2.22.0,<2.23.0)"]
+imagebuilder = ["types-aiobotocore-imagebuilder (>=2.22.0,<2.23.0)"]
+importexport = ["types-aiobotocore-importexport (>=2.22.0,<2.23.0)"]
+inspector = ["types-aiobotocore-inspector (>=2.22.0,<2.23.0)"]
+inspector-scan = ["types-aiobotocore-inspector-scan (>=2.22.0,<2.23.0)"]
+inspector2 = ["types-aiobotocore-inspector2 (>=2.22.0,<2.23.0)"]
+internetmonitor = ["types-aiobotocore-internetmonitor (>=2.22.0,<2.23.0)"]
+invoicing = ["types-aiobotocore-invoicing (>=2.22.0,<2.23.0)"]
+iot = ["types-aiobotocore-iot (>=2.22.0,<2.23.0)"]
+iot-data = ["types-aiobotocore-iot-data (>=2.22.0,<2.23.0)"]
+iot-jobs-data = ["types-aiobotocore-iot-jobs-data (>=2.22.0,<2.23.0)"]
+iotanalytics = ["types-aiobotocore-iotanalytics (>=2.22.0,<2.23.0)"]
+iotdeviceadvisor = ["types-aiobotocore-iotdeviceadvisor (>=2.22.0,<2.23.0)"]
+iotevents = ["types-aiobotocore-iotevents (>=2.22.0,<2.23.0)"]
+iotevents-data = ["types-aiobotocore-iotevents-data (>=2.22.0,<2.23.0)"]
+iotfleethub = ["types-aiobotocore-iotfleethub (>=2.22.0,<2.23.0)"]
+iotfleetwise = ["types-aiobotocore-iotfleetwise (>=2.22.0,<2.23.0)"]
+iotsecuretunneling = ["types-aiobotocore-iotsecuretunneling (>=2.22.0,<2.23.0)"]
+iotsitewise = ["types-aiobotocore-iotsitewise (>=2.22.0,<2.23.0)"]
+iotthingsgraph = ["types-aiobotocore-iotthingsgraph (>=2.22.0,<2.23.0)"]
+iottwinmaker = ["types-aiobotocore-iottwinmaker (>=2.22.0,<2.23.0)"]
+iotwireless = ["types-aiobotocore-iotwireless (>=2.22.0,<2.23.0)"]
+ivs = ["types-aiobotocore-ivs (>=2.22.0,<2.23.0)"]
+ivs-realtime = ["types-aiobotocore-ivs-realtime (>=2.22.0,<2.23.0)"]
+ivschat = ["types-aiobotocore-ivschat (>=2.22.0,<2.23.0)"]
+kafka = ["types-aiobotocore-kafka (>=2.22.0,<2.23.0)"]
+kafkaconnect = ["types-aiobotocore-kafkaconnect (>=2.22.0,<2.23.0)"]
+kendra = ["types-aiobotocore-kendra (>=2.22.0,<2.23.0)"]
+kendra-ranking = ["types-aiobotocore-kendra-ranking (>=2.22.0,<2.23.0)"]
+keyspaces = ["types-aiobotocore-keyspaces (>=2.22.0,<2.23.0)"]
+kinesis = ["types-aiobotocore-kinesis (>=2.22.0,<2.23.0)"]
+kinesis-video-archived-media = ["types-aiobotocore-kinesis-video-archived-media (>=2.22.0,<2.23.0)"]
+kinesis-video-media = ["types-aiobotocore-kinesis-video-media (>=2.22.0,<2.23.0)"]
+kinesis-video-signaling = ["types-aiobotocore-kinesis-video-signaling (>=2.22.0,<2.23.0)"]
+kinesis-video-webrtc-storage = ["types-aiobotocore-kinesis-video-webrtc-storage (>=2.22.0,<2.23.0)"]
+kinesisanalytics = ["types-aiobotocore-kinesisanalytics (>=2.22.0,<2.23.0)"]
+kinesisanalyticsv2 = ["types-aiobotocore-kinesisanalyticsv2 (>=2.22.0,<2.23.0)"]
+kinesisvideo = ["types-aiobotocore-kinesisvideo (>=2.22.0,<2.23.0)"]
+kms = ["types-aiobotocore-kms (>=2.22.0,<2.23.0)"]
+lakeformation = ["types-aiobotocore-lakeformation (>=2.22.0,<2.23.0)"]
+lambda = ["types-aiobotocore-lambda (>=2.22.0,<2.23.0)"]
+launch-wizard = ["types-aiobotocore-launch-wizard (>=2.22.0,<2.23.0)"]
+lex-models = ["types-aiobotocore-lex-models (>=2.22.0,<2.23.0)"]
+lex-runtime = ["types-aiobotocore-lex-runtime (>=2.22.0,<2.23.0)"]
+lexv2-models = ["types-aiobotocore-lexv2-models (>=2.22.0,<2.23.0)"]
+lexv2-runtime = ["types-aiobotocore-lexv2-runtime (>=2.22.0,<2.23.0)"]
+license-manager = ["types-aiobotocore-license-manager (>=2.22.0,<2.23.0)"]
+license-manager-linux-subscriptions = ["types-aiobotocore-license-manager-linux-subscriptions (>=2.22.0,<2.23.0)"]
+license-manager-user-subscriptions = ["types-aiobotocore-license-manager-user-subscriptions (>=2.22.0,<2.23.0)"]
+lightsail = ["types-aiobotocore-lightsail (>=2.22.0,<2.23.0)"]
+location = ["types-aiobotocore-location (>=2.22.0,<2.23.0)"]
+logs = ["types-aiobotocore-logs (>=2.22.0,<2.23.0)"]
+lookoutequipment = ["types-aiobotocore-lookoutequipment (>=2.22.0,<2.23.0)"]
+lookoutmetrics = ["types-aiobotocore-lookoutmetrics (>=2.22.0,<2.23.0)"]
+lookoutvision = ["types-aiobotocore-lookoutvision (>=2.22.0,<2.23.0)"]
+m2 = ["types-aiobotocore-m2 (>=2.22.0,<2.23.0)"]
+machinelearning = ["types-aiobotocore-machinelearning (>=2.22.0,<2.23.0)"]
+macie2 = ["types-aiobotocore-macie2 (>=2.22.0,<2.23.0)"]
+mailmanager = ["types-aiobotocore-mailmanager (>=2.22.0,<2.23.0)"]
+managedblockchain = ["types-aiobotocore-managedblockchain (>=2.22.0,<2.23.0)"]
+managedblockchain-query = ["types-aiobotocore-managedblockchain-query (>=2.22.0,<2.23.0)"]
+marketplace-agreement = ["types-aiobotocore-marketplace-agreement (>=2.22.0,<2.23.0)"]
+marketplace-catalog = ["types-aiobotocore-marketplace-catalog (>=2.22.0,<2.23.0)"]
+marketplace-deployment = ["types-aiobotocore-marketplace-deployment (>=2.22.0,<2.23.0)"]
+marketplace-entitlement = ["types-aiobotocore-marketplace-entitlement (>=2.22.0,<2.23.0)"]
+marketplace-reporting = ["types-aiobotocore-marketplace-reporting (>=2.22.0,<2.23.0)"]
+marketplacecommerceanalytics = ["types-aiobotocore-marketplacecommerceanalytics (>=2.22.0,<2.23.0)"]
+mediaconnect = ["types-aiobotocore-mediaconnect (>=2.22.0,<2.23.0)"]
+mediaconvert = ["types-aiobotocore-mediaconvert (>=2.22.0,<2.23.0)"]
+medialive = ["types-aiobotocore-medialive (>=2.22.0,<2.23.0)"]
+mediapackage = ["types-aiobotocore-mediapackage (>=2.22.0,<2.23.0)"]
+mediapackage-vod = ["types-aiobotocore-mediapackage-vod (>=2.22.0,<2.23.0)"]
+mediapackagev2 = ["types-aiobotocore-mediapackagev2 (>=2.22.0,<2.23.0)"]
+mediastore = ["types-aiobotocore-mediastore (>=2.22.0,<2.23.0)"]
+mediastore-data = ["types-aiobotocore-mediastore-data (>=2.22.0,<2.23.0)"]
+mediatailor = ["types-aiobotocore-mediatailor (>=2.22.0,<2.23.0)"]
+medical-imaging = ["types-aiobotocore-medical-imaging (>=2.22.0,<2.23.0)"]
+memorydb = ["types-aiobotocore-memorydb (>=2.22.0,<2.23.0)"]
+meteringmarketplace = ["types-aiobotocore-meteringmarketplace (>=2.22.0,<2.23.0)"]
+mgh = ["types-aiobotocore-mgh (>=2.22.0,<2.23.0)"]
+mgn = ["types-aiobotocore-mgn (>=2.22.0,<2.23.0)"]
+migration-hub-refactor-spaces = ["types-aiobotocore-migration-hub-refactor-spaces (>=2.22.0,<2.23.0)"]
+migrationhub-config = ["types-aiobotocore-migrationhub-config (>=2.22.0,<2.23.0)"]
+migrationhuborchestrator = ["types-aiobotocore-migrationhuborchestrator (>=2.22.0,<2.23.0)"]
+migrationhubstrategy = ["types-aiobotocore-migrationhubstrategy (>=2.22.0,<2.23.0)"]
+mq = ["types-aiobotocore-mq (>=2.22.0,<2.23.0)"]
+mturk = ["types-aiobotocore-mturk (>=2.22.0,<2.23.0)"]
+mwaa = ["types-aiobotocore-mwaa (>=2.22.0,<2.23.0)"]
+neptune = ["types-aiobotocore-neptune (>=2.22.0,<2.23.0)"]
+neptune-graph = ["types-aiobotocore-neptune-graph (>=2.22.0,<2.23.0)"]
+neptunedata = ["types-aiobotocore-neptunedata (>=2.22.0,<2.23.0)"]
+network-firewall = ["types-aiobotocore-network-firewall (>=2.22.0,<2.23.0)"]
+networkflowmonitor = ["types-aiobotocore-networkflowmonitor (>=2.22.0,<2.23.0)"]
+networkmanager = ["types-aiobotocore-networkmanager (>=2.22.0,<2.23.0)"]
+networkmonitor = ["types-aiobotocore-networkmonitor (>=2.22.0,<2.23.0)"]
+notifications = ["types-aiobotocore-notifications (>=2.22.0,<2.23.0)"]
+notificationscontacts = ["types-aiobotocore-notificationscontacts (>=2.22.0,<2.23.0)"]
+oam = ["types-aiobotocore-oam (>=2.22.0,<2.23.0)"]
+observabilityadmin = ["types-aiobotocore-observabilityadmin (>=2.22.0,<2.23.0)"]
+omics = ["types-aiobotocore-omics (>=2.22.0,<2.23.0)"]
+opensearch = ["types-aiobotocore-opensearch (>=2.22.0,<2.23.0)"]
+opensearchserverless = ["types-aiobotocore-opensearchserverless (>=2.22.0,<2.23.0)"]
+opsworks = ["types-aiobotocore-opsworks (>=2.22.0,<2.23.0)"]
+opsworkscm = ["types-aiobotocore-opsworkscm (>=2.22.0,<2.23.0)"]
+organizations = ["types-aiobotocore-organizations (>=2.22.0,<2.23.0)"]
+osis = ["types-aiobotocore-osis (>=2.22.0,<2.23.0)"]
+outposts = ["types-aiobotocore-outposts (>=2.22.0,<2.23.0)"]
+panorama = ["types-aiobotocore-panorama (>=2.22.0,<2.23.0)"]
+partnercentral-selling = ["types-aiobotocore-partnercentral-selling (>=2.22.0,<2.23.0)"]
+payment-cryptography = ["types-aiobotocore-payment-cryptography (>=2.22.0,<2.23.0)"]
+payment-cryptography-data = ["types-aiobotocore-payment-cryptography-data (>=2.22.0,<2.23.0)"]
+pca-connector-ad = ["types-aiobotocore-pca-connector-ad (>=2.22.0,<2.23.0)"]
+pca-connector-scep = ["types-aiobotocore-pca-connector-scep (>=2.22.0,<2.23.0)"]
+pcs = ["types-aiobotocore-pcs (>=2.22.0,<2.23.0)"]
+personalize = ["types-aiobotocore-personalize (>=2.22.0,<2.23.0)"]
+personalize-events = ["types-aiobotocore-personalize-events (>=2.22.0,<2.23.0)"]
+personalize-runtime = ["types-aiobotocore-personalize-runtime (>=2.22.0,<2.23.0)"]
+pi = ["types-aiobotocore-pi (>=2.22.0,<2.23.0)"]
+pinpoint = ["types-aiobotocore-pinpoint (>=2.22.0,<2.23.0)"]
+pinpoint-email = ["types-aiobotocore-pinpoint-email (>=2.22.0,<2.23.0)"]
+pinpoint-sms-voice = ["types-aiobotocore-pinpoint-sms-voice (>=2.22.0,<2.23.0)"]
+pinpoint-sms-voice-v2 = ["types-aiobotocore-pinpoint-sms-voice-v2 (>=2.22.0,<2.23.0)"]
+pipes = ["types-aiobotocore-pipes (>=2.22.0,<2.23.0)"]
+polly = ["types-aiobotocore-polly (>=2.22.0,<2.23.0)"]
+pricing = ["types-aiobotocore-pricing (>=2.22.0,<2.23.0)"]
+privatenetworks = ["types-aiobotocore-privatenetworks (>=2.22.0,<2.23.0)"]
+proton = ["types-aiobotocore-proton (>=2.22.0,<2.23.0)"]
+qapps = ["types-aiobotocore-qapps (>=2.22.0,<2.23.0)"]
+qbusiness = ["types-aiobotocore-qbusiness (>=2.22.0,<2.23.0)"]
+qconnect = ["types-aiobotocore-qconnect (>=2.22.0,<2.23.0)"]
+qldb = ["types-aiobotocore-qldb (>=2.22.0,<2.23.0)"]
+qldb-session = ["types-aiobotocore-qldb-session (>=2.22.0,<2.23.0)"]
+quicksight = ["types-aiobotocore-quicksight (>=2.22.0,<2.23.0)"]
+ram = ["types-aiobotocore-ram (>=2.22.0,<2.23.0)"]
+rbin = ["types-aiobotocore-rbin (>=2.22.0,<2.23.0)"]
+rds = ["types-aiobotocore-rds (>=2.22.0,<2.23.0)"]
+rds-data = ["types-aiobotocore-rds-data (>=2.22.0,<2.23.0)"]
+redshift = ["types-aiobotocore-redshift (>=2.22.0,<2.23.0)"]
+redshift-data = ["types-aiobotocore-redshift-data (>=2.22.0,<2.23.0)"]
+redshift-serverless = ["types-aiobotocore-redshift-serverless (>=2.22.0,<2.23.0)"]
+rekognition = ["types-aiobotocore-rekognition (>=2.22.0,<2.23.0)"]
+repostspace = ["types-aiobotocore-repostspace (>=2.22.0,<2.23.0)"]
+resiliencehub = ["types-aiobotocore-resiliencehub (>=2.22.0,<2.23.0)"]
+resource-explorer-2 = ["types-aiobotocore-resource-explorer-2 (>=2.22.0,<2.23.0)"]
+resource-groups = ["types-aiobotocore-resource-groups (>=2.22.0,<2.23.0)"]
+resourcegroupstaggingapi = ["types-aiobotocore-resourcegroupstaggingapi (>=2.22.0,<2.23.0)"]
+robomaker = ["types-aiobotocore-robomaker (>=2.22.0,<2.23.0)"]
+rolesanywhere = ["types-aiobotocore-rolesanywhere (>=2.22.0,<2.23.0)"]
+route53 = ["types-aiobotocore-route53 (>=2.22.0,<2.23.0)"]
+route53-recovery-cluster = ["types-aiobotocore-route53-recovery-cluster (>=2.22.0,<2.23.0)"]
+route53-recovery-control-config = ["types-aiobotocore-route53-recovery-control-config (>=2.22.0,<2.23.0)"]
+route53-recovery-readiness = ["types-aiobotocore-route53-recovery-readiness (>=2.22.0,<2.23.0)"]
+route53domains = ["types-aiobotocore-route53domains (>=2.22.0,<2.23.0)"]
+route53profiles = ["types-aiobotocore-route53profiles (>=2.22.0,<2.23.0)"]
+route53resolver = ["types-aiobotocore-route53resolver (>=2.22.0,<2.23.0)"]
+rum = ["types-aiobotocore-rum (>=2.22.0,<2.23.0)"]
+s3 = ["types-aiobotocore-s3 (>=2.22.0,<2.23.0)"]
+s3control = ["types-aiobotocore-s3control (>=2.22.0,<2.23.0)"]
+s3outposts = ["types-aiobotocore-s3outposts (>=2.22.0,<2.23.0)"]
+s3tables = ["types-aiobotocore-s3tables (>=2.22.0,<2.23.0)"]
+sagemaker = ["types-aiobotocore-sagemaker (>=2.22.0,<2.23.0)"]
+sagemaker-a2i-runtime = ["types-aiobotocore-sagemaker-a2i-runtime (>=2.22.0,<2.23.0)"]
+sagemaker-edge = ["types-aiobotocore-sagemaker-edge (>=2.22.0,<2.23.0)"]
+sagemaker-featurestore-runtime = ["types-aiobotocore-sagemaker-featurestore-runtime (>=2.22.0,<2.23.0)"]
+sagemaker-geospatial = ["types-aiobotocore-sagemaker-geospatial (>=2.22.0,<2.23.0)"]
+sagemaker-metrics = ["types-aiobotocore-sagemaker-metrics (>=2.22.0,<2.23.0)"]
+sagemaker-runtime = ["types-aiobotocore-sagemaker-runtime (>=2.22.0,<2.23.0)"]
+savingsplans = ["types-aiobotocore-savingsplans (>=2.22.0,<2.23.0)"]
+scheduler = ["types-aiobotocore-scheduler (>=2.22.0,<2.23.0)"]
+schemas = ["types-aiobotocore-schemas (>=2.22.0,<2.23.0)"]
+sdb = ["types-aiobotocore-sdb (>=2.22.0,<2.23.0)"]
+secretsmanager = ["types-aiobotocore-secretsmanager (>=2.22.0,<2.23.0)"]
+security-ir = ["types-aiobotocore-security-ir (>=2.22.0,<2.23.0)"]
+securityhub = ["types-aiobotocore-securityhub (>=2.22.0,<2.23.0)"]
+securitylake = ["types-aiobotocore-securitylake (>=2.22.0,<2.23.0)"]
+serverlessrepo = ["types-aiobotocore-serverlessrepo (>=2.22.0,<2.23.0)"]
+service-quotas = ["types-aiobotocore-service-quotas (>=2.22.0,<2.23.0)"]
+servicecatalog = ["types-aiobotocore-servicecatalog (>=2.22.0,<2.23.0)"]
+servicecatalog-appregistry = ["types-aiobotocore-servicecatalog-appregistry (>=2.22.0,<2.23.0)"]
+servicediscovery = ["types-aiobotocore-servicediscovery (>=2.22.0,<2.23.0)"]
+ses = ["types-aiobotocore-ses (>=2.22.0,<2.23.0)"]
+sesv2 = ["types-aiobotocore-sesv2 (>=2.22.0,<2.23.0)"]
+shield = ["types-aiobotocore-shield (>=2.22.0,<2.23.0)"]
+signer = ["types-aiobotocore-signer (>=2.22.0,<2.23.0)"]
+simspaceweaver = ["types-aiobotocore-simspaceweaver (>=2.22.0,<2.23.0)"]
+sms = ["types-aiobotocore-sms (>=2.22.0,<2.23.0)"]
+sms-voice = ["types-aiobotocore-sms-voice (>=2.22.0,<2.23.0)"]
+snow-device-management = ["types-aiobotocore-snow-device-management (>=2.22.0,<2.23.0)"]
+snowball = ["types-aiobotocore-snowball (>=2.22.0,<2.23.0)"]
+sns = ["types-aiobotocore-sns (>=2.22.0,<2.23.0)"]
+socialmessaging = ["types-aiobotocore-socialmessaging (>=2.22.0,<2.23.0)"]
+sqs = ["types-aiobotocore-sqs (>=2.22.0,<2.23.0)"]
+ssm = ["types-aiobotocore-ssm (>=2.22.0,<2.23.0)"]
+ssm-contacts = ["types-aiobotocore-ssm-contacts (>=2.22.0,<2.23.0)"]
+ssm-incidents = ["types-aiobotocore-ssm-incidents (>=2.22.0,<2.23.0)"]
+ssm-quicksetup = ["types-aiobotocore-ssm-quicksetup (>=2.22.0,<2.23.0)"]
+ssm-sap = ["types-aiobotocore-ssm-sap (>=2.22.0,<2.23.0)"]
+sso = ["types-aiobotocore-sso (>=2.22.0,<2.23.0)"]
+sso-admin = ["types-aiobotocore-sso-admin (>=2.22.0,<2.23.0)"]
+sso-oidc = ["types-aiobotocore-sso-oidc (>=2.22.0,<2.23.0)"]
+stepfunctions = ["types-aiobotocore-stepfunctions (>=2.22.0,<2.23.0)"]
+storagegateway = ["types-aiobotocore-storagegateway (>=2.22.0,<2.23.0)"]
+sts = ["types-aiobotocore-sts (>=2.22.0,<2.23.0)"]
+supplychain = ["types-aiobotocore-supplychain (>=2.22.0,<2.23.0)"]
+support = ["types-aiobotocore-support (>=2.22.0,<2.23.0)"]
+support-app = ["types-aiobotocore-support-app (>=2.22.0,<2.23.0)"]
+swf = ["types-aiobotocore-swf (>=2.22.0,<2.23.0)"]
+synthetics = ["types-aiobotocore-synthetics (>=2.22.0,<2.23.0)"]
+taxsettings = ["types-aiobotocore-taxsettings (>=2.22.0,<2.23.0)"]
+textract = ["types-aiobotocore-textract (>=2.22.0,<2.23.0)"]
+timestream-influxdb = ["types-aiobotocore-timestream-influxdb (>=2.22.0,<2.23.0)"]
+timestream-query = ["types-aiobotocore-timestream-query (>=2.22.0,<2.23.0)"]
+timestream-write = ["types-aiobotocore-timestream-write (>=2.22.0,<2.23.0)"]
+tnb = ["types-aiobotocore-tnb (>=2.22.0,<2.23.0)"]
+transcribe = ["types-aiobotocore-transcribe (>=2.22.0,<2.23.0)"]
+transfer = ["types-aiobotocore-transfer (>=2.22.0,<2.23.0)"]
+translate = ["types-aiobotocore-translate (>=2.22.0,<2.23.0)"]
+trustedadvisor = ["types-aiobotocore-trustedadvisor (>=2.22.0,<2.23.0)"]
+verifiedpermissions = ["types-aiobotocore-verifiedpermissions (>=2.22.0,<2.23.0)"]
+voice-id = ["types-aiobotocore-voice-id (>=2.22.0,<2.23.0)"]
+vpc-lattice = ["types-aiobotocore-vpc-lattice (>=2.22.0,<2.23.0)"]
+waf = ["types-aiobotocore-waf (>=2.22.0,<2.23.0)"]
+waf-regional = ["types-aiobotocore-waf-regional (>=2.22.0,<2.23.0)"]
+wafv2 = ["types-aiobotocore-wafv2 (>=2.22.0,<2.23.0)"]
+wellarchitected = ["types-aiobotocore-wellarchitected (>=2.22.0,<2.23.0)"]
+wisdom = ["types-aiobotocore-wisdom (>=2.22.0,<2.23.0)"]
+workdocs = ["types-aiobotocore-workdocs (>=2.22.0,<2.23.0)"]
+workmail = ["types-aiobotocore-workmail (>=2.22.0,<2.23.0)"]
+workmailmessageflow = ["types-aiobotocore-workmailmessageflow (>=2.22.0,<2.23.0)"]
+workspaces = ["types-aiobotocore-workspaces (>=2.22.0,<2.23.0)"]
+workspaces-thin-client = ["types-aiobotocore-workspaces-thin-client (>=2.22.0,<2.23.0)"]
+workspaces-web = ["types-aiobotocore-workspaces-web (>=2.22.0,<2.23.0)"]
+xray = ["types-aiobotocore-xray (>=2.22.0,<2.23.0)"]
+
+[[package]]
+name = "types-aiobotocore-bedrock"
+version = "2.18.0"
+description = "Type annotations for aiobotocore Bedrock 2.18.0 service generated with mypy-boto3-builder 8.8.0"
+optional = false
+python-versions = ">=3.8"
+groups = ["dev"]
+files = [
+ {file = "types_aiobotocore_bedrock-2.18.0-py3-none-any.whl", hash = "sha256:6ec0ca46f1f0f616df7f2b800ac3f3d14abc7b1429e728b7b281331abe8af7e5"},
+ {file = "types_aiobotocore_bedrock-2.18.0.tar.gz", hash = "sha256:a4f8860be6a02239bff4d8fa036230579431a690d37c312a0af8bd52e980e887"},
+]
+
+[package.dependencies]
+typing-extensions = {version = "*", markers = "python_version < \"3.12\""}
+
+[[package]]
+name = "types-aiobotocore-bedrock-runtime"
+version = "2.18.0"
+description = "Type annotations for aiobotocore BedrockRuntime 2.18.0 service generated with mypy-boto3-builder 8.8.0"
+optional = false
+python-versions = ">=3.8"
+groups = ["dev"]
+files = [
+ {file = "types_aiobotocore_bedrock_runtime-2.18.0-py3-none-any.whl", hash = "sha256:bb375ed664d6602bcb9b1e376dd4cb16914b5c8b68e9a81238768d04fabc83d9"},
+ {file = "types_aiobotocore_bedrock_runtime-2.18.0.tar.gz", hash = "sha256:f98fd11235fe626aedcbebb4d392dd177bbe842dda9dd168932a4db2789f08dd"},
+]
+
+[package.dependencies]
+typing-extensions = {version = "*", markers = "python_version < \"3.12\""}
+
+[[package]]
+name = "types-aiofiles"
+version = "24.1.0.20250516"
+description = "Typing stubs for aiofiles"
+optional = false
+python-versions = ">=3.9"
+groups = ["dev"]
+files = [
+ {file = "types_aiofiles-24.1.0.20250516-py3-none-any.whl", hash = "sha256:ec265994629146804b656a971c46f393ce860305834b3cacb4b8b6fb7dba7e33"},
+ {file = "types_aiofiles-24.1.0.20250516.tar.gz", hash = "sha256:7fd2a7f793bbe180b7b22cd4f59300fe61fdc9940b3bbc9899ffe32849b95188"},
+]
+
+[[package]]
+name = "types-awscrt"
+version = "0.27.2"
+description = "Type annotations and code completion for awscrt"
+optional = false
+python-versions = ">=3.8"
+groups = ["dev"]
+files = [
+ {file = "types_awscrt-0.27.2-py3-none-any.whl", hash = "sha256:49a045f25bbd5ad2865f314512afced933aed35ddbafc252e2268efa8a787e4e"},
+ {file = "types_awscrt-0.27.2.tar.gz", hash = "sha256:acd04f57119eb15626ab0ba9157fc24672421de56e7bd7b9f61681fedee44e91"},
+]
+
+[[package]]
+name = "types-beautifulsoup4"
+version = "4.12.0.20250516"
+description = "Typing stubs for beautifulsoup4"
+optional = false
+python-versions = ">=3.9"
+groups = ["dev"]
+files = [
+ {file = "types_beautifulsoup4-4.12.0.20250516-py3-none-any.whl", hash = "sha256:5923399d4a1ba9cc8f0096fe334cc732e130269541d66261bb42ab039c0376ee"},
+ {file = "types_beautifulsoup4-4.12.0.20250516.tar.gz", hash = "sha256:aa19dd73b33b70d6296adf92da8ab8a0c945c507e6fb7d5db553415cc77b417e"},
+]
+
+[package.dependencies]
+types-html5lib = "*"
+
+[[package]]
+name = "types-html5lib"
+version = "1.1.11.20250516"
+description = "Typing stubs for html5lib"
+optional = false
+python-versions = ">=3.9"
+groups = ["dev"]
+files = [
+ {file = "types_html5lib-1.1.11.20250516-py3-none-any.whl", hash = "sha256:5e407b14b1bd2b9b1107cbd1e2e19d4a0c46d60febd231c7ab7313d7405663c1"},
+ {file = "types_html5lib-1.1.11.20250516.tar.gz", hash = "sha256:65043a6718c97f7d52567cc0cdf41efbfc33b1f92c6c0c5e19f60a7ec69ae720"},
+]
+
+[[package]]
+name = "types-markdown"
+version = "3.8.0.20250415"
+description = "Typing stubs for Markdown"
+optional = false
+python-versions = ">=3.9"
+groups = ["dev"]
+files = [
+ {file = "types_markdown-3.8.0.20250415-py3-none-any.whl", hash = "sha256:b41abed474a303ba300e3a4cf6f27eda339219124a59d529a158203570007776"},
+ {file = "types_markdown-3.8.0.20250415.tar.gz", hash = "sha256:98ab13587d1177769d93e55586d3dc97047df75bc6e37ce4074666f5dd4212ba"},
+]
+
+[[package]]
+name = "types-networkx"
+version = "3.4.2.20250523"
+description = "Typing stubs for networkx"
+optional = false
+python-versions = ">=3.10"
+groups = ["dev"]
+files = [
+ {file = "types_networkx-3.4.2.20250523-py3-none-any.whl", hash = "sha256:c8743e177411c22d586ae8a20c5f0a83d078de98156f31e22b0f26b412c315af"},
+ {file = "types_networkx-3.4.2.20250523.tar.gz", hash = "sha256:c35e7b39b72e3fc1a8a2c13df7609c34e41fc63d1ddaeec8fe5ed019c08e9e51"},
+]
+
+[package.dependencies]
+numpy = ">=1.20"
+
+[[package]]
+name = "types-openpyxl"
+version = "3.1.5.20250516"
+description = "Typing stubs for openpyxl"
+optional = false
+python-versions = ">=3.9"
+groups = ["dev"]
+files = [
+ {file = "types_openpyxl-3.1.5.20250516-py3-none-any.whl", hash = "sha256:87c6b04b30fd1cbab85dc93cbe4f57ce1eb3df5d2911f742a1a0e3bf94314dfc"},
+ {file = "types_openpyxl-3.1.5.20250516.tar.gz", hash = "sha256:691339abe141a5713f115558cc39023ebdda6298bfa875d575cc5a961a3c5523"},
+]
+
+[[package]]
+name = "types-pytz"
+version = "2025.2.0.20250516"
+description = "Typing stubs for pytz"
+optional = false
+python-versions = ">=3.9"
+groups = ["dev"]
+files = [
+ {file = "types_pytz-2025.2.0.20250516-py3-none-any.whl", hash = "sha256:e0e0c8a57e2791c19f718ed99ab2ba623856b11620cb6b637e5f62ce285a7451"},
+ {file = "types_pytz-2025.2.0.20250516.tar.gz", hash = "sha256:e1216306f8c0d5da6dafd6492e72eb080c9a166171fa80dd7a1990fd8be7a7b3"},
+]
+
+[[package]]
+name = "types-pyyaml"
+version = "6.0.12.20250516"
+description = "Typing stubs for PyYAML"
+optional = false
+python-versions = ">=3.9"
+groups = ["dev"]
+files = [
+ {file = "types_pyyaml-6.0.12.20250516-py3-none-any.whl", hash = "sha256:8478208feaeb53a34cb5d970c56a7cd76b72659442e733e268a94dc72b2d0530"},
+ {file = "types_pyyaml-6.0.12.20250516.tar.gz", hash = "sha256:9f21a70216fc0fa1b216a8176db5f9e0af6eb35d2f2932acb87689d03a5bf6ba"},
+]
+
+[[package]]
+name = "types-requests"
+version = "2.32.0.20250515"
+description = "Typing stubs for requests"
+optional = false
+python-versions = ">=3.9"
+groups = ["dev"]
+files = [
+ {file = "types_requests-2.32.0.20250515-py3-none-any.whl", hash = "sha256:f8eba93b3a892beee32643ff836993f15a785816acca21ea0ffa006f05ef0fb2"},
+ {file = "types_requests-2.32.0.20250515.tar.gz", hash = "sha256:09c8b63c11318cb2460813871aaa48b671002e59fda67ca909e9883777787581"},
+]
+
+[package.dependencies]
+urllib3 = ">=2"
+
+[[package]]
+name = "types-s3transfer"
+version = "0.12.0"
+description = "Type annotations and code completion for s3transfer"
+optional = false
+python-versions = ">=3.8"
+groups = ["dev"]
+files = [
+ {file = "types_s3transfer-0.12.0-py3-none-any.whl", hash = "sha256:101bbc5b7f00b71512374df881f480fc6bf63c948b5098ab024bf3370fbfb0e8"},
+ {file = "types_s3transfer-0.12.0.tar.gz", hash = "sha256:f8f59201481e904362873bf0be3267f259d60ad946ebdfcb847d092a1fa26f98"},
+]
+
+[[package]]
+name = "types-toml"
+version = "0.10.8.20240310"
+description = "Typing stubs for toml"
+optional = false
+python-versions = ">=3.8"
+groups = ["dev"]
+files = [
+ {file = "types-toml-0.10.8.20240310.tar.gz", hash = "sha256:3d41501302972436a6b8b239c850b26689657e25281b48ff0ec06345b8830331"},
+ {file = "types_toml-0.10.8.20240310-py3-none-any.whl", hash = "sha256:627b47775d25fa29977d9c70dc0cbab3f314f32c8d8d0c012f2ef5de7aaec05d"},
+]
+
+[[package]]
+name = "typing-extensions"
+version = "4.13.2"
+description = "Backported and Experimental Type Hints for Python 3.8+"
+optional = false
+python-versions = ">=3.8"
+groups = ["main", "dev"]
+files = [
+ {file = "typing_extensions-4.13.2-py3-none-any.whl", hash = "sha256:a439e7c04b49fec3e5d3e2beaa21755cadbbdc391694e28ccdd36ca4a1408f8c"},
+ {file = "typing_extensions-4.13.2.tar.gz", hash = "sha256:e6c81219bd689f51865d9e372991c540bda33a0379d5573cddb9a3a23f7caaef"},
+]
+
+[[package]]
+name = "typing-inspect"
+version = "0.9.0"
+description = "Runtime inspection utilities for typing module."
+optional = true
+python-versions = "*"
+groups = ["main"]
+markers = "extra == \"mistralai\""
+files = [
+ {file = "typing_inspect-0.9.0-py3-none-any.whl", hash = "sha256:9ee6fc59062311ef8547596ab6b955e1b8aa46242d854bfc78f4f6b0eff35f9f"},
+ {file = "typing_inspect-0.9.0.tar.gz", hash = "sha256:b23fc42ff6f6ef6954e4852c1fb512cdd18dbea03134f91f856a95ccc9461f78"},
+]
+
+[package.dependencies]
+mypy-extensions = ">=0.3.0"
+typing-extensions = ">=3.7.4"
+
+[[package]]
+name = "tzdata"
+version = "2025.2"
+description = "Provider of IANA time zone data"
+optional = false
+python-versions = ">=2"
+groups = ["main"]
+files = [
+ {file = "tzdata-2025.2-py2.py3-none-any.whl", hash = "sha256:1a403fada01ff9221ca8044d701868fa132215d84beb92242d9acd2147f667a8"},
+ {file = "tzdata-2025.2.tar.gz", hash = "sha256:b60a638fcc0daffadf82fe0f57e53d06bdec2f36c4df66280ae79bce6bd6f2b9"},
+]
+
+[[package]]
+name = "urllib3"
+version = "2.4.0"
+description = "HTTP library with thread-safe connection pooling, file post, and more."
+optional = false
+python-versions = ">=3.9"
+groups = ["main", "dev"]
+files = [
+ {file = "urllib3-2.4.0-py3-none-any.whl", hash = "sha256:4e16665048960a0900c702d4a66415956a584919c03361cac9f1df5c5dd7e813"},
+ {file = "urllib3-2.4.0.tar.gz", hash = "sha256:414bc6535b787febd7567804cc015fee39daab8ad86268f1310a9250697de466"},
+]
+
+[package.extras]
+brotli = ["brotli (>=1.0.9)", "brotlicffi (>=0.8.0)"]
+h2 = ["h2 (>=4,<5)"]
+socks = ["pysocks (>=1.5.6,!=1.5.7,<2.0)"]
+zstd = ["zstandard (>=0.18.0)"]
+
+[[package]]
+name = "wrapt"
+version = "1.17.2"
+description = "Module for decorators, wrappers and monkey patching."
+optional = true
+python-versions = ">=3.8"
+groups = ["main"]
+markers = "extra == \"bedrock\""
+files = [
+ {file = "wrapt-1.17.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:3d57c572081fed831ad2d26fd430d565b76aa277ed1d30ff4d40670b1c0dd984"},
+ {file = "wrapt-1.17.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:b5e251054542ae57ac7f3fba5d10bfff615b6c2fb09abeb37d2f1463f841ae22"},
+ {file = "wrapt-1.17.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:80dd7db6a7cb57ffbc279c4394246414ec99537ae81ffd702443335a61dbf3a7"},
+ {file = "wrapt-1.17.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0a6e821770cf99cc586d33833b2ff32faebdbe886bd6322395606cf55153246c"},
+ {file = "wrapt-1.17.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b60fb58b90c6d63779cb0c0c54eeb38941bae3ecf7a73c764c52c88c2dcb9d72"},
+ {file = "wrapt-1.17.2-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b870b5df5b71d8c3359d21be8f0d6c485fa0ebdb6477dda51a1ea54a9b558061"},
+ {file = "wrapt-1.17.2-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:4011d137b9955791f9084749cba9a367c68d50ab8d11d64c50ba1688c9b457f2"},
+ {file = "wrapt-1.17.2-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:1473400e5b2733e58b396a04eb7f35f541e1fb976d0c0724d0223dd607e0f74c"},
+ {file = "wrapt-1.17.2-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:3cedbfa9c940fdad3e6e941db7138e26ce8aad38ab5fe9dcfadfed9db7a54e62"},
+ {file = "wrapt-1.17.2-cp310-cp310-win32.whl", hash = "sha256:582530701bff1dec6779efa00c516496968edd851fba224fbd86e46cc6b73563"},
+ {file = "wrapt-1.17.2-cp310-cp310-win_amd64.whl", hash = "sha256:58705da316756681ad3c9c73fd15499aa4d8c69f9fd38dc8a35e06c12468582f"},
+ {file = "wrapt-1.17.2-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:ff04ef6eec3eee8a5efef2401495967a916feaa353643defcc03fc74fe213b58"},
+ {file = "wrapt-1.17.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:4db983e7bca53819efdbd64590ee96c9213894272c776966ca6306b73e4affda"},
+ {file = "wrapt-1.17.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:9abc77a4ce4c6f2a3168ff34b1da9b0f311a8f1cfd694ec96b0603dff1c79438"},
+ {file = "wrapt-1.17.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0b929ac182f5ace000d459c59c2c9c33047e20e935f8e39371fa6e3b85d56f4a"},
+ {file = "wrapt-1.17.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f09b286faeff3c750a879d336fb6d8713206fc97af3adc14def0cdd349df6000"},
+ {file = "wrapt-1.17.2-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1a7ed2d9d039bd41e889f6fb9364554052ca21ce823580f6a07c4ec245c1f5d6"},
+ {file = "wrapt-1.17.2-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:129a150f5c445165ff941fc02ee27df65940fcb8a22a61828b1853c98763a64b"},
+ {file = "wrapt-1.17.2-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:1fb5699e4464afe5c7e65fa51d4f99e0b2eadcc176e4aa33600a3df7801d6662"},
+ {file = "wrapt-1.17.2-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:9a2bce789a5ea90e51a02dfcc39e31b7f1e662bc3317979aa7e5538e3a034f72"},
+ {file = "wrapt-1.17.2-cp311-cp311-win32.whl", hash = "sha256:4afd5814270fdf6380616b321fd31435a462019d834f83c8611a0ce7484c7317"},
+ {file = "wrapt-1.17.2-cp311-cp311-win_amd64.whl", hash = "sha256:acc130bc0375999da18e3d19e5a86403667ac0c4042a094fefb7eec8ebac7cf3"},
+ {file = "wrapt-1.17.2-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:d5e2439eecc762cd85e7bd37161d4714aa03a33c5ba884e26c81559817ca0925"},
+ {file = "wrapt-1.17.2-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:3fc7cb4c1c744f8c05cd5f9438a3caa6ab94ce8344e952d7c45a8ed59dd88392"},
+ {file = "wrapt-1.17.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:8fdbdb757d5390f7c675e558fd3186d590973244fab0c5fe63d373ade3e99d40"},
+ {file = "wrapt-1.17.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5bb1d0dbf99411f3d871deb6faa9aabb9d4e744d67dcaaa05399af89d847a91d"},
+ {file = "wrapt-1.17.2-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d18a4865f46b8579d44e4fe1e2bcbc6472ad83d98e22a26c963d46e4c125ef0b"},
+ {file = "wrapt-1.17.2-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bc570b5f14a79734437cb7b0500376b6b791153314986074486e0b0fa8d71d98"},
+ {file = "wrapt-1.17.2-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:6d9187b01bebc3875bac9b087948a2bccefe464a7d8f627cf6e48b1bbae30f82"},
+ {file = "wrapt-1.17.2-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:9e8659775f1adf02eb1e6f109751268e493c73716ca5761f8acb695e52a756ae"},
+ {file = "wrapt-1.17.2-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:e8b2816ebef96d83657b56306152a93909a83f23994f4b30ad4573b00bd11bb9"},
+ {file = "wrapt-1.17.2-cp312-cp312-win32.whl", hash = "sha256:468090021f391fe0056ad3e807e3d9034e0fd01adcd3bdfba977b6fdf4213ea9"},
+ {file = "wrapt-1.17.2-cp312-cp312-win_amd64.whl", hash = "sha256:ec89ed91f2fa8e3f52ae53cd3cf640d6feff92ba90d62236a81e4e563ac0e991"},
+ {file = "wrapt-1.17.2-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:6ed6ffac43aecfe6d86ec5b74b06a5be33d5bb9243d055141e8cabb12aa08125"},
+ {file = "wrapt-1.17.2-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:35621ae4c00e056adb0009f8e86e28eb4a41a4bfa8f9bfa9fca7d343fe94f998"},
+ {file = "wrapt-1.17.2-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:a604bf7a053f8362d27eb9fefd2097f82600b856d5abe996d623babd067b1ab5"},
+ {file = "wrapt-1.17.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5cbabee4f083b6b4cd282f5b817a867cf0b1028c54d445b7ec7cfe6505057cf8"},
+ {file = "wrapt-1.17.2-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:49703ce2ddc220df165bd2962f8e03b84c89fee2d65e1c24a7defff6f988f4d6"},
+ {file = "wrapt-1.17.2-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8112e52c5822fc4253f3901b676c55ddf288614dc7011634e2719718eaa187dc"},
+ {file = "wrapt-1.17.2-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:9fee687dce376205d9a494e9c121e27183b2a3df18037f89d69bd7b35bcf59e2"},
+ {file = "wrapt-1.17.2-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:18983c537e04d11cf027fbb60a1e8dfd5190e2b60cc27bc0808e653e7b218d1b"},
+ {file = "wrapt-1.17.2-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:703919b1633412ab54bcf920ab388735832fdcb9f9a00ae49387f0fe67dad504"},
+ {file = "wrapt-1.17.2-cp313-cp313-win32.whl", hash = "sha256:abbb9e76177c35d4e8568e58650aa6926040d6a9f6f03435b7a522bf1c487f9a"},
+ {file = "wrapt-1.17.2-cp313-cp313-win_amd64.whl", hash = "sha256:69606d7bb691b50a4240ce6b22ebb319c1cfb164e5f6569835058196e0f3a845"},
+ {file = "wrapt-1.17.2-cp313-cp313t-macosx_10_13_universal2.whl", hash = "sha256:4a721d3c943dae44f8e243b380cb645a709ba5bd35d3ad27bc2ed947e9c68192"},
+ {file = "wrapt-1.17.2-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:766d8bbefcb9e00c3ac3b000d9acc51f1b399513f44d77dfe0eb026ad7c9a19b"},
+ {file = "wrapt-1.17.2-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:e496a8ce2c256da1eb98bd15803a79bee00fc351f5dfb9ea82594a3f058309e0"},
+ {file = "wrapt-1.17.2-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:40d615e4fe22f4ad3528448c193b218e077656ca9ccb22ce2cb20db730f8d306"},
+ {file = "wrapt-1.17.2-cp313-cp313t-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a5aaeff38654462bc4b09023918b7f21790efb807f54c000a39d41d69cf552cb"},
+ {file = "wrapt-1.17.2-cp313-cp313t-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9a7d15bbd2bc99e92e39f49a04653062ee6085c0e18b3b7512a4f2fe91f2d681"},
+ {file = "wrapt-1.17.2-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:e3890b508a23299083e065f435a492b5435eba6e304a7114d2f919d400888cc6"},
+ {file = "wrapt-1.17.2-cp313-cp313t-musllinux_1_2_i686.whl", hash = "sha256:8c8b293cd65ad716d13d8dd3624e42e5a19cc2a2f1acc74b30c2c13f15cb61a6"},
+ {file = "wrapt-1.17.2-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:4c82b8785d98cdd9fed4cac84d765d234ed3251bd6afe34cb7ac523cb93e8b4f"},
+ {file = "wrapt-1.17.2-cp313-cp313t-win32.whl", hash = "sha256:13e6afb7fe71fe7485a4550a8844cc9ffbe263c0f1a1eea569bc7091d4898555"},
+ {file = "wrapt-1.17.2-cp313-cp313t-win_amd64.whl", hash = "sha256:eaf675418ed6b3b31c7a989fd007fa7c3be66ce14e5c3b27336383604c9da85c"},
+ {file = "wrapt-1.17.2-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:5c803c401ea1c1c18de70a06a6f79fcc9c5acfc79133e9869e730ad7f8ad8ef9"},
+ {file = "wrapt-1.17.2-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:f917c1180fdb8623c2b75a99192f4025e412597c50b2ac870f156de8fb101119"},
+ {file = "wrapt-1.17.2-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:ecc840861360ba9d176d413a5489b9a0aff6d6303d7e733e2c4623cfa26904a6"},
+ {file = "wrapt-1.17.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bb87745b2e6dc56361bfde481d5a378dc314b252a98d7dd19a651a3fa58f24a9"},
+ {file = "wrapt-1.17.2-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:58455b79ec2661c3600e65c0a716955adc2410f7383755d537584b0de41b1d8a"},
+ {file = "wrapt-1.17.2-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b4e42a40a5e164cbfdb7b386c966a588b1047558a990981ace551ed7e12ca9c2"},
+ {file = "wrapt-1.17.2-cp38-cp38-musllinux_1_2_aarch64.whl", hash = "sha256:91bd7d1773e64019f9288b7a5101f3ae50d3d8e6b1de7edee9c2ccc1d32f0c0a"},
+ {file = "wrapt-1.17.2-cp38-cp38-musllinux_1_2_i686.whl", hash = "sha256:bb90fb8bda722a1b9d48ac1e6c38f923ea757b3baf8ebd0c82e09c5c1a0e7a04"},
+ {file = "wrapt-1.17.2-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:08e7ce672e35efa54c5024936e559469436f8b8096253404faeb54d2a878416f"},
+ {file = "wrapt-1.17.2-cp38-cp38-win32.whl", hash = "sha256:410a92fefd2e0e10d26210e1dfb4a876ddaf8439ef60d6434f21ef8d87efc5b7"},
+ {file = "wrapt-1.17.2-cp38-cp38-win_amd64.whl", hash = "sha256:95c658736ec15602da0ed73f312d410117723914a5c91a14ee4cdd72f1d790b3"},
+ {file = "wrapt-1.17.2-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:99039fa9e6306880572915728d7f6c24a86ec57b0a83f6b2491e1d8ab0235b9a"},
+ {file = "wrapt-1.17.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:2696993ee1eebd20b8e4ee4356483c4cb696066ddc24bd70bcbb80fa56ff9061"},
+ {file = "wrapt-1.17.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:612dff5db80beef9e649c6d803a8d50c409082f1fedc9dbcdfde2983b2025b82"},
+ {file = "wrapt-1.17.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:62c2caa1585c82b3f7a7ab56afef7b3602021d6da34fbc1cf234ff139fed3cd9"},
+ {file = "wrapt-1.17.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c958bcfd59bacc2d0249dcfe575e71da54f9dcf4a8bdf89c4cb9a68a1170d73f"},
+ {file = "wrapt-1.17.2-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:fc78a84e2dfbc27afe4b2bd7c80c8db9bca75cc5b85df52bfe634596a1da846b"},
+ {file = "wrapt-1.17.2-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:ba0f0eb61ef00ea10e00eb53a9129501f52385c44853dbd6c4ad3f403603083f"},
+ {file = "wrapt-1.17.2-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:1e1fe0e6ab7775fd842bc39e86f6dcfc4507ab0ffe206093e76d61cde37225c8"},
+ {file = "wrapt-1.17.2-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:c86563182421896d73858e08e1db93afdd2b947a70064b813d515d66549e15f9"},
+ {file = "wrapt-1.17.2-cp39-cp39-win32.whl", hash = "sha256:f393cda562f79828f38a819f4788641ac7c4085f30f1ce1a68672baa686482bb"},
+ {file = "wrapt-1.17.2-cp39-cp39-win_amd64.whl", hash = "sha256:36ccae62f64235cf8ddb682073a60519426fdd4725524ae38874adf72b5f2aeb"},
+ {file = "wrapt-1.17.2-py3-none-any.whl", hash = "sha256:b18f2d1533a71f069c7f82d524a52599053d4c7166e9dd374ae2136b7f40f7c8"},
+ {file = "wrapt-1.17.2.tar.gz", hash = "sha256:41388e9d4d1522446fe79d3213196bd9e3b301a336965b9e27ca2788ebd122f3"},
+]
+
+[[package]]
+name = "yarl"
+version = "1.20.0"
+description = "Yet another URL library"
+optional = false
+python-versions = ">=3.9"
+groups = ["main"]
+files = [
+ {file = "yarl-1.20.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:f1f6670b9ae3daedb325fa55fbe31c22c8228f6e0b513772c2e1c623caa6ab22"},
+ {file = "yarl-1.20.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:85a231fa250dfa3308f3c7896cc007a47bc76e9e8e8595c20b7426cac4884c62"},
+ {file = "yarl-1.20.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:1a06701b647c9939d7019acdfa7ebbfbb78ba6aa05985bb195ad716ea759a569"},
+ {file = "yarl-1.20.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7595498d085becc8fb9203aa314b136ab0516c7abd97e7d74f7bb4eb95042abe"},
+ {file = "yarl-1.20.0-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:af5607159085dcdb055d5678fc2d34949bd75ae6ea6b4381e784bbab1c3aa195"},
+ {file = "yarl-1.20.0-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:95b50910e496567434cb77a577493c26bce0f31c8a305135f3bda6a2483b8e10"},
+ {file = "yarl-1.20.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b594113a301ad537766b4e16a5a6750fcbb1497dcc1bc8a4daae889e6402a634"},
+ {file = "yarl-1.20.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:083ce0393ea173cd37834eb84df15b6853b555d20c52703e21fbababa8c129d2"},
+ {file = "yarl-1.20.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:4f1a350a652bbbe12f666109fbddfdf049b3ff43696d18c9ab1531fbba1c977a"},
+ {file = "yarl-1.20.0-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:fb0caeac4a164aadce342f1597297ec0ce261ec4532bbc5a9ca8da5622f53867"},
+ {file = "yarl-1.20.0-cp310-cp310-musllinux_1_2_armv7l.whl", hash = "sha256:d88cc43e923f324203f6ec14434fa33b85c06d18d59c167a0637164863b8e995"},
+ {file = "yarl-1.20.0-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:e52d6ed9ea8fd3abf4031325dc714aed5afcbfa19ee4a89898d663c9976eb487"},
+ {file = "yarl-1.20.0-cp310-cp310-musllinux_1_2_ppc64le.whl", hash = "sha256:ce360ae48a5e9961d0c730cf891d40698a82804e85f6e74658fb175207a77cb2"},
+ {file = "yarl-1.20.0-cp310-cp310-musllinux_1_2_s390x.whl", hash = "sha256:06d06c9d5b5bc3eb56542ceeba6658d31f54cf401e8468512447834856fb0e61"},
+ {file = "yarl-1.20.0-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:c27d98f4e5c4060582f44e58309c1e55134880558f1add7a87c1bc36ecfade19"},
+ {file = "yarl-1.20.0-cp310-cp310-win32.whl", hash = "sha256:f4d3fa9b9f013f7050326e165c3279e22850d02ae544ace285674cb6174b5d6d"},
+ {file = "yarl-1.20.0-cp310-cp310-win_amd64.whl", hash = "sha256:bc906b636239631d42eb8a07df8359905da02704a868983265603887ed68c076"},
+ {file = "yarl-1.20.0-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:fdb5204d17cb32b2de2d1e21c7461cabfacf17f3645e4b9039f210c5d3378bf3"},
+ {file = "yarl-1.20.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:eaddd7804d8e77d67c28d154ae5fab203163bd0998769569861258e525039d2a"},
+ {file = "yarl-1.20.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:634b7ba6b4a85cf67e9df7c13a7fb2e44fa37b5d34501038d174a63eaac25ee2"},
+ {file = "yarl-1.20.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6d409e321e4addf7d97ee84162538c7258e53792eb7c6defd0c33647d754172e"},
+ {file = "yarl-1.20.0-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:ea52f7328a36960ba3231c6677380fa67811b414798a6e071c7085c57b6d20a9"},
+ {file = "yarl-1.20.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c8703517b924463994c344dcdf99a2d5ce9eca2b6882bb640aa555fb5efc706a"},
+ {file = "yarl-1.20.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:077989b09ffd2f48fb2d8f6a86c5fef02f63ffe6b1dd4824c76de7bb01e4f2e2"},
+ {file = "yarl-1.20.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0acfaf1da020253f3533526e8b7dd212838fdc4109959a2c53cafc6db611bff2"},
+ {file = "yarl-1.20.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b4230ac0b97ec5eeb91d96b324d66060a43fd0d2a9b603e3327ed65f084e41f8"},
+ {file = "yarl-1.20.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:0a6a1e6ae21cdd84011c24c78d7a126425148b24d437b5702328e4ba640a8902"},
+ {file = "yarl-1.20.0-cp311-cp311-musllinux_1_2_armv7l.whl", hash = "sha256:86de313371ec04dd2531f30bc41a5a1a96f25a02823558ee0f2af0beaa7ca791"},
+ {file = "yarl-1.20.0-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:dd59c9dd58ae16eaa0f48c3d0cbe6be8ab4dc7247c3ff7db678edecbaf59327f"},
+ {file = "yarl-1.20.0-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:a0bc5e05f457b7c1994cc29e83b58f540b76234ba6b9648a4971ddc7f6aa52da"},
+ {file = "yarl-1.20.0-cp311-cp311-musllinux_1_2_s390x.whl", hash = "sha256:c9471ca18e6aeb0e03276b5e9b27b14a54c052d370a9c0c04a68cefbd1455eb4"},
+ {file = "yarl-1.20.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:40ed574b4df723583a26c04b298b283ff171bcc387bc34c2683235e2487a65a5"},
+ {file = "yarl-1.20.0-cp311-cp311-win32.whl", hash = "sha256:db243357c6c2bf3cd7e17080034ade668d54ce304d820c2a58514a4e51d0cfd6"},
+ {file = "yarl-1.20.0-cp311-cp311-win_amd64.whl", hash = "sha256:8c12cd754d9dbd14204c328915e23b0c361b88f3cffd124129955e60a4fbfcfb"},
+ {file = "yarl-1.20.0-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:e06b9f6cdd772f9b665e5ba8161968e11e403774114420737f7884b5bd7bdf6f"},
+ {file = "yarl-1.20.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:b9ae2fbe54d859b3ade40290f60fe40e7f969d83d482e84d2c31b9bff03e359e"},
+ {file = "yarl-1.20.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:6d12b8945250d80c67688602c891237994d203d42427cb14e36d1a732eda480e"},
+ {file = "yarl-1.20.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:087e9731884621b162a3e06dc0d2d626e1542a617f65ba7cc7aeab279d55ad33"},
+ {file = "yarl-1.20.0-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:69df35468b66c1a6e6556248e6443ef0ec5f11a7a4428cf1f6281f1879220f58"},
+ {file = "yarl-1.20.0-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3b2992fe29002fd0d4cbaea9428b09af9b8686a9024c840b8a2b8f4ea4abc16f"},
+ {file = "yarl-1.20.0-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:4c903e0b42aab48abfbac668b5a9d7b6938e721a6341751331bcd7553de2dcae"},
+ {file = "yarl-1.20.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bf099e2432131093cc611623e0b0bcc399b8cddd9a91eded8bfb50402ec35018"},
+ {file = "yarl-1.20.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:8a7f62f5dc70a6c763bec9ebf922be52aa22863d9496a9a30124d65b489ea672"},
+ {file = "yarl-1.20.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:54ac15a8b60382b2bcefd9a289ee26dc0920cf59b05368c9b2b72450751c6eb8"},
+ {file = "yarl-1.20.0-cp312-cp312-musllinux_1_2_armv7l.whl", hash = "sha256:25b3bc0763a7aca16a0f1b5e8ef0f23829df11fb539a1b70476dcab28bd83da7"},
+ {file = "yarl-1.20.0-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:b2586e36dc070fc8fad6270f93242124df68b379c3a251af534030a4a33ef594"},
+ {file = "yarl-1.20.0-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:866349da9d8c5290cfefb7fcc47721e94de3f315433613e01b435473be63daa6"},
+ {file = "yarl-1.20.0-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:33bb660b390a0554d41f8ebec5cd4475502d84104b27e9b42f5321c5192bfcd1"},
+ {file = "yarl-1.20.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:737e9f171e5a07031cbee5e9180f6ce21a6c599b9d4b2c24d35df20a52fabf4b"},
+ {file = "yarl-1.20.0-cp312-cp312-win32.whl", hash = "sha256:839de4c574169b6598d47ad61534e6981979ca2c820ccb77bf70f4311dd2cc64"},
+ {file = "yarl-1.20.0-cp312-cp312-win_amd64.whl", hash = "sha256:3d7dbbe44b443b0c4aa0971cb07dcb2c2060e4a9bf8d1301140a33a93c98e18c"},
+ {file = "yarl-1.20.0-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:2137810a20b933b1b1b7e5cf06a64c3ed3b4747b0e5d79c9447c00db0e2f752f"},
+ {file = "yarl-1.20.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:447c5eadd750db8389804030d15f43d30435ed47af1313303ed82a62388176d3"},
+ {file = "yarl-1.20.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:42fbe577272c203528d402eec8bf4b2d14fd49ecfec92272334270b850e9cd7d"},
+ {file = "yarl-1.20.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:18e321617de4ab170226cd15006a565d0fa0d908f11f724a2c9142d6b2812ab0"},
+ {file = "yarl-1.20.0-cp313-cp313-manylinux_2_17_armv7l.manylinux2014_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:4345f58719825bba29895011e8e3b545e6e00257abb984f9f27fe923afca2501"},
+ {file = "yarl-1.20.0-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:5d9b980d7234614bc4674468ab173ed77d678349c860c3af83b1fffb6a837ddc"},
+ {file = "yarl-1.20.0-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:af4baa8a445977831cbaa91a9a84cc09debb10bc8391f128da2f7bd070fc351d"},
+ {file = "yarl-1.20.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:123393db7420e71d6ce40d24885a9e65eb1edefc7a5228db2d62bcab3386a5c0"},
+ {file = "yarl-1.20.0-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ab47acc9332f3de1b39e9b702d9c916af7f02656b2a86a474d9db4e53ef8fd7a"},
+ {file = "yarl-1.20.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:4a34c52ed158f89876cba9c600b2c964dfc1ca52ba7b3ab6deb722d1d8be6df2"},
+ {file = "yarl-1.20.0-cp313-cp313-musllinux_1_2_armv7l.whl", hash = "sha256:04d8cfb12714158abf2618f792c77bc5c3d8c5f37353e79509608be4f18705c9"},
+ {file = "yarl-1.20.0-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:7dc63ad0d541c38b6ae2255aaa794434293964677d5c1ec5d0116b0e308031f5"},
+ {file = "yarl-1.20.0-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:f9d02b591a64e4e6ca18c5e3d925f11b559c763b950184a64cf47d74d7e41877"},
+ {file = "yarl-1.20.0-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:95fc9876f917cac7f757df80a5dda9de59d423568460fe75d128c813b9af558e"},
+ {file = "yarl-1.20.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:bb769ae5760cd1c6a712135ee7915f9d43f11d9ef769cb3f75a23e398a92d384"},
+ {file = "yarl-1.20.0-cp313-cp313-win32.whl", hash = "sha256:70e0c580a0292c7414a1cead1e076c9786f685c1fc4757573d2967689b370e62"},
+ {file = "yarl-1.20.0-cp313-cp313-win_amd64.whl", hash = "sha256:4c43030e4b0af775a85be1fa0433119b1565673266a70bf87ef68a9d5ba3174c"},
+ {file = "yarl-1.20.0-cp313-cp313t-macosx_10_13_universal2.whl", hash = "sha256:b6c4c3d0d6a0ae9b281e492b1465c72de433b782e6b5001c8e7249e085b69051"},
+ {file = "yarl-1.20.0-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:8681700f4e4df891eafa4f69a439a6e7d480d64e52bf460918f58e443bd3da7d"},
+ {file = "yarl-1.20.0-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:84aeb556cb06c00652dbf87c17838eb6d92cfd317799a8092cee0e570ee11229"},
+ {file = "yarl-1.20.0-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f166eafa78810ddb383e930d62e623d288fb04ec566d1b4790099ae0f31485f1"},
+ {file = "yarl-1.20.0-cp313-cp313t-manylinux_2_17_armv7l.manylinux2014_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:5d3d6d14754aefc7a458261027a562f024d4f6b8a798adb472277f675857b1eb"},
+ {file = "yarl-1.20.0-cp313-cp313t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:2a8f64df8ed5d04c51260dbae3cc82e5649834eebea9eadfd829837b8093eb00"},
+ {file = "yarl-1.20.0-cp313-cp313t-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:4d9949eaf05b4d30e93e4034a7790634bbb41b8be2d07edd26754f2e38e491de"},
+ {file = "yarl-1.20.0-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9c366b254082d21cc4f08f522ac201d0d83a8b8447ab562732931d31d80eb2a5"},
+ {file = "yarl-1.20.0-cp313-cp313t-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:91bc450c80a2e9685b10e34e41aef3d44ddf99b3a498717938926d05ca493f6a"},
+ {file = "yarl-1.20.0-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:9c2aa4387de4bc3a5fe158080757748d16567119bef215bec643716b4fbf53f9"},
+ {file = "yarl-1.20.0-cp313-cp313t-musllinux_1_2_armv7l.whl", hash = "sha256:d2cbca6760a541189cf87ee54ff891e1d9ea6406079c66341008f7ef6ab61145"},
+ {file = "yarl-1.20.0-cp313-cp313t-musllinux_1_2_i686.whl", hash = "sha256:798a5074e656f06b9fad1a162be5a32da45237ce19d07884d0b67a0aa9d5fdda"},
+ {file = "yarl-1.20.0-cp313-cp313t-musllinux_1_2_ppc64le.whl", hash = "sha256:f106e75c454288472dbe615accef8248c686958c2e7dd3b8d8ee2669770d020f"},
+ {file = "yarl-1.20.0-cp313-cp313t-musllinux_1_2_s390x.whl", hash = "sha256:3b60a86551669c23dc5445010534d2c5d8a4e012163218fc9114e857c0586fdd"},
+ {file = "yarl-1.20.0-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:3e429857e341d5e8e15806118e0294f8073ba9c4580637e59ab7b238afca836f"},
+ {file = "yarl-1.20.0-cp313-cp313t-win32.whl", hash = "sha256:65a4053580fe88a63e8e4056b427224cd01edfb5f951498bfefca4052f0ce0ac"},
+ {file = "yarl-1.20.0-cp313-cp313t-win_amd64.whl", hash = "sha256:53b2da3a6ca0a541c1ae799c349788d480e5144cac47dba0266c7cb6c76151fe"},
+ {file = "yarl-1.20.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:119bca25e63a7725b0c9d20ac67ca6d98fa40e5a894bd5d4686010ff73397914"},
+ {file = "yarl-1.20.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:35d20fb919546995f1d8c9e41f485febd266f60e55383090010f272aca93edcc"},
+ {file = "yarl-1.20.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:484e7a08f72683c0f160270566b4395ea5412b4359772b98659921411d32ad26"},
+ {file = "yarl-1.20.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8d8a3d54a090e0fff5837cd3cc305dd8a07d3435a088ddb1f65e33b322f66a94"},
+ {file = "yarl-1.20.0-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:f0cf05ae2d3d87a8c9022f3885ac6dea2b751aefd66a4f200e408a61ae9b7f0d"},
+ {file = "yarl-1.20.0-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a884b8974729e3899d9287df46f015ce53f7282d8d3340fa0ed57536b440621c"},
+ {file = "yarl-1.20.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:f8d8aa8dd89ffb9a831fedbcb27d00ffd9f4842107d52dc9d57e64cb34073d5c"},
+ {file = "yarl-1.20.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3b4e88d6c3c8672f45a30867817e4537df1bbc6f882a91581faf1f6d9f0f1b5a"},
+ {file = "yarl-1.20.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:bdb77efde644d6f1ad27be8a5d67c10b7f769804fff7a966ccb1da5a4de4b656"},
+ {file = "yarl-1.20.0-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:4ba5e59f14bfe8d261a654278a0f6364feef64a794bd456a8c9e823071e5061c"},
+ {file = "yarl-1.20.0-cp39-cp39-musllinux_1_2_armv7l.whl", hash = "sha256:d0bf955b96ea44ad914bc792c26a0edcd71b4668b93cbcd60f5b0aeaaed06c64"},
+ {file = "yarl-1.20.0-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:27359776bc359ee6eaefe40cb19060238f31228799e43ebd3884e9c589e63b20"},
+ {file = "yarl-1.20.0-cp39-cp39-musllinux_1_2_ppc64le.whl", hash = "sha256:04d9c7a1dc0a26efb33e1acb56c8849bd57a693b85f44774356c92d610369efa"},
+ {file = "yarl-1.20.0-cp39-cp39-musllinux_1_2_s390x.whl", hash = "sha256:faa709b66ae0e24c8e5134033187a972d849d87ed0a12a0366bedcc6b5dc14a5"},
+ {file = "yarl-1.20.0-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:44869ee8538208fe5d9342ed62c11cc6a7a1af1b3d0bb79bb795101b6e77f6e0"},
+ {file = "yarl-1.20.0-cp39-cp39-win32.whl", hash = "sha256:b7fa0cb9fd27ffb1211cde944b41f5c67ab1c13a13ebafe470b1e206b8459da8"},
+ {file = "yarl-1.20.0-cp39-cp39-win_amd64.whl", hash = "sha256:d4fad6e5189c847820288286732075f213eabf81be4d08d6cc309912e62be5b7"},
+ {file = "yarl-1.20.0-py3-none-any.whl", hash = "sha256:5d0fe6af927a47a230f31e6004621fd0959eaa915fc62acfafa67ff7229a3124"},
+ {file = "yarl-1.20.0.tar.gz", hash = "sha256:686d51e51ee5dfe62dec86e4866ee0e9ed66df700d55c828a615640adc885307"},
+]
+
+[package.dependencies]
+idna = ">=2.0"
+multidict = ">=4.0"
+propcache = ">=0.2.1"
+
+[[package]]
+name = "yattag"
+version = "1.16.1"
+description = "Generate HTML or XML in a pythonic way. Pure python alternative to web template engines.Can fill HTML forms with default values and error messages."
+optional = false
+python-versions = "*"
+groups = ["main"]
+files = [
+ {file = "yattag-1.16.1.tar.gz", hash = "sha256:baa8f254e7ea5d3e0618281ad2ff5610e0e5360b3608e695c29bfb3b29d051f4"},
+]
+
+[extras]
+anthropic = ["anthropic"]
+bedrock = ["aioboto3", "boto3"]
+fal = ["fal-client"]
+google = ["google-auth-oauthlib"]
+mistralai = ["mistralai"]
+
+[metadata]
+lock-version = "2.1"
+python-versions = ">=3.11,<3.12"
+content-hash = "e22167583ba126f8af24af9736fcb854cf7ab64efa3fab9e019fedf931eb22f5"
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 000000000..f04c030af
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,261 @@
+[tool.poetry]
+name = "pipelex"
+version = "0.2.7"
+description = "Pipelex is an open-source dev tool based on a simple declarative language that lets you define replicable, structured, composable LLM pipelines."
+authors = ["Evotis S.A.S. <[email protected]>"]
+maintainers = ["Pipelex staff <[email protected]>"]
+license = "MIT"
+readme = "README.md"
+repository = "https://github.com/Pipelex/pipelex"
+homepage = "https://pipelex.com"
+classifiers = [
+ "Programming Language :: Python :: 3",
+ "Programming Language :: Python :: 3.11",
+ "Operating System :: OS Independent",
+ "License :: OSI Approved :: MIT License",
+]
+exclude = ["tests/"]
+
+[tool.poetry.urls]
+Documentation = "https://github.com/Pipelex/pipelex/blob/dev/doc/Documentation.md"
+Changelog = "https://github.com/Pipelex/pipelex/blob/dev/CHANGELOG.md"
+
+[[tool.poetry.packages]]
+include = "pipelex"
+
+[[tool.poetry.packages]]
+include = "pyproject.toml"
+to = "pipelex"
+
+[tool.poetry.scripts]
+pipelex = "pipelex.cli._cli:app"
+
+[build-system]
+build-backend = "poetry.core.masonry.api"
+requires = ["poetry-core"]
+
+[tool.poetry.dependencies]
+python = ">=3.11,<3.12"
+aiofiles = "<24.0"
+filetype = "^1.2.0"
+httpx = "^0.27.0"
+instructor = "1.7.2"
+jinja2 = "^3.1.4"
+json2html = "^1.3.0"
+kajson = "0.1.4"
+markdown = "^3.6"
+networkx = "^3.4.2"
+openai = "^1.60.1"
+openpyxl = "^3.1.5" # Used by pandas to handle excel files
+pandas = "^2.2.3"
+pillow = "^11.2.1"
+pypdfium2 = "^4.30.1"
+pydantic = "2.10.6"
+python-dotenv = "^1.0.1"
+PyYAML = "^6.0.2"
+rich = "^13.8.1"
+shortuuid = "^1.0.13"
+toml = "^0.10.2"
+typer = "^0.12.5"
+typing-extensions = "^4.12.2"
+yattag = "^1.15.2"
+
+aioboto3 = { version = "^13.4.0", optional = true }
+anthropic = { version = "^0.49.0", optional = true }
+boto3 = { version = "^1.34.131", optional = true }
+fal-client = { version = "^0.4.1", optional = true }
+google-auth-oauthlib = { version = "^1.2.1", optional = true }
+mistralai = { version = "1.5.2", optional = true }
+
+[tool.poetry.extras]
+anthropic = ["anthropic"]
+bedrock = ["boto3", "aioboto3"]
+fal = ["fal-client"]
+google = ["google-auth-oauthlib"]
+mistralai = ["mistralai"]
+
+[tool.poetry.group.dev.dependencies]
+boto3-stubs = "^1.35.24"
+mypy = "^1.11.2"
+pyright = "1.1.398" # version 1.1.399 generates a ton of false positives
+pandas-stubs = "^2.2.3.241126"
+pytest = "^8.3.3"
+pytest-cov = "^6.1.1"
+pytest-pretty = "1.2.0"
+pytest_asyncio = "^0.24.0"
+ruff = "^0.6.8"
+types-aioboto3 = { version = "^13.4.0", extras = [
+ "bedrock",
+ "bedrock-runtime",
+] }
+types-aiofiles = "^24.1.0.20240626"
+types-beautifulsoup4 = "^4.12.0.20240907"
+types-markdown = "^3.6.0.20240316"
+types-networkx = "^3.3.0.20241020"
+types-openpyxl = "^3.1.5.20250306"
+types-requests = "^2.32.0.2024091"
+types-PyYAML = "^6.0.12.20250326"
+types-toml = "^0.10.8.20240310"
+
+[tool.mypy]
+check_untyped_defs = true
+exclude = "^.*\\.venv/.*$"
+mypy_path = "."
+packages = ["pipelex", "tests"]
+plugins = ["pydantic.mypy"]
+python_version = "3.11"
+warn_return_any = true
+warn_unused_configs = true
+
+[[tool.mypy.overrides]]
+ignore_missing_imports = true
+module = ["filetype", "json2html", "pypdfium2", "pypdfium2.raw"]
+
+[tool.pyright]
+analyzeUnannotatedFunctions = true
+deprecateTypingAliases = false
+disableBytesTypePromotions = true
+enableExperimentalFeatures = false
+enableTypeIgnoreComments = true
+exclude = ["**/node_modules", "**/__pycache__"]
+extraPaths = ["./tests"]
+include = ["pipelex", "tests"]
+pythonVersion = "3.11"
+reportAbstractUsage = "error"
+reportArgumentType = "error"
+reportAssertAlwaysTrue = "error"
+reportAssertTypeFailure = "error"
+reportAssignmentType = "error"
+reportAttributeAccessIssue = "error"
+reportCallInDefaultInitializer = true
+reportCallIssue = "error"
+reportConstantRedefinition = "error"
+reportDeprecated = "error"
+reportDuplicateImport = "error"
+reportFunctionMemberAccess = "error"
+reportGeneralTypeIssues = "error"
+reportImplicitOverride = true
+reportImplicitStringConcatenation = false
+reportImportCycles = true
+reportIncompatibleMethodOverride = "error"
+reportIncompatibleVariableOverride = "error"
+reportIncompleteStub = "error"
+reportInconsistentConstructor = "error"
+reportInconsistentOverload = "error"
+reportIndexIssue = "error"
+reportInvalidStringEscapeSequence = "error"
+reportInvalidStubStatement = "error"
+reportInvalidTypeArguments = "error"
+reportInvalidTypeForm = "error"
+reportInvalidTypeVarUse = "error"
+reportMatchNotExhaustive = "error"
+reportMissingImports = "error"
+reportMissingModuleSource = "warning"
+reportMissingParameterType = "error"
+reportMissingSuperCall = "none"
+reportMissingTypeArgument = "error"
+reportMissingTypeStubs = false
+reportNoOverloadImplementation = "error"
+reportOperatorIssue = "error"
+reportOptionalCall = "error"
+reportOptionalContextManager = "error"
+reportOptionalIterable = "error"
+reportOptionalMemberAccess = "error"
+reportOptionalOperand = "error"
+reportOptionalSubscript = "error"
+reportOverlappingOverload = "error"
+reportPossiblyUnboundVariable = "error"
+reportPrivateImportUsage = "error"
+reportPrivateUsage = "error"
+reportPropertyTypeMismatch = true
+reportRedeclaration = "error"
+reportReturnType = "error"
+reportSelfClsParameterName = "error"
+reportShadowedImports = true
+reportTypeCommentUsage = "error"
+reportTypedDictNotRequiredAccess = "error"
+reportUnboundVariable = "error"
+reportUndefinedVariable = "error"
+reportUninitializedInstanceVariable = "none"
+reportUnknownArgumentType = "error"
+reportUnknownLambdaType = "error"
+reportUnknownMemberType = "error"
+reportUnknownParameterType = "error"
+reportUnknownVariableType = "error"
+reportUnnecessaryCast = "error"
+reportUnnecessaryComparison = "error"
+reportUnnecessaryContains = "error"
+reportUnnecessaryIsInstance = "error"
+reportUnnecessaryTypeIgnoreComment = "none"
+reportUnsupportedDunderAll = "error"
+reportUntypedBaseClass = "error"
+reportUntypedClassDecorator = "error"
+reportUntypedFunctionDecorator = "error"
+reportUntypedNamedTuple = "error"
+reportUnusedCallResult = "none"
+reportUnusedClass = "error"
+reportUnusedCoroutine = "error"
+reportUnusedExcept = "error"
+reportUnusedExpression = "error"
+reportUnusedFunction = "error"
+reportUnusedImport = "none"
+reportUnusedVariable = "error"
+reportWildcardImportFromLibrary = "error"
+strictDictionaryInference = true
+strictListInference = true
+strictParameterNoneValue = true
+strictSetInference = true
+typeCheckingMode = "strict"
+
+[tool.pytest.ini_options]
+addopts = "--import-mode=importlib -ra -m 'not inference and not llm and not imgg and not ocr'"
+asyncio_default_fixture_loop_scope = "session"
+markers = [
+ "inference: slow and costly due to inference calls",
+ "llm: slow and costly due to llm inference calls",
+ "imgg: slow and costly due to imgg inference calls",
+ "ocr: slow and costly due to ocr inference calls",
+ "gha_disabled: tests that should not run in GitHub Actions",
+]
+minversion = "8.0"
+
+[tool.coverage.run]
+source = ["pipelex"]
+omit = ["tests/*", "**/__init__.py"]
+
+[tool.coverage.report]
+exclude_lines = [
+ "pragma: no cover",
+ "def __repr__",
+ "raise NotImplementedError",
+ "if __name__ == .__main__.:",
+ "pass",
+ "raise ImportError",
+]
+
+[tool.ruff]
+exclude = [".mypy_cache", ".ruff_cache", ".venv", ".vscode", "trigger_pipeline"]
+line-length = 150
+target-version = "py311"
+
+[tool.ruff.format]
+
+[tool.ruff.lint]
+ignore = ["F401"]
+external = ["F401"]
+select = [
+ "E4",
+ "E7",
+ "E9",
+ "F",
+ "A001",
+ "A002",
+ "A003",
+ "RUF008",
+ "RUF009",
+ "RUF012",
+ "RUF013",
+ "RUF100",
+ "E501",
+ "I",
+]
diff --git a/tests/__init__.py b/tests/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/tests/__init__.py
@@ -0,0 +1 @@
+
diff --git a/tests/cogt/__init__.py b/tests/cogt/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/tests/cogt/__init__.py
@@ -0,0 +1 @@
+
diff --git a/tests/cogt/asynch/__init__.py b/tests/cogt/asynch/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/tests/cogt/asynch/__init__.py
@@ -0,0 +1 @@
+
diff --git a/tests/cogt/asynch/content_generator/conftest.py b/tests/cogt/asynch/content_generator/conftest.py
new file mode 100644
index 000000000..6afb61501
--- /dev/null
+++ b/tests/cogt/asynch/content_generator/conftest.py
@@ -0,0 +1,18 @@
+from typing import AsyncGenerator
+
+import pytest_asyncio
+from pytest import FixtureRequest
+from rich import print
+
+from pipelex.cogt.content_generation.content_generator import ContentGenerator
+
+
+@pytest_asyncio.fixture # pyright: ignore[reportUntypedFunctionDecorator, reportUnknownMemberType]
+async def content_generator(request: FixtureRequest) -> AsyncGenerator[ContentGenerator, None]:
+ # Code to run before each test
+ print("\n[magenta]ContentGenerator setup[/magenta]")
+ content_generator = ContentGenerator()
+ # Return it for use in tests
+ yield content_generator
+ # Code to run after each test
+ print("\n[magenta]ContentGenerator teardown[/magenta]")
diff --git a/tests/cogt/asynch/content_generator/test_content_generator.py b/tests/cogt/asynch/content_generator/test_content_generator.py
new file mode 100644
index 000000000..e93b21900
--- /dev/null
+++ b/tests/cogt/asynch/content_generator/test_content_generator.py
@@ -0,0 +1,165 @@
+from typing import List, cast
+
+import pytest
+from pytest import FixtureRequest
+
+from pipelex import pretty_print
+from pipelex.cogt.content_generation.content_generator import ContentGenerator
+from pipelex.cogt.exceptions import LLMHandleNotFoundError
+from pipelex.cogt.image.generated_image import GeneratedImage
+from pipelex.cogt.imgg.imgg_handle import ImggHandle
+from pipelex.cogt.imgg.imgg_prompt import ImggPrompt
+from pipelex.cogt.llm.llm_models.llm_setting import LLMSetting
+from pipelex.cogt.llm.llm_prompt import LLMPrompt
+from pipelex.cogt.ocr.ocr_handle import OcrHandle
+from pipelex.cogt.ocr.ocr_input import OcrInput
+from pipelex.cogt.ocr.ocr_job_components import OcrJobConfig, OcrJobParams
+from pipelex.cogt.ocr.ocr_output import OcrOutput
+from pipelex.hub import get_llm_deck
+from pipelex.mission.job_metadata import JobMetadata
+from tests.cogt.test_data import Employee
+from tests.test_data import ImageTestCases
+
+USER_TEXT_FOR_BASE = """
+Write a detailed description of a woman's clothing in the style of a 19th-century novel.
+Keep it short: 3 sentences max
+"""
+
+USER_TEXT_FOR_SINGLE_PERSON = "name: John, age: 30, job: bank teller"
+USER_TEXT_FOR_SINGLE_PERSON_TEXT_THEN_OBJECT = """
+Imagine a female character that decides to become a cop once reaching middle age.
+Present this character in a couple of very short sentences.
+Be sure to include the character's full name, age and job.
+"""
+MULTIPLE_USER_TEXTS_FOR_PEOPLE = [
+ "name: Bob, age: 25, job: banker",
+ "name: Maria, age: 35, job: consultant",
+ "name: SLartiblfastikur, age: 30, job: fizzy buzzer",
+ "name: Alice, age: 40, job: developer",
+ "name: Tom, age: 45, job: TV presenter",
+ "name: Jerry, age: 50, job: nurse",
+]
+USER_TEXTS_FOR_PEOPLE_STR = "\n".join(MULTIPLE_USER_TEXTS_FOR_PEOPLE)
+USER_TEXT_FOR_MULTIPLE_PEOPLE_TEXT_THEN_OBJECT = """
+Imagine the 4 main characters for a sitcom in Paris.
+Present each character in one very short sentence.
+Be sure to include each character's full name, age and job.
+"""
+
+USER_TEXT_FOR_HAIKU = """
+Write a haiku about the meaning of life
+"""
+
+
[email protected](loop_scope="class")
+class TestContentGenerator:
+ @pytest.mark.llm
+ @pytest.mark.inference
+ async def test_make_llm_text_only(self, request: FixtureRequest, content_generator: ContentGenerator):
+ llm_setting_main = get_llm_deck().get_llm_setting(llm_setting_or_preset_id="llm_for_testing_gen_text")
+
+ text: str = await content_generator.make_llm_text(
+ job_metadata=JobMetadata(
+ top_job_id=cast(str, request.node.originalname), # pyright: ignore[reportUnknownMemberType]
+ ),
+ llm_prompt_for_text=LLMPrompt(user_text=USER_TEXT_FOR_BASE),
+ llm_setting_main=llm_setting_main,
+ )
+ pretty_print(text, title="make_llm_text")
+
+ assert isinstance(text, str)
+
+ @pytest.mark.llm
+ @pytest.mark.inference
+ async def test_make_object_direct(self, request: FixtureRequest, content_generator: ContentGenerator):
+ llm_setting_for_object = get_llm_deck().get_llm_setting(llm_setting_or_preset_id="llm_for_testing_gen_object")
+
+ person_direct: Employee = await content_generator.make_object_direct(
+ job_metadata=JobMetadata(
+ top_job_id=cast(str, request.node.originalname), # pyright: ignore[reportUnknownMemberType]
+ ),
+ object_class=Employee,
+ llm_prompt_for_object=LLMPrompt(user_text=USER_TEXT_FOR_SINGLE_PERSON),
+ llm_setting_for_object=llm_setting_for_object,
+ )
+ pretty_print(person_direct, title="make_object_direct")
+
+ assert isinstance(person_direct, Employee)
+
+ @pytest.mark.llm
+ @pytest.mark.inference
+ async def test_make_object_list_direct(self, request: FixtureRequest, content_generator: ContentGenerator):
+ llm_setting_for_object = get_llm_deck().get_llm_setting(llm_setting_or_preset_id="llm_for_testing_gen_object")
+
+ person_list_direct: List[Employee] = await content_generator.make_object_list_direct(
+ job_metadata=JobMetadata(
+ top_job_id=cast(str, request.node.originalname), # pyright: ignore[reportUnknownMemberType]
+ ),
+ object_class=Employee,
+ llm_prompt_for_object_list=LLMPrompt(user_text=USER_TEXTS_FOR_PEOPLE_STR),
+ llm_setting_for_object_list=llm_setting_for_object,
+ )
+ pretty_print(person_list_direct, title="make_object_list_direct")
+
+ assert isinstance(person_list_direct, list)
+ assert all(isinstance(person, Employee) for person in person_list_direct)
+
+ @pytest.mark.imgg
+ @pytest.mark.inference
+ async def test_make_image(self, request: FixtureRequest, content_generator: ContentGenerator):
+ image: GeneratedImage = await content_generator.make_single_image(
+ job_metadata=JobMetadata(
+ top_job_id=cast(str, request.node.originalname), # pyright: ignore[reportUnknownMemberType]
+ ),
+ imgg_handle=ImggHandle.SDXL_LIGHTNING,
+ imgg_prompt=ImggPrompt(
+ positive_text="A dog with sunglasses coding on a laptop",
+ ),
+ )
+ pretty_print(image, title="make_image")
+ assert isinstance(image, GeneratedImage)
+
+ async def test_make_jinja2_text(self, request: FixtureRequest, content_generator: ContentGenerator):
+ context = {
+ "the_answer": "elementary, my dear Watson",
+ }
+
+ jinja2_text: str = await content_generator.make_jinja2_text(
+ context=context,
+ jinja2="The answer is: {{ the_answer }}",
+ )
+ pretty_print(jinja2_text, title="jinja2_text")
+ assert isinstance(jinja2_text, str)
+ assert jinja2_text == "The answer is: elementary, my dear Watson"
+
+ @pytest.mark.ocr
+ @pytest.mark.inference
+ async def test_make_ocr_extract_pages(self, request: FixtureRequest, content_generator: ContentGenerator):
+ ocr_output = await content_generator.make_ocr_extract_pages(
+ job_metadata=JobMetadata(
+ top_job_id=cast(str, request.node.originalname), # pyright: ignore[reportUnknownMemberType]
+ ),
+ ocr_handle=OcrHandle.MISTRAL_OCR,
+ ocr_input=OcrInput(image_uri=ImageTestCases.IMAGE_FILE_PATH),
+ ocr_job_params=OcrJobParams.make_default_ocr_job_params(),
+ ocr_job_config=OcrJobConfig(),
+ )
+ pretty_print(ocr_output, title="ocr_extract_pages")
+ assert isinstance(ocr_output, OcrOutput)
+
+ @pytest.mark.llm
+ @pytest.mark.inference
+ async def test_make_llm_text_with_error(self, request: FixtureRequest, content_generator: ContentGenerator):
+ BAD_HANDLE_TO_TEST_FAILURE = "bad_handle_to_test_failure"
+ llm_setting_main = LLMSetting(llm_handle=BAD_HANDLE_TO_TEST_FAILURE, temperature=0.5, max_tokens=100)
+ with pytest.raises(LLMHandleNotFoundError) as excinfo:
+ await content_generator.make_llm_text(
+ job_metadata=JobMetadata(
+ top_job_id=cast(str, request.node.originalname), # pyright: ignore[reportUnknownMemberType]
+ ),
+ llm_prompt_for_text=LLMPrompt(user_text=USER_TEXT_FOR_BASE),
+ llm_setting_main=llm_setting_main,
+ )
+ error = excinfo.value
+ pretty_print(f"Caught expected error: {error}")
+ assert str(error).startswith("LLM Engine blueprint for llm_handle 'bad_handle_to_test_failure' not found")
diff --git a/tests/cogt/asynch/imgg/__init__.py b/tests/cogt/asynch/imgg/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/tests/cogt/asynch/imgg/__init__.py
@@ -0,0 +1 @@
+
diff --git a/tests/cogt/asynch/imgg/test_imgg.py b/tests/cogt/asynch/imgg/test_imgg.py
new file mode 100644
index 000000000..03273dcb0
--- /dev/null
+++ b/tests/cogt/asynch/imgg/test_imgg.py
@@ -0,0 +1,23 @@
+import pytest
+
+from pipelex import pretty_print
+from pipelex.cogt.imgg.imgg_job_factory import ImggJobFactory
+from pipelex.hub import get_imgg_worker
+from tests.cogt.test_data import IMGGTestCases
+
+
[email protected](loop_scope="class")
+class TestAsyncCogtImgg:
+ @pytest.mark.parametrize("topic, imgg_prompt_text", IMGGTestCases.IMAGE_DESC)
+ async def test_imgg_async_using_handle(self, imgg_handle: str, topic: str, imgg_prompt_text: str):
+ pretty_print(imgg_prompt_text, title=topic)
+ imgg_worker_async = get_imgg_worker(imgg_handle=imgg_handle)
+ imgg_job = ImggJobFactory.make_imgg_job_from_prompt_contents(
+ positive_text=imgg_prompt_text,
+ )
+ generated_image = await imgg_worker_async.gen_image(
+ imgg_job=imgg_job,
+ )
+ pretty_print(generated_image, title=f"Generated Image, topic={topic}")
diff --git a/tests/cogt/asynch/imgg/test_imgg_fal.py b/tests/cogt/asynch/imgg/test_imgg_fal.py
new file mode 100644
index 000000000..a58a7e841
--- /dev/null
+++ b/tests/cogt/asynch/imgg/test_imgg_fal.py
@@ -0,0 +1,23 @@
+import pytest
+
+from pipelex import pretty_print
+from pipelex.cogt.imgg.imgg_handle import ImggHandle
+from pipelex.cogt.imgg.imgg_job_factory import ImggJobFactory
+from pipelex.hub import get_imgg_worker
+from tests.cogt.test_data import IMGGTestCases
+
+
[email protected](loop_scope="class")
+class TestFalAsync:
+ @pytest.mark.parametrize("topic, imgg_prompt_text", IMGGTestCases.IMAGE_DESC)
+ async def test_fal_async(self, topic: str, imgg_prompt_text: str, imgg_handle: ImggHandle):
+ fal_worker_async = get_imgg_worker(imgg_handle=imgg_handle)
+ imgg_job = ImggJobFactory.make_imgg_job_from_prompt_contents(
+ positive_text=imgg_prompt_text,
+ )
+ generated_image = await fal_worker_async.gen_image(
+ imgg_job=imgg_job,
+ )
+ pretty_print(generated_image, title=f"Generated Image, topic={topic}")
diff --git a/tests/cogt/asynch/llm_async/__init__.py b/tests/cogt/asynch/llm_async/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/tests/cogt/asynch/llm_async/__init__.py
@@ -0,0 +1 @@
+
diff --git a/tests/cogt/asynch/llm_async/test_llm_engines.py b/tests/cogt/asynch/llm_async/test_llm_engines.py
new file mode 100644
index 000000000..16c0f4162
--- /dev/null
+++ b/tests/cogt/asynch/llm_async/test_llm_engines.py
@@ -0,0 +1,144 @@
+import pytest
+
+from pipelex import log, pretty_print
+from pipelex.cogt.llm.llm_job import LLMJob
+from pipelex.cogt.llm.llm_job_components import LLMJobParams
+from pipelex.cogt.llm.llm_job_factory import LLMJobFactory
+from pipelex.cogt.llm.llm_models.llm_engine import LLMEngine
+from pipelex.cogt.llm.llm_models.llm_engine_factory import LLMEngineFactory
+from pipelex.cogt.llm.llm_models.llm_family import LLMCreator, LLMFamily
+from pipelex.cogt.llm.llm_models.llm_platform import LLMPlatform
+from pipelex.cogt.llm.llm_worker_abstract import LLMWorkerAbstract
+from pipelex.cogt.llm.llm_worker_factory import LLMWorkerFactory
+from pipelex.hub import get_inference_manager, get_llm_deck, get_llm_models_provider, get_report_delegate
+from tests.cogt.test_data import LLMTestConstants, Person
+
+
[email protected](loop_scope="class")
+class TestAsyncLLMEngines:
+ async def run_inference(self, llm_worker: LLMWorkerAbstract, llm_job: LLMJob):
+ generated_text = await llm_worker.gen_text(llm_job=llm_job)
+ assert generated_text
+ pretty_print(generated_text)
+ llm_model = llm_worker.llm_engine.llm_model
+ if llm_model.is_gen_object_supported:
+ generated_object = await llm_worker.gen_object(llm_job=llm_job, schema=Person)
+ assert generated_object
+ pretty_print(generated_object)
+ else:
+ log.info(f"No object generation supported for this model: '{llm_model.name_and_version_and_platform}'")
+
+ async def test_one_llm_engine(self, llm_job_params: LLMJobParams, llm_handle: str):
+ inference_manager = get_inference_manager()
+ llm_worker = inference_manager.get_llm_worker(llm_handle=llm_handle)
+ llm_job = LLMJobFactory.make_llm_job_from_prompt_contents(
+ system_text=None,
+ user_text=LLMTestConstants.USER_TEXT_SHORT,
+ llm_job_params=llm_job_params,
+ )
+ await self.run_inference(llm_worker=llm_worker, llm_job=llm_job)
+
+ async def test_one_llm_engine_by_llm_id_and_platform(self, llm_job_params: LLMJobParams, llm_id: str, llm_platform: LLMPlatform):
+ log.info(f"Testing {llm_id} on {llm_platform}")
+ llm_models_provider = get_llm_models_provider()
+ llm_models = llm_models_provider.get_all_llm_models()
+ llm_worker_factory = LLMWorkerFactory()
+ for llm_model in llm_models:
+ platform_llm_id = llm_model.platform_llm_id.get(llm_platform)
+ if llm_id != platform_llm_id:
+ continue
+
+ llm_engine = LLMEngine(
+ llm_platform=llm_platform,
+ llm_model=llm_model,
+ )
+ llm_worker = llm_worker_factory.make_llm_worker(
+ llm_engine=llm_engine,
+ report_delegate=get_report_delegate(),
+ )
+ llm_job = LLMJobFactory.make_llm_job_from_prompt_contents(
+ system_text=None,
+ user_text=LLMTestConstants.USER_TEXT_SHORT,
+ llm_job_params=llm_job_params,
+ )
+ log.info(f"Running inference for {llm_model.name_and_version_and_platform}")
+ await self.run_inference(llm_worker=llm_worker, llm_job=llm_job)
+
+ async def test_llm_engines_from_one_family(self, llm_job_params: LLMJobParams, llm_family: LLMFamily):
+ inference_manager = get_inference_manager()
+ llm_handle_to_llm_engine_blueprint = get_llm_deck().llm_handles
+ count = 0
+ for llm_handle, llm_engine_blueprint in llm_handle_to_llm_engine_blueprint.items():
+ llm_engine = LLMEngineFactory.make_llm_engine(llm_engine_blueprint=llm_engine_blueprint)
+ if llm_engine.llm_model.llm_family != llm_family:
+ continue
+ llm_worker = inference_manager.get_llm_worker(
+ llm_handle=llm_handle,
+ specific_llm_engine_blueprint=llm_engine_blueprint,
+ )
+ llm_job = LLMJobFactory.make_llm_job_from_prompt_contents(
+ system_text=None,
+ user_text=LLMTestConstants.USER_TEXT_SHORT,
+ llm_job_params=llm_job_params,
+ )
+ await self.run_inference(llm_worker=llm_worker, llm_job=llm_job)
+ count += 1
+
+ log.info(f"Tested {count} llm_engines for family {llm_family}")
+
+ async def test_llm_engines_from_one_creator(self, llm_job_params: LLMJobParams, llm_creator: LLMCreator):
+ inference_manager = get_inference_manager()
+ llm_handle_to_llm_engine_blueprint = get_llm_deck().llm_handles
+ for llm_handle, llm_engine_blueprint in llm_handle_to_llm_engine_blueprint.items():
+ llm_engine = LLMEngineFactory.make_llm_engine(llm_engine_blueprint=llm_engine_blueprint)
+ if llm_engine.llm_model.llm_family.creator != llm_creator:
+ continue
+ llm_worker = inference_manager.get_llm_worker(
+ llm_handle=llm_handle,
+ specific_llm_engine_blueprint=llm_engine_blueprint,
+ )
+ llm_job = LLMJobFactory.make_llm_job_from_prompt_contents(
+ system_text=None,
+ user_text=LLMTestConstants.USER_TEXT_SHORT,
+ llm_job_params=llm_job_params,
+ )
+ await self.run_inference(llm_worker=llm_worker, llm_job=llm_job)
+
+ async def test_llm_engines_from_one_platform(self, llm_job_params: LLMJobParams, llm_platform: LLMPlatform):
+ llm_models_provider = get_llm_models_provider()
+ llm_models = llm_models_provider.get_all_llm_models()
+ llm_worker_factory = LLMWorkerFactory()
+ for llm_model in llm_models:
+ if llm_platform not in llm_model.enabled_platforms:
+ continue
+ llm_engine = LLMEngine(
+ llm_platform=llm_platform,
+ llm_model=llm_model,
+ )
+ llm_worker = llm_worker_factory.make_llm_worker(
+ llm_engine=llm_engine,
+ report_delegate=get_report_delegate(),
+ )
+ llm_job = LLMJobFactory.make_llm_job_from_prompt_contents(
+ system_text=None,
+ user_text=LLMTestConstants.USER_TEXT_SHORT,
+ llm_job_params=llm_job_params,
+ )
+ await self.run_inference(llm_worker=llm_worker, llm_job=llm_job)
+
+ async def test_llm_handle_to_llm_engine_default(self, llm_job_params: LLMJobParams):
+ inference_manager = get_inference_manager()
+ llm_handle_to_llm_engine_blueprint = get_llm_deck().llm_handles
+ for llm_handle in llm_handle_to_llm_engine_blueprint.keys():
+ llm_worker = inference_manager.get_llm_worker(llm_handle=llm_handle)
+ assert llm_worker
+ llm_job = LLMJobFactory.make_llm_job_from_prompt_contents(
+ system_text=None,
+ user_text=LLMTestConstants.USER_TEXT_SHORT,
+ llm_job_params=llm_job_params,
+ )
+ assert llm_job
+ # ENABLE THIS TO TEST THE INFERENCE with all base models
+ # await self.run_inference(llm_worker=llm_worker, llm_job=llm_job)
diff --git a/tests/cogt/asynch/llm_async/test_llm_gen_object.py b/tests/cogt/asynch/llm_async/test_llm_gen_object.py
new file mode 100644
index 000000000..51107cc97
--- /dev/null
+++ b/tests/cogt/asynch/llm_async/test_llm_gen_object.py
@@ -0,0 +1,105 @@
+import asyncio
+from typing import List, Tuple
+
+import pytest
+from pydantic import BaseModel
+
+from pipelex import pretty_print
+from pipelex.cogt.llm.llm_job_components import LLMJobParams
+from pipelex.cogt.llm.llm_job_factory import LLMJobFactory
+from pipelex.hub import get_llm_deck, get_llm_worker
+from tests.cogt.test_data import LLMTestCases
+
+
+def get_async_worker_and_job(llm_preset_id: str, user_text: str):
+ llm_setting = get_llm_deck().get_llm_setting(llm_setting_or_preset_id=llm_preset_id)
+ pretty_print(llm_setting, title=llm_preset_id)
+ pretty_print(user_text)
+ llm_worker = get_llm_worker(llm_handle=llm_setting.llm_handle)
+ llm_job_params = llm_setting.make_llm_job_params()
+ llm_job = LLMJobFactory.make_llm_job_from_prompt_contents(
+ user_text=user_text,
+ llm_job_params=llm_job_params,
+ )
+ return llm_worker, llm_job
+
+
[email protected](loop_scope="class")
+class TestAsyncCogtLLMGenObject:
+ @pytest.mark.parametrize("user_text, expected_instance", LLMTestCases.SINGLE_OBJECT)
+ async def test_gen_object_async_using_handle(self, llm_job_params: LLMJobParams, llm_handle: str, user_text: str, expected_instance: BaseModel):
+ llm_worker = get_llm_worker(llm_handle=llm_handle)
+ if not llm_worker.llm_engine.is_gen_object_supported:
+ pytest.skip(f"LLM '{llm_handle}' does not support object generation")
+ llm_job = LLMJobFactory.make_llm_job_from_prompt_contents(
+ user_text=user_text,
+ llm_job_params=llm_job_params,
+ )
+ expected_class = expected_instance.__class__
+ output = await llm_worker.gen_object(llm_job=llm_job, schema=expected_class)
+ pretty_print(output, title=f"Output from {llm_handle}")
+ assert isinstance(output, expected_class)
+ assert output.model_dump(serialize_as_any=True) == expected_instance.model_dump(serialize_as_any=True)
+
+ @pytest.mark.parametrize("user_text, expected_instance", LLMTestCases.SINGLE_OBJECT)
+ async def test_gen_object_async_using_llm_preset(self, llm_preset_id: str, user_text: str, expected_instance: BaseModel):
+ llm_worker, llm_job = get_async_worker_and_job(llm_preset_id=llm_preset_id, user_text=user_text)
+ if not llm_worker.llm_engine.is_gen_object_supported:
+ pytest.skip(f"LLM '{llm_worker.llm_engine.tag}' does not support object generation")
+ expected_class = expected_instance.__class__
+ output = await llm_worker.gen_object(llm_job=llm_job, schema=expected_class)
+ pretty_print(output)
+ assert isinstance(output, expected_class)
+ assert output.model_dump(serialize_as_any=True) == expected_instance.model_dump(serialize_as_any=True)
+
+ @pytest.mark.parametrize("case_tuples", LLMTestCases.MULTIPLE_OBJECTS)
+ async def test_gen_object_async_multiple_using_handle(
+ self, llm_job_params: LLMJobParams, llm_handle: str, case_tuples: List[Tuple[str, BaseModel]]
+ ):
+ llm_worker = get_llm_worker(llm_handle=llm_handle)
+ if not llm_worker.llm_engine.is_gen_object_supported:
+ pytest.skip(f"LLM '{llm_handle}' does not support object generation")
+ tasks: List[asyncio.Task[BaseModel]] = []
+ for case_tuple in case_tuples:
+ user_text, expected_instance = case_tuple
+ expected_class = expected_instance.__class__
+ llm_job = LLMJobFactory.make_llm_job_from_prompt_contents(
+ user_text=user_text,
+ llm_job_params=llm_job_params,
+ )
+ task: asyncio.Task[BaseModel] = asyncio.create_task(llm_worker.gen_object(llm_job=llm_job, schema=expected_class))
+ tasks.append(task)
+
+ output = await asyncio.gather(*tasks)
+ pretty_print(output)
+ for output_index, output_instance in enumerate(output):
+ expected_instance = case_tuples[output_index][1]
+ expected_class = expected_instance.__class__
+ assert isinstance(output_instance, expected_class)
+ assert output_instance.model_dump(serialize_as_any=True) == expected_instance.model_dump(serialize_as_any=True)
+
+ @pytest.mark.parametrize("case_tuples", LLMTestCases.MULTIPLE_OBJECTS)
+ async def test_gen_object_async_multiple_using_llm_preset(self, llm_preset_id: str, case_tuples: List[Tuple[str, BaseModel]]):
+ llm_worker, llm_job = get_async_worker_and_job(llm_preset_id=llm_preset_id, user_text=case_tuples[0][0])
+ if not llm_worker.llm_engine.is_gen_object_supported:
+ pytest.skip(f"LLM '{llm_worker.llm_engine.tag}' does not support object generation")
+ tasks: List[asyncio.Task[BaseModel]] = []
+ for case_tuple in case_tuples:
+ user_text, expected_instance = case_tuple
+ expected_class = expected_instance.__class__
+ llm_job = LLMJobFactory.make_llm_job_from_prompt_contents(
+ user_text=user_text,
+ llm_job_params=llm_job.job_params,
+ )
+ task: asyncio.Task[BaseModel] = asyncio.create_task(llm_worker.gen_object(llm_job=llm_job, schema=expected_class))
+ tasks.append(task)
+
+ output = await asyncio.gather(*tasks)
+ pretty_print(output)
+ for output_index, output_instance in enumerate(output):
+ expected_instance = case_tuples[output_index][1]
+ expected_class = expected_instance.__class__
+ assert isinstance(output_instance, expected_class)
+ assert output_instance.model_dump(serialize_as_any=True) == expected_instance.model_dump(serialize_as_any=True)
diff --git a/tests/cogt/asynch/llm_async/test_llm_gen_text.py b/tests/cogt/asynch/llm_async/test_llm_gen_text.py
new file mode 100644
index 000000000..d882e97af
--- /dev/null
+++ b/tests/cogt/asynch/llm_async/test_llm_gen_text.py
@@ -0,0 +1,75 @@
+import asyncio
+from typing import List
+
+import pytest
+
+from pipelex import log, pretty_print
+from pipelex.cogt.llm.llm_job_components import LLMJobParams
+from pipelex.cogt.llm.llm_job_factory import LLMJobFactory
+from pipelex.cogt.llm.llm_models.llm_family import LLMFamily
+from pipelex.hub import get_llm_deck, get_llm_worker, get_report_delegate
+from tests.cogt.test_data import LLMTestCases
+
+
+def get_async_worker_and_job(llm_preset_id: str, user_text: str):
+ llm_setting = get_llm_deck().get_llm_setting(llm_setting_or_preset_id=llm_preset_id)
+ pretty_print(llm_setting, title=llm_preset_id)
+ pretty_print(user_text)
+ llm_worker = get_llm_worker(llm_handle=llm_setting.llm_handle)
+ llm_job_params = llm_setting.make_llm_job_params()
+ llm_job = LLMJobFactory.make_llm_job_from_prompt_contents(
+ user_text=user_text,
+ llm_job_params=llm_job_params,
+ )
+ return llm_worker, llm_job
+
+
[email protected](loop_scope="class")
+class TestAsyncCogtLLMGenText:
+ @pytest.mark.parametrize("topic, prompt_text", LLMTestCases.SINGLE_TEXT)
+ async def test_gen_text_async_using_handle(self, llm_job_params: LLMJobParams, llm_handle: str, topic: str, prompt_text: str):
+ pretty_print(prompt_text, title=topic)
+ llm_worker = get_llm_worker(llm_handle=llm_handle)
+ llm_job = LLMJobFactory.make_llm_job_from_prompt_contents(
+ user_text=prompt_text,
+ llm_job_params=llm_job_params,
+ )
+ generated_text = await llm_worker.gen_text(llm_job=llm_job)
+ assert generated_text
+ pretty_print(generated_text)
+ get_report_delegate().generate_report()
+
+ @pytest.mark.parametrize("topic, prompt_text", LLMTestCases.SINGLE_TEXT)
+ async def test_gen_text_async_using_llm_preset(self, llm_preset_id: str, topic: str, prompt_text: str):
+ llm_worker, llm_job = get_async_worker_and_job(llm_preset_id=llm_preset_id, user_text=prompt_text)
+ generated_text = await llm_worker.gen_text(llm_job=llm_job)
+ assert generated_text
+ pretty_print(generated_text)
+
+ @pytest.mark.parametrize("topic, prompt_text", LLMTestCases.SINGLE_TEXT)
+ async def test_gen_text_async_multiple_using_llm_preset(self, llm_preset_id: str, topic: str, prompt_text: str):
+ llm_worker, llm_job = get_async_worker_and_job(llm_preset_id=llm_preset_id, user_text=prompt_text)
+ job_params_base = llm_job.job_params
+ max_tokens = 30
+ temperature = 0.1
+ tasks: List[asyncio.Task[str]] = []
+ for _ in range(4):
+ max_tokens += 50
+ temperature += 0.2
+ if temperature > 1:
+ break
+ if llm_worker.llm_engine.llm_model.llm_family == LLMFamily.O_SERIES:
+ log.warning("LLMFamily.O1, forcing temprature to 1, setting minimum tokens to avoid empty output")
+ completion_max_tokens = max(max_tokens, 2000)
+ llm_job.job_params = job_params_base.model_copy(update={"max_tokens": completion_max_tokens, "temperature": 1})
+ else:
+ llm_job.job_params = job_params_base.model_copy(update={"max_tokens": max_tokens, "temperature": temperature})
+ task: asyncio.Task[str] = asyncio.create_task(llm_worker.gen_text(llm_job=llm_job))
+ tasks.append(task)
+
+ generated_texts = await asyncio.gather(*tasks)
+ for generated_text in generated_texts:
+ assert generated_text
+ pretty_print(generated_text)
diff --git a/tests/cogt/asynch/llm_async/test_llm_job_async_factory.py b/tests/cogt/asynch/llm_async/test_llm_job_async_factory.py
new file mode 100644
index 000000000..eff00e35f
--- /dev/null
+++ b/tests/cogt/asynch/llm_async/test_llm_job_async_factory.py
@@ -0,0 +1,50 @@
+import random
+
+import pytest
+
+from pipelex import pretty_print
+from pipelex.cogt.llm.llm_job import LLMJobParams
+from pipelex.cogt.llm.llm_job_factory import LLMJobFactory
+from pipelex.cogt.llm.llm_prompt_template import LLMPromptTemplate
+from pipelex.hub import get_llm_worker
+from tests.cogt.test_data import LLMTestConstants
+
+
[email protected](loop_scope="class")
+class TestAsyncLLMJobFactory:
+ async def test_llm_job_using_generic_prompt_factory(self):
+ llm_prompt_template = LLMPromptTemplate.from_template_contents(user_text=LLMTestConstants.PROMPT_TEMPLATE_TEXT)
+ random_color = random.choice(LLMTestConstants.PROMPT_COLOR_EXAMPLES)
+ llm_job = await LLMJobFactory.make_llm_job_from_prompt_factory(
+ llm_prompt_factory=llm_prompt_template,
+ llm_prompt_arguments={"color": random_color},
+ llm_job_params=LLMJobParams(temperature=0.5, max_tokens=50, seed=None),
+ )
+ assert llm_job
+ pretty_print(llm_job)
+
+ async def test_llm_job_using_prompt_template(self):
+ llm_prompt_template = LLMPromptTemplate.from_template_contents(user_text=LLMTestConstants.PROMPT_TEMPLATE_TEXT)
+ random_color = random.choice(LLMTestConstants.PROMPT_COLOR_EXAMPLES)
+ llm_job = await LLMJobFactory.make_llm_job_from_prompt_template(
+ llm_prompt_template=llm_prompt_template,
+ llm_prompt_arguments={"color": random_color},
+ llm_job_params=LLMJobParams(temperature=0.5, max_tokens=50, seed=None),
+ )
+ assert llm_job
+ pretty_print(llm_job)
+
+ @pytest.mark.llm
+ @pytest.mark.inference
+ async def test_llm_job_and_gen_text(self, llm_handle: str):
+ llm_worker = get_llm_worker(llm_handle=llm_handle)
+ llm_prompt_template = LLMPromptTemplate.from_template_contents(user_text=LLMTestConstants.PROMPT_TEMPLATE_TEXT)
+ random_color = random.choice(LLMTestConstants.PROMPT_COLOR_EXAMPLES)
+ llm_job = await LLMJobFactory.make_llm_job_from_prompt_template(
+ llm_prompt_template=llm_prompt_template,
+ llm_prompt_arguments={"color": random_color},
+ llm_job_params=LLMJobParams(temperature=0.5, max_tokens=50, seed=None),
+ )
+ generated_text = await llm_worker.gen_text(llm_job=llm_job)
+ assert generated_text
+ pretty_print(generated_text)
diff --git a/tests/cogt/asynch/llm_async/test_llm_report.py b/tests/cogt/asynch/llm_async/test_llm_report.py
new file mode 100644
index 000000000..5f85a50aa
--- /dev/null
+++ b/tests/cogt/asynch/llm_async/test_llm_report.py
@@ -0,0 +1,62 @@
+import asyncio
+from typing import List
+
+import pytest
+
+from pipelex import pretty_print
+from pipelex.cogt.llm.llm_job_factory import LLMJobFactory
+from pipelex.hub import get_llm_deck, get_llm_worker, get_report_delegate
+from tests.cogt.test_data import LLMTestCases
+
+
+async def test_llm_report_without_running_anything():
+ get_report_delegate().generate_report()
+
+
[email protected](loop_scope="class")
+class TestLLMReport:
+ @pytest.mark.parametrize("topic, prompt_text", LLMTestCases.SINGLE_TEXT)
+ async def test_llm_report_single(self, llm_preset_id: str, topic: str, prompt_text: str):
+ llm_worker, llm_job = self._get_async_worker_and_job(llm_preset_id=llm_preset_id, prompt_text=prompt_text)
+ generated_text = await llm_worker.gen_text(llm_job=llm_job)
+ assert generated_text
+ pretty_print(generated_text)
+ get_report_delegate().generate_report()
+
+ def _get_async_worker_and_job(self, llm_preset_id: str, prompt_text: str):
+ llm_setting = get_llm_deck().get_llm_setting(llm_setting_or_preset_id=llm_preset_id)
+ pretty_print(llm_setting, title=llm_preset_id)
+ pretty_print(prompt_text)
+ llm_worker = get_llm_worker(llm_handle=llm_setting.llm_handle)
+ llm_job_params = llm_setting.make_llm_job_params()
+ llm_job = LLMJobFactory.make_llm_job_from_prompt_contents(
+ user_text=prompt_text,
+ llm_job_params=llm_job_params,
+ )
+ return llm_worker, llm_job
+
+ async def test_llm_report_multiple(self):
+ nb_generations = 3
+ prompt_text = LLMTestCases.USER_TEXT_HAIKU
+ llm_preset_ids = [
+ "llm_for_testing_gen_text",
+ "llm_for_testing_gen_object",
+ ]
+ tasks: List[asyncio.Task[str]] = []
+ for llm_preset_id in llm_preset_ids:
+ llm_worker, llm_job = self._get_async_worker_and_job(llm_preset_id=llm_preset_id, prompt_text=prompt_text)
+ job_params_base = llm_job.job_params
+ max_tokens = 30
+ for _ in range(nb_generations):
+ max_tokens += 50
+ job_params = job_params_base.model_copy(update={"max_tokens": max_tokens})
+ llm_job = llm_job.model_copy(update={"job_params": job_params})
+ task: asyncio.Task[str] = asyncio.create_task(llm_worker.gen_text(llm_job=llm_job))
+ tasks.append(task)
+ generated_texts = await asyncio.gather(*tasks)
+ pretty_print(generated_texts)
+
+ get_report_delegate().generate_report()
diff --git a/tests/cogt/asynch/llm_async/test_llm_vision.py b/tests/cogt/asynch/llm_async/test_llm_vision.py
new file mode 100644
index 000000000..0213af168
--- /dev/null
+++ b/tests/cogt/asynch/llm_async/test_llm_vision.py
@@ -0,0 +1,92 @@
+from typing import Tuple
+
+import pytest
+
+from pipelex import pretty_print
+from pipelex.cogt.exceptions import LLMCapabilityError, PromptImageFormatError
+from pipelex.cogt.image.prompt_image import PromptImageBytes, PromptImagePath
+from pipelex.cogt.image.prompt_image_factory import PromptImageFactory
+from pipelex.cogt.llm.llm_job import LLMJobParams
+from pipelex.cogt.llm.llm_job_factory import LLMJobFactory
+from pipelex.hub import get_llm_worker
+from pipelex.tools.misc.base_64_utils import load_binary_as_base64
+from tests.cogt.test_data import LLMVisionTestCases
+
+
[email protected](loop_scope="class")
+class TestLLMVision:
+ @pytest.mark.parametrize("topic, image_uri", LLMVisionTestCases.IMAGES_MIXED_SOURCES)
+ async def test_gen_text_from_vision_by_url(self, llm_handle_for_vision: str, topic: str, image_uri: str):
+ prompt_image = PromptImageFactory.make_prompt_image_from_uri(uri=image_uri)
+ llm_worker = get_llm_worker(llm_handle=llm_handle_for_vision)
+ llm_job = LLMJobFactory.make_llm_job_from_prompt_contents(
+ user_text=LLMVisionTestCases.VISION_USER_TEXT_2,
+ user_images=[prompt_image],
+ llm_job_params=LLMJobParams(temperature=0.5, max_tokens=200, seed=None),
+ )
+ try:
+ generated_text = await llm_worker.gen_text(llm_job=llm_job)
+ assert generated_text
+ pretty_print(generated_text, title=f"Vision of {topic}")
+ except LLMCapabilityError as exc:
+ pytest.skip(f"Vision capability not supported for this LLM: {llm_handle_for_vision} because {exc}")
+ except PromptImageFormatError as exc:
+ pytest.skip(f"Prompt Image format not supported for this LLM: {llm_handle_for_vision} because {exc}")
+
+ @pytest.mark.parametrize("topic, image_path", LLMVisionTestCases.IMAGE_PATHS)
+ async def test_gen_text_from_vision_by_bytes(self, llm_handle_for_vision: str, topic: str, image_path: str):
+ image_bytes = load_binary_as_base64(path=image_path)
+ prompt_image = PromptImageBytes(b64_image_bytes=image_bytes)
+ llm_worker = get_llm_worker(llm_handle=llm_handle_for_vision)
+ llm_job = LLMJobFactory.make_llm_job_from_prompt_contents(
+ user_text=LLMVisionTestCases.VISION_USER_TEXT_2,
+ user_images=[prompt_image],
+ llm_job_params=LLMJobParams(temperature=0.5, max_tokens=200, seed=None),
+ )
+ try:
+ generated_text = await llm_worker.gen_text(llm_job=llm_job)
+ assert generated_text
+ pretty_print(generated_text, title=f"Vision of {topic}")
+ except LLMCapabilityError as exc:
+ pytest.skip(f"Vision capability not supported for this LLM: {llm_handle_for_vision} because {exc}")
+ except PromptImageFormatError as exc:
+ pytest.skip(f"Prompt Image format not supported for this LLM: {llm_handle_for_vision} because {exc}")
+
+ @pytest.mark.parametrize("topic, image_path", LLMVisionTestCases.IMAGE_PATHS)
+ async def test_gen_text_from_vision_by_path(self, llm_handle_for_vision: str, topic: str, image_path: str):
+ prompt_image = PromptImagePath(file_path=image_path)
+ llm_worker = get_llm_worker(llm_handle=llm_handle_for_vision)
+ llm_job = LLMJobFactory.make_llm_job_from_prompt_contents(
+ user_text=LLMVisionTestCases.VISION_USER_TEXT_2,
+ user_images=[prompt_image],
+ llm_job_params=LLMJobParams(temperature=0.5, max_tokens=200, seed=None),
+ )
+ try:
+ generated_text = await llm_worker.gen_text(llm_job=llm_job)
+ assert generated_text
+ pretty_print(generated_text, title=f"Vision of {topic}")
+ except LLMCapabilityError as exc:
+ pytest.skip(f"Vision capability not supported for this LLM: {llm_handle_for_vision} because {exc}")
+ except PromptImageFormatError as exc:
+ pytest.skip(f"Prompt Image format not supported for this LLM: {llm_handle_for_vision} because {exc}")
+
+ @pytest.mark.parametrize("topic, image_pair", LLMVisionTestCases.IMAGE_PATH_PAIRS)
+ async def test_gen_text_from_vision_2_images(self, llm_handle_for_vision: str, topic: str, image_pair: Tuple[str, str]):
+ prompt_image1 = PromptImagePath(file_path=image_pair[0])
+ prompt_image2 = PromptImagePath(file_path=image_pair[1])
+ llm_worker = get_llm_worker(llm_handle=llm_handle_for_vision)
+ llm_job = LLMJobFactory.make_llm_job_from_prompt_contents(
+ user_text=LLMVisionTestCases.VISION_IMAGES_COMPARE_PROMPT,
+ user_images=[prompt_image1, prompt_image2],
+ llm_job_params=LLMJobParams(temperature=0.5, max_tokens=500, seed=None),
+ )
+ try:
+ generated_text = await llm_worker.gen_text(llm_job=llm_job)
+ assert generated_text
+ pretty_print(generated_text, title=f"Comparative vision of {topic}")
+ except LLMCapabilityError as exc:
+ pytest.skip(f"Vision capability not supported for this LLM: {llm_handle_for_vision} because {exc}")
+ except PromptImageFormatError as exc:
+ pytest.skip(f"Prompt Image format not supported for this LLM: {llm_handle_for_vision} because {exc}")
diff --git a/tests/cogt/asynch/llm_providers/__init__.py b/tests/cogt/asynch/llm_providers/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/tests/cogt/asynch/llm_providers/__init__.py
@@ -0,0 +1 @@
+
diff --git a/tests/cogt/asynch/llm_providers/conftest.py b/tests/cogt/asynch/llm_providers/conftest.py
new file mode 100644
index 000000000..0072729b4
--- /dev/null
+++ b/tests/cogt/asynch/llm_providers/conftest.py
@@ -0,0 +1,15 @@
+import pytest
+
+from pipelex.cogt.llm.llm_models.llm_platform import LLMPlatform
+
+
[email protected](params=LLMPlatform.list_openai_related())
+def llm_platform_for_openai_sdk(request: pytest.FixtureRequest) -> LLMPlatform:
+ assert isinstance(request.param, LLMPlatform)
+ return request.param
+
+
[email protected](params=LLMPlatform.list_anthropic_related())
+def llm_platform_for_anthropic_sdk(request: pytest.FixtureRequest) -> LLMPlatform:
+ assert isinstance(request.param, LLMPlatform)
+ return request.param
diff --git a/tests/cogt/asynch/llm_providers/test_anthropic.py b/tests/cogt/asynch/llm_providers/test_anthropic.py
new file mode 100644
index 000000000..840a42e31
--- /dev/null
+++ b/tests/cogt/asynch/llm_providers/test_anthropic.py
@@ -0,0 +1,54 @@
+import pytest
+from rich import box
+from rich.console import Console
+from rich.table import Table
+
+from pipelex.cogt.exceptions import LLMSDKError
+from pipelex.cogt.llm.llm_models.llm_platform import LLMPlatform
+from pipelex.cogt.plugin.anthropic.anthropic_llms import anthropic_list_anthropic_models
+
+
+# make t VERBOSE=2 TEST=TestAnthropic
[email protected](loop_scope="class")
+class TestAnthropic:
+ # pytest -k test_anthropic_list_models -s -vv
+ # make t VERBOSE=2 TEST=test_anthropic_list_models
+ async def test_anthropic_list_models(
+ self,
+ pytestconfig: pytest.Config,
+ llm_platform_for_anthropic_sdk: LLMPlatform,
+ ):
+ try:
+ anthropic_models_list = await anthropic_list_anthropic_models(llm_platform=llm_platform_for_anthropic_sdk)
+ except LLMSDKError as exc:
+ if "does not support listing models" in str(exc):
+ pytest.skip(f"Skipping: {exc}")
+ else:
+ raise exc
+ if pytestconfig.get_verbosity() >= 2:
+ # Create and configure the table
+ console = Console()
+ table = Table(
+ title="Available Anthropic Models",
+ show_header=True,
+ header_style="bold cyan",
+ box=box.SQUARE_DOUBLE_HEAD,
+ )
+
+ # Add columns
+ table.add_column("Model ID", style="green")
+ table.add_column("Display Name", style="blue")
+ table.add_column("Created At", style="yellow")
+
+ # Add rows
+ for model in anthropic_models_list:
+ # Format the date as YYYY-MM-DD
+ created_date = model.created_at.strftime("%Y-%m-%d") if model.created_at else "N/A"
+ table.add_row(model.id, model.display_name, created_date)
+
+ # Print the table
+ console.print("\n")
+ console.print(table)
+ console.print("\n")
diff --git a/tests/cogt/asynch/llm_providers/test_openai.py b/tests/cogt/asynch/llm_providers/test_openai.py
new file mode 100644
index 000000000..438cda9f2
--- /dev/null
+++ b/tests/cogt/asynch/llm_providers/test_openai.py
@@ -0,0 +1,35 @@
+import pytest
+
+from pipelex import pretty_print
+from pipelex.cogt.exceptions import LLMSDKError
+from pipelex.cogt.llm.llm_models.llm_platform import LLMPlatform
+from pipelex.cogt.plugin.openai.openai_llms import openai_list_available_models
+from pipelex.config import get_config
+from pipelex.hub import get_secrets_provider
+
+
+# make t VERBOSE=2 TEST=TestOpenAI
[email protected](loop_scope="class")
+class TestOpenAI:
+ async def test_openai_api_key(self):
+ openai_openai_config = get_config().cogt.llm_config.openai_openai_config
+ assert openai_openai_config.get_api_key(secrets_provider=get_secrets_provider())
+
+ # pytest -k test_openai_list_available_models -s -vv
+ async def test_openai_list_available_models(
+ self,
+ pytestconfig: pytest.Config,
+ llm_platform_for_openai_sdk: LLMPlatform,
+ ):
+ try:
+ openai_models_list = await openai_list_available_models(llm_platform=llm_platform_for_openai_sdk)
+ except LLMSDKError as exc:
+ if "does not support listing models" in str(exc):
+ pytest.skip(f"Skipping: {exc}")
+ else:
+ raise exc
+ if pytestconfig.get_verbosity() >= 2:
+ list_of_ids = [model.id for model in openai_models_list]
+ pretty_print(list_of_ids, title=f"models available for {llm_platform_for_openai_sdk}")
diff --git a/tests/cogt/asynch/ocr/test_ocr.py b/tests/cogt/asynch/ocr/test_ocr.py
new file mode 100644
index 000000000..ca3c56dbc
--- /dev/null
+++ b/tests/cogt/asynch/ocr/test_ocr.py
@@ -0,0 +1,81 @@
+import pytest
+
+from pipelex import pretty_print
+from pipelex.cogt.ocr.ocr_handle import OcrHandle
+from pipelex.cogt.ocr.ocr_input import OcrInput
+from pipelex.cogt.ocr.ocr_job_components import OcrJobParams
+from pipelex.cogt.ocr.ocr_job_factory import OcrJobFactory
+from pipelex.config import get_config
+from pipelex.hub import get_ocr_worker
+from pipelex.tools.misc.file_utils import get_incremental_directory_path
+from tests.test_data import ImageTestCases, PDFTestCases
+
+
[email protected](loop_scope="class")
+class TestOcr:
+ @pytest.mark.parametrize("file_path", PDFTestCases.DOCUMENT_FILE_PATHS)
+ async def test_ocr_pdr_path(self, file_path: str):
+ ocr_worker = get_ocr_worker(ocr_handle=OcrHandle.MISTRAL_OCR)
+ ocr_job = OcrJobFactory.make_ocr_job(
+ ocr_input=OcrInput(pdf_uri=file_path),
+ )
+ ocr_output = await ocr_worker.ocr_extract_pages(ocr_job=ocr_job)
+ pretty_print(ocr_output, title="OCR Output")
+
+ assert ocr_output.pages
+
+ @pytest.mark.parametrize("url", PDFTestCases.DOCUMENT_URLS)
+ async def test_ocr_url(self, url: str):
+ ocr_worker = get_ocr_worker(ocr_handle=OcrHandle.MISTRAL_OCR)
+ ocr_job = OcrJobFactory.make_ocr_job(
+ ocr_input=OcrInput(pdf_uri=url),
+ )
+ ocr_output = await ocr_worker.ocr_extract_pages(ocr_job=ocr_job)
+ pretty_print(ocr_output, title="OCR Output")
+ assert ocr_output.pages
+
+ @pytest.mark.parametrize("file_path", [ImageTestCases.IMAGE_FILE_PATH])
+ async def test_ocr_image_file(self, file_path: str):
+ ocr_worker = get_ocr_worker(ocr_handle=OcrHandle.MISTRAL_OCR)
+ ocr_job = OcrJobFactory.make_ocr_job(
+ ocr_input=OcrInput(image_uri=file_path),
+ )
+ ocr_output = await ocr_worker.ocr_extract_pages(ocr_job=ocr_job)
+ pretty_print(ocr_output, title="OCR Output")
+ assert ocr_output.pages
+
+ @pytest.mark.parametrize("url", [ImageTestCases.IMAGE_URL])
+ async def test_ocr_image_url(self, url: str):
+ ocr_worker = get_ocr_worker(ocr_handle=OcrHandle.MISTRAL_OCR)
+ ocr_job = OcrJobFactory.make_ocr_job(
+ ocr_input=OcrInput(image_uri=url),
+ )
+ ocr_output = await ocr_worker.ocr_extract_pages(ocr_job=ocr_job)
+ pretty_print(ocr_output, title="OCR Output")
+ assert ocr_output.pages
+
+ @pytest.mark.parametrize("file_path", PDFTestCases.DOCUMENT_FILE_PATHS)
+ async def test_ocr_image_save(self, file_path: str):
+ ocr_worker = get_ocr_worker(ocr_handle=OcrHandle.MISTRAL_OCR)
+ ocr_job_params = OcrJobParams(
+ should_include_images=True,
+ should_caption_images=False,
+ should_include_page_views=False,
+ page_views_dpi=72,
+ )
+ ocr_job = OcrJobFactory.make_ocr_job(
+ ocr_input=OcrInput(pdf_uri=file_path),
+ ocr_job_params=ocr_job_params,
+ )
+ ocr_output = await ocr_worker.ocr_extract_pages(ocr_job=ocr_job)
+ pretty_print(ocr_output, title="OCR Output")
+ directory = get_incremental_directory_path(
+ base_path="results/test_ocr_image_save",
+ base_name="ocr_output",
+ )
+ ocr_output.save_to_directory(
+ directory=directory,
+ page_text_file_name=get_config().cogt.ocr_config.page_output_text_file_name,
+ )
diff --git a/tests/cogt/conftest.py b/tests/cogt/conftest.py
new file mode 100644
index 000000000..76829f08c
--- /dev/null
+++ b/tests/cogt/conftest.py
@@ -0,0 +1,181 @@
+import pytest
+
+from pipelex.cogt.imgg.imgg_handle import ImggHandle
+from pipelex.cogt.llm.llm_job_components import LLMJobParams
+from pipelex.cogt.llm.llm_models.llm_family import LLMCreator, LLMFamily
+from pipelex.cogt.llm.llm_models.llm_platform import LLMPlatform
+
+
+ params=[
+ "llm_for_testing_gen_text",
+ "llm_for_testing_gen_object",
+ "llm_for_creative_writing",
+ ]
+)
+def llm_preset_id(request: pytest.FixtureRequest) -> str:
+ assert isinstance(request.param, str)
+ return request.param
+
+
+# TODO: make it efficient to also test multiple platforms like openai/azure and mistral/anthropic/bedrock
+ params=[
+ # "o1",
+ # "gpt-4o",
+ "gpt-4o-mini",
+ # "gpt-4-5-preview",
+ # "o1-mini",
+ # "o3-mini",
+ # "claude-3-haiku",
+ # "claude-3-5-sonnet",
+ # "claude-3-7-sonnet",
+ # "mistral-large",
+ # "ministral-3b",
+ # "ministral-8b",
+ # "pixtral-12b",
+ # "pixtral-large",
+ # "gemini-1-5-pro",
+ # "gemini-1-5-flash",
+ # "gemini-2-flash",
+ # "gemini-2-pro",
+ # "gemini-2-5-flash",
+ # "gemini-2-5-pro",
+ # "bedrock-mistral-large",
+ # "bedrock-claude-3-7-sonnet",
+ # "bedrock-meta-llama-3-3-70b-instruct",
+ # "bedrock-nova-pro",
+ # "sonar",
+ ]
+)
+def llm_handle(request: pytest.FixtureRequest) -> str:
+ assert isinstance(request.param, str)
+ return request.param
+
+
+ params=[
+ # "o1",
+ # "o3-mini",
+ # "gpt-4o",
+ "gpt-4o-mini",
+ # "gpt-4-5-preview",
+ # "claude-3-haiku",
+ # "claude-3-5-sonnet",
+ # "claude-3-7-sonnet",
+ # "pixtral-12b",
+ # "pixtral-large",
+ # "gemini-1-5-pro",
+ # "gemini-1-5-flash",
+ # "gemini-2-flash",
+ # "gemini-2-pro",
+ # "gemini-2-5-pro",
+ # "gemini-2-5-flash",
+ ]
+)
+def llm_handle_for_vision(request: pytest.FixtureRequest) -> str:
+ assert isinstance(request.param, str)
+ return request.param
+
+
+ params=[
+ # LLMFamily.GPT_4,
+ # LLMFamily.GPT_4_1,
+ LLMFamily.GPT_4O,
+ # LLMFamily.GPT_4_5,
+ # LLMFamily.O_SERIES,
+ # LLMFamily.PERPLEXITY_SEARCH,
+ # LLMFamily.PERPLEXITY_REASONING,
+ # LLMFamily.PERPLEXITY_RESEARCH,
+ # LLMFamily.PERPLEXITY_DEEPSEEK,
+ # LLMFamily.GEMINI,
+ # LLMFamily.GEMMA,
+ ]
+)
+def llm_family(request: pytest.FixtureRequest) -> LLMFamily:
+ assert isinstance(request.param, LLMFamily)
+ return request.param
+
+
+ params=[
+ # LLMCreator.ALIBABA,
+ # LLMCreator.AMAZON,
+ # LLMCreator.ANTHROPIC,
+ # LLMCreator.DEEPSEEK,
+ # LLMCreator.GOOGLE,
+ LLMCreator.OPENAI,
+ # LLMCreator.META,
+ # LLMCreator.MISTRAL,
+ # LLMCreator.PERPLEXITY,
+ ]
+)
+def llm_creator(request: pytest.FixtureRequest) -> LLMCreator:
+ assert isinstance(request.param, LLMCreator)
+ return request.param
+
+
+ params=[
+ # LLMPlatform.ANTHROPIC,
+ # LLMPlatform.AZURE_OPENAI,
+ # LLMPlatform.BEDROCK,
+ # LLMPlatform.BEDROCK_ANTHROPIC,
+ # LLMPlatform.MISTRAL,
+ LLMPlatform.OPENAI,
+ # LLMPlatform.PERPLEXITY,
+ # LLMPlatform.VERTEXAI_OPENAI,
+ # LLMPlatform.CUSTOM_OPENAI,
+ ]
+)
+def llm_platform(request: pytest.FixtureRequest) -> LLMPlatform:
+ assert isinstance(request.param, LLMPlatform)
+ return request.param
+
+
+ params=[
+ "gpt-4o-mini",
+ # "open-mixtral-8x7b",
+ # "google/gemini-2.0-flash",
+ # "google/gemini-2.5-pro-exp-03-25",
+ # "o1",
+ # "o4-mini",
+ # "bedrock-mistral-large",
+ # "sonar",
+ # "claude-3-7-sonnet",
+ # "gemma3:4b",
+ # "llama4:scout",
+ ]
+)
+def llm_id(request: pytest.FixtureRequest) -> str:
+ assert isinstance(request.param, str)
+ return request.param
+
+
+ params=[
+ # ImggHandle.FLUX_1_PRO_LEGACY,
+ # ImggHandle.FLUX_1_1_PRO,
+ # ImggHandle.FLUX_1_1_ULTRA,
+ ImggHandle.SDXL_LIGHTNING,
+ ]
+)
+def imgg_handle(request: pytest.FixtureRequest) -> ImggHandle:
+ assert isinstance(request.param, ImggHandle)
+ return request.param
+
+
+ params=[
+ LLMJobParams(
+ temperature=0.5,
+ max_tokens=None,
+ seed=None,
+ ),
+ ]
+)
+def llm_job_params(request: pytest.FixtureRequest) -> LLMJobParams:
+ assert isinstance(request.param, LLMJobParams)
+ return request.param
diff --git a/tests/cogt/synchro/__init__.py b/tests/cogt/synchro/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/tests/cogt/synchro/__init__.py
@@ -0,0 +1 @@
+
diff --git a/tests/cogt/synchro/llm_providers/__init__.py b/tests/cogt/synchro/llm_providers/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/tests/cogt/synchro/llm_providers/__init__.py
@@ -0,0 +1 @@
+
diff --git a/tests/cogt/synchro/llm_providers/conftest.py b/tests/cogt/synchro/llm_providers/conftest.py
new file mode 100644
index 000000000..19a5312f2
--- /dev/null
+++ b/tests/cogt/synchro/llm_providers/conftest.py
@@ -0,0 +1,13 @@
+import pytest
+
+
[email protected](params=["anthropic", "mistral", "meta", "amazon"])
+def bedrock_provider(request: pytest.FixtureRequest) -> str:
+ assert isinstance(request.param, str)
+ return request.param
+
+
[email protected](params=["us-east-1", "us-west-2"])
+def bedrock_region_name(request: pytest.FixtureRequest) -> str:
+ assert isinstance(request.param, str)
+ return request.param
diff --git a/tests/cogt/synchro/llm_providers/test_bedrock.py b/tests/cogt/synchro/llm_providers/test_bedrock.py
new file mode 100644
index 000000000..e9955c355
--- /dev/null
+++ b/tests/cogt/synchro/llm_providers/test_bedrock.py
@@ -0,0 +1,77 @@
+from typing import Any, Dict, List
+
+import boto3
+import pytest
+from rich import box
+from rich.console import Console
+from rich.table import Table
+
+
+# make t VERBOSE=2 TEST=TestBedrock
+class TestBedrock:
+ # pytest -k test_bedrock_list_available_models -s -vv
+ def test_bedrock_list_available_models(
+ self,
+ pytestconfig: pytest.Config,
+ bedrock_provider: str,
+ bedrock_region_name: str,
+ ):
+ client = boto3.client("bedrock", region_name=bedrock_region_name) # pyright: ignore[reportUnknownMemberType, reportUnknownVariableType]
+ response: Dict[str, Any] = client.list_foundation_models(byProvider=bedrock_provider) # pyright: ignore[reportUnknownMemberType, reportUnknownVariableType]
+ bedrock_models_list: List[Dict[str, Any]] = response["modelSummaries"] # pyright: ignore[reportUnknownVariableType]
+ if pytestconfig.get_verbosity() >= 2:
+ # Create and configure the table
+ console = Console()
+ table = Table(
+ title=f"Models from {bedrock_provider} available for Bedrock in {bedrock_region_name}",
+ show_header=True,
+ header_style="bold cyan",
+ box=box.SQUARE_DOUBLE_HEAD,
+ )
+
+ # Add columns
+ table.add_column("Model ID", style="green")
+ table.add_column("Model ARN", style="yellow")
+
+ # Add rows
+ for model in bedrock_models_list: # pyright: ignore[reportUnknownVariableType]
+ table.add_row(model["modelId"], model["modelArn"]) # pyright: ignore[reportUnknownArgumentType]
+
+ # Print the table
+ console.print("\n")
+ console.print(table)
+ console.print("\n")
+
+ # pytest -k test_bedrock_list_inference_profiles -s -vv
+ def test_bedrock_list_inference_profiles(
+ self,
+ pytestconfig: pytest.Config,
+ bedrock_region_name: str,
+ ):
+ client = boto3.client("bedrock", region_name=bedrock_region_name) # pyright: ignore[reportUnknownMemberType, reportUnknownVariableType]
+ response: Dict[str, Any] = client.list_inference_profiles() # pyright: ignore[reportUnknownMemberType, reportUnknownVariableType]
+ inference_profiles_list: List[Dict[str, Any]] = response["inferenceProfileSummaries"] # pyright: ignore[reportUnknownVariableType]
+ if pytestconfig.get_verbosity() >= 2:
+ # Create and configure the table
+ console = Console()
+ table = Table(
+ title=f"Inference Profiles Available for Bedrock in {bedrock_region_name}",
+ show_header=True,
+ header_style="bold cyan",
+ box=box.SQUARE_DOUBLE_HEAD,
+ )
+
+ # Add columns
+ table.add_column("Profile ID", style="green")
+ table.add_column("Profile ARN", style="yellow")
+
+ # Add rows
+ for profile in inference_profiles_list: # pyright: ignore[reportUnknownVariableType]
+ table.add_row(profile["inferenceProfileId"], profile["inferenceProfileArn"]) # pyright: ignore[reportUnknownArgumentType]
+
+ # Print the table
+ console.print("\n")
+ console.print(table)
+ console.print("\n")
diff --git a/tests/cogt/synchro/llm_providers/test_mistral.py b/tests/cogt/synchro/llm_providers/test_mistral.py
new file mode 100644
index 000000000..4d0f89d91
--- /dev/null
+++ b/tests/cogt/synchro/llm_providers/test_mistral.py
@@ -0,0 +1,48 @@
+import pytest
+from rich import box
+from rich.console import Console
+from rich.table import Table
+
+from pipelex import pretty_print
+from pipelex.cogt.plugin.mistral.mistral_llms import list_mistral_models
+
+
+# make t VERBOSE=2 TEST=TestMistral
+class TestMistral:
+ # pytest -k test_mistral_list_models -s -vv
+ # make t VERBOSE=2 TEST=test_mistral_list_models
+ def test_mistral_list_models(self, pytestconfig: pytest.Config):
+ mistral_models_list = list_mistral_models()
+ if pytestconfig.get_verbosity() >= 2:
+ # Create and configure the table
+ console = Console()
+ table = Table(
+ title="Available Mistral Models",
+ show_header=True,
+ header_style="bold cyan",
+ box=box.SQUARE_DOUBLE_HEAD,
+ )
+
+ # Add columns
+ table.add_column("LLM ID", style="green")
+ table.add_column("Max Context Length", style="yellow")
+
+ # Add rows
+ for model in mistral_models_list:
+ if max_context_length := model.max_context_length:
+ table.add_row(model.id, str(max_context_length))
+
+ # Print the table
+ console.print("\n")
+ console.print(table)
+ console.print("\n")
+
+ # pytest -k test_mistral_list_model_ids -s -vv
+ # make t VERBOSE=2 TEST=test_mistral_list_model_ids
+ def test_mistral_list_model_ids(self, pytestconfig: pytest.Config):
+ mistral_models_list = list_mistral_models()
+ mistral_model_ids = [{"id": model.id, "aliases": model.aliases} for model in mistral_models_list]
+ if pytestconfig.get_verbosity() >= 2:
+ pretty_print(mistral_model_ids)
diff --git a/tests/cogt/synchro/serde/__init__.py b/tests/cogt/synchro/serde/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/tests/cogt/synchro/serde/__init__.py
@@ -0,0 +1 @@
+
diff --git a/tests/cogt/synchro/serde/conftest.py b/tests/cogt/synchro/serde/conftest.py
new file mode 100644
index 000000000..ecbde1d94
--- /dev/null
+++ b/tests/cogt/synchro/serde/conftest.py
@@ -0,0 +1,62 @@
+from typing import Any, ClassVar, Dict, List
+
+from pydantic import BaseModel
+
+from pipelex.cogt.image.prompt_image import PromptImagePath
+from pipelex.cogt.llm.llm_prompt import LLMPrompt
+from pipelex.cogt.llm.llm_prompt_template import LLMPromptTemplate
+from pipelex.cogt.llm.llm_prompt_template_inputs import LLMPromptTemplateInputs
+
+proto_prompt = LLMPrompt(
+ user_text="Some user text in the template",
+)
+
+base_template_inputs_1 = LLMPromptTemplateInputs(
+ root={"foo": "bar"},
+)
+
+my_prompt_template_model_1 = LLMPromptTemplate(
+ proto_prompt=proto_prompt,
+ base_template_inputs=base_template_inputs_1,
+)
+
+base_template_inputs_2 = LLMPromptTemplateInputs(
+ root={},
+)
+
+my_prompt_template_model_2 = LLMPromptTemplate(
+ proto_prompt=proto_prompt,
+ base_template_inputs=base_template_inputs_2,
+)
+
+dict_1 = {
+ "proto_prompt": LLMPrompt(
+ system_text=None,
+ user_text="Some user text in the template",
+ user_images=[],
+ ),
+ "base_template_inputs": LLMPromptTemplateInputs(root={}),
+ "source_system_template_name": None,
+ "source_user_template_name": "markdown_reordering_vision_claude3_5_sonnet",
+}
+
+prompt_with_image_path = LLMPrompt(
+ system_text="Some system text",
+ user_text="Some user text",
+ user_images=[
+ PromptImagePath(file_path="some_file_path"),
+ ],
+)
+
+
+class SerDeTestCases:
+ PYDANTIC_EXAMPLES: ClassVar[List[BaseModel]] = [
+ my_prompt_template_model_1,
+ my_prompt_template_model_2,
+ ]
+ PYDANTIC_EXAMPLES_USING_SUBCLASS: ClassVar[List[BaseModel]] = [
+ prompt_with_image_path,
+ ]
+ PYDANTIC_EXAMPLES_DICT: ClassVar[List[Dict[str, Any]]] = [
+ dict_1,
+ ]
diff --git a/tests/cogt/synchro/serde/test_serde_llm_classes.py b/tests/cogt/synchro/serde/test_serde_llm_classes.py
new file mode 100644
index 000000000..d2aae88f7
--- /dev/null
+++ b/tests/cogt/synchro/serde/test_serde_llm_classes.py
@@ -0,0 +1,83 @@
+from typing import Any, Dict
+
+import pytest
+from kajson import kajson
+from pydantic import BaseModel
+
+from pipelex import pretty_print
+from pipelex.cogt.llm.llm_prompt_template import LLMPromptTemplate
+
+from .conftest import SerDeTestCases
+
+
+class TestSerDeLLMClasses:
+ @pytest.mark.parametrize("test_obj", SerDeTestCases.PYDANTIC_EXAMPLES + SerDeTestCases.PYDANTIC_EXAMPLES_USING_SUBCLASS)
+ def test_serde_by_str(self, test_obj: Any):
+ # Serialize the model to a json string
+ serialized_str: str = kajson.dumps(test_obj, indent=4) # pyright: ignore[reportUnknownMemberType]
+ pretty_print(serialized_str, title="Serialized JSON")
+ deserialized = kajson.loads(serialized_str) # pyright: ignore[reportUnknownMemberType]
+ pretty_print(deserialized, title=f"Deserialized by kajson as {type(deserialized).__name__}")
+
+ # Assertions to ensure the process worked correctly
+ assert test_obj == deserialized
+
+ @pytest.mark.parametrize("test_obj", SerDeTestCases.PYDANTIC_EXAMPLES)
+ def test_serde_by_dump(
+ self,
+ test_obj: BaseModel,
+ ):
+ # Note: serde_by_dump, based on pydantic model_dump, doesn't handle subclasses
+
+ # Serialize the model to a dictionary
+ deserialized_dict = test_obj.model_dump(serialize_as_any=True)
+ pretty_print(deserialized_dict, title="Serialized")
+
+ # Validate the dictionary back to a model
+ the_class = type(test_obj)
+ deserialized = the_class.model_validate(deserialized_dict)
+ pretty_print(deserialized, title="Deserialized")
+
+ assert test_obj == deserialized
+
+ @pytest.mark.parametrize("test_dict", SerDeTestCases.PYDANTIC_EXAMPLES_DICT)
+ def test_serde_model_validate_from_dict(
+ self,
+ test_dict: Dict[str, Any],
+ ):
+ pretty_print(test_dict, title="Original dict")
+ # Deserialize the dictionary to a LLMPromptTemplate model
+ the_obj = LLMPromptTemplate.model_validate(test_dict)
+ pretty_print(the_obj, title="Deserialized from dict")
+
+ # Serialize the model to a dictionary
+ deserialized_dict = the_obj.model_dump(serialize_as_any=True)
+ pretty_print(deserialized_dict, title="Serialized")
+
+ # Validate the dictionary back to a model
+ the_class = type(the_obj)
+ deserialized = the_class.model_validate(deserialized_dict)
+ pretty_print(deserialized, title="Deserialized")
+
+ assert the_obj == deserialized
+
+ @pytest.mark.parametrize("test_dict", SerDeTestCases.PYDANTIC_EXAMPLES_DICT)
+ def test_serde_instantiate_from_kwargs(
+ self,
+ test_dict: Dict[str, Any],
+ ):
+ pretty_print(test_dict, title="Original dict")
+ # Deserialize the dictionary to a LLMPromptTemplate model
+ the_obj = LLMPromptTemplate(**test_dict)
+ pretty_print(the_obj, title="Deserialized from dict")
+
+ # Serialize the model to a dictionary
+ deserialized_dict = the_obj.model_dump(serialize_as_any=True)
+ pretty_print(deserialized_dict, title="Serialized")
+
+ # Validate the dictionary back to a model
+ the_class = type(the_obj)
+ deserialized = the_class.model_validate(deserialized_dict)
+ pretty_print(deserialized, title="Deserialized")
+
+ assert the_obj == deserialized
diff --git a/tests/cogt/synchro/test_llm_model_provider.py b/tests/cogt/synchro/test_llm_model_provider.py
new file mode 100644
index 000000000..d1d6e7b46
--- /dev/null
+++ b/tests/cogt/synchro/test_llm_model_provider.py
@@ -0,0 +1,138 @@
+from typing import List, Optional
+
+import pytest
+from rich import box
+from rich.console import Console, Group, RenderableType
+from rich.padding import Padding
+from rich.table import Table
+from rich.text import Text
+
+from pipelex import log, pretty_print
+from pipelex.cogt.llm.llm_models.llm_engine import LLMEngine
+from pipelex.cogt.llm.llm_models.llm_engine_blueprint import LLMEngineBlueprint
+from pipelex.cogt.llm.llm_models.llm_engine_factory import LLMEngineFactory
+from pipelex.cogt.llm.llm_models.llm_model import LLMModel
+from pipelex.cogt.llm.llm_models.llm_platform import LLMPlatform, LLMPlatformChoice
+from pipelex.hub import get_llm_models_provider
+
+
+def print_models(models: List[LLMModel], title: Optional[str] = None):
+ console = Console()
+ table = Table(
+ title=title,
+ show_header=True,
+ show_lines=True,
+ header_style="bold cyan",
+ box=box.SQUARE_DOUBLE_HEAD,
+ )
+ table.add_column("Creator")
+ table.add_column("Family")
+ table.add_column("Name")
+ table.add_column("Version")
+ table.add_column("Default platform")
+ table.add_column("Platform ids")
+
+ sorted_models = sorted(models, key=lambda m: (m.llm_family, m.llm_name, m.version))
+ for model in sorted_models:
+ platform_elemnts: List[RenderableType] = []
+ for platform, llm_id in model.platform_llm_id.items():
+ text = Text.assemble((platform, platform.console_color), f" - {llm_id}")
+ if platform != list(model.platform_llm_id.keys())[-1]:
+ ready = Padding(text, (0, 0, 1, 0))
+ else:
+ ready = Padding(text, (0, 0, 0, 0))
+ platform_elemnts.append(ready)
+ platforms = Group(*platform_elemnts)
+
+ table.add_row(
+ Text(model.llm_family.creator, model.llm_family.creator.console_color),
+ model.llm_family,
+ model.llm_name,
+ model.version,
+ model.default_platform,
+ platforms,
+ )
+ console.print("\n")
+ console.print(table)
+
+
+class TestLLMModelsDB:
+ def test_llm_models_loading(self, pytestconfig: pytest.Config):
+ all_llm_models = get_llm_models_provider().get_all_llm_models()
+ if pytestconfig.get_verbosity() >= 2:
+ print_models(models=all_llm_models, title="All available LLM Models (unit testing)")
+ assert len(all_llm_models) > 0, "No LLM models found"
+ assert all(isinstance(model, LLMModel) for model in all_llm_models), "Invalid model type found"
+ for llm_model in all_llm_models:
+ log.debug(f"Checking model: {llm_model.name_and_version}")
+ assert llm_model.llm_name, "Missing llm_name"
+ assert llm_model.version, "Missing version"
+ assert llm_model.llm_family, "Missing llm_family"
+ assert llm_model.default_platform, "Missing default_platform"
+ assert llm_model.platform_llm_id, "Missing platform_llm_id"
+
+ @pytest.mark.parametrize(
+ "llm_name, llm_version, llm_platform_choice",
+ [
+ # ("mistral-large", "latest", "default"),
+ # ("mistral-large", "latest", LLMPlatform.BEDROCK_MISTRAL),
+ # ("mistral-large", "latest", LLMPlatform.MISTRAL),
+ # ("gpt-4o", "2024-08-06", "default"),
+ ("gpt-4o", "2024-08-06", LLMPlatform.OPENAI),
+ # ("gpt-4.1-mini", "latest", LLMPlatform.OPENAI),
+ # ("gpt-4o-mini", "latest", LLMPlatform.ANTHROPIC),
+ # ("gpt-4o-mini", "latest", LLMPlatform.BEDROCK_ANTHROPIC),
+ # ("gpt-4o-mini", "latest", LLMPlatform.AZURE_OPENAI),
+ # ("gpt-4o-mini", "latest", LLMPlatform.MISTRAL),
+ ],
+ )
+ def test_get_llm_model(
+ self,
+ llm_name: str,
+ llm_version: str,
+ llm_platform_choice: LLMPlatformChoice,
+ ):
+ model = get_llm_models_provider().get_llm_model(llm_name=llm_name, llm_version=llm_version, llm_platform_choice=llm_platform_choice)
+ pretty_print(model)
+ assert isinstance(model, LLMModel)
+ assert model.llm_name == llm_name
+ if llm_version != "latest":
+ assert model.version == llm_version
+ if llm_platform_choice == "default":
+ assert model.default_platform in model.platform_llm_id
+ else:
+ llm_platform = llm_platform_choice
+ assert llm_platform in model.platform_llm_id
+
+ @pytest.mark.parametrize(
+ "llm_name, llm_version, llm_platform_choice",
+ [
+ # ("mistral-large", "latest", "default"),
+ # ("mistral-large", "latest", LLMPlatform.BEDROCK_MISTRAL),
+ # ("mistral-large", "latest", LLMPlatform.MISTRAL),
+ # ("gpt-4o", "2024-08-06", "default"),
+ ("gpt-4o", "2024-08-06", LLMPlatform.OPENAI),
+ # ("gpt-4o-mini", "latest", LLMPlatform.ANTHROPIC),
+ # ("gpt-4o-mini", "latest", LLMPlatform.BEDROCK_ANTHROPIC),
+ # ("gpt-4o-mini", "latest", LLMPlatform.AZURE_OPENAI),
+ # ("gpt-4o-mini", "latest", LLMPlatform.MISTRAL),
+ ],
+ )
+ def test_make_llm_engine(
+ self,
+ llm_name: str,
+ llm_version: str,
+ llm_platform_choice: LLMPlatformChoice,
+ ):
+ engine_card: LLMEngineBlueprint = LLMEngineBlueprint(
+ llm_name=llm_name,
+ llm_version=llm_version,
+ llm_platform_choice=llm_platform_choice,
+ )
+ engine = LLMEngineFactory.make_llm_engine(engine_card)
+ pretty_print(engine)
+
+ assert engine is not None
+ assert isinstance(engine, LLMEngine)
+ assert engine.llm_model.llm_name == llm_name
+ assert engine.llm_model.version == llm_version
diff --git a/tests/cogt/synchro/test_setup_workers.py b/tests/cogt/synchro/test_setup_workers.py
new file mode 100644
index 000000000..375748cbd
--- /dev/null
+++ b/tests/cogt/synchro/test_setup_workers.py
@@ -0,0 +1,10 @@
+import pytest
+
+from pipelex.hub import get_inference_manager
+
+
+class TestCogtSetupWorkers:
+ def test_setup_inference_manager(self):
+ get_inference_manager().setup_llm_workers()
+ get_inference_manager().setup_imgg_workers()
diff --git a/tests/cogt/test_data.py b/tests/cogt/test_data.py
new file mode 100644
index 000000000..6f8bc7181
--- /dev/null
+++ b/tests/cogt/test_data.py
@@ -0,0 +1,148 @@
+from enum import StrEnum
+from typing import ClassVar, List, Tuple
+
+from pydantic import BaseModel, Field, field_validator
+
+from tests.pipelex.test_data import PipeTestCases
+
+
+class Person(BaseModel):
+ name: str
+ age: int
+
+
+class Employee(Person):
+ job: str = Field(description="Job title, must be lowercase")
+
+ @field_validator("job")
+ @classmethod
+ def validate_lowercase_job(cls, v: str) -> str:
+ if not v.islower():
+ raise ValueError("job title must be lowercase")
+ return v
+
+
+class PetSpecies(StrEnum):
+ DOG = "dog"
+ CAT = "cat"
+ BIRD = "bird"
+ FISH = "fish"
+ HAMSTER = "hamster"
+
+
+class Pet(BaseModel):
+ species: PetSpecies
+ name: str
+
+
+class LLMVisionTestCases:
+ VISION_USER_TEXT_1 = "Describe the provide image."
+ VISION_USER_TEXT_2 = "What is this image about ?"
+ VISION_IMAGES_COMPARE_PROMPT = "Compare these two images"
+
+ URL_WIKIPEDIA_ALAN_TURING = "https://upload.wikimedia.org/wikipedia/commons/thumb/4/40/Alan_Turing_%281912-1954%29_in_1936_at_Princeton_University_%28cropped%29.jpg/440px-Alan_Turing_%281912-1954%29_in_1936_at_Princeton_University_%28cropped%29.jpg"
+
+ TEST_IMAGE_DIRECTORY = "tests/data/images"
+
+ PATH_IMG_PNG_1 = f"{TEST_IMAGE_DIRECTORY}/ai_lympics.png"
+ PATH_IMG_JPEG_1 = f"{TEST_IMAGE_DIRECTORY}/ai_lympics.jpg"
+
+ PATH_IMG_PNG_2 = f"{TEST_IMAGE_DIRECTORY}/animal_lympics.png"
+ PATH_IMG_JPEG_2 = f"{TEST_IMAGE_DIRECTORY}/animal_lympics.jpg"
+
+ PATH_IMG_PNG_3 = f"{TEST_IMAGE_DIRECTORY}/eiffel_tower.png"
+ PATH_IMG_JPEG_3 = f"{TEST_IMAGE_DIRECTORY}/eiffel_tower.jpg"
+
+ PATH_IMG_GANTT_1 = f"{TEST_IMAGE_DIRECTORY}/gantt_tree_house.png"
+
+ IMAGE_PATHS: ClassVar[List[Tuple[str, str]]] = [ # topic, image_path
+ ("AI Lympics PNG", PATH_IMG_PNG_1),
+ ("AI Lympics JPEG", PATH_IMG_JPEG_1),
+ ("Gantt Chart", PATH_IMG_GANTT_1),
+ ]
+ IMAGE_PATH_PAIRS: ClassVar[List[Tuple[str, Tuple[str, str]]]] = [ # topic, image_pair
+ ("AI Lympics PNG", (PATH_IMG_PNG_1, PATH_IMG_PNG_2)),
+ ]
+
+ IMAGES_MIXED_SOURCES: ClassVar[List[Tuple[str, str]]] = [ # topic, image_uri
+ (
+ "Alan Turing",
+ URL_WIKIPEDIA_ALAN_TURING,
+ ),
+ (
+ "AI Lympics",
+ PATH_IMG_PNG_1,
+ ),
+ (
+ "Eiffel Tower",
+ PATH_IMG_JPEG_3,
+ ),
+ (
+ "Gantt chart",
+ PipeTestCases.URL_IMG_GANTT_1,
+ ),
+ ]
+
+
+class LLMTestConstants:
+ USER_TEXT_SHORT = "In one sentence, who is Bill Gates?"
+ PROMPT_TEMPLATE_TEXT = "Can you give one example of flower which is {color} in color ?"
+ PROMPT_COLOR_EXAMPLES: ClassVar[List[str]] = [
+ "red",
+ "blue",
+ "green",
+ "yellow",
+ "orange",
+ "purple",
+ "pink",
+ "black",
+ "white",
+ ]
+
+
+class LLMTestCases:
+ USER_TEXT_HAIKU = "Write a sonnet about the sea"
+ USER_TEXT_TRICKY = """
+When my son was 7 he was 3ft tall. When he was 8 he was 4ft tall. When he was 9 he was 5ft tall.
+How tall do you think he was when he was 12? and at 15?
+"""
+ SINGLE_TEXT: ClassVar[List[Tuple[str, str]]] = [ # topic, prompt_text
+ ("Haiku", USER_TEXT_HAIKU),
+ ("Tricky", USER_TEXT_TRICKY),
+ ]
+ SINGLE_OBJECT: ClassVar[List[Tuple[str, BaseModel]]] = [
+ ("name: John, age: 30", Person(name="John", age=30)),
+ ("Betty Draper, 51", Person(name="Betty Draper", age=51)),
+ ("Whiskers, the cat", Pet(species=PetSpecies.CAT, name="Whiskers")),
+ ("Whiskers, the dog", Pet(species=PetSpecies.DOG, name="Whiskers")),
+ ]
+ MULTIPLE_OBJECTS: ClassVar[List[List[Tuple[str, BaseModel]]]] = [
+ [
+ ("name: John, age: 30", Person(name="John", age=30)),
+ # ("Betty Draper, 51", Person(name="Betty Draper", age=51)),
+ ("Whiskers, the cat", Pet(species=PetSpecies.CAT, name="Whiskers")),
+ ("Whiskers, the dog", Pet(species=PetSpecies.DOG, name="Whiskers")),
+ ],
+ [
+ # ("name: Alice, age: 25", Person(name="Alice", age=25)),
+ ("My sister's plumber, Bob Smith, is 42", Employee(name="Bob Smith", age=42, job="plumber")),
+ ("Fluffy, the hamster", Pet(species=PetSpecies.HAMSTER, name="Fluffy")),
+ ("Rex, the dog", Pet(species=PetSpecies.DOG, name="Rex")),
+ ],
+ ]
+
+
+class IMGGTestCases:
+ IMGG_PROMPT_1 = "woman wearing marino cargo pants"
+ IMGG_PROMPT_2 = "wide legged denim pants with hippy addition"
+ IMGG_PROMPT_3 = """
+Woman typing on a laptop. On the laptop screen you see python code to generate code to write a prompt for an AI model.
+"""
+ IMGG_PROMPT_4 = "a dog wearing sunglasses and playing poker"
+
+ IMAGE_DESC: ClassVar[List[Tuple[str, str]]] = [ # topic, imgg_prompt_text
+ # (IMGG_PROMPT_1, IMGG_PROMPT_1),
+ # (IMGG_PROMPT_2, IMGG_PROMPT_2),
+ # (IMGG_PROMPT_3, IMGG_PROMPT_3),
+ (IMGG_PROMPT_4, IMGG_PROMPT_4),
+ ]
diff --git a/tests/conftest.py b/tests/conftest.py
new file mode 100644
index 000000000..0a881b93e
--- /dev/null
+++ b/tests/conftest.py
@@ -0,0 +1,48 @@
+from typing import Any
+
+import pytest
+from rich import print
+from rich.console import Console
+from rich.traceback import Traceback
+
+import pipelex.config
+import pipelex.pipelex
+from pipelex import log
+from pipelex.config import get_config
+
+pytest_plugins = [
+ "pipelex.test_extras.shared_pytest_plugins",
+]
+
+
[email protected](scope="module", autouse=True)
+def reset_pipelex_config_fixture():
+ # Code to run before each test
+ print("\n[magenta]pipelex setup[/magenta]")
+ try:
+ pipelex_instance = pipelex.pipelex.Pipelex.make()
+ config = get_config()
+ log.verbose(config, title="Test config")
+ assert isinstance(config, pipelex.config.PipelexConfig)
+ assert config.project_name == "pipelex"
+ except Exception as exc:
+ Console().print(Traceback())
+ pytest.exit(f"Critical Pipelex setup error: {exc}")
+ yield
+ # Code to run after each test
+ print("\n[magenta]pipelex teardown[/magenta]")
+ pipelex_instance.teardown()
+
+
[email protected](scope="function", autouse=True)
+def pretty():
+ # Code to run before each test
+ print("\n")
+ yield
+ # Code to run after each test
+ print("\n")
+
+
[email protected](scope="session", autouse=True) # pyright: ignore[reportUntypedFunctionDecorator, reportUnknownMemberType]
+def apply_manage_pipelex_libraries(manage_pipelex_libraries_with_overwrite: Any): # pyright: ignore[reportUnknownParameterType]
+ return
diff --git a/tests/data/documents/illustrated_train_article.pdf b/tests/data/documents/illustrated_train_article.pdf
new file mode 100644
index 000000000..945eb3541
Binary files /dev/null and b/tests/data/documents/illustrated_train_article.pdf differ
diff --git a/tests/data/documents/solar_system.pdf b/tests/data/documents/solar_system.pdf
new file mode 100644
index 000000000..3f6b549bc
Binary files /dev/null and b/tests/data/documents/solar_system.pdf differ
diff --git a/tests/data/documents/solar_system.png b/tests/data/documents/solar_system.png
new file mode 100644
index 000000000..2e0795996
Binary files /dev/null and b/tests/data/documents/solar_system.png differ
diff --git a/tests/data/images/ai_lympics.jpg b/tests/data/images/ai_lympics.jpg
new file mode 100644
index 000000000..c737a0599
Binary files /dev/null and b/tests/data/images/ai_lympics.jpg differ
diff --git a/tests/data/images/ai_lympics.png b/tests/data/images/ai_lympics.png
new file mode 100644
index 000000000..c01ae2093
Binary files /dev/null and b/tests/data/images/ai_lympics.png differ
diff --git a/tests/data/images/animal_lympics.jpg b/tests/data/images/animal_lympics.jpg
new file mode 100644
index 000000000..a36d0f2b4
Binary files /dev/null and b/tests/data/images/animal_lympics.jpg differ
diff --git a/tests/data/images/animal_lympics.png b/tests/data/images/animal_lympics.png
new file mode 100644
index 000000000..4d264fd27
Binary files /dev/null and b/tests/data/images/animal_lympics.png differ
diff --git a/tests/data/images/eiffel_tower.jpg b/tests/data/images/eiffel_tower.jpg
new file mode 100644
index 000000000..7b11667bf
Binary files /dev/null and b/tests/data/images/eiffel_tower.jpg differ
diff --git a/tests/data/images/eiffel_tower.png b/tests/data/images/eiffel_tower.png
new file mode 100644
index 000000000..e7a455b29
Binary files /dev/null and b/tests/data/images/eiffel_tower.png differ
diff --git a/tests/data/images/gantt_tree_house.png b/tests/data/images/gantt_tree_house.png
new file mode 100644
index 000000000..c105d922d
Binary files /dev/null and b/tests/data/images/gantt_tree_house.png differ
diff --git a/tests/pipelex/__init__.py b/tests/pipelex/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/tests/pipelex/__init__.py
@@ -0,0 +1 @@
+
diff --git a/tests/pipelex/asynch/__init__.py b/tests/pipelex/asynch/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/tests/pipelex/asynch/__init__.py
@@ -0,0 +1 @@
+
diff --git a/tests/pipelex/asynch/conftest.py b/tests/pipelex/asynch/conftest.py
new file mode 100644
index 000000000..2d0853d52
--- /dev/null
+++ b/tests/pipelex/asynch/conftest.py
@@ -0,0 +1,61 @@
+import os
+from typing import AsyncGenerator, AsyncIterator, Awaitable, Callable
+
+import pytest_asyncio
+from pytest import FixtureRequest
+from rich import print
+
+from pipelex.core.pipe_output import PipeOutput
+from pipelex.hub import get_activity_manager
+from pipelex.mission.activity.activity_handler import ActivityHandlerForResultFiles
+from pipelex.pipe_works.pipe_router import PipeRouter
+from pipelex.pipe_works.pipe_router_protocol import PipeRouterProtocol
+from pipelex.tools.misc.file_utils import get_incremental_directory_path, remove_folder
+from pipelex.tools.misc.json_utils import save_as_json_to_path
+
+
+@pytest_asyncio.fixture # pyright: ignore[reportUntypedFunctionDecorator, reportUnknownMemberType]
+async def pipe_router(request: FixtureRequest) -> AsyncGenerator[PipeRouterProtocol, None]:
+ # Code to run before each PipeRouter
+ print("\n[magenta]PipeRouter setup[/magenta]")
+ the_pipe_router = PipeRouter()
+ # Return it for use in tests
+ yield the_pipe_router
+ # Code to run after each test
+ print("\n[magenta]PipeRouter teardown[/magenta]")
+
+
+@pytest_asyncio.fixture # pyright: ignore[reportUntypedFunctionDecorator, reportUnknownMemberType]
+async def pipe_result_handler(request: FixtureRequest) -> AsyncIterator[tuple[str, ActivityHandlerForResultFiles]]:
+ """
+ This fixture is used to handle the result of a pipe run in unit tests.
+ It creates and registers an activity handler to save the activities of the pipe into a specific directory.
+ It returns a tuple with the result directory path and the activity handler, which enables the
+ calling test to save whatever it wants into that result directory.
+ """
+ # Setup result handler
+ pipe_code: str = request.node.callspec.params.get("pipe_code", "test_pipe") if hasattr(request.node, "callspec") else "test_pipe" # type: ignore
+ if not isinstance(pipe_code, str):
+ raise RuntimeError(f"pipe_code is not a string: {pipe_code}")
+ result_dir_path = get_incremental_directory_path(
+ base_path="temp/unit_test_results",
+ base_name=pipe_code,
+ )
+ activity_handler = ActivityHandlerForResultFiles(result_dir_path=result_dir_path)
+ get_activity_manager().add_activity_callback(key="pipelex_unit_test", callback=activity_handler.handle_activity)
+
+ yield result_dir_path, activity_handler
+
+ # Cleanup after test
+ get_activity_manager().remove_activity_callback(key="pipelex_unit_test")
+ remove_folder(result_dir_path)
+
+
+@pytest_asyncio.fixture # pyright: ignore[reportUntypedFunctionDecorator, reportUnknownMemberType]
+async def save_working_memory() -> Callable[[PipeOutput, str], Awaitable[None]]:
+ async def _save_working_memory(pipe_output: PipeOutput, result_dir_path: str) -> None:
+ pipe_output.working_memory.pretty_print()
+ working_memory_path = os.path.join(result_dir_path, "working_memory.json")
+ save_as_json_to_path(object_to_save=pipe_output.working_memory, path=working_memory_path)
+
+ return _save_working_memory
diff --git a/tests/pipelex/asynch/test_client.py b/tests/pipelex/asynch/test_client.py
new file mode 100644
index 000000000..c83b40bf4
--- /dev/null
+++ b/tests/pipelex/asynch/test_client.py
@@ -0,0 +1,176 @@
+import os
+from typing import List
+
+import pytest
+from pydantic import BaseModel
+
+from pipelex.client.client import PipelexClient
+from pipelex.client.protocol import PipeRequest, PipeState
+from pipelex.core.stuff import Stuff
+from pipelex.core.stuff_content import ImageContent, TextContent
+from pipelex.core.stuff_factory import StuffFactory
+from pipelex.core.working_memory import WorkingMemory
+
+from pipelex import pretty_print
+
+
+class Example(BaseModel):
+ pipe_code: str
+ dynamic_output_concept: str
+ memory: List[Stuff]
+
+
[email protected](loop_scope="class")
+class TestPipelexClient:
+ @pytest.fixture
+ def examples(self) -> List[Example]:
+ """
+ Fixture providing test examples for API client tests.
+
+ Returns:
+ List[Example]: A list of test examples containing different pipe execution scenarios:
+ - Text-based question answering with context and excerpts
+ - Gantt chart image processing
+ """
+ return [
+ Example(
+ pipe_code="retrieve_then_answer", # pipe_code
+ dynamic_output_concept="contracts.Fees",
+ memory=[
+ StuffFactory.make_stuff(
+ concept_code="questions.ProjectContext",
+ name="project_context",
+ content=TextContent(
+ text="The project context is a licensing agreement between WebTech Solutions Inc. and DataAnalytics Corp for the use of WebTech's cloud-based data processing platform. The document contains various sections including licensing terms, service levels, and fee structures. The agreement was executed on January 15, 2023, and is valid for a period of 36 months."
+ ),
+ ),
+ StuffFactory.make_stuff(
+ concept_code="answer.Question",
+ name="question",
+ content=TextContent(
+ text="What are the transaction fees for using the WebTech Solutions data processing platform, and how are they calculated?"
+ ),
+ ),
+ StuffFactory.make_stuff(
+ concept_code="questions.TargetConcept",
+ name="target_concept",
+ content=TextContent(text="Fees"),
+ ),
+ StuffFactory.make_stuff(
+ concept_code="basic.ClientInstructions",
+ name="client_instructions",
+ content=TextContent(
+ text="Please focus on the standard transaction fees from Schedule B, not the implementation fees or monthly subscription costs. The client specifically wants to understand if there are percentage-based fees or fixed amount charges for each transaction and what currency they need to pay in. If there are tiered fees based on volume, please identify the standard tier (100,000 to 500,000 transactions)."
+ ),
+ ),
+ StuffFactory.make_stuff(
+ concept_code="native.Text",
+ name="text",
+ content=TextContent(
+ text="""
+MASTER SERVICE AGREEMENT
+BETWEEN WEBTECH SOLUTIONS INC. AND DATAANALYTICS CORP
+
+EFFECTIVE DATE: January 15, 2023
+
+1. DEFINITIONS
+1.1 "Transaction" means each individual data processing request submitted by Licensee to the Platform.
+1.2 "Platform" refers to WebTech Solutions' proprietary cloud-based data processing infrastructure and software.
+1.3 "Fees" means all charges payable by the Licensee to WebTech as set forth in Schedule B.
+
+2. TERM AND TERMINATION
+2.1 This Agreement shall commence on the Effective Date and shall continue for a period of thirty-six (36) months ("Initial Term").
+
+7. PAYMENT TERMS
+7.1 Licensee shall pay all Fees in accordance with Schedule B.
+7.2 All Fees are exclusive of applicable taxes.
+7.3 WebTech shall invoice Licensee on a monthly basis for Transaction Fees incurred during the previous month.
+7.4 All invoices are payable within thirty (30) days of receipt.
+7.5 Late payments shall accrue interest at a rate of 1.5% per month or the maximum rate permitted by law, whichever is less.
+
+SCHEDULE B - FEE SCHEDULE
+
+1. IMPLEMENTATION FEES
+One-time implementation and integration fee: $25,000 USD
+
+2. SUBSCRIPTION FEES
+Monthly platform access: $5,000 USD per month
+
+3. TRANSACTION FEES
+3.1 Standard Pricing Model:
+- 0-100,000 transactions per month: 2.75% of transaction value
+- 100,001-500,000 transactions per month: 2.3% of transaction value
+- 500,001+ transactions per month: 1.9% of transaction value
+
+3.2 Alternative Fixed Fee Model (available upon request):
+- 0-100,000 transactions per month: $0.15 USD per transaction
+- 100,001-500,000 transactions per month: $0.12 USD per transaction
+- 500,001+ transactions per month: $0.09 USD per transaction
+
+3.3 All percentage-based transaction fees are calculated based on the monetary value of the data being processed.
+
+3.4 Minimum monthly transaction fee: $1,000 USD
+
+9. CURRENCY AND PAYMENT METHODS
+9.1 All fees specified in this Agreement are in United States Dollars (USD).
+9.2 Licensee may request to be billed in EUR or GBP, subject to WebTech's current exchange rates plus a 1% currency conversion fee.
+9.3 Payment methods accepted:
+- ACH transfer
+- Wire transfer
+- Corporate credit card (subject to a 2.5% processing fee)
+
+AMENDMENT 1 TO SCHEDULE B - EFFECTIVE MARCH 1, 2023
+
+Upon mutual agreement between WebTech Solutions Inc. and DataAnalytics Corp, the following modifications to the Transaction Fees in Schedule B are hereby implemented:
+
+For DataAnalytics Corp's European operations only:
+- Transaction fees shall be billed at a flat rate of 2.1% of transaction value for all volume tiers
+- Minimum monthly transaction fee reduced to €800 EUR
+- All European transactions shall be billed in Euros (EUR)
+
+This amendment applies only to transactions originating from DataAnalytics Corp's European business units and does not modify the fee structure for operations in other regions.
+
+"""
+ ),
+ ),
+ ],
+ ),
+ ]
+
+ async def test_execute_pipe(
+ self,
+ examples: List[Example],
+ ):
+ """
+ Test the execute_pipe method with different examples.
+
+ Args:
+ examples: List of test examples from the fixture
+ """
+ # ruff: noqa
+ for example in examples:
+ # Create working memory from example data
+ memory = WorkingMemory()
+ for stuff in example.memory:
+ memory.add_new_stuff(name=stuff.stuff_name or stuff.concept_code, stuff=stuff)
+
+ pipe_execute_request = PipeRequest(
+ memory=memory,
+ dynamic_output_concept=example.dynamic_output_concept,
+ )
+
+ # Execute pipe
+ client = PipelexClient()
+ result = await client.execute_pipe(
+ pipe_code=example.pipe_code,
+ pipe_execute_request=pipe_execute_request,
+ use_local_execution=True,
+ )
+ pretty_print(result)
+
+ # Verify result
+ assert result.pipe_code == example.pipe_code
+ assert result.state == PipeState.COMPLETED
+ assert result.pipe_output is not None
diff --git a/tests/pipelex/asynch/test_pipe_batch.py b/tests/pipelex/asynch/test_pipe_batch.py
new file mode 100644
index 000000000..0aa502d84
--- /dev/null
+++ b/tests/pipelex/asynch/test_pipe_batch.py
@@ -0,0 +1,54 @@
+import pytest
+from pytest import FixtureRequest
+
+from pipelex import pretty_print
+from pipelex.core.pipe_output import PipeOutput
+from pipelex.core.pipe_run_params_factory import PipeRunParamsFactory
+from pipelex.core.stuff_content import ListContent, TextContent
+from pipelex.core.stuff_factory import StuffFactory
+from pipelex.core.working_memory_factory import WorkingMemoryFactory
+from pipelex.hub import get_mission_tracker, get_report_delegate
+from pipelex.pipe_works.pipe_router_protocol import PipeRouterProtocol
+
+
[email protected](loop_scope="class")
+class TestPipeBatch:
+ async def test_pipe_batch_basic(
+ self,
+ request: FixtureRequest,
+ pipe_router: PipeRouterProtocol,
+ ):
+ # Create Stuff objects
+ invoice_list_stuff = StuffFactory.make_stuff(
+ concept_code="test_pipe_batch.TestPipeBatchItem",
+ content=ListContent(
+ items=[
+ TextContent(text="data_1"),
+ TextContent(text="data_2"),
+ ]
+ ),
+ name="test_pipe_batch_item",
+ )
+
+ # Create Working Memory
+ working_memory = WorkingMemoryFactory.make_from_single_stuff(invoice_list_stuff)
+
+ # Run the pipe
+ pipe_output: PipeOutput = await pipe_router.run_pipe_code(
+ pipe_code="test_pipe_batch",
+ pipe_run_params=PipeRunParamsFactory.make_run_params(),
+ working_memory=working_memory,
+ )
+
+ # Log output and generate report
+ pretty_print(pipe_output, title="Processing output for invoice")
+ get_report_delegate().generate_report()
+
+ # Basic assertions
+ assert pipe_output is not None
+ assert pipe_output.working_memory is not None
+ assert pipe_output.main_stuff is not None
+
+ get_mission_tracker().output_flowchart()
diff --git a/tests/pipelex/asynch/test_pipe_llm.py b/tests/pipelex/asynch/test_pipe_llm.py
new file mode 100644
index 000000000..d78717a23
--- /dev/null
+++ b/tests/pipelex/asynch/test_pipe_llm.py
@@ -0,0 +1,78 @@
+from typing import List
+
+import pytest
+
+from pipelex import log, pretty_print
+from pipelex.core.concept_native import NativeConcept
+from pipelex.core.stuff import Stuff
+from pipelex.core.working_memory_factory import WorkingMemoryFactory
+from pipelex.hub import get_report_delegate
+from pipelex.pipe_operators.pipe_llm import PipeLLM, PipeLLMOutput
+from pipelex.pipe_operators.pipe_llm_prompt import PipeLLMPrompt
+from pipelex.pipe_works.pipe_job_factory import PipeJobFactory
+from pipelex.pipe_works.pipe_router_protocol import PipeRouterProtocol
+from tests.pipelex.test_data import PipeTestCases
+
+
[email protected](loop_scope="class")
+class TestPipeLLM:
+ async def test_pipe_llm(self, pipe_router: PipeRouterProtocol):
+ pipe_job = PipeJobFactory.make_pipe_job(
+ pipe=PipeLLM(
+ code="adhoc_for_test_pipe_llm",
+ domain="generic",
+ output_concept_code=NativeConcept.TEXT.code,
+ pipe_llm_prompt=PipeLLMPrompt(
+ code="adhoc_for_test_pipe_llm",
+ domain="generic",
+ system_prompt=PipeTestCases.SYSTEM_PROMPT,
+ user_text=PipeTestCases.USER_PROMPT,
+ ),
+ ),
+ )
+ pipe_llm_output: PipeLLMOutput = await pipe_router.run_pipe_job(
+ pipe_job=pipe_job,
+ )
+
+ log.verbose(pipe_llm_output, title="stuff")
+ llm_generated_text = pipe_llm_output.main_stuff_as_text
+ pretty_print(llm_generated_text, title="llm_generated_text")
+ get_report_delegate().generate_report()
+
+ @pytest.mark.llm
+ @pytest.mark.inference
+ @pytest.mark.asyncio(loop_scope="class")
+ @pytest.mark.parametrize("stuff, attribute_paths", PipeTestCases.STUFFS_IMAGE_ATTRIBUTES)
+ async def test_pipe_llm_attribute_image(
+ self,
+ pipe_router: PipeRouterProtocol,
+ stuff: Stuff,
+ attribute_paths: List[str],
+ ):
+ working_memory = WorkingMemoryFactory.make_from_single_stuff(stuff=stuff)
+
+ pipe_job = PipeJobFactory.make_pipe_job(
+ working_memory=working_memory,
+ pipe=PipeLLM(
+ code="adhoc_for_test_pipe_llm_image",
+ domain="generic",
+ output_concept_code=NativeConcept.TEXT.code,
+ pipe_llm_prompt=PipeLLMPrompt(
+ code="adhoc_for_test_pipe_llm_image",
+ domain="generic",
+ system_prompt=PipeTestCases.SYSTEM_PROMPT,
+ user_text=PipeTestCases.MULTI_IMG_DESC_PROMPT,
+ user_images=attribute_paths,
+ ),
+ ),
+ )
+ pipe_llm_output: PipeLLMOutput = await pipe_router.run_pipe_job(
+ pipe_job=pipe_job,
+ )
+
+ log.verbose(pipe_llm_output, title="stuff")
+ llm_generated_text = pipe_llm_output.main_stuff_as_text
+ pretty_print(llm_generated_text, title="llm_generated_text")
+ get_report_delegate().generate_report()
diff --git a/tests/pipelex/asynch/test_pipe_ocr.py b/tests/pipelex/asynch/test_pipe_ocr.py
new file mode 100644
index 000000000..e5e3e3eed
--- /dev/null
+++ b/tests/pipelex/asynch/test_pipe_ocr.py
@@ -0,0 +1,73 @@
+import pytest
+
+from pipelex import pretty_print
+from pipelex.core.concept_native import NativeConcept
+from pipelex.core.stuff_content import PageContent
+from pipelex.core.working_memory_factory import WorkingMemoryFactory
+from pipelex.pipe_operators.pipe_ocr import PipeOcr, PipeOcrOutput
+from pipelex.pipe_works.pipe_job_factory import PipeJobFactory
+from pipelex.pipe_works.pipe_router_protocol import PipeRouterProtocol
+from tests.pipelex.test_data import PipeOcrTestCases
+
+
[email protected](loop_scope="class")
+class TestPipeOCR:
+ @pytest.mark.parametrize("image_url", PipeOcrTestCases.PIPE_OCR_IMAGE_TEST_CASES)
+ async def test_pipe_ocr_image(
+ self,
+ pipe_router: PipeRouterProtocol,
+ image_url: str,
+ ):
+ pipe_job = PipeJobFactory.make_pipe_job(
+ pipe=PipeOcr(
+ code="adhoc_for_test_pipe_ocr_image",
+ domain="generic",
+ image_stuff_name="page_scan",
+ should_include_images=True,
+ should_caption_images=False,
+ should_include_page_views=True,
+ page_views_dpi=300,
+ output_concept_code=NativeConcept.TEXT_AND_IMAGES.code,
+ ),
+ working_memory=WorkingMemoryFactory.make_from_image(
+ image_url=image_url,
+ concept_code="ocr.PageScan",
+ name="page_scan",
+ ),
+ )
+ pipe_ocr_output: PipeOcrOutput = await pipe_router.run_pipe_job(
+ pipe_job=pipe_job,
+ )
+ ocr_text = pipe_ocr_output.main_stuff_as_list(item_type=PageContent)
+ pretty_print(ocr_text, title="ocr_text")
+
+ @pytest.mark.parametrize("pdf_url", PipeOcrTestCases.PIPE_OCR_PDF_TEST_CASES)
+ async def test_pipe_ocr_pdf(
+ self,
+ pipe_router: PipeRouterProtocol,
+ pdf_url: str,
+ ):
+ pipe_job = PipeJobFactory.make_pipe_job(
+ pipe=PipeOcr(
+ code="adhoc_for_test_pipe_ocr_pdf",
+ domain="generic",
+ pdf_stuff_name="pdf",
+ should_include_images=True,
+ should_caption_images=False,
+ should_include_page_views=True,
+ page_views_dpi=300,
+ output_concept_code=NativeConcept.TEXT_AND_IMAGES.code,
+ ),
+ working_memory=WorkingMemoryFactory.make_from_pdf(
+ pdf_url=pdf_url,
+ concept_code=NativeConcept.PDF.code,
+ name="pdf",
+ ),
+ )
+ pipe_ocr_output: PipeOcrOutput = await pipe_router.run_pipe_job(
+ pipe_job=pipe_job,
+ )
+ ocr_text = pipe_ocr_output.main_stuff_as_list(item_type=PageContent)
+ pretty_print(ocr_text, title="ocr_text")
diff --git a/tests/pipelex/asynch/test_pipe_router.py b/tests/pipelex/asynch/test_pipe_router.py
new file mode 100644
index 000000000..3b28fb352
--- /dev/null
+++ b/tests/pipelex/asynch/test_pipe_router.py
@@ -0,0 +1,199 @@
+from typing import Any, Optional, Tuple, Type, cast
+
+import pytest
+from pytest import FixtureRequest
+
+from pipelex import log, pretty_print
+from pipelex.core.pipe_output import PipeOutput
+from pipelex.core.pipe_run_params import BatchParams, PipeOutputMultiplicity
+from pipelex.core.pipe_run_params_factory import PipeRunParamsFactory
+from pipelex.core.stuff import Stuff
+from pipelex.core.stuff_factory import StuffBlueprint
+from pipelex.core.working_memory import WorkingMemory
+from pipelex.core.working_memory_factory import WorkingMemoryFactory
+from pipelex.hub import get_mission_tracker, get_pipe_router, get_report_delegate
+from pipelex.mission.activity.activity_handler import ActivityHandlerForResultFiles
+from pipelex.mission.job_metadata import JobMetadata
+from pipelex.pipe_works.pipe_router_protocol import PipeRouterProtocol
+from tests.pipelex.test_data import PipeTestCases
+
+
[email protected](loop_scope="class")
+class TestPipeRouter:
+ @pytest.mark.parametrize("topic, blueprint, pipe_code", PipeTestCases.BLUEPRINT_AND_PIPE)
+ async def test_pipe_from_blueprint(
+ self,
+ request: FixtureRequest,
+ pipe_result_handler: Tuple[str, ActivityHandlerForResultFiles],
+ save_working_memory: Any,
+ topic: str,
+ blueprint: StuffBlueprint,
+ pipe_code: str,
+ pipe_router: PipeRouterProtocol,
+ ):
+ log.verbose(blueprint, title=f"{topic}: start from '{blueprint.name}', run pipe '{pipe_code}'")
+ working_memory = WorkingMemoryFactory.make_from_single_blueprint(blueprint=blueprint)
+ pipe_output: PipeOutput = await pipe_router.run_pipe_code(
+ pipe_code=pipe_code,
+ pipe_run_params=PipeRunParamsFactory.make_run_params(),
+ working_memory=working_memory,
+ job_metadata=JobMetadata(
+ top_job_id=cast(str, request.node.originalname), # type: ignore
+ ),
+ )
+ log.verbose(pipe_output, title="pipe_output")
+ pretty_print(pipe_output, title="pipe_output")
+
+ # Save stuff context
+ result_dir_path, _ = pipe_result_handler
+ await save_working_memory(pipe_output, result_dir_path)
+
+ get_report_delegate().generate_report()
+
+ @pytest.mark.parametrize("topic, stuff, pipe_code", PipeTestCases.STUFF_AND_PIPE)
+ async def test_pipe_from_stuff(
+ self,
+ request: FixtureRequest,
+ pipe_result_handler: Tuple[str, ActivityHandlerForResultFiles],
+ save_working_memory: Any,
+ topic: str,
+ stuff: Stuff,
+ pipe_code: str,
+ pipe_router: PipeRouterProtocol,
+ ):
+ log.verbose(stuff, title=f"{topic}: start from '{stuff.stuff_name}', run pipe '{pipe_code}'")
+ working_memory = WorkingMemoryFactory.make_from_single_stuff(stuff=stuff)
+ pipe_output: PipeOutput = await pipe_router.run_pipe_code(
+ pipe_code=pipe_code,
+ pipe_run_params=PipeRunParamsFactory.make_run_params(),
+ working_memory=working_memory,
+ job_metadata=JobMetadata(
+ top_job_id=cast(str, request.node.originalname), # type: ignore
+ ),
+ )
+ get_report_delegate().generate_report()
+
+ # Save stuff context
+ result_dir_path, _ = pipe_result_handler
+ await save_working_memory(pipe_output, result_dir_path)
+
+ @pytest.mark.parametrize("topic, pipe_code", PipeTestCases.NO_INPUT)
+ async def test_pipe_no_input(
+ self,
+ request: FixtureRequest,
+ pipe_result_handler: Tuple[str, ActivityHandlerForResultFiles],
+ save_working_memory: Any,
+ topic: str,
+ pipe_code: str,
+ pipe_router: PipeRouterProtocol,
+ ):
+ log.verbose(f"{topic}: just run pipe '{pipe_code}'")
+ pipe_output: PipeOutput = await pipe_router.run_pipe_code(
+ pipe_code=pipe_code,
+ pipe_run_params=PipeRunParamsFactory.make_run_params(),
+ working_memory=WorkingMemory(),
+ job_metadata=JobMetadata(
+ top_job_id=cast(str, request.node.originalname), # type: ignore
+ ),
+ )
+ get_report_delegate().generate_report()
+
+ # Save stuff context
+ result_dir_path, _ = pipe_result_handler
+ await save_working_memory(pipe_output, result_dir_path)
+
+ stuff = pipe_output.main_stuff
+ pretty_print(stuff, title=f"{topic}: run pipe '{pipe_code}'")
+ pretty_print(stuff.content.rendered_html(), title=f"{topic}: run pipe '{pipe_code}' in html")
+ pretty_print(stuff.content.rendered_markdown(), title=f"{topic}: run pipe '{pipe_code}' in markdown")
+
+ @pytest.mark.parametrize("topic, pipe_code, output_multiplicity", PipeTestCases.NO_INPUT_PARALLEL1)
+ async def test_pipe_batch_no_input(
+ self,
+ request: FixtureRequest,
+ pipe_router: PipeRouterProtocol,
+ pipe_result_handler: Tuple[str, ActivityHandlerForResultFiles],
+ save_working_memory: Any,
+ topic: str,
+ pipe_code: str,
+ output_multiplicity: Optional[PipeOutputMultiplicity],
+ ):
+ log.verbose(f"{topic}: just run pipe '{pipe_code}'")
+ pipe_output: PipeOutput = await pipe_router.run_pipe_code(
+ pipe_code=pipe_code,
+ pipe_run_params=PipeRunParamsFactory.make_run_params(
+ output_multiplicity=output_multiplicity,
+ ),
+ working_memory=WorkingMemory(),
+ job_metadata=JobMetadata(
+ top_job_id=cast(str, request.node.originalname), # type: ignore
+ ),
+ )
+ get_report_delegate().generate_report()
+
+ # Save stuff context
+ result_dir_path, _ = pipe_result_handler
+ await save_working_memory(pipe_output, result_dir_path)
+
+ stuff = pipe_output.main_stuff
+ pretty_print(stuff, title=f"{topic}: run pipe '{pipe_code}'")
+ pretty_print(stuff.content.rendered_html(), title=f"{topic}: run pipe '{pipe_code}' in html")
+ pretty_print(stuff.content.rendered_markdown(), title=f"{topic}: run pipe '{pipe_code}' in markdown")
+
+ @pytest.mark.parametrize("pipe_code, stuff, input_list_stuff_name, input_item_stuff_name", PipeTestCases.BATCH_TEST)
+ async def test_pipe_batch_with_list_content(
+ self,
+ request: FixtureRequest,
+ pipe_result_handler: Tuple[str, ActivityHandlerForResultFiles],
+ save_working_memory: Any,
+ pipe_router: PipeRouterProtocol,
+ pipe_code: str,
+ stuff: Stuff,
+ input_list_stuff_name: str,
+ input_item_stuff_name: str,
+ ):
+ working_memory = WorkingMemoryFactory.make_from_single_stuff(stuff=stuff)
+ pipe_output: PipeOutput = await pipe_router.run_pipe_code(
+ pipe_code=pipe_code,
+ pipe_run_params=PipeRunParamsFactory.make_run_params(
+ batch_params=BatchParams(
+ input_list_stuff_name=input_list_stuff_name,
+ input_item_stuff_name=input_item_stuff_name,
+ )
+ ),
+ working_memory=working_memory,
+ job_metadata=JobMetadata(
+ top_job_id=cast(str, request.node.originalname), # type: ignore
+ ),
+ )
+ pretty_print(pipe_output, title=f"run pipe '{pipe_code}'")
+ get_report_delegate().generate_report()
+
+ get_mission_tracker().output_flowchart(is_detailed=True)
+
+ @pytest.mark.parametrize("pipe_code, exception, expected_error_message", PipeTestCases.FAILURE_PIPES)
+ async def test_pipe_infinite_loop(
+ self,
+ request: FixtureRequest,
+ pipe_code: str,
+ exception: Type[Exception],
+ expected_error_message: str,
+ ):
+ pipe_code = "infinite_loop_1"
+ log.verbose(f"This pipe '{pipe_code}' is supposed to cause an error of type: {exception.__name__}")
+ with pytest.raises(exception) as exc:
+ await get_pipe_router().run_pipe_code(
+ pipe_code=pipe_code,
+ pipe_run_params=PipeRunParamsFactory.make_run_params(
+ pipe_stack_limit=6,
+ ),
+ job_metadata=JobMetadata(
+ top_job_id=cast(str, request.node.originalname), # type: ignore
+ ),
+ )
+ pretty_print(exc.value, title="exception")
+ assert expected_error_message in str(exc.value)
+ get_report_delegate().generate_report()
diff --git a/tests/pipelex/asynch/test_simple_pipe_run.py b/tests/pipelex/asynch/test_simple_pipe_run.py
new file mode 100644
index 000000000..76687e0fa
--- /dev/null
+++ b/tests/pipelex/asynch/test_simple_pipe_run.py
@@ -0,0 +1,48 @@
+from typing import cast
+
+import pytest
+
+from pipelex import log, pretty_print
+from pipelex.core.pipe_output import PipeOutput
+from pipelex.core.stuff_content import ListContent, TextContent
+from pipelex.core.working_memory_factory import WorkingMemoryFactory
+from pipelex.hub import get_report_delegate
+from pipelex.run import run_pipe_code
+from tests.pipelex.test_data import PipeTestCases
+
+
[email protected](loop_scope="class")
+class TestSimplePipeRun:
+ async def test_pipe_run(self):
+ working_memory = WorkingMemoryFactory.make_from_text(
+ text=PipeTestCases.USER_TEXT_COLORS,
+ )
+ pipe_output: PipeOutput = await run_pipe_code(
+ pipe_code="extract_colors",
+ working_memory=working_memory,
+ )
+
+ colors_list = cast(ListContent[TextContent], pipe_output.main_stuff.content)
+ pretty_print(colors_list, title="colors_list")
+ colors_list = pipe_output.main_stuff.as_list_of_fixed_content_type(item_type=TextContent)
+ pretty_print(colors_list, title="colors_list")
+ colors_list = pipe_output.main_stuff_as_list(item_type=TextContent)
+ pretty_print(colors_list, title="colors_list")
+
+ @pytest.mark.parametrize("pipe_code, input_concept_code, str_value", PipeTestCases.SIMPLE_PIPE_RUN_FROM_STR)
+ async def test_execute_pipe_from_str(self, pipe_code: str, input_concept_code: str, str_value: str):
+ working_memory = WorkingMemoryFactory.make_from_text(
+ concept_code=input_concept_code,
+ text=str_value,
+ )
+ pipe_output: PipeOutput = await run_pipe_code(
+ pipe_code=pipe_code,
+ working_memory=working_memory,
+ )
+
+ log.verbose(pipe_output, title="pipe_output")
+ pretty_print(pipe_output, title="pipe_output")
+ get_report_delegate().generate_report()
diff --git a/tests/pipelex/synchro/__init__.py b/tests/pipelex/synchro/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/tests/pipelex/synchro/__init__.py
@@ -0,0 +1 @@
+
diff --git a/tests/pipelex/synchro/test_libraries.py b/tests/pipelex/synchro/test_libraries.py
new file mode 100644
index 000000000..87873dfc4
--- /dev/null
+++ b/tests/pipelex/synchro/test_libraries.py
@@ -0,0 +1,104 @@
+"""
+make t TEST=TestLibraries
+"""
+
+from typing import Optional
+
+import pytest
+from rich import box
+from rich.console import Console
+from rich.table import Table
+
+from pipelex import pretty_print
+from pipelex.core.concept_library import ConceptLibrary
+from pipelex.core.pipe_library import PipeLibrary
+from pipelex.libraries.library_manager import LibraryManager
+from tests.pipelex.test_data import LibraryTestCases
+
+
+def pretty_print_all_pipes(
+ pipe_library: PipeLibrary,
+ title: Optional[str] = None,
+):
+ console = Console()
+ table = Table(
+ title=title,
+ show_header=True,
+ show_lines=True,
+ header_style="bold cyan",
+ box=box.SQUARE_DOUBLE_HEAD,
+ )
+ table.add_column("Domain")
+ table.add_column("Code")
+ table.add_column("Definition")
+ table.add_column("Class")
+ table.add_column("Input")
+ table.add_column("Output")
+
+ ordered_items = sorted(pipe_library.root.values(), key=lambda x: (x.domain, x.code))
+ for pipe in ordered_items:
+ table.add_row(
+ pipe.domain,
+ pipe.code,
+ pipe.definition,
+ pipe.__class__.__name__,
+ pipe.input_concept_code,
+ pipe.output_concept_code,
+ )
+
+ console.print("\n")
+ console.print(table)
+
+
+def pretty_print_all_concepts(
+ concept_library: ConceptLibrary,
+ title: Optional[str] = None,
+):
+ console = Console()
+ table = Table(
+ title=title,
+ show_header=True,
+ show_lines=True,
+ header_style="bold cyan",
+ box=box.SQUARE_DOUBLE_HEAD,
+ )
+ table.add_column("Domain")
+ table.add_column("Code")
+ table.add_column("Definition")
+ table.add_column("Class")
+ table.add_column("Inherits From")
+ # make a list ordered by domain then code
+ ordered_concepts = sorted(concept_library.root.values(), key=lambda x: (x.domain, x.code))
+ for concept in ordered_concepts:
+ table.add_row(
+ concept.domain,
+ concept.code,
+ concept.definition,
+ concept.structure_class_name,
+ ", ".join(concept.refines),
+ )
+
+ console.print("\n")
+ console.print(table)
+
+
+class TestLibraries:
+ @pytest.mark.parametrize("known_concept, known_pipe", LibraryTestCases.KNOWN_CONCEPTS_AND_PIPES)
+ def test_load_combo_libraries(
+ self,
+ known_concept: str,
+ known_pipe: str,
+ ):
+ # Initialize and load libraries
+ library_manager = LibraryManager()
+ library_manager.load_libraries()
+
+ # Verify that libraries were loaded
+ assert len(library_manager.concept_library.root) > 0, "No concepts were loaded"
+ assert len(library_manager.pipe_library.root) > 0, "No pipes were loaded"
+
+ # Test individual concepts and pipes
+ assert library_manager.concept_library.get_concept(known_concept) is not None
+ pretty_print(f"Concept: {known_concept} is correctly loaded as {library_manager.concept_library.get_concept(known_concept)}")
+ assert library_manager.pipe_library.get_optional_pipe(known_pipe) is not None
+ pretty_print(f"Pipe: {known_pipe} is correctly loaded as {library_manager.pipe_library.get_optional_pipe(known_pipe)}")
diff --git a/tests/pipelex/test_data.py b/tests/pipelex/test_data.py
new file mode 100644
index 000000000..c2b93eefd
--- /dev/null
+++ b/tests/pipelex/test_data.py
@@ -0,0 +1,310 @@
+from typing import Any, ClassVar, List, Optional, Tuple, Type
+
+from pydantic import BaseModel
+from typing_extensions import override
+
+from pipelex.core.pipe_run_params import PipeOutputMultiplicity
+from pipelex.core.stuff import Stuff
+from pipelex.core.stuff_content import ImageContent, ListContent, PDFContent, StructuredContent, TextContent
+from pipelex.core.stuff_factory import StuffBlueprint, StuffFactory
+from pipelex.exceptions import PipeStackOverflowError
+from pipelex.tools.templating.templating_models import PromptingStyle, TagStyle, TextFormat
+from tests.test_data import ImageTestCases, PDFTestCases
+
+
+class SomeContentWithImageAttribute(StructuredContent):
+ image_attribute: ImageContent
+
+
+class SomeContentWithImageSubObjectAttribute(StructuredContent):
+ image_attribute: ImageContent
+ sub_object: Optional["SomeContentWithImageAttribute"] = None
+
+
+class PipeTestCases:
+ SYSTEM_PROMPT = "You are a pirate, you always talk like a pirate."
+ USER_PROMPT = "In 3 sentences, tell me about the sea."
+ USER_TEXT_TRICKY_1 = """
+ When my son was 7 he was 3ft tall. When he was 8 he was 4ft tall. When he was 9 he was 5ft tall.
+ How tall do you think he was when he was 12? and at 15?
+ """
+ USER_TEXT_TRICKY_2 = """
+ A man, a cabbage, and a goat are trying to cross a river.
+ They have a boat that can only carry three things at once. How do they do it?
+ """
+ USER_TEXT_COLORS = """
+ The sky is blue.
+ The grass is green.
+ The sun is yellow.
+ The moon is white.
+ """
+ MULTI_IMG_DESC_PROMPT = "If there is one image, describe it. If there are multiple images, compare them."
+ URL_IMG_GANTT_1 = "https://storage.googleapis.com/public_test_files_7fa6_4277_9ab/diagrams/gantt_tree_house.png" # AI generated
+ URL_IMG_FASHION_PHOTO_1 = "https://storage.googleapis.com/public_test_files_7fa6_4277_9ab/fashion/fashion_photo_1.jpg" # AI generated
+ URL_IMG_FASHION_PHOTO_2 = "https://storage.googleapis.com/public_test_files_7fa6_4277_9ab/fashion/fashion_photo_2.png" # AI generated
+
+ # Create simple Stuff objects
+ SIMPLE_STUFF_TEXT = StuffFactory.make_stuff(
+ name="text",
+ concept_code="native.Text",
+ content=TextContent(text="Describe a t-shirt in 2 sentences"),
+ pipelex_session_id="unit_test",
+ )
+ SIMPLE_STUFF_IMAGE = StuffFactory.make_stuff(
+ name="image",
+ concept_code="native.Image",
+ content=ImageContent(url=URL_IMG_FASHION_PHOTO_1),
+ pipelex_session_id="unit_test",
+ )
+ SIMPLE_STUFF_PDF = StuffFactory.make_stuff(
+ name="pdf",
+ concept_code="native.PDF",
+ content=PDFContent(url=PDFTestCases.DOCUMENT_URLS[0]),
+ pipelex_session_id="unit_test",
+ )
+ COMPLEX_STUFF = StuffFactory.make_stuff(
+ name="complex",
+ concept_code="tests.Complex",
+ content=ListContent(
+ items=[
+ TextContent(text="The quick brown fox jumps over the lazy dog"),
+ ImageContent(url=URL_IMG_GANTT_1),
+ ]
+ ),
+ pipelex_session_id="unit_test",
+ )
+
+ STUFF_CONTENT_WITH_IMAGE_ATTRIBUTE_1 = SomeContentWithImageAttribute(image_attribute=ImageContent(url=URL_IMG_FASHION_PHOTO_1))
+ STUFF_WITH_IMAGE_ATTRIBUTE = StuffFactory.make_stuff(
+ concept_code="native.Image",
+ content=STUFF_CONTENT_WITH_IMAGE_ATTRIBUTE_1,
+ name="stuff_with_image",
+ pipelex_session_id="unit_test",
+ )
+ STUFF_CONTENT_WITH_IMAGE_ATTRIBUTE_IN_SUB_OBJECT = SomeContentWithImageSubObjectAttribute(
+ image_attribute=ImageContent(url=URL_IMG_FASHION_PHOTO_2),
+ sub_object=STUFF_CONTENT_WITH_IMAGE_ATTRIBUTE_1,
+ )
+ STUFF_WITH_IMAGE_ATTRIBUTE_IN_SUB_OBJECT = StuffFactory.make_stuff(
+ concept_code="native.Image",
+ content=STUFF_CONTENT_WITH_IMAGE_ATTRIBUTE_IN_SUB_OBJECT,
+ name="stuff_with_image_in_sub_object",
+ pipelex_session_id="unit_test",
+ )
+ STUFFS_IMAGE_ATTRIBUTES: ClassVar[List[Tuple[Stuff, List[str]]]] = [ # stuff, attribute_paths
+ (STUFF_WITH_IMAGE_ATTRIBUTE, ["stuff_with_image.image_attribute"]),
+ (STUFF_WITH_IMAGE_ATTRIBUTE_IN_SUB_OBJECT, ["stuff_with_image_in_sub_object.image_attribute"]),
+ (STUFF_WITH_IMAGE_ATTRIBUTE_IN_SUB_OBJECT, ["stuff_with_image_in_sub_object.sub_object.image_attribute"]),
+ (
+ STUFF_WITH_IMAGE_ATTRIBUTE_IN_SUB_OBJECT,
+ [
+ "stuff_with_image_in_sub_object.image_attribute",
+ "stuff_with_image_in_sub_object.sub_object.image_attribute",
+ ],
+ ),
+ ]
+ TRICKY_QUESTION_BLUEPRINT = StuffBlueprint(name="question", concept="answer.Question", value=USER_TEXT_TRICKY_2)
+ BLUEPRINT_AND_PIPE: ClassVar[List[Tuple[str, StuffBlueprint, str]]] = [ # topic, blueprint, pipe
+ (
+ "Tricky question conclude",
+ TRICKY_QUESTION_BLUEPRINT,
+ "conclude_tricky_question_by_steps",
+ ),
+ ]
+ NO_INPUT: ClassVar[List[Tuple[str, str]]] = [ # topic, pipe
+ (
+ "Test with no input",
+ "test_no_input",
+ ),
+ (
+ "Test with no input that could be long",
+ "test_no_input_that_could_be_long",
+ ),
+ ]
+ NO_INPUT_PARALLEL1: ClassVar[List[Tuple[str, str, Optional[PipeOutputMultiplicity]]]] = [ # topic, pipe, multiplicity
+ (
+ "Nature colors painting",
+ "choose_colors",
+ 5,
+ ),
+ (
+ "Power Rangers colors",
+ "imagine_nature_scene_of_original_power_rangers_colors",
+ None,
+ ),
+ (
+ "Power Rangers colors",
+ "imagine_nature_scene_of_alltime_power_rangers_colors",
+ True,
+ ),
+ ]
+
+ BATCH_TEST: ClassVar[List[Tuple[str, Stuff, str, str]]] = [ # pipe_code, stuff, input_list_stuff_name, input_item_stuff_name
+ (
+ "batch_test",
+ StuffFactory.make_stuff(
+ concept_code="flows.Color",
+ name="colors",
+ content=ListContent(
+ items=[
+ TextContent(text="blue"),
+ TextContent(text="red"),
+ TextContent(text="green"),
+ ]
+ ),
+ pipelex_session_id="unit_test",
+ ),
+ "colors",
+ "color",
+ ),
+ ]
+ STUFF_AND_PIPE: ClassVar[List[Tuple[str, Stuff, str]]] = [ # topic, stuff, pipe_code
+ # (
+ # "Process Simple Image",
+ # SIMPLE_STUFF_IMAGE,
+ # "simple_llm_test_from_image",
+ # ),
+ (
+ "Extract page contents from PDF",
+ SIMPLE_STUFF_PDF,
+ "extract_page_contents_from_pdf",
+ ),
+ ]
+ SIMPLE_PIPE_RUN_FROM_STR: ClassVar[List[Tuple[str, str, str]]] = [ # pipe_code, input_concept_code, str_value
+ (
+ "extract_colors",
+ "native.Text",
+ USER_TEXT_COLORS,
+ ),
+ ]
+ FAILURE_PIPES: ClassVar[List[Tuple[str, Type[Exception], str]]] = [
+ (
+ "infinite_loop_1",
+ PipeStackOverflowError,
+ "Exceeded pipe stack limit",
+ ),
+ ]
+
+
+class Fruit(BaseModel):
+ name: str
+ color: str
+
+ @override
+ def __str__(self) -> str:
+ return self.name
+
+
+class JINJA2TestCases:
+ JINJA2_NAME: ClassVar[List[str]] = [
+ "jinja2_test_template",
+ ]
+ JINJA2_FOR_ANY: ClassVar[List[str]] = [
+ "I want a {{ place_holder }} cocktail.",
+ ]
+ JINJA2_FILTER_TAG = """
+Tag filter:
+{{ place_holder | tag("some stuff") }}
+"""
+ JINJA2_FILTER_FORMAT = """
+Format filter:
+{{ place_holder | format }}
+"""
+ JINJA2_FILTER_FORMAT_PLAIN = """
+Format filter plain:
+{{ place_holder | format("plain") }}
+"""
+ JINJA2_FILTER_FORMAT_JSON = """
+Format filter json:
+{{ place_holder | format("json") }}
+"""
+ JINJA2_FILTER_FORMAT_MARKDOWN = """
+Format filter markdown:
+{{ place_holder | format("markdown") }}
+"""
+ JINJA2_FILTER_FORMAT_HTML = """
+Format filter html:
+{{ place_holder | format("html") }}
+"""
+ JINJA2_FILTER_FORMAT_SPREADSHEET = """
+Format filter spreadsheet:
+{{ place_holder | format("spreadsheet") }}
+"""
+ JINJA2_ALL_METHODS = """
+Direct (no filter):
+{{ place_holder }}
+
+Format filter:
+{{ place_holder | format }}
+
+Tag filter:
+{{ place_holder | tag("some stuff") }}
+
+Format filter json:
+{{ place_holder | format("json") }}
+
+Format filter markdown:
+{{ place_holder | format("markdown") }}
+
+Format filter html:
+{{ place_holder | format("html") }}
+
+"""
+ JINJA2_FOR_STUFF: ClassVar[List[str]] = [
+ JINJA2_FILTER_TAG,
+ JINJA2_FILTER_FORMAT,
+ JINJA2_FILTER_FORMAT_PLAIN,
+ JINJA2_FILTER_FORMAT_JSON,
+ JINJA2_FILTER_FORMAT_MARKDOWN,
+ JINJA2_FILTER_FORMAT_HTML,
+ JINJA2_FILTER_FORMAT_SPREADSHEET,
+ JINJA2_ALL_METHODS,
+ ]
+ STYLE: ClassVar[List[PromptingStyle]] = [
+ PromptingStyle(
+ tag_style=TagStyle.NO_TAG,
+ text_format=TextFormat.PLAIN,
+ ),
+ PromptingStyle(
+ tag_style=TagStyle.TICKS,
+ text_format=TextFormat.MARKDOWN,
+ ),
+ PromptingStyle(
+ tag_style=TagStyle.XML,
+ text_format=TextFormat.HTML,
+ ),
+ PromptingStyle(
+ tag_style=TagStyle.SQUARE_BRACKETS,
+ text_format=TextFormat.JSON,
+ ),
+ ]
+ COLOR: ClassVar[List[str]] = [
+ "red",
+ "blue",
+ "green",
+ ]
+ FRUIT: ClassVar[List[Fruit]] = [
+ (Fruit(color="red", name="cherry")),
+ (Fruit(color="blue", name="blueberry")),
+ (Fruit(color="green", name="grape")),
+ ]
+ ANY_OBJECT: ClassVar[List[Tuple[str, Any]]] = [
+ ("cherry", PipeTestCases.SIMPLE_STUFF_TEXT),
+ ("complex", PipeTestCases.COMPLEX_STUFF),
+ ]
+
+
+class LibraryTestCases:
+ KNOWN_CONCEPTS_AND_PIPES: ClassVar[List[Tuple[str, str]]] = [ # concept, pipe
+ ("cars.CarDescription", "generate_car_description"),
+ ("animals.AnimalDescription", "generate_animal_description"),
+ ("gpu.GPUDescription", "generate_gpu_description"),
+ ]
+
+
+class PipeOcrTestCases:
+ PIPE_OCR_IMAGE_TEST_CASES: ClassVar[List[str]] = [
+ ImageTestCases.IMAGE_FILE_PATH,
+ ImageTestCases.IMAGE_URL,
+ ]
+ PIPE_OCR_PDF_TEST_CASES: ClassVar[List[str]] = PDFTestCases.DOCUMENT_FILE_PATHS + PDFTestCases.DOCUMENT_URLS
diff --git a/tests/pipelex_unit_test.toml b/tests/pipelex_unit_test.toml
new file mode 100644
index 000000000..7034400ea
--- /dev/null
+++ b/tests/pipelex_unit_test.toml
@@ -0,0 +1,11 @@
+
+
+[cogt.llm_config.preferred_platforms]
+# These override the defaults set for any llm integration
+# Use at your convenience:
+# gpt-4o-mini = "azure_openai"
+# gpt-4o = "azure_openai"
+# claude-3-7-sonnet = "bedrock_anthropic"
+
+[cogt.imgg_config]
+default_imgg_handle = "fal-ai/fast-lightning-sdxl"
diff --git a/tests/py.typed b/tests/py.typed
new file mode 100644
index 000000000..e69de29bb
diff --git a/tests/test_boot.py b/tests/test_boot.py
new file mode 100644
index 000000000..66234378a
--- /dev/null
+++ b/tests/test_boot.py
@@ -0,0 +1,4 @@
+def test_boot():
+ # This test does nothing but the conftest runs Pipelex.make().
+ # Therefore this test will fail if Pipelex.make() fails.
+ assert True
diff --git a/tests/test_data.py b/tests/test_data.py
new file mode 100644
index 000000000..28ea3cbe6
--- /dev/null
+++ b/tests/test_data.py
@@ -0,0 +1,17 @@
+from typing import ClassVar, List
+
+
+class PDFTestCases:
+ DOCUMENT_FILE_PATHS: ClassVar[List[str]] = [
+ # "tests/data/documents/solar_system.pdf",
+ "tests/data/documents/illustrated_train_article.pdf",
+ ]
+ DOCUMENT_URLS: ClassVar[List[str]] = [
+ "https://storage.googleapis.com/public_test_files_7fa6_4277_9ab/documents/solar_system.pdf",
+ ]
+
+
+# TODO: move the other shared test images here from other test_data.py files
+class ImageTestCases:
+ IMAGE_FILE_PATH = "tests/data/documents/solar_system.png"
+ IMAGE_URL = "https://storage.googleapis.com/public_test_files_7fa6_4277_9ab/documents/solar_system.png"
diff --git a/tests/test_pipelines/__init__.py b/tests/test_pipelines/__init__.py
new file mode 100644
index 000000000..191fc7df8
--- /dev/null
+++ b/tests/test_pipelines/__init__.py
@@ -0,0 +1,7 @@
+from pipelex.tools.log.log import log
+from pipelex.tools.misc.pretty import pretty_print
+
+__all__ = [
+ "log",
+ "pretty_print",
+]
diff --git a/tests/test_pipelines/answer.toml b/tests/test_pipelines/answer.toml
new file mode 100644
index 000000000..4c3183f80
--- /dev/null
+++ b/tests/test_pipelines/answer.toml
@@ -0,0 +1,251 @@
+
+
+domain = "answer"
+definition = "The domain for questions and answers"
+
+[concept]
+Answer = "An answer to a question"
+Question = "A question to a problem"
+EnrichedQuestion = "An enriched question"
+GroundTruth = "The ground truth answer"
+Correctness = "Correctness of an answer"
+YesNo = "Yes/No answer format"
+
+[pipe]
+[pipe.write_context_of_text]
+PipeLLM = "Write the context of a sample of text"
+input = "native.Text"
+output = "native.Text"
+llm = "llm_to_retrieve"
+prompt_template = """
+You will receive a text.
+Your task is to write the context of the text.
+This context should be maximum of 30 words. The goal is to quickly understand the type of ducument by just reding this context.
+
+@text
+"""
+
+[pipe.retrieve_excerpts]
+PipeLLM = "Find the most relevant excerpts in a text that answers a specific question"
+input = "native.Text"
+output = "retrieve.RetrievedExcerpt"
+llm = "llm_to_retrieve"
+multiple_output = true
+prompt_template = """
+@text
+
+@question
+
+Your task is to find all relevant excerpts from the text that contribute to answering this question.
+It might not contain the exact answer, but it should be relevant to the question.
+
+Output each excerpt and its justification in the specified structured format, but ONLY for actual found excerpts.
+"""
+
+[pipe.enrich_question]
+PipeLLM = "Get an enriched question"
+input = "answer.Question"
+output = "EnrichedQuestion"
+llm = "llm_to_enrich"
+prompt_template = """
+Your task is to reformulate a form field into a question for a LLM.
+
+@context
+
+Here is the name of one of the fields in a form I have to fill in: '{{ question|format }}'.
+Each word is important therefore do not extrapolate or create information.
+
+{% if client_instructions %}
+ Here are important instructions from the customer to take into account in order to enrich the question.
+ The client instructions are important and you absolutely must follow them. However, it DOES NOT contain the answer.
+ @client_instructions
+{% endif %}
+
+{% if target_concept.content.choices %}
+ To help you understand the question and potential ambiguity, here are the ONLY possible values for the answer:
+ {% for value in target_concept.content.choices %}
+ - {{ value }}
+ {% endfor %}
+{% endif %}
+You can always choose to ouput this base fallback answer:
+{% for value in target_concept.content.BaseAnswer %}
+- {{ value }}
+{% endfor %}
+
+{% if target_concept.content.model_fields %}
+ Here are the fields that you have to fill in:
+ {% for field_name, field in target_concept.content.model_fields.items() %}
+ - {{ field_name }}: {{ field.annotation }}
+ {% endfor %}
+{% endif %}
+
+{% if target_concept.content.__doc__ %}
+Here are some guidelines about the desired output of the answer.
+{{ target_concept.content.__doc__ }}
+{% endif %}
+
+Here is the main task: If I were to prompt an LLM to extract this information from a specific section of the contract, what should I ask?
+
+Here are some rules that you absolutely must follow:
+- No need to add instructions like "based on the provided contract", just write the question in English, no need for code.
+- No need for intros like "Here is a reformulated question", just write the question.
+- It is important that you specify that the question is a Yes/No question if it is the case.
+"""
+
+[pipe.clean_answer]
+PipeLLM = "Clean the answer"
+input = "native.Dynamic"
+output = "native.Dynamic"
+prompt_template = """
+You are helping to clean answers that were generated from analyzing document excerpts to answer specific questions.
+
+Here is the answer to clean:
+@answer
+
+Your task is to clean the answer by handling cases where no clear answer could be found in the document excerpts.
+
+ONLY output the cleaned answer - do not add any explanation or commentary.
+
+If the answer contains any of these patterns, output "Indeterminate":
+- Empty or blank answers (including empty JSON objects)
+- Statements indicating no relevant information was found
+- Phrases like:
+ * "The excerpts are not relevant to the question"
+ * "There is nothing relevant in the document to answer"
+ * "Based on the document, there is nothing..."
+ * "No information found in the document"
+ * "Cannot determine from the provided excerpts"
+ * "No relevant excerpts were found"
+
+Important rules:
+- Keep "NO" answers unchanged
+- Keep "not_applicable" or "indeterminate" answers unchanged
+- Preserve all other valid answers exactly as they are
+- DO NOT add any explanation or commentary to your output
+
+{% if target_concept.content.model_fields %}
+ Here are the fields that you have to fill in:
+ {% for field_name, field in target_concept.content.model_fields.items() %}
+ - {{ field_name }}: {{ field.annotation }}
+ {% endfor %}
+{% endif %}
+
+{% if target_concept.content.__doc__ %}
+Here are some guidelines about the desired output of the answer.
+{{ target_concept.content.__doc__ }}
+{% endif %}
+"""
+
+[pipe.pre_answer_question]
+PipeLLM = "Answer the question in a dynamically specified format"
+input = "EnrichedQuestion"
+output = "native.Dynamic"
+llm = "llm_to_answer"
+prompt_template = """
+Your task is to extract information in a contract.
+
+Here is some context about the contract:
+@context
+
+To help you, your assistant has already enriched the question and extracted the most relevant excerpts{% if client_instructions %},
+and provided you with some hints (can be considered as client instructions){% endif %}.
+
+Here is the question:
+@enriched_question
+
+Here are the relevant excerpts:
+Not all of them are necessarily relevant to the question, but all of them are relevant to the contract.
+@excerpts
+
+{% if client_instructions %}
+Here are important instructions from the customer to take into account in order to enrich the question.
+The client instructions are important and you absolutely must follow them. However, it DOES NOT contain the answer.
+@client_instructions
+{% endif %}
+
+{% if target_concept.content.choices %}
+To help you understand the question and potential ambiguity, here are the ONLY possible values for the answer:
+{% for value in target_concept.content.choices %}
+- {{ value }}
+{% endfor %}
+{% endif %}
+You can always choose to ouput this base fallback answer:
+{% for value in target_concept.content.BaseAnswer %}
+- {{ value }}
+{% endfor %}
+
+{% if target_concept.content.model_fields %}
+Here are the fields that you have to fill in:
+{% for field_name, field in target_concept.content.model_fields.items() %}
+- {{ field_name }}: {{ field.annotation }}
+{% endfor %}
+{% endif %}
+
+{% if target_concept.content.__doc__ %}
+Here are some guidelines about the desired output of the answer.
+{{ target_concept.content.__doc__ }}
+{% endif %}
+
+Important rules for answering:
+- For Yes/No questions: Answer "NO" if no excerpts or inconclusive evidence (with explanation) are provided.
+- For multiple choice questions: Mark as "indeterminate" if no excerpts or inconclusive evidence (with explanation) are provided.
+- Always cite the answer with citations EXCEPT when the answer is "indeterminate"
+- When evidence is clear: Provide answer with citations
+- When no answer is applicable, or the answer says that its not applicable, mark as "not_applicable" with explanation.
+- If the target_format is FreeText, it must be a text.
+- [IMPORTANT] DO NOT add commentaries like "Based on.. According to...", just output the answer.
+- [IMPORTANT] DO NOT extrapolate or create information. Base your answer solely on the provided excerpts.
+- Please, cite the exact sentences that you used to answer the question in a "citation" paragraph.
+- Make sure that you also cite the clause number if provided (20.1 for instance).
+
+Here is the fields format of the answer you must output:
+answer, citations, short_comment
+"""
+
+[pipe.answer_question]
+PipeSequence = "Answer the question in a dynamically specified format"
+input = "EnrichedQuestion"
+output = "native.Dynamic"
+steps = [
+ { pipe = "pre_answer_question", result = "answer" },
+ { pipe = "clean_answer", result = "cleaned_answer" },
+]
+
+[pipe.retrieve_then_answer]
+PipeSequence = "Answer a question, given the target type and the excerpts neeeded to answer it"
+input = "answer.Question"
+output = "native.Dynamic"
+steps = [
+ { pipe = "write_context_of_text", result = "context" },
+ { pipe = "retrieve_excerpts", result = "excerpts" },
+ { pipe = "enrich_question", result = "enriched_question" },
+ { pipe = "answer_question", result = "answer" },
+]
+
+[pipe.verify_correctness]
+PipeLLM = "Verify the correctness of the answer"
+input = "Answer"
+output = "Correctness"
+prompt_template = """
+You are a helpful assistant that verifies the correctness of an answer.
+
+Your task is to verify if the answer is correct or not compared to a ground truth.
+Sometimes the answer is correct, sometimes it is not.
+
+Here is the question it was asked:
+@question
+
+Here is the answer to verify:
+@answer
+
+Here is the expected answer:
+@ground_truth
+
+Consider that the ground_truth is always correct.
+If the ground_truth is empty, consider that the answer should be "not_applicable" or "indeterminate", or that no excerpts was found.
+If the grund_truth is an extract of a clause of a contract, or multiple clauses, try to find out if the answer is globally the same clause that was extracted.
+If the answer miss a lot of information, it is wrong. If it extracted more, it is correct.
+
+Here is the format of the answer you must output:
+correctness as a boolean, explanation as a string
+"""
diff --git a/tests/test_pipelines/basic.toml b/tests/test_pipelines/basic.toml
new file mode 100644
index 000000000..c275875c2
--- /dev/null
+++ b/tests/test_pipelines/basic.toml
@@ -0,0 +1,171 @@
+
+
+domain = "basic"
+definition = "The domain for basic concepts"
+
+[concept]
+Excerpt = "A text excerpt from a document"
+BunchOfExcerpts = "A text gathering a bunch of excerpts from a document"
+ClientInstructions = "Expert human in the loop"
+FreeText = "A free text"
+
+[pipe]
+[pipe.write_query]
+PipeLLM = "Write a query to a retrieval system"
+input = "answer.Question"
+output = "questions.Query"
+prompt_template = """
+You are studying a contract. As usual, you are given a form to fill in about this contract.
+Fortunately, you have a natural language based retrieval system that can help you recover useful, required, information.
+
+Your task is to formulate a search query for the retrieval system based on the provided field and contextual information.
+
+And here is the context about the contract:
+{{ project_context|tag("context") }}
+
+So here is the field to fill in:
+{{ question|tag("field") }}
+
+Write the query in a concise way, ensuring that you include the context for the retrieval system.
+Reformulate the field if needed.
+Your answer will be directly used as the query to the retrieval system, so make sure it is usable as a query (do not add quotes, introduction text, etc.).
+"""
+
+[pipe.get_answer_format]
+PipeLLM = "Analyze the most relevant format the answer should be in"
+input = "answer.Question"
+output = "questions.AnswerFormat"
+prompt_template = """
+You are studying a contract. As usual, you are given a form to fill in about this contract.
+I want you to identify what format the answer should be returned in.
+Examples:
+- if the question is 'What is the height of the Eiffel Tower?', you should return 'a distance'.
+- if the question is 'Paul is 30 years old, John is half of Paul's age plus 20 years, who is older?', you should return 'a name'.
+
+But the output format is quite simple (a percentage, a date, a duration, a company name, etc.).
+
+{{ question|tag("question")}}
+"""
+
+
+[pipe.get_instructions]
+PipeLLM = "Get instructions to answer an enriched question"
+input = "answer.Question"
+output = "questions.Instructions"
+prompt_template = """
+Your task is to help answer a question.
+More specifically, you have to tell what to look for in the document, how to proceed etc.
+
+Here is the question:
+{{ question|tag("question") }}
+
+Give your hints in a concise way.
+"""
+
+[pipe.answer_enriched_question_with_blobs]
+PipeLLM = "Answer an enriched question with blobs"
+input = "answer.Question"
+output = "answer.Answer"
+prompt_template = """
+Your task is to answer a question about a contract.
+
+You will be given relevant excerpts from the contract.
+
+You will also be given some additional hints to help you answer the question. They come from a senior lawyer.
+
+{{ excerpts|tag("question") }}
+
+{{ excerpts|tag("excerpts") }}
+
+{{ instructions|tag("instructions") }}
+
+Answer the question **without giving too much details about what you have done to find the answer**. Just answer and give some factual explanations (like citing the excerpts).
+"""
+
+[pipe.get_format_answer_instructions]
+PipeLLM = "Get instructions to format the answer"
+input = "answer.Answer"
+output = "questions.FormatAnswerInstructions"
+prompt_template = """
+I have an LLM answer to a question that is too verbose. I need to format it in a specific format.
+Your role is to tell me how to do it.
+
+Here is the question I asked:
+{{ question|tag("question") }}
+
+Here is the LLM answer I got:
+{{ answer|tag("answer") }}
+
+Here is the expected format type I am asked to answer in:
+{{ answer_format|tag("answer_format") }}
+
+
+For instance, if the question is "What is the height of the Eiffel Tower?" and the answer is "The Eiffel Tower is very high, it is about three hundred meters high" while the expected format is "a distance in meters".
+You should answer something like:
+"Pay attention to the numeric value and the unit. Here, the numeric value is three hundred and the unit is meters.
+You then need to convert it to a number with its unit."
+"""
+
+[pipe.format_answer]
+PipeLLM = "Format the answer"
+input = "answer.Answer"
+output = "questions.FormattedAnswer"
+prompt_template = """
+Your role is to format an LLM answer to a question.
+You will be given an answer, a specific target format and some instructions.
+
+Here is the answer:
+{{ answer|tag("answer") }}
+
+Here is the target format:
+{{ answer_format|tag("answer_format") }}
+
+Here are the instructions:
+{{ format_answer_instructions|tag("format_answer_instructions") }}
+
+For instance, if the answer is "The Eiffel Tower is very high, it is about three hundred meters high", the format is "a distance in meters", while instructions are "Pay attention to the numeric value and the unit. Here, the numeric value is three hundred and the unit is meters":
+You should answer "320 meters"
+"""
+
+
+[pipe.answer_question_with_blobs]
+PipeSequence = "Answer a question in a formatted way by first analyzing the most relevant format the answer should be in and output a type"
+input = "answer.Question"
+output = "answer.Answer"
+steps = [
+ { pipe = "get_answer_format", result = "answer_format" },
+ { pipe = "get_instructions", result = "instructions" },
+ { pipe = "answer_enriched_question_with_blobs", result = "answer" },
+ { pipe = "get_format_answer_instructions", result = "format_answer_instructions" },
+ { pipe = "format_answer", result = "formatted_answer" },
+]
+
+[pipe.answer_question_with_excerpts]
+PipeLLM = "Answer the question in a dynamically specified format"
+input = "answer.Question"
+output = "answer.Answer"
+prompt_template = """
+Your task is to answer a question about a contract.
+
+Here is some context about the contract:
+{{ project_context|format }}
+
+To help you, your assistant has already enriched the question and extracted the most relevant excerpts{% if client_instructions %}, and provided you with some customer instructions{% endif %}.
+Please, cite the exact sentences/clauses that you used to answer the question in a "citations" paragraph.
+Make sure that you also cite the clauses number if provided (20.1 for instance).
+You can use multiple parts of the text to answer the question, and provide multiple citations as an array.
+
+Here is the question:
+{{ enriched_question|tag("enriched_question") }}
+
+Here are the relevant excerpts:
+{{ excerpts|tag("excerpts") }}
+
+{% if client_instructions %}
+Here are important instructions from the customer that have to be taken into account in order to answer the question:
+{{ client_instructions|tag("client_instructions") }}
+{% endif %}
+
+Be aware that you have the possibility to return "Indeterminate" if the answer is not found in the text, or if no excerpts are provided.
+DO NOT extrapolate, DO NOT create information that is not provided. Base your answer on what you are given in this prompt.
+"""
diff --git a/tests/test_pipelines/contracts.py b/tests/test_pipelines/contracts.py
new file mode 100644
index 000000000..66406f1d0
--- /dev/null
+++ b/tests/test_pipelines/contracts.py
@@ -0,0 +1,75 @@
+from enum import StrEnum
+from typing import Any, List, Literal, Optional, Union
+
+from pydantic import Field, model_validator
+from typing_extensions import Self, override
+
+from pipelex_libraries.pipelines.base_library.questions import BaseAnswer, MultipleChoiceAnswer, SourcedAnswer
+
+
+class Fees(SourcedAnswer[Any]):
+ class Value(StrEnum):
+ PERCENTAGE = "Percentage"
+ AMOUNT = "Amount"
+ INDETERMINATE = "Indeterminate"
+
+ class Currency(StrEnum):
+ USD = "USD"
+ EUR = "EUR"
+ GBP = "GBP"
+ AUD = "AUD"
+ CAD = "CAD"
+ UNKNOWN = "Unknown currency"
+
+ answer: Union[float, BaseAnswer] = Field(
+ default=BaseAnswer.INDETERMINATE,
+ description="The fee value - for percentages use decimal (e.g. 2.5 for 2.5%), for amounts use the absolute value",
+ )
+ fee_type: Value = Field(default=Value.PERCENTAGE, description="The type of fee (percentage or amount)")
+ fee_currency: Optional[Currency] = Field(
+ default=None, description="The currency of the fee amount. Required when fee_type is AMOUNT, should be None for PERCENTAGE"
+ )
+
+ @model_validator(mode="after")
+ def validate_fee(self) -> Self:
+ if isinstance(self.answer, float):
+ if self.answer < 0 or self.answer > 100:
+ raise ValueError("Fee value must be between 0 and 100")
+ if self.fee_type == self.Value.AMOUNT and not self.fee_currency:
+ raise ValueError("Currency is required when fee type is AMOUNT")
+ if self.fee_type == self.Value.PERCENTAGE and self.fee_currency:
+ raise ValueError("Currency should not be set when fee type is PERCENTAGE")
+ return self
+
+ @override
+ def render_spreadsheet(self) -> str:
+ if self.not_applicable:
+ return BaseAnswer.NOT_APPLICABLE.value
+ elif self.indeterminate:
+ return BaseAnswer.INDETERMINATE.value
+ if self.fee_type == self.Value.PERCENTAGE:
+ return f"{self.answer}"
+ else:
+ return f"{self.answer} {self.fee_currency.value if self.fee_currency else 'Unknown'}"
+
+
+class GoverningLaw(SourcedAnswer[Any]):
+ """
+ The Governing Law can be a country, a state, a city, a law code, etc.
+ It should be the name used in the contract.
+ """
+
+ answer: Union[str, BaseAnswer] = Field(description="The governing law")
+
+
+class ContractTypeChoices(StrEnum):
+ CONTRACT = "Contract"
+ AMENDMENT = "Amendment"
+
+
+class ContractType(MultipleChoiceAnswer[Literal[ContractTypeChoices.CONTRACT, ContractTypeChoices.AMENDMENT]]):
+ """The type of the contract - either a main contract or an amendment."""
+
+ choices: List[str] = Field(
+ default=[choice.value for choice in ContractTypeChoices], description="The list of choices for the multiple choice question."
+ )
diff --git a/tests/test_pipelines/contracts.toml b/tests/test_pipelines/contracts.toml
new file mode 100644
index 000000000..58bd26f48
--- /dev/null
+++ b/tests/test_pipelines/contracts.toml
@@ -0,0 +1,13 @@
+
+
+domain = "contracts"
+definition = "The domain for analyzing contracts"
+system_prompt = "You are an expert in contract analysis."
+
+[concept]
+Contract = "A document or a set of documents that legally binds two or more parties to an agreement"
+Amendment = "A change or addition to a legal document"
+ClmFieldName = "Field Name from a contract lifecycle management system"
+GoverningLaw = "Governing law of a contract"
+Fees = "Fees provided by a contract"
+ContractType = "Type of contract"
diff --git a/tests/test_pipelines/failure_modes.toml b/tests/test_pipelines/failure_modes.toml
new file mode 100644
index 000000000..a0f0581c8
--- /dev/null
+++ b/tests/test_pipelines/failure_modes.toml
@@ -0,0 +1,24 @@
+
+
+domain = "failure_modes"
+definition = "This domain is for testing failure modes"
+
+[concept]
+
+[pipe.dummy]
+PipeLLM = "This pipe is a dummy pipe"
+input = "native.Text"
+output = "native.Text"
+llm = { llm_handle = "gpt-4o-mini", temperature = 1, max_tokens = 50 }
+prompt_template = """
+This is a dummy prompt, do whatever you want. Something funny but not a joke, ok?
+"""
+
+[pipe.infinite_loop_1]
+PipeSequence = "This pipe will cause an infinite loop"
+input = "native.Text"
+output = "native.Text"
+steps = [
+ { pipe = "dummy", result = "dummy_result" },
+ { pipe = "infinite_loop_1", result = "disaster" },
+]
diff --git a/tests/test_pipelines/misc_tests/__init__.py b/tests/test_pipelines/misc_tests/__init__.py
new file mode 100644
index 000000000..191fc7df8
--- /dev/null
+++ b/tests/test_pipelines/misc_tests/__init__.py
@@ -0,0 +1,7 @@
+from pipelex.tools.log.log import log
+from pipelex.tools.misc.pretty import pretty_print
+
+__all__ = [
+ "log",
+ "pretty_print",
+]
diff --git a/tests/test_pipelines/misc_tests/flows.toml b/tests/test_pipelines/misc_tests/flows.toml
new file mode 100644
index 000000000..7a1011625
--- /dev/null
+++ b/tests/test_pipelines/misc_tests/flows.toml
@@ -0,0 +1,80 @@
+
+
+domain = "flows"
+definition = "A collection of pipes that are used to test the flow of a pipeline"
+
+[concept]
+Color = "A color"
+
+[pipe.extract_colors]
+PipeLLM = "Extract Colors"
+output = "Color"
+prompt_template = """
+Extract colors from the following text:
+
+{{ text|tag }}
+"""
+multiple_output = true
+
+[pipe]
+[pipe.choose_colors]
+PipeLLM = "Choose Colors"
+output = "Color"
+prompt_template = """
+Choose {{ _nb_output }} colors.
+"""
+llm = "llm_for_creative_writing"
+
+[pipe.sequence_for_batch_test]
+PipeSequence = "Sequence for parallel test"
+input = "Color"
+output = "Color"
+steps = [
+ { pipe = "capitalize_color", result = "capitalized_color" },
+ { pipe = "capitalize_last_letter", result = "capitalized_last_letter" },
+ # { pipe = "reverse_letters", result = "reversed_color" },
+]
+
+[pipe.batch_test]
+PipeBatch = "Batch Test"
+input = "Color"
+output = "Color"
+branch_pipe_code = "sequence_for_batch_test"
+
+[pipe.capitalize_color]
+PipeLLM = "Capitalize Colors"
+input = "Color"
+output = "Color"
+prompt_template = """
+Put the first letter of a word that represents a color as a capital letter.
+Here is the word:
+
+{{ color|tag("color") }}
+
+Output only the word, nothing else.
+"""
+
+[pipe.capitalize_last_letter]
+PipeLLM = "Capitalize Last Letter"
+input = "Color"
+output = "Color"
+prompt_template = """
+Put the last letter of a word that represents a color as a capital letter.
+Here is the word:
+
+{{ capitalized_color|tag("color") }}
+
+Output only the word, nothing else.
+"""
+
+[pipe.reverse_letters]
+PipeLLM = "Reverse Letters"
+input = "Color"
+output = "Color"
+prompt_template = """
+Reverse the letters of this word:
+
+{{ color|tag("word") }}
+
+Output only the reversed word, nothing else.
+"""
diff --git a/tests/test_pipelines/misc_tests/multiplicity.toml b/tests/test_pipelines/misc_tests/multiplicity.toml
new file mode 100644
index 000000000..c009a192a
--- /dev/null
+++ b/tests/test_pipelines/misc_tests/multiplicity.toml
@@ -0,0 +1,79 @@
+
+
+domain = "multiplicity"
+definition = "Test library about multiplicity"
+
+[concept]
+Color = "A color"
+ProductOfNature = "Something produced by Nature"
+FantasyScene = "A fantasy scene"
+
+[pipe.original_power_ranger_colors]
+PipeLLM = "Recall the colors of the original power rangers"
+output = "Color"
+prompt_template = """
+Remind me of the colors of the {{ _nb_output }} original power rangers.
+"""
+llm = "llm_for_creative_writing"
+nb_output = 5
+
+[pipe.alltime_power_ranger_colors]
+PipeLLM = "Recall the colors of all the power rangers"
+output = "Color"
+prompt_template = """
+Remind me of the colors of all the power rangers over all series.
+Don't list the names of the characters or the name of the series: just list the colors.
+"""
+llm = "llm_for_creative_writing"
+
+[pipe.imagine_nature_product]
+PipeLLM = "Imagine a product of nature"
+input = "Color"
+output = "ProductOfNature"
+prompt_template = """
+Propose a product of nature of this color: {{ color|format("plain") }}.
+Just state what it is in a single sentence.
+"""
+
+[pipe.imagine_fantasy_scene_including_products_of_nature]
+PipeLLM = "Imagine a fantasy scene including products of nature"
+input = "ProductOfNature"
+output = "FantasyScene"
+prompt_template = """
+Imagine a fantasy scene including the following products of nature:
+
+{{ product_of_nature|tag("products of nature") }}
+
+Keep it short and concise, just one sentence.
+"""
+
+[pipe.imagine_nature_product_list]
+PipeSequence = "Imagine nature products of different colors"
+output = "native.Image"
+steps = [
+ { pipe = "choose_colors", result = "color", nb_output = 3 },
+ { pipe = "imagine_nature_product", result = "product_of_nature" },
+ { pipe = "imagine_fantasy_scene_including_products_of_nature", result = "imgg_prompt" },
+ { pipe = "generate_image", result = "image" },
+]
+
+[pipe.imagine_nature_scene_of_original_power_rangers_colors]
+PipeSequence = "Imagine nature scenes of Power Rangers colors"
+output = "native.Image"
+steps = [
+ { pipe = "original_power_ranger_colors", result = "color" },
+ { pipe = "imagine_nature_product", result = "product_of_nature" },
+ { pipe = "imagine_fantasy_scene_including_products_of_nature", result = "imgg_prompt" },
+ # { pipe = "generate_image", result = "image" },
+]
+
+
+[pipe.imagine_nature_scene_of_alltime_power_rangers_colors]
+PipeSequence = "Imagine nature scenes of Power Rangers colors"
+output = "native.Image"
+steps = [
+ { pipe = "alltime_power_ranger_colors", result = "color", multiple_output = true },
+ { pipe = "imagine_nature_product", result = "product_of_nature" },
+ { pipe = "imagine_fantasy_scene_including_products_of_nature", result = "imgg_prompt" },
+ # { pipe = "generate_image", result = "image" },
+]
diff --git a/tests/test_pipelines/misc_tests/pipe_batch.toml b/tests/test_pipelines/misc_tests/pipe_batch.toml
new file mode 100644
index 000000000..23b20bd66
--- /dev/null
+++ b/tests/test_pipelines/misc_tests/pipe_batch.toml
@@ -0,0 +1,23 @@
+
+
+domain = "test_pipe_batch"
+definition = "Pipelines to test Pipe Batch"
+
+[concept]
+[concept.Random]
+Concept = "TestPipeBatchItem"
+
+[pipe.test_pipe_batch_item]
+PipeLLM = "Test Pipe Batch"
+input = "TestPipeBatchItem"
+output = "TestPipeBatchItem"
+prompt_template = """
+Output this "item" and add "Hello" at the beginning of the output.
+{{ _batch_item|tag("item") }}
+"""
+
+[pipe.test_pipe_batch]
+PipeBatch = "Test Pipe Batch 2"
+input = "TestPipeBatchItem"
+output = "TestPipeBatchItem"
+branch_pipe_code = "test_pipe_batch_item"
diff --git a/tests/test_pipelines/misc_tests/subfolder_1/cars.toml b/tests/test_pipelines/misc_tests/subfolder_1/cars.toml
new file mode 100644
index 000000000..f1e161258
--- /dev/null
+++ b/tests/test_pipelines/misc_tests/subfolder_1/cars.toml
@@ -0,0 +1,21 @@
+
+
+domain = "cars"
+definition = "The test domain for handling car descriptions"
+system_prompt = "You are an expert at describing cars based on their brand, model, and year."
+
+[concept]
+Car = "A car reference, including its brand, model, and year"
+CarDescription = "A detailed description of a car model"
+
+[pipe]
+[pipe.generate_car_description]
+PipeLLM = "Generate a description of a car"
+input = "Car"
+output = "CarDescription"
+prompt_template = """
+Given the reference to a car, generate a description of the car.
+
+Car:
+{{ car|tag }}
+"""
diff --git a/tests/test_pipelines/misc_tests/subfolder_2/animals.toml b/tests/test_pipelines/misc_tests/subfolder_2/animals.toml
new file mode 100644
index 000000000..138cd25ee
--- /dev/null
+++ b/tests/test_pipelines/misc_tests/subfolder_2/animals.toml
@@ -0,0 +1,21 @@
+
+
+domain = "animals"
+definition = "The test domain for handling animal descriptions"
+system_prompt = "You are an expert at describing animals based on their species, breed, and age."
+
+[concept]
+Animal = "An animal reference, including its species, breed, and age"
+AnimalDescription = "A detailed description of an animal"
+
+[pipe]
+[pipe.generate_animal_description]
+PipeLLM = "Generate a description of an animal"
+input = "Animal"
+output = "AnimalDescription"
+prompt_template = """
+Given the reference to an animal, generate a description of the animal.
+
+Animal:
+{{ animal|tag }}
+"""
diff --git a/tests/test_pipelines/misc_tests/subfolder_2/subfolder/gpu.toml b/tests/test_pipelines/misc_tests/subfolder_2/subfolder/gpu.toml
new file mode 100644
index 000000000..f4058566f
--- /dev/null
+++ b/tests/test_pipelines/misc_tests/subfolder_2/subfolder/gpu.toml
@@ -0,0 +1,21 @@
+
+
+domain = "gpu"
+definition = "The test domain for handling GPU descriptions"
+system_prompt = "You are an expert at describing GPUs based on their brand, model, and price."
+
+[concept]
+GPU = "A GPU reference, including its brand, model, and price"
+GPUDescription = "A detailed description of a GPU"
+
+[pipe]
+[pipe.generate_gpu_description]
+PipeLLM = "Generate a description of a GPU"
+input = "GPU"
+output = "GPUDescription"
+prompt_template = """
+Given the reference to a GPU, generate a description of the GPU.
+
+GPU:
+{{ gpu|tag }}
+"""
diff --git a/tests/test_pipelines/misc_tests/test_errors.toml b/tests/test_pipelines/misc_tests/test_errors.toml
new file mode 100644
index 000000000..f68ee0588
--- /dev/null
+++ b/tests/test_pipelines/misc_tests/test_errors.toml
@@ -0,0 +1,45 @@
+
+
+domain = "test_errors"
+definition = "This library is intended for testing errors"
+
+# [pipe.jinja2_syntax_error]
+# PipeLLM = "Jinja2 syntax error (on purpose, for testing): bad curly braces"
+# input = "native.Text"
+# output = "native.Text"
+# prompt_template = """
+# {{ a123|tag }
+# """
+
+# [pipe.jinja2_dummy_filter1]
+# PipeLLM = "Jinja2 undefined filter (on purpose, for testing)"
+# input = "native.Text"
+# output = "native.Text"
+# prompt_template = """
+# {{ foobar|dummy_filter1 }}
+# """
+
+# [pipe.jinja2_dummy_filter2]
+# PipeLLM = "Jinja2 undefined filter (on purpose, for testing)"
+# input = "native.Text"
+# output = "native.Text"
+# prompt_template = """
+# {{ foobar|dummy_filter2() }}
+# """
+
+# [pipe.jinja2_dummy_filter3]
+# PipeLLM = "Jinja2 undefined filter (on purpose, for testing)"
+# input = "native.Text"
+# output = "native.Text"
+# prompt_template = """
+# {{ foobar|dummy_filter3("param") }}
+# """
+
+
+# [pipe.jinja2_dummy_filter4]
+# PipeLLM = "Jinja2 undefined filter (on purpose, for testing)"
+# input = "native.Text"
+# output = "native.Text"
+# prompt_template = """
+# {{ foobar|dummy_filter4(param1, param2) }}
+# """
diff --git a/tests/test_pipelines/misc_tests/test_jinja2.toml b/tests/test_pipelines/misc_tests/test_jinja2.toml
new file mode 100644
index 000000000..65dccb9fa
--- /dev/null
+++ b/tests/test_pipelines/misc_tests/test_jinja2.toml
@@ -0,0 +1,22 @@
+
+
+domain = "test_jinja2"
+definition = "This library is intended for testing Jinja2"
+
+
+[pipe.jinja2_test_1]
+PipeJinja2 = "Jinja2 test 1"
+input = "native.Text"
+output = "native.Text"
+jinja2 = """
+This is a simple test prompt:
+@text
+"""
+prompting_style = { tag_style = "square_brackets", text_format = "markdown" }
+template_category = "llm_prompt"
+
+# [pipe.jinja2_test_2]
+# PipeJinja2 = "Jinja2 test 2"
+# input = "native.Text"
+# output = "native.Text"
+# jinja2_name = "non-existing-name"
diff --git a/tests/test_pipelines/misc_tests/tests.py b/tests/test_pipelines/misc_tests/tests.py
new file mode 100644
index 000000000..e648f6c2b
--- /dev/null
+++ b/tests/test_pipelines/misc_tests/tests.py
@@ -0,0 +1,5 @@
+from pipelex.core.stuff_content import ListContent, TextContent
+
+
+class RandomListContent(ListContent[TextContent]):
+ pass
diff --git a/tests/test_pipelines/misc_tests/tests.toml b/tests/test_pipelines/misc_tests/tests.toml
new file mode 100644
index 000000000..a244d6bf1
--- /dev/null
+++ b/tests/test_pipelines/misc_tests/tests.toml
@@ -0,0 +1,107 @@
+
+
+domain = "tests"
+definition = "This library is intended for testing purposes"
+
+[concept]
+FictionCharacter = "A character in a fiction story"
+ArticleAndCritic = "An article and a critique of it"
+Complex = "A complex object"
+
+[pipe.simple_llm_test_from_text]
+PipeLLM = "Simple LLM test from text"
+input = "native.Text"
+output = "native.Text"
+prompt_template = """
+This is a simple test prompt:
+@text
+"""
+[pipe.simple_llm_test_from_image]
+PipeLLM = "Simple LLM test from image"
+input = "native.Image"
+output = "native.Text"
+prompt_template = """
+Describe the using rap lyrics, including puns and references to the image.
+"""
+images = ["image"]
+
+[pipe.create_characters]
+PipeLLM = "Create Characters"
+output = "FictionCharacter"
+prompt_template = """
+Create a list of 3 characters for a story about a startup in Paris, France.
+Be concise.
+"""
+llm = { llm_handle = "gpt-4o", temperature = 1, max_tokens = "auto" }
+multiple_output = true
+
+[pipe.create_synopsis]
+PipeLLM = "Create Synopsis"
+input = "native.Text"
+output = "native.Text"
+llm = "llm_for_creative_writing"
+prompt_template = """
+Create a short synopsis for a story about:
+
+@text
+
+Be concise: 3 sentences max.
+"""
+
+
+# TODO: fix testing implict concept
+[pipe.test_implicit_concept]
+PipeLLM = "Implicit concept"
+output = "RandomConceptCodeThatDoesNotExist"
+prompt_template = """
+This is is a test prompt.
+
+Output what is here:
+
+{{ a123|tag }}
+"""
+
+[pipe.is_article_critic_reasonable]
+PipeLLM = "Article Critic Evaluator"
+input = "ArticleAndCritic"
+output = "native.Text"
+prompt_template = """
+You are an expert at evaluating article critiques. Your task is to determine if the given critique of an article is reasonable and valuable.
+Article to evaluate:
+
+{{ my_article|tag }}
+
+Critique to evaluate:
+
+{{ critic|tag }}
+
+Evaluate if this critique is reasonable and valuable. Consider the following aspects:
+1. Is the critique specific and detailed?
+2. Does it provide constructive feedback?
+3. Is it supported by examples from the article?
+4. Is the tone professional?
+5. Does it focus on the content rather than personal attacks?
+Output only 'true' if the critique is reasonable and valuable, or 'false' if it is not.
+"""
+
+[pipe.test_no_input]
+PipeLLM = "No Input"
+output = "native.Text"
+llm = "llm_for_testing_gen_text"
+prompt_template = """
+Explain that this is a test prompt which took no input from the user.
+"""
+
+[pipe.test_no_input_that_could_be_long]
+PipeLLM = "No Input but generates a text that could be long"
+output = "native.Text"
+llm = { llm_handle = "gpt-4o-mini", temperature = 0.5, max_tokens = 100 }
+prompt_template = """
+Tell me a short story about a red baloon.
+"""
+
+[pipe.generate_3_images]
+PipeImgGen = "Generate 3 AI images"
+input = "images.ImggPrompt"
+output = "native.Image"
+nb_output = 3
diff --git a/tests/tools/__init__.py b/tests/tools/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/tests/tools/__init__.py
@@ -0,0 +1 @@
+
diff --git a/tests/tools/basic/__init__.py b/tests/tools/basic/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/tests/tools/basic/__init__.py
@@ -0,0 +1 @@
+
diff --git a/tests/tools/basic/test_pretty.py b/tests/tools/basic/test_pretty.py
new file mode 100644
index 000000000..2685be738
--- /dev/null
+++ b/tests/tools/basic/test_pretty.py
@@ -0,0 +1,218 @@
+import re
+import textwrap
+from typing import Dict, List, Optional, Union
+
+from pydantic import BaseModel, Field
+from pytest import CaptureFixture
+
+from pipelex.tools.misc.pretty import pretty_print, pretty_print_in_sandbox
+
+
+class Address(BaseModel):
+ street: str
+ city: str
+ country: str
+ postal_code: Optional[str] = None
+
+
+class UserPreferences(BaseModel):
+ theme: str = "dark"
+ notifications: bool = True
+ tags: List[str] = Field(default_factory=list)
+
+
+class ComplexUser(BaseModel):
+ name: str
+ age: int
+ email: Optional[str]
+ addresses: List[Address]
+ preferences: UserPreferences
+ metadata: Dict[str, Union[str, int, bool]] = Field(default_factory=dict)
+
+
+class TestPrettyPrintInSandbox:
+ @staticmethod
+ def remove_ansi_escape_codes(text: str) -> str:
+ ansi_escape = re.compile(r"\x1B\[[0-?]*[ -/]*[@-~]")
+ return ansi_escape.sub("", text)
+
+ def test_empty_content(self, capsys: CaptureFixture[str]):
+ pretty_print_in_sandbox(content="")
+
+ captured = capsys.readouterr()
+ output = self.remove_ansi_escape_codes(captured.out)
+
+ expected_output = textwrap.dedent("""\
+ ╭────╮
+ │ │
+ ╰────╯
+ """)
+
+ assert output == expected_output, f"Output did not match expected:\n{output}"
+
+ def test_none_content(self, capsys: CaptureFixture[str]):
+ pretty_print_in_sandbox(content=None, title="title", subtitle="subtitle")
+
+ captured = capsys.readouterr()
+ output = self.remove_ansi_escape_codes(captured.out)
+
+ expected_output = textwrap.dedent("""\
+ ╭────────────────────╮
+ │ title (subtitle): │
+ │ None │
+ ╰────────────────────╯
+ """)
+
+ assert output == expected_output, f"Output did not match expected:\n{output}"
+
+ def test_pretty_print_with_brackets_optional_edge_case(self, capsys: CaptureFixture[str]):
+ pretty_print(content="Optional[float]", title="title")
+
+ captured = capsys.readouterr()
+ output = self.remove_ansi_escape_codes(captured.out)
+ expected_output = textwrap.dedent("""\
+ ╭─ title ─────────╮
+ │ Optional[float] │
+ ╰─────────────────╯
+ """)
+
+ assert output == expected_output, f"Output did not match expected:\n{output}"
+
+ def test_pretty_print_with_brackets_basic(self, capsys: CaptureFixture[str]):
+ pretty_print(content="SomethingBeforeBracketsAnd[SomethingBetweenBrackets]", title="title")
+
+ captured = capsys.readouterr()
+ output = self.remove_ansi_escape_codes(captured.out)
+
+ expected_output = textwrap.dedent("""\
+ ╭─ title ──────────────────────────────────────────────╮
+ │ SomethingBeforeBracketsAnd[SomethingBetweenBrackets] │
+ ╰──────────────────────────────────────────────────────╯
+ """)
+
+ assert output == expected_output, f"Output did not match expected:\n{output}"
+
+ def test_pretty_print_with_nested_brackets(self, capsys: CaptureFixture[str]):
+ pretty_print(content="List[Optional[int]]", title="title")
+
+ captured = capsys.readouterr()
+ output = self.remove_ansi_escape_codes(captured.out)
+
+ expected_output = textwrap.dedent("""\
+ ╭─ title ─────────────╮
+ │ List[Optional[int]] │
+ ╰─────────────────────╯
+ """)
+
+ assert output == expected_output, f"Output did not match expected:\n{output}"
+
+ def test_pretty_print_with_multiple_brackets(self, capsys: CaptureFixture[str]):
+ pretty_print(content="Union[str, List[int], Dict[str, Any]]", title="title")
+
+ captured = capsys.readouterr()
+ output = self.remove_ansi_escape_codes(captured.out)
+
+ expected_output = textwrap.dedent("""\
+ ╭─ title ───────────────────────────────╮
+ │ Union[str, List[int], Dict[str, Any]] │
+ ╰───────────────────────────────────────╯
+ """)
+
+ assert output == expected_output, f"Output did not match expected:\n{output}"
+
+ def test_pretty_print_with_special_chars_and_brackets(self, capsys: CaptureFixture[str]):
+ pretty_print(content="@decorator[*args, **kwargs]", title="title")
+
+ captured = capsys.readouterr()
+ output = self.remove_ansi_escape_codes(captured.out)
+
+ expected_output = textwrap.dedent("""\
+ ╭─ title ─────────────────────╮
+ │ @decorator[*args, **kwargs] │
+ ╰─────────────────────────────╯
+ """)
+
+ assert output == expected_output, f"Output did not match expected:\n{output}"
+
+ def test_pretty_print_with_empty_brackets(self, capsys: CaptureFixture[str]):
+ pretty_print(content="List[]", title="title")
+
+ captured = capsys.readouterr()
+ output = self.remove_ansi_escape_codes(captured.out)
+
+ expected_output = textwrap.dedent("""\
+ ╭─ title ─╮
+ │ List[] │
+ ╰─────────╯
+ """)
+
+ assert output == expected_output, f"Output did not match expected:\n{output}"
+
+ def test_pretty_print_with_unmatched_brackets(self, capsys: CaptureFixture[str]):
+ pretty_print(content="Unmatched[bracket", title="title")
+
+ captured = capsys.readouterr()
+ output = self.remove_ansi_escape_codes(captured.out)
+
+ expected_output = textwrap.dedent("""\
+ ╭─ title ───────────╮
+ │ Unmatched[bracket │
+ ╰───────────────────╯
+ """)
+
+ assert output == expected_output, f"Output did not match expected:\n{output}"
+
+ def test_pretty_print_with_unicode_and_brackets(self, capsys: CaptureFixture[str]):
+ pretty_print(content="🐍Python[版本3.11]", title="title")
+
+ captured = capsys.readouterr()
+ output = self.remove_ansi_escape_codes(captured.out)
+
+ expected_output = textwrap.dedent("""\
+ ╭─ title ────────────╮
+ │ 🐍Python[版本3.11] │
+ ╰────────────────────╯
+ """)
+
+ assert output == expected_output, f"Output did not match expected:\n{output}"
+
+ def test_pretty_print_pydantic_object(self, capsys: CaptureFixture[str]):
+ # Create a complex nested object
+ user = ComplexUser(
+ name="John Doe",
+ age=30,
+ addresses=[
+ Address(street="123 Main St", city="Springfield", country="USA", postal_code="12345"),
+ Address(street="456 Side St", city="Brooklyn", country="USA"),
+ ],
+ preferences=UserPreferences(theme="light", notifications=False, tags=["python", "coding"]),
+ metadata={"last_login": "2024-03-20", "login_count": 42, "is_active": True},
+ )
+
+ pretty_print(content=user, title="Complex User")
+
+ captured = capsys.readouterr()
+ output = self.remove_ansi_escape_codes(captured.out)
+
+ expected_output = textwrap.dedent("""\
+ ╭─ Complex User ──────────────────────────────────────────────────────────────────────────────────╮
+ │ ComplexUser( │
+ │ name='John Doe', │
+ │ age=30, │
+ │ email='[email protected]', │
+ │ addresses=[ │
+ │ Address(street='123 Main St', city='Springfield', country='USA', postal_code='12345'), │
+ │ Address(street='456 Side St', city='Brooklyn', country='USA', postal_code=None) │
+ │ ], │
+ │ preferences=UserPreferences( │
+ │ theme='light', │
+ │ notifications=False, │
+ │ tags=['python', 'coding'] │
+ │ ), │
+ │ metadata={'last_login': '2024-03-20', 'login_count': 42, 'is_active': True} │
+ │ ) │
+ ╰─────────────────────────────────────────────────────────────────────────────────────────────────╯
+ """)
+
+ assert output == expected_output, f"Make sure you enable pytest '-s' option. Output did not match expected:\n{output}"
diff --git a/tests/tools/basic/test_pydantic.py b/tests/tools/basic/test_pydantic.py
new file mode 100644
index 000000000..a8725a1c7
--- /dev/null
+++ b/tests/tools/basic/test_pydantic.py
@@ -0,0 +1,35 @@
+from typing import Any, Dict
+
+from pydantic import RootModel
+
+from pipelex import log
+
+MyDictType = Dict[str, Any]
+
+
+class MyRootModel(RootModel[MyDictType]):
+ def check(self):
+ if not self.root:
+ log.debug("self.root is empty")
+ log.debug(f"self.root.items(): {self.root.items()}")
+ log.debug(f"self.root: {self.root}")
+
+
+class TestPydantic:
+ def test_root_model(self):
+ my_root_model_1 = MyRootModel(root={"a": 1, "b": 2})
+ log.debug(my_root_model_1)
+ log.debug(f"my_root_model_1.root: {my_root_model_1.root}")
+
+ my_root_model_2 = MyRootModel(root={})
+ log.debug(my_root_model_2)
+ log.debug(f"my_root_model_2.root: {my_root_model_2.root}")
+ if not my_root_model_2.root:
+ log.debug("my_root_model_2.root is empty")
+
+ my_root_model_2.check()
+
+ def test_validate_root_model(self):
+ my_root_model_3_dict = {"root": {"a": 1, "b": 2}}
+ my_root_model_3 = MyRootModel.model_validate(my_root_model_3_dict)
+ log.debug(my_root_model_3)
diff --git a/tests/tools/basic/test_text.py b/tests/tools/basic/test_text.py
new file mode 100644
index 000000000..237cf5f3d
--- /dev/null
+++ b/tests/tools/basic/test_text.py
@@ -0,0 +1,19 @@
+import pytest
+
+from pipelex.tools.misc.string_utils import has_text
+
+
+ "case, expected",
+ [
+ ("!!!", False),
+ (" ", False),
+ ("Hello!", True),
+ ("123", True),
+ ("@#$%^", False),
+ ('" "', False),
+ ("```\n```", False),
+ ],
+)
+def test_has_text(case: str, expected: bool) -> None:
+ assert has_text(case) == expected, f"has_text('{case}') should be {expected}"
diff --git a/tests/tools/class_registry/test_class_registry.py b/tests/tools/class_registry/test_class_registry.py
new file mode 100644
index 000000000..780810abf
--- /dev/null
+++ b/tests/tools/class_registry/test_class_registry.py
@@ -0,0 +1,34 @@
+from typing import List
+
+import pytest
+from kajson.class_registry import class_registry
+
+from pipelex.core.stuff_content import StuffContent
+from tests.tools.test_data import ClassRegistryTestCases
+
+
+class TestClassRegistry:
+ @pytest.mark.asyncio
+ @pytest.mark.parametrize(
+ "folder, classes_to_register, classes_not_to_register",
+ [
+ (
+ ClassRegistryTestCases.MODEL_FOLDER_PATH,
+ ClassRegistryTestCases.CLASSES_TO_REGISTER,
+ ClassRegistryTestCases.CLASSES_NOT_TO_REGISTER,
+ ),
+ ],
+ )
+ async def test_register_classes_in_folder(
+ self,
+ folder: str,
+ classes_to_register: List[str],
+ classes_not_to_register: List[str],
+ ) -> None:
+ class_registry.register_classes_in_folder(folder_path=folder, base_class=StuffContent)
+
+ for class_name in classes_to_register:
+ assert class_registry.get_class(class_name) is not None
+
+ for class_name in classes_not_to_register:
+ assert class_registry.get_class(class_name) is None
diff --git a/tests/tools/data/images/white_square.png b/tests/tools/data/images/white_square.png
new file mode 100644
index 000000000..c2339c9c9
Binary files /dev/null and b/tests/tools/data/images/white_square.png differ
diff --git a/tests/tools/data/mock_folder_with_classes/subfolder/test_model_c.py b/tests/tools/data/mock_folder_with_classes/subfolder/test_model_c.py
new file mode 100644
index 000000000..b8e966651
--- /dev/null
+++ b/tests/tools/data/mock_folder_with_classes/subfolder/test_model_c.py
@@ -0,0 +1,7 @@
+from pipelex.core.stuff_content import StuffContent
+
+
+class Class3(StuffContent):
+ name: str
+ color: str
+ speed: int
diff --git a/tests/tools/data/mock_folder_with_classes/test_model_a.py b/tests/tools/data/mock_folder_with_classes/test_model_a.py
new file mode 100644
index 000000000..d1252e29d
--- /dev/null
+++ b/tests/tools/data/mock_folder_with_classes/test_model_a.py
@@ -0,0 +1,29 @@
+from pydantic import BaseModel
+
+from pipelex.core.stuff_content import StuffContent
+
+
+class ClassA(BaseModel):
+ name: str
+ color: str
+ speed: int
+ content: StuffContent
+
+
+class ClassB:
+ name: str
+ color: str
+ speed: int
+ content: StuffContent
+
+ def __init__(self, name: str, color: str, speed: int, content: StuffContent):
+ self.name = name
+ self.color = color
+ self.speed = speed
+ self.content = content
+
+
+class Class1(StuffContent):
+ name: str
+ color: str
+ speed: int
diff --git a/tests/tools/data/mock_folder_with_classes/test_model_b.py b/tests/tools/data/mock_folder_with_classes/test_model_b.py
new file mode 100644
index 000000000..e263e3f23
--- /dev/null
+++ b/tests/tools/data/mock_folder_with_classes/test_model_b.py
@@ -0,0 +1,13 @@
+from pipelex.core.stuff_content import StructuredContent, StuffContent
+
+
+class Class2(StuffContent):
+ name: str
+ color: str
+ speed: int
+
+
+class Class4(StructuredContent):
+ name: str
+ color: str
+ speed: int
diff --git a/tests/tools/misc/__init__.py b/tests/tools/misc/__init__.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/tests/tools/misc/__init__.py
@@ -0,0 +1 @@
+
diff --git a/tests/tools/misc/test_httpx_fetching.py b/tests/tools/misc/test_httpx_fetching.py
new file mode 100644
index 000000000..c9b4dcbe1
--- /dev/null
+++ b/tests/tools/misc/test_httpx_fetching.py
@@ -0,0 +1,33 @@
+import pytest
+
+from pipelex.tools.misc.file_fetch_utils import fetch_file_from_url_httpx, fetch_file_from_url_httpx_async
+from tests.tools.test_data import TestURLs
+
+
+class TestHttpxFetching:
+ @pytest.mark.asyncio
+ @pytest.mark.parametrize("url", TestURLs.PUBLIC_URLS)
+ async def test_fetch_file_from_url_httpx_async(
+ self,
+ url: str,
+ ) -> None:
+ assert (
+ await fetch_file_from_url_httpx_async(
+ url=url,
+ timeout=60,
+ )
+ is not None
+ )
+
+ @pytest.mark.parametrize("url", TestURLs.PUBLIC_URLS)
+ def test_fetch_file_from_url_httpx(
+ self,
+ url: str,
+ ) -> None:
+ assert (
+ fetch_file_from_url_httpx(
+ url=url,
+ timeout=60,
+ )
+ is not None
+ )
diff --git a/tests/tools/misc/test_markdown.py b/tests/tools/misc/test_markdown.py
new file mode 100644
index 000000000..ff04d563b
--- /dev/null
+++ b/tests/tools/misc/test_markdown.py
@@ -0,0 +1,35 @@
+from typing import Any, Dict, List
+
+from pydantic import BaseModel
+
+from pipelex.tools.misc.markdown_utils import convert_to_markdown
+
+
+class Article(BaseModel):
+ title: str
+ author: str
+ tags: List[str]
+ content: str
+ metadata: Dict[str, Any]
+
+
+def test_convert_md():
+ obj = Article(
+ title="My Awesome Article",
+ author="John Doe",
+ tags=["python", "markdown", "conversion"],
+ content="This is the first paragraph of the article.\n\nHere is another paragraph.",
+ metadata={
+ "published": True,
+ "views": 150,
+ "related_articles": [{"title": "Another Article", "author": "Jane Doe"}, {"title": "Yet Another Article", "author": "Alice"}],
+ },
+ )
+
+ json_data = obj.model_dump()
+ json_data_md = convert_to_markdown(json_data)
+ print(json_data_md)
+
+ # Convert that dictionary to Markdown
+ obj_md = convert_to_markdown(obj)
+ print(obj_md)
diff --git a/tests/tools/misc/test_model_helpers.py b/tests/tools/misc/test_model_helpers.py
new file mode 100644
index 000000000..d96b15eb3
--- /dev/null
+++ b/tests/tools/misc/test_model_helpers.py
@@ -0,0 +1,36 @@
+from typing import Any, Dict, cast
+
+from pydantic import BaseModel, Field
+
+from pipelex.tools.typing.pydantic_utils import ExtraFieldAttribute, serialize_model
+
+
+class ChildModel(BaseModel):
+ child_name: str
+ child_secret: str = Field(
+ ...,
+ json_schema_extra={ExtraFieldAttribute.IS_HIDDEN: True}, # This field should be hidden
+ )
+
+
+class ParentModel(BaseModel):
+ parent_name: str
+ child: ChildModel
+
+
+def test_serialize_model_with_hidden_fields():
+ # Create nested models
+ child = ChildModel(child_name="foo", child_secret="secret_foo")
+ parent = ParentModel(parent_name="bar", child=child)
+
+ # Test default model_dump() shows everything
+ model_dump_result: Dict[str, Any] = parent.model_dump()
+ child_dict = cast(Dict[str, Any], model_dump_result["child"])
+ assert "child_secret" in child_dict
+ assert child_dict["child_secret"] == "secret_foo"
+
+ # Test our custom serializer omits hidden fields (child_secret)
+ serialized_result = cast(Dict[str, Any], serialize_model(parent))
+ child_serialized = cast(Dict[str, Any], serialized_result["child"])
+ assert "child_secret" not in child_serialized
+ assert serialized_result == {"parent_name": "bar", "child": {"child_name": "foo"}}
diff --git a/tests/tools/test_aws.py b/tests/tools/test_aws.py
new file mode 100644
index 000000000..d85d16a47
--- /dev/null
+++ b/tests/tools/test_aws.py
@@ -0,0 +1,21 @@
+import pytest
+
+from pipelex.config import get_config
+from pipelex.tools.aws.aws_config import AwsKeyMethod
+
+
+# Not testing AwsKeyMethod.ENV because it's not supposed to work in the test environment.
+# @pytest.fixture(params=list(AwsKeyMethod))
[email protected](params=[AwsKeyMethod.SECRET_PROVIDER])
+def aws_key_method(request: pytest.FixtureRequest) -> AwsKeyMethod:
+ assert isinstance(request.param, AwsKeyMethod)
+ return request.param
+
+
+def test_get_aws_access_keys(aws_key_method: AwsKeyMethod):
+ aws_config = get_config().pipelex.aws_config
+ aws_access_key_id, aws_secret_access_key, aws_region = aws_config.get_aws_access_keys_with_method(api_key_method=aws_key_method)
+ assert aws_access_key_id
+ assert aws_secret_access_key
+ assert aws_region
diff --git a/tests/tools/test_class_structure.py b/tests/tools/test_class_structure.py
new file mode 100644
index 000000000..8bafed80f
--- /dev/null
+++ b/tests/tools/test_class_structure.py
@@ -0,0 +1,27 @@
+from pydantic import BaseModel
+
+from pipelex import pretty_print
+from pipelex.tools.typing.type_inspector import get_type_structure
+
+
+class Simple(BaseModel):
+ """A simple class that references itself."""
+
+ field_1: int
+ field_2: "Simple"
+
+
+def test_self_referencing_class_no_loop():
+ """Test that get_type_structure handles self-referencing classes without infinite loops."""
+ # Prepare test data
+ TestClass = Simple
+ TestClass.model_rebuild()
+
+ # Call the function
+ structure = get_type_structure(TestClass, base_class=BaseModel)
+ pretty_print(structure, title="Structure")
+
+ # Assert the result
+ assert len(structure) > 0, "Structure should not be empty"
+ assert structure.count("Class 'Simple':") == 1, "Class should only appear once"
+ assert any("field_2" in line and "Simple" in line for line in structure), "Structure should show next field with self-reference"
diff --git a/tests/tools/test_data.py b/tests/tools/test_data.py
new file mode 100644
index 000000000..adcd93905
--- /dev/null
+++ b/tests/tools/test_data.py
@@ -0,0 +1,29 @@
+from typing import ClassVar, List
+
+
+class TestURLs:
+ URL_GCP_PUBLIC = "https://storage.googleapis.com/public_test_files_7fa6_4277_9ab/diagrams/gantt_tree_house.png"
+ URL_WIKIPEDIA = "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Olympic_rings_on_the_Eiffel_Tower_2024_%2819%29.jpg/440px-Olympic_rings_on_the_Eiffel_Tower_2024_%2819%29.jpg"
+
+ PUBLIC_URLS: ClassVar[List[str]] = [
+ URL_GCP_PUBLIC,
+ URL_WIKIPEDIA,
+ ]
+
+
+class ClassRegistryTestCases:
+ MODEL_FOLDER_PATH = "tests/tools/data/mock_folder_with_classes"
+ CLASSES_TO_REGISTER: ClassVar[List[str]] = [
+ "Class1",
+ "Class2",
+ "Class3",
+ "Class4",
+ ]
+ CLASSES_NOT_TO_REGISTER: ClassVar[List[str]] = [
+ "ClassA",
+ "ClassB",
+ ]
+
+
+class FileHelperTestCases:
+ TEST_IMAGE = "tests/tools/data/images/white_square.png"
diff --git a/tests/tools/test_file_helpers.py b/tests/tools/test_file_helpers.py
new file mode 100644
index 000000000..fe82ef912
--- /dev/null
+++ b/tests/tools/test_file_helpers.py
@@ -0,0 +1,30 @@
+import base64
+
+import pytest
+
+from pipelex.tools.misc.base_64_utils import encode_to_base64_async, load_binary_as_base64_async
+from tests.tools.test_data import FileHelperTestCases
+
+
+async def test_load_image_as_base64_from_bytes_async():
+ # Prepare test data
+ with open(FileHelperTestCases.TEST_IMAGE, "rb") as image_file:
+ test_image_bytes = image_file.read()
+ expected_base64 = base64.b64encode(test_image_bytes)
+
+ # Call the function
+ result = await encode_to_base64_async(test_image_bytes)
+
+ # Assert the result
+ assert result == expected_base64
+ assert isinstance(result, bytes)
+
+
+async def test_load_image_as_base64_from_path_async():
+ # Call the function
+ result = await load_binary_as_base64_async(FileHelperTestCases.TEST_IMAGE)
+
+ # Assert that the result is bytes
+ assert isinstance(result, bytes)
diff --git a/tests/tools/test_jinja2.py b/tests/tools/test_jinja2.py
new file mode 100644
index 000000000..8f2e7a07d
--- /dev/null
+++ b/tests/tools/test_jinja2.py
@@ -0,0 +1,89 @@
+from typing import Any
+
+import pytest
+
+from pipelex import log, pretty_print
+from pipelex.hub import get_template_provider
+from pipelex.tools.templating.jinja2_rendering import render_jinja2
+from pipelex.tools.templating.jinja2_template_category import Jinja2TemplateCategory
+from pipelex.tools.templating.templating_models import PromptingStyle, TagStyle, TextFormat
+from tests.pipelex.test_data import Fruit, JINJA2TestCases
+
+PLACE_HOLDER = "place_holder"
+
+
[email protected](loop_scope="class")
+class TestRenderJinja2:
+ @pytest.mark.parametrize("jinja2_name", JINJA2TestCases.JINJA2_NAME)
+ @pytest.mark.parametrize("color", JINJA2TestCases.COLOR)
+ async def test_render_jinja2_name_from_text(self, jinja2_name: str, color: str):
+ temlating_context = {PLACE_HOLDER: color}
+ prompting_style = PromptingStyle(
+ tag_style=TagStyle.NO_TAG,
+ text_format=TextFormat.MARKDOWN,
+ )
+
+ jinja2_text: str = await render_jinja2(
+ template_category=Jinja2TemplateCategory.LLM_PROMPT,
+ template_provider=get_template_provider(),
+ temlating_context=temlating_context,
+ jinja2_name=jinja2_name,
+ jinja2=None,
+ prompting_style=prompting_style,
+ )
+ pretty_print(jinja2_text, title="jinja2_text")
+
+ @pytest.mark.parametrize("jinja2", JINJA2TestCases.JINJA2_FOR_ANY)
+ @pytest.mark.parametrize("color", JINJA2TestCases.COLOR)
+ async def test_render_jinja2_from_text(self, jinja2: str, color: str):
+ temlating_context = {PLACE_HOLDER: color}
+ prompting_style = PromptingStyle(
+ tag_style=TagStyle.NO_TAG,
+ text_format=TextFormat.MARKDOWN,
+ )
+
+ jinja2_text: str = await render_jinja2(
+ template_category=Jinja2TemplateCategory.LLM_PROMPT,
+ template_provider=get_template_provider(),
+ temlating_context=temlating_context,
+ jinja2_name=None,
+ jinja2=jinja2,
+ prompting_style=prompting_style,
+ )
+ pretty_print(jinja2_text, title="jinja2_text")
+
+ @pytest.mark.parametrize("jinja2", JINJA2TestCases.JINJA2_FOR_ANY)
+ @pytest.mark.parametrize("fruit", JINJA2TestCases.FRUIT)
+ async def test_render_jinja2_from_specific_object(self, jinja2: str, fruit: Fruit):
+ temlating_context = {PLACE_HOLDER: fruit}
+ prompting_style = PromptingStyle(
+ tag_style=TagStyle.NO_TAG,
+ text_format=TextFormat.MARKDOWN,
+ )
+
+ jinja2_text: str = await render_jinja2(
+ template_category=Jinja2TemplateCategory.LLM_PROMPT,
+ template_provider=get_template_provider(),
+ temlating_context=temlating_context,
+ jinja2_name=None,
+ jinja2=jinja2,
+ prompting_style=prompting_style,
+ )
+ pretty_print(jinja2_text, title="jinja2_text")
+
+ @pytest.mark.parametrize("jinja2", JINJA2TestCases.JINJA2_FOR_STUFF)
+ @pytest.mark.parametrize("prompting_style", JINJA2TestCases.STYLE)
+ @pytest.mark.parametrize("topic, any_object", JINJA2TestCases.ANY_OBJECT)
+ async def test_render_jinja2_from_any_object(self, jinja2: str, prompting_style: PromptingStyle, topic: str, any_object: Any):
+ temlating_context = {PLACE_HOLDER: any_object}
+ log.verbose(f"Rendering Jinja2 for '{topic}' with style '{prompting_style}'")
+ jinja2_text: str = await render_jinja2(
+ template_category=Jinja2TemplateCategory.LLM_PROMPT,
+ template_provider=get_template_provider(),
+ temlating_context=temlating_context,
+ jinja2_name=None,
+ jinja2=jinja2,
+ prompting_style=prompting_style,
+ )
+ log.verbose(f"Jinja2 rendered Jinja2 for '{topic}' with style '{prompting_style}':\n{jinja2_text}")
+ pretty_print(jinja2_text, title="jinja2_text")
diff --git a/tests/tools/test_pdf.py b/tests/tools/test_pdf.py
new file mode 100644
index 000000000..8e31425c4
--- /dev/null
+++ b/tests/tools/test_pdf.py
@@ -0,0 +1,12 @@
+import pytest
+
+from pipelex.tools.pdf.pypdfium2_renderer import pypdfium2_renderer
+from tests.test_data import PDFTestCases
+
+
[email protected](loop_scope="class")
+class TestPDF:
+ @pytest.mark.parametrize("file_path", PDFTestCases.DOCUMENT_FILE_PATHS)
+ async def test_pdf_path_to_images(self, file_path: str):
+ images = await pypdfium2_renderer.render_pdf_pages(file_path)
+ assert len(images) > 0
diff --git a/tests/tools/test_testing.py b/tests/tools/test_testing.py
new file mode 100644
index 000000000..71de983f1
--- /dev/null
+++ b/tests/tools/test_testing.py
@@ -0,0 +1,5 @@
+from pipelex.tools.runtime_manager import runtime_manager
+
+
+def test_testing():
+ assert runtime_manager.run_mode == "unit_test"
diff --git a/tests/tools/test_utilities.py b/tests/tools/test_utilities.py
new file mode 100644
index 000000000..a7741507b
--- /dev/null
+++ b/tests/tools/test_utilities.py
@@ -0,0 +1,24 @@
+import inspect
+
+from pipelex import pretty_print
+from pipelex.tools.config.manager import config_manager
+
+
+class TestUtilities:
+ def test_get_package_name_here_1(self):
+ frame = inspect.currentframe()
+ module = inspect.getmodule(frame)
+ assert module is not None
+ package_name = module.__name__.split(sep=".", maxsplit=1)[0]
+ pretty_print(package_name, title="package_name")
+ assert package_name == "tests"
+
+ def test_get_package_name_here_2(self):
+ """Get the name of the package containing this module."""
+ package_name = __name__.split(".", maxsplit=1)[0]
+ pretty_print(package_name, title="package_name")
+ assert package_name == "tests"
+
+ def test_get_project_name(self):
+ project_name = config_manager.get_project_name()
+ pretty_print(project_name, title="project_name")