Skip to content

Generated type for tuples not compatible with OpenAI #97

Description

@rgbkrk

Example

from typing import Tuple, List

def color_shades(rgb_color: Tuple[int, int, int], num_shades: int) -> List[Tuple[int, int, int]]:
    """
    Generate a list of shades for a given RGB color.

    Args:
        rgb_color: A tuple of three integers representing an RGB color.
        num_shades: The number of shades to generate.

    Returns:
        A list of tuples, each containing three integers representing an RGB color.
    """
    shades = [
        (
            max(0, min(255, int(rgb_color[0] * (1 - j / num_shades)))),
            max(0, min(255, int(rgb_color[1] * (1 - j / num_shades)))),
            max(0, min(255, int(rgb_color[2] * (1 - j / num_shades)))),
        )
        for j in range(num_shades)
    ]
    return shades

from chatlab import Chat

chat = Chat(
    chat_functions=[color_shades]
)

await chat("Compute some shades of periwinkle.")
BadRequestError: Error code: 400 - {'error': {'message': "Invalid schema for function 'color_shades': [{'type': 'integer'}, {'type': 'integer'}, {'type': 'integer'}] is not of type 'object', 'boolean'", 'type': 'invalid_request_error', 'param': None, 'code': None}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions