Skip to content

Add self-referencing properties field to Tool.Property #724

Description

@LinNan1

The Property class currently lacks a properties field, so it cannot represent nested object schemas.

File: ollama/_types.py

Change: Add a properties field to the Property class to enable recursive nesting.

class Property(SubscriptableBaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True)
type: Optional[Union[str, Sequence[str]]] = None
items: Optional[Any] = None
description: Optional[str] = None
enum: Optional[Sequence[Any]] = None
properties: Optional[Mapping[str, Property]] = None
parameters: Optional[Parameters] = None
function: Optional[Function] = None

      class Property(SubscriptableBaseModel):
        model_config = ConfigDict(arbitrary_types_allowed=True)

        type: Optional[Union[str, Sequence[str]]] = None
        items: Optional[Any] = None
        description: Optional[str] = None
        enum: Optional[Sequence[Any]] = None
+       properties: Optional[Mapping[str, 'Property']] = None

      properties: Optional[Mapping[str, Property]] = None

This enables arbitrary-depth nesting using Pydantic's forward reference. No breaking changes.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions