mirascope icon indicating copy to clipboard operation
mirascope copied to clipboard

Add `ProviderChatMessage` e.g. `OpenAIChatMessage` types and coerce to message params under the hood

Open willbakst opened this issue 8 months ago • 9 comments

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 insert response.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

willbakst avatar Jun 07 '24 15:06 willbakst