Skip to content

add some defaults to schema title if not explicitly annotated #26

@Lance-Drane

Description

@Lance-Drane

Request from iHub - we need to be able to reliably provide higher-level information for both humans and LLMs to be able to pick an endpoint to use.

Simple types will often not provide enough information in the schema by default, the SDK should correct this

In this example:

@intersect_message
def my_endpoint(self, temperature: int) -> int:
  ...

the generated schema for both input and output would simply look like this:

{
  "type": "integer"
}

The python code is valid and it should be supported for domain scientists to use this syntax. The high-level output name can generally be deduced from the function name, so we need to be able to be able to generate a schema which looks like this for the input:

{
  "type": "integer",
  "title": "temperature"
}

The ideal approach is to try to utilize Pydantic annotations to obtain this, and fall back to the parameter name if we can't get a Pydantic annotation.

NOTE

The following syntax is already supported by INTERSECT and will already work:

from typing import Annotated
from pydantic import Field
from intersect_sdk import intersect_message

def my_endpoint(self, ignored_parameter_name: Annotated[int, Field(title="temperature", description="longer description goes here")]) -> int:
  ...

This is the preferred way of defining "simple" endpoints for schema (and is necessary to add validation support), but we still want to provide support for the more straightforward way of writing Python functions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready_for_releaseIssue has been completed, but the resolution has not been pushed out to a release.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions