You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fromtypingimportTuple, Listdefcolor_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)))),
)
forjinrange(num_shades)
]
returnshadesfromchatlabimportChatchat=Chat(
chat_functions=[color_shades]
)
awaitchat("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}}
The text was updated successfully, but these errors were encountered:
rgbkrk
changed the title
Tuples not processable via OpenAI
Generated type for tuples not compatible with OpenAI
Oct 16, 2023
The easy solution is to switch this to accepting List[int]. Perhaps we just need to detect and knock tuples down to a list type with one inner type.
fromtypingimportTuple, Listdefcolor_shades(rgb_color: List[int], num_shades: int) ->List[Tuple[int, int, int]]:
""" Generate a list of shades for a given RGB color. Args: rgb_color: A list 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)))),
)
forjinrange(num_shades)
]
returnshades
Example
The text was updated successfully, but these errors were encountered: