Skip to content

Commit

Permalink
fix: silence unknown part type errors (#229)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefl authored Oct 15, 2024
1 parent e9b02c6 commit 2e3e56b
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
PromptDocument,
StateDocument,
TextDocument,
UnknownDocument,
parseMessageParts,
} from "@oakai/aila/src/protocol/jsonPatchProtocol";
import { isSafe } from "@oakai/core/src/utils/ailaModeration/helpers";
Expand Down Expand Up @@ -234,10 +235,14 @@ function ChatMessagePart({
action: ActionMessagePart,
moderation: ModerationMessagePart,
id: IdMessagePart,
}[part.document.type];
unknown: UnknownMessagePart,
}[part.document.type] as React.ComponentType<{
part: typeof part.document;
moderationModalHelpers: ModerationModalHelpers;
}>;

if (!PartComponent) {
console.log("Unknown part type", part.document.type, part); // eslint-disable-line no-console
console.log("Unknown part type", part.document.type, JSON.stringify(part)); // eslint-disable-line no-console
return null;
}

Expand Down Expand Up @@ -311,6 +316,11 @@ function ActionMessagePart({
return null;
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
function UnknownMessagePart({ part }: Readonly<{ part: UnknownDocument }>) {
return null;
}

function PartInspector({ part }: Readonly<{ part: MessagePart }>) {
return (
<div className="w-full bg-gray-200 px-8 py-16">
Expand Down

0 comments on commit 2e3e56b

Please sign in to comment.