Build AI methods with your coding agent, then run them anywhere: as an MCP for chatbots, as a webapp for people, or via API for your software.
feature/make-from-str-default-native-text (#78)
Thomas Hebrard377a89c78a8d
diff --git a/pipelex/core/stuff_factory.py b/pipelex/core/stuff_factory.pyindex a64b2e8bb..412eb28d8 100644--- a/pipelex/core/stuff_factory.py+++ b/pipelex/core/stuff_factory.py@@ -95,9 +95,9 @@ class StuffFactory:@classmethoddef make_from_str(cls,- concept_code: str,str_value: str,name: Optional[str] = None,+ concept_code: str = NativeConcept.TEXT.code,pipelex_session_id: Optional[str] = None,) -> Stuff:if not Concept.concept_str_contains_domain(concept_code):diff --git a/pipelex/pipe_operators/pipe_llm_prompt.py b/pipelex/pipe_operators/pipe_llm_prompt.pyindex 5191d7104..bcbd228e1 100644--- a/pipelex/pipe_operators/pipe_llm_prompt.py+++ b/pipelex/pipe_operators/pipe_llm_prompt.py@@ -234,6 +234,7 @@ class PipeLLMPrompt(PipeOperator):"You do NOT need to output a formatted JSON object, another LLM will take care of that. ""If you cannot find a value that is Optional, output None for that field.""However, you MUST clearly output the values for each of these fields in your response.\n---\n"+ "DO NOT create information. If the information is not present, output None.")return output_structure_promptdiff --git a/pipelex/tools/typing/type_inspector.py b/pipelex/tools/typing/type_inspector.pyindex 7f206447d..84a866320 100644--- a/pipelex/tools/typing/type_inspector.py+++ b/pipelex/tools/typing/type_inspector.py@@ -120,13 +120,19 @@ def get_type_structure(for arg in non_none:if isinstance(arg, type):collect_types(arg)+ elif hasattr(arg, "__origin__"): # Handle nested generics+ collect_types(arg)elif origin in (list, List):if isinstance(args[0], type):collect_types(args[0])+ elif hasattr(args[0], "__origin__"): # Handle nested generics+ collect_types(args[0])elif origin in (dict, Dict):for arg in args:if isinstance(arg, type):collect_types(arg)+ elif hasattr(arg, "__origin__"): # Handle nested generics+ collect_types(arg)return# Collect enumsdiff --git a/tests/tools/typing/test_type_inspector.py b/tests/tools/typing/test_type_inspector.pyindex 149f763d7..399c195d9 100644--- a/tests/tools/typing/test_type_inspector.py+++ b/tests/tools/typing/test_type_inspector.py@@ -1,6 +1,7 @@+from datetime import datetimefrom typing import List, Literal, Optional-from pydantic import BaseModel, Field+from pydantic import BaseModel, Field, field_validatorfrom pytest import FixtureRequestfrom pipelex.core.stuff_content import ListContent, StructuredContent, TextContent@@ -88,6 +89,38 @@ class ComplexListContent(ListContent[PersonContent]):items: List[PersonContent]+class GanttTaskDetails(StructuredContent):+ """Do not include timezone in the dates."""++ name: str+ start_date: Optional[datetime] = None+ end_date: Optional[datetime] = None++ @field_validator("start_date", "end_date")+ @classmethod+ def remove_tzinfo(cls, v: Optional[datetime]) -> Optional[datetime]:+ if v is not None:+ return v.replace(tzinfo=None)+ return v+++class Milestone(StructuredContent):+ name: str+ date: Optional[datetime]++ @field_validator("date")+ @classmethod+ def remove_tzinfo(cls, v: Optional[datetime]) -> Optional[datetime]:+ if v is not None:+ return v.replace(tzinfo=None)+ return v+++class GanttChart(StructuredContent):+ tasks: Optional[List[GanttTaskDetails]] = None+ milestones: Optional[List[Milestone]] = None++class TestTypeInspector:"""Tests for the type inspector functionality"""@@ -268,3 +301,24 @@ class TestTypeInspector:' WORLD = "world"',]assert result == expected, f"Expected:\n{''.join(expected)}\n\nGot:\n{''.join(result)}"++ def test_gantt_chart_content(self, request: FixtureRequest):+ """Test structure of Gantt chart content with datetime validators"""++ result = get_type_structure(GanttChart, base_class=StructuredContent)+ expected = [+ "class GanttChart(StructuredContent):",+ " tasks: Optional[List[GanttTaskDetails]] = None",+ " milestones: Optional[List[Milestone]] = None",+ "",+ "class GanttTaskDetails(StructuredContent):",+ ' """Do not include timezone in the dates."""',+ " name: str",+ " start_date: Optional[datetime] = None",+ " end_date: Optional[datetime] = None",+ "",+ "class Milestone(StructuredContent):",+ " name: str",+ " date: Optional[datetime] = None",+ ]+ assert result == expected, f"Expected:\n{''.join(expected)}\n\nGot:\n{''.join(result)}"