Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions sdks/langchain/src/toolbox_langchain_sdk/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Optional, Type
from typing import Any, Optional, Type, cast

import yaml
from aiohttp import ClientSession
Expand Down Expand Up @@ -51,10 +51,13 @@ def _schema_to_model(model_name: str, schema: list[ParameterSchema]) -> Type[Bas
"""
field_definitions = {}
for field in schema:
field_definitions[field.name] = (
# TODO: Remove the hardcoded optional types once optional fields are supported by Toolbox.
Optional[_parse_type(field.type)],
Field(description=field.description),
field_definitions[field.name] = cast(
Any,
(
# TODO: Remove the hardcoded optional types once optional fields are supported by Toolbox.
Optional[_parse_type(field.type)],
Field(description=field.description),
),
)

return create_model(model_name, **field_definitions)
Expand Down
13 changes: 8 additions & 5 deletions sdks/llamaindex/src/toolbox_llamaindex_sdk/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Optional, Type
from typing import Any, Optional, Type, cast

import yaml
from aiohttp import ClientSession
Expand Down Expand Up @@ -51,10 +51,13 @@ def _schema_to_model(model_name: str, schema: list[ParameterSchema]) -> Type[Bas
"""
field_definitions = {}
for field in schema:
field_definitions[field.name] = (
# TODO: Remove the hardcoded optional types once optional fields are supported by Toolbox.
Optional[_parse_type(field.type)],
Field(description=field.description),
field_definitions[field.name] = cast(
Any,
(
# TODO: Remove the hardcoded optional types once optional fields are supported by Toolbox.
Optional[_parse_type(field.type)],
Field(description=field.description),
),
)

return create_model(model_name, **field_definitions)
Expand Down