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.

Concept definition

Louis Choquel3ae235b4eeda
diff --git a/docs/pages/build-reliable-ai-workflows-with-pipelex/define_your_concepts.md b/docs/pages/build-reliable-ai-workflows-with-pipelex/define_your_concepts.md
index c5201c47f..0beec74a0 100644
--- a/docs/pages/build-reliable-ai-workflows-with-pipelex/define_your_concepts.md
+++ b/docs/pages/build-reliable-ai-workflows-with-pipelex/define_your_concepts.md
@@ -198,15 +198,15 @@ Use the `refines` field to indicate when one concept is a more specific version
Document = "A written or printed record"
[concept.Contract]
-Concept = "A legally binding agreement between parties"
+definition = "A legally binding agreement between parties"
refines = "Document"
[concept.EmploymentContract]
-Concept = "A contract between an employer and employee"
+definition = "A contract between an employer and employee"
refines = "Contract"
[concept.NonCompeteClause]
-Concept = "A contract clause restricting competitive activities"
+definition = "A contract clause restricting competitive activities"
refines = "ContractClause"
```
@@ -238,15 +238,15 @@ domain = "content"
Text = "Written content in natural language"
[concept.Article]
-Concept = "A written composition on a specific topic"
+definition = "A written composition on a specific topic"
refines = "Text"
[concept.NewsArticle]
-Concept = "An article reporting current events"
+definition = "An article reporting current events"
refines = "Article"
[concept.OpinionPiece]
-Concept = "An article expressing personal views"
+definition = "An article expressing personal views"
refines = "Article"
[pipe.summarize_text]
diff --git a/pipelex/libraries/library_manager.py b/pipelex/libraries/library_manager.py
index 12adc0d48..d525d9ad4 100644
--- a/pipelex/libraries/library_manager.py
+++ b/pipelex/libraries/library_manager.py
@@ -240,13 +240,13 @@ class LibraryManager(LibraryManagerAbstract):
)
self.concept_library.add_new_concept(concept=concept_from_def)
else:
- # Complex dictionary blueprint - guaranteed by blueprint schema
- concept_from_dict = ConceptFactory.make_from_details_dict(
- domain_code=blueprint.domain,
+ # Complex ConceptBlueprint - guaranteed by blueprint schema
+ concept_from_blueprint = ConceptFactory.make_concept_from_blueprint(
+ domain=blueprint.domain,
code=concept_name,
- details_dict=concept_data,
+ concept_blueprint=concept_data,
)
- self.concept_library.add_new_concept(concept=concept_from_dict)
+ self.concept_library.add_new_concept(concept=concept_from_blueprint)
except ValidationError as exc:
error_msg = format_pydantic_validation_error(exc)
raise ConceptBlueprintError(
diff --git a/pipelex/libraries/pipeline_blueprint.py b/pipelex/libraries/pipeline_blueprint.py
index 186aba66a..b9370587d 100644
--- a/pipelex/libraries/pipeline_blueprint.py
+++ b/pipelex/libraries/pipeline_blueprint.py
@@ -3,6 +3,7 @@ from typing import Any, Dict, List, Optional, Union
from pydantic import BaseModel, Field
+from pipelex.core.concept_factory import ConceptBlueprint
from pipelex.exceptions import LibraryError
from pipelex.tools.misc.toml_utils import dict_to_toml_string, save_toml_to_path
@@ -52,7 +53,7 @@ class PipelineLibraryBlueprint(BaseModel):
prompt_template_to_structure: Optional[str] = None
# Concepts section - concept_name -> definition (string) or blueprint (dict)
- concept: Dict[str, Union[str, Dict[str, Any]]] = Field(default_factory=dict)
+ concept: Dict[str, Union[str, ConceptBlueprint]] = Field(default_factory=dict)
# Pipes section - pipe_name -> blueprint dict
pipe: Dict[str, Dict[str, Any]] = Field(default_factory=dict)
diff --git a/pipelex/libraries/pipelines/images.toml b/pipelex/libraries/pipelines/images.toml
index 073bbb575..f708d0e89 100644
--- a/pipelex/libraries/pipelines/images.toml
+++ b/pipelex/libraries/pipelines/images.toml
@@ -5,11 +5,11 @@ definition = "Generic image-related domain"
VisualDescription = "Visual description of something"
[concept.ImgGenPrompt]
-Concept = "Prompt to generate an image"
+definition = "Prompt to generate an image"
refines = "Text"
[concept.Photo]
-Concept = "Photo"
+definition = "Photo"
structure = "ImageContent"
refines = "Image"
diff --git a/tests/test_pipelines/concept_library/is_compatible_concept_code.toml b/tests/test_pipelines/concept_library/is_compatible_concept_code.toml
index c44da1afc..dd7d2f0ae 100644
--- a/tests/test_pipelines/concept_library/is_compatible_concept_code.toml
+++ b/tests/test_pipelines/concept_library/is_compatible_concept_code.toml
@@ -9,38 +9,38 @@ FundamentalsDoc = "A comprehensive overview of the fundamental concepts and prin
# Concept that explicitly refines Text
[concept.ExplicitTextConcept]
-Concept = "A concept that explicitly refines Text"
+definition = "A concept that explicitly refines Text"
refines = ["Text"]
# Concept that refines Image
[concept.ImageBasedConcept]
-Concept = "A concept based on images"
+definition = "A concept based on images"
refines = ["Image"]
# Concept that refines FundamentalsDoc
[concept.DocumentationConcept]
-Concept = "A specialized documentation concept"
+definition = "A specialized documentation concept"
structure = "DocumentationConcept"
refines = ["FundamentalsDoc"]
# Concept that refines both Text and Image (multiple inheritance)
[concept.MultiMediaConcept]
-Concept = "A concept that combines text and images"
+definition = "A concept that combines text and images"
structure = "MultiMediaConcept"
refines = ["Text", "Image"]
# Concept with custom structure that doesn't refine anything
[concept.IndependentConcept]
-Concept = "An independent concept with custom structure"
+definition = "An independent concept with custom structure"
structure = "IndependentConcept"
# Concept that refines a non-native concept
[concept.SpecializedDoc]
-Concept = "A specialized document that builds on FundamentalsDoc"
+definition = "A specialized document that builds on FundamentalsDoc"
refines = ["FundamentalsDoc"]
# Chain of inheritance: Text -> ExplicitTextConcept -> DerivedTextConcept
[concept.DerivedTextConcept]
-Concept = "A concept derived from ExplicitTextConcept"
+definition = "A concept derived from ExplicitTextConcept"
refines = ["ExplicitTextConcept"]
diff --git a/tests/test_pipelines/tricky_questions.toml b/tests/test_pipelines/tricky_questions.toml
index 9f1ecff97..f15dcd7e3 100644
--- a/tests/test_pipelines/tricky_questions.toml
+++ b/tests/test_pipelines/tricky_questions.toml
@@ -8,7 +8,7 @@ QuestionAnalysis = "Analysis of a question"
ThoughtfulAnswerConclusion = "Conclusion of a thoughtful answer"
[concept.ThoughtfulAnswer]
-Concept = "A thoughtful answer to a question"
+definition = "A thoughtful answer to a question"
structure = "ThoughtfulAnswer"
refines = "AnswerToAQuestion"