letta-ai / letta

Letta (formerly MemGPT) is a framework for creating LLM services with memory.
https://letta.com
Apache License 2.0
13.05k stars 1.43k forks source link

Python type list[dict] has no corresponding JSON schema type #2116

Open lemorage opened 1 day ago

lemorage commented 1 day ago

Describe the bug I wrote a tool that has the following function signature def weekly_report_typesetting_print(self: "Agent", weekly_report_data: list[dict]) -> str:, but after I registered this tool to an agent and started the program, I got the error Failed to execute source code: Python type list[dict] has no corresponding JSON schema type. I changed the type annotation to list, but it still failed.

I think the problem is due to the mappings in type_to_json_schema_type here. It only specifies List[str]: "array" and List[int]: "array". Can we add more mappings?

Please describe your setup

cpacker commented 1 day ago

Thanks @lemorage , this should be patched in #2117 (will merge in soon)

However if possible I'd recommend using stronger types than dict (for example a Pydantic model), since you won't be able to use structured outputs w/ dict (though e.g. List[str] would work)

lemorage commented 19 hours ago

Cool! I see, thanks for the amazing job!