mirascope
mirascope copied to clipboard
Add `ProviderChatMessage` e.g. `OpenAIChatMessage` types and coerce to message params under the hood
Add
ProviderChatMessage
e.g.OpenAIChatMessage
types and coerce to message params under the hood. If reading the OpenAI docs or coming from their SDK, users will expect to be able to insertresponse.message
into chat history. This is because OpenAI makes that work even though their typing doesn't match that. We should just allow for this insertion and under the hood convert any output pydantic models into their input typed dict counterparts. This way users don't have to learn the difference and mirascope just makes it easy.
@jbbakst I'm feeling less sold on this having implemented the message_param
given that using message_param
matches the typing of the SDK (even though it technically accepts the response message type) and provides a common interface across providers where sometimes you can't pass the message in directly.
Originally posted by @willbakst in https://github.com/Mirascope/mirascope/issues/264#issuecomment-2153663959