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
Update Chat Model Serialization #1226
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
bffc5d4
to
dbcfa2d
Compare
dbcfa2d
to
5c7efd3
Compare
export interface StoredMessage { | ||
type: string; | ||
role: string | undefined; | ||
text: string; | ||
data: StoredMessageData; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do feel like I'd rather shim this, mark it, then remove the shim when 1.0.0 comes out as a breaking change - I know all this is recent but have seen a few people using it already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jacoblee93 thoughts on the mapV1MessageToStoredMessage ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm for it! Just would add a comment saying to remove when ready to make a breaking change so we don't forget about it
c5deea2
to
a787a3a
Compare
export function mapStoredMessagesToChatMessages( | ||
messages: StoredMessage[] | ||
): BaseChatMessage[] { | ||
return messages.map((message) => { | ||
switch (message.type) { | ||
const stored_msg = mapV1MessageToStoredMessage(message); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Camel case to match JS variable name style
export function mapV1MessageToStoredMessage( | ||
message: StoredMessage | StoredMessageV1 | ||
): StoredMessage { | ||
if ("data" in message) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be some weird edge case where message has the data
property set but is undefined
- the more idiomatic way to do this in TS is (weirdly):
if (message.data !== undefined) {
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool thank you!
7069413
to
86b9091
Compare
Unify format with the python lib, which was defined of yore as