PrefectHQ/marvin

Invalid schema error with complex types

oohmygaud opened this issue · 2 comments

First check

  • I added a descriptive title to this issue.
  • I used the GitHub search to try to find a similar issue and didn't find one.
  • I searched the Marvin documentation for this issue.

Bug summary

I encountered an error while working with complex types - it seems that using nested types with lists will break the schema. Including the ComplexType causes an error response "Invalid schema for function".

Reproduction

from pydantic import BaseModel
from typing import List

class SimpleType(BaseModel):
    name: str
    value: str

class ComplexType(BaseModel):
    name: str
    value: List[SimpleType]

class MarvinParseResult(BaseModel):
    simple_type: SimpleType
    complex_type: ComplexType # Comment this out and it passes

Error

'Error code: 400 - {\'error\': {\'message\': "Invalid schema for function \'FormatResponse\'. Please ensure it is a valid JSON Schema.", \'type\': \'invalid_request_error\', \'param\': \'tools[0].function.parameters\', \'code\': \'invalid_function_parameters\'}}

Versions

Version:		2.3.3
Python version:		3.10.12
OS/Arch:		linux/x86_64

Additional context

No response

hi @oohmygaud - thank you for the issue!

can you provide the code and input arguments you used when you got your traceback? (e.g. calling ai.fn or extract)

Hi @zzstoatzz & @oohmygaud , in case useful - I can replicate this same error with your code plus this:

import marvin
results = marvin.generate(target=MarvinParseResult, n=2)