Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid schema error with complex types #946

Open
3 tasks done
oohmygaud opened this issue Jun 28, 2024 · 2 comments
Open
3 tasks done

Invalid schema error with complex types #946

oohmygaud opened this issue Jun 28, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@oohmygaud
Copy link

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

@oohmygaud oohmygaud added the bug Something isn't working label Jun 28, 2024
@zzstoatzz
Copy link
Collaborator

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)

@andehr
Copy link
Contributor

andehr commented Jul 31, 2024

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants