Skip to content

Commit

Permalink
Fix autotype history fix (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
dqbd authored Oct 31, 2023
1 parent 9b8e9a4 commit 6e4967a
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,22 @@ export const chatMessagesTester = rankWith(
}

if ("anyOf" in schema.items && schema.items.anyOf != null) {
return schema.items.anyOf.every(
(schema) =>
return schema.items.anyOf.every((schema) => {
const isObjectMessage =
schema.type === "object" &&
(schema.title?.endsWith("Message") ||
schema.title?.endsWith("MessageChunk"))
);
schema.title?.endsWith("MessageChunk"));

const isTupleMessage =
schema.type === "array" &&
schema.minItems === 2 &&
schema.maxItems === 2 &&
Array.isArray(schema.items) &&
schema.items.length === 2 &&
schema.items.every((schema) => schema.type === "string");

return isObjectMessage || isTupleMessage;
});
}

return false;
Expand Down

0 comments on commit 6e4967a

Please sign in to comment.