Skip to content

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Fix union types

haxziec70a09e64be1
diff --git a/python/composio/utils/shared.py b/python/composio/utils/shared.py
index 9922a2b21..6a1cfd2a1 100644
--- a/python/composio/utils/shared.py
+++ b/python/composio/utils/shared.py
@@ -58,17 +58,8 @@ def json_schema_to_pydantic_type(
]
if len(pydantic_types) == 1:
return pydantic_types[0]
- if len(pydantic_types) == 2:
- return t.Union[
- t.cast(t.Type, pydantic_types[0]), t.cast(t.Type, pydantic_types[1])
- ]
- if len(pydantic_types) == 3:
- return t.Union[
- t.cast(t.Type, pydantic_types[0]),
- t.cast(t.Type, pydantic_types[1]),
- t.cast(t.Type, pydantic_types[2]),
- ]
- raise ValueError("Invalid 'oneOf' schema")
+ # Create Union with any number of types
+ return t.Union[tuple(t.cast(t.Type, ptype) for ptype in pydantic_types)]
# Add fallback type - string
if "type" not in json_schema: