stanfordnlp / dspy

DSPy: The framework for programming—not prompting—language models
https://dspy.ai
MIT License
19.37k stars 1.47k forks source link

chat_adapter: Format fields as JSON #1569

Closed tkellogg closed 1 month ago

tkellogg commented 1 month ago

When fields are Pydantic objects, the chat_adapter was formatting them as python code, which led to some strange behavior (BootstrapFewShot would start off with JSON and then revert to unparseable python code after it started adding examples).

I'm not sure if I put the tests in the right spot, but it seemed convenient to leverage situations that were already being created. I also did dataclasses since they were right there.