diff --git a/libs/partners/robocorp/tests/unit_tests/test_toolkits.py b/libs/partners/robocorp/tests/unit_tests/test_toolkits.py index cf8e63128f2..e7284de5d60 100644 --- a/libs/partners/robocorp/tests/unit_tests/test_toolkits.py +++ b/libs/partners/robocorp/tests/unit_tests/test_toolkits.py @@ -12,6 +12,10 @@ from langchain_core.utils.function_calling import ( from langchain_robocorp.toolkits import ActionServerToolkit from ._fixtures import FakeChatLLMT +from pydantic import __version__ + +# Get the version tuple (it may contain a suffix like 'rc1') +VERSION_TUPLE = tuple(int(x) if x.isdigit() else x for x in __version__.split(".")) def test_initialization() -> None: @@ -91,36 +95,60 @@ Strictly adhere to the schema.""" assert set(params["properties"].keys()) == {"sheet", "rows_to_add"} desc = "The columns that make up the row" - expected = { - "description": "the rows to be added to the sheet", - "allOf": [ - { - "title": "Rows To Add", - "type": "object", - "properties": { - "rows": { - "title": "Rows", - "description": "The rows that need to be added", - "type": "array", - "items": { - "title": "Row", - "type": "object", - "properties": { - "columns": { - "title": "Columns", - "description": desc, - "type": "array", - "items": {"type": "string"}, - } + + if VERSION_TUPLE < (2, 9): + expected = { + "description": "the rows to be added to the sheet", + "allOf": [ + { + "title": "Rows To Add", + "type": "object", + "properties": { + "rows": { + "title": "Rows", + "description": "The rows that need to be added", + "type": "array", + "items": { + "title": "Row", + "type": "object", + "properties": { + "columns": { + "title": "Columns", + "description": desc, + "type": "array", + "items": {"type": "string"}, + } + }, + "required": ["columns"], }, - "required": ["columns"], + } + }, + "required": ["rows"], + } + ], + } + else: + expected = { + "properties": { + "rows": { + "description": "The rows that need to be added", + "items": { + "properties": { + "columns": { + "description": "The columns that make up the row", + "items": {"type": "string"}, + "type": "array", + } }, - } - }, - "required": ["rows"], - } - ], - } + "required": ["columns"], + "type": "object", + }, + "type": "array", + } + }, + "required": ["rows"], + "type": "object", + } assert params["properties"]["rows_to_add"] == expected