Skip to content

Commit

Permalink
[Fix] Table output component for record type (#753)
Browse files Browse the repository at this point in the history
fixed table output component for record type

Co-authored-by: vishnuszipstack <[email protected]>
  • Loading branch information
jagadeeswaran-zipstack and vishnuszipstack authored Sep 30, 2024
1 parent bac1a78 commit 175c288
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { SpinnerLoader } from "../../widgets/spinner-loader/SpinnerLoader";
import { TokenUsage } from "../token-usage/TokenUsage";
import { useWindowDimensions } from "../../../hooks/useWindowDimensions";
import { useCustomToolStore } from "../../../store/custom-tool-store";
import { TABLE_ENFORCE_TYPE } from "./constants";
import { TABLE_ENFORCE_TYPE, RECORD_ENFORCE_TYPE } from "./constants";
import { CopyPromptOutputBtn } from "./CopyPromptOutputBtn";
import { useAlertStore } from "../../../store/alert-store";
import { PromptOutputExpandBtn } from "./PromptOutputExpandBtn";
Expand Down Expand Up @@ -78,6 +78,8 @@ function PromptOutput({
} = useCustomToolStore();
const { setAlertDetails } = useAlertStore();
const { generatePromptOutputKey } = usePromptOutput();
const isTableExtraction =
enforceType === TABLE_ENFORCE_TYPE || enforceType === RECORD_ENFORCE_TYPE;

const tooltipContent = (adapterConf) => (
<div>
Expand All @@ -100,7 +102,7 @@ function PromptOutput({
const getColSpan = () => (componentWidth < 1200 ? 24 : 6);

const copyOutputToClipboard = (text) => {
if (!text || text === "undefined" || enforceType === TABLE_ENFORCE_TYPE) {
if (!text || text === "undefined" || isTableExtraction) {
return;
}

Expand Down Expand Up @@ -152,7 +154,7 @@ function PromptOutput({
)}
<div className="prompt-profile-run">
<CopyPromptOutputBtn
isDisabled={enforceType === TABLE_ENFORCE_TYPE}
isDisabled={isTableExtraction}
copyToClipboard={() =>
copyOutputToClipboard(displayPromptResult(promptOutput, true))
}
Expand Down Expand Up @@ -323,7 +325,7 @@ function PromptOutput({
<>
<Divider className="prompt-card-divider" />
<div className={"prompt-card-result prompt-card-div"}>
{enforceType === TABLE_ENFORCE_TYPE ? (
{isTableExtraction ? (
<div />
) : (
<>
Expand Down Expand Up @@ -374,7 +376,7 @@ function PromptOutput({
</Button>
</Tooltip>
<CopyPromptOutputBtn
isDisabled={enforceType === TABLE_ENFORCE_TYPE}
isDisabled={isTableExtraction}
copyToClipboard={() =>
copyOutputToClipboard(
displayPromptResult(promptOutputData?.output, true)
Expand All @@ -390,7 +392,7 @@ function PromptOutput({
/>
</div>
</div>
{enforceType === TABLE_ENFORCE_TYPE && TableOutput && (
{isTableExtraction && TableOutput && (
<TableOutput output={promptOutputData?.output} />
)}
</>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Col, Image, Modal, Row, Typography } from "antd";
import PropTypes from "prop-types";

import { DisplayPromptResult } from "./DisplayPromptResult";
import { TABLE_ENFORCE_TYPE } from "./constants";
import { TABLE_ENFORCE_TYPE, RECORD_ENFORCE_TYPE } from "./constants";
import SpaceWrapper from "../../widgets/space-wrapper/SpaceWrapper";
import { useCustomToolStore } from "../../../store/custom-tool-store";
import usePromptOutput from "../../../hooks/usePromptOutput";
Expand Down Expand Up @@ -78,7 +79,9 @@ function PromptOutputsModal({
)}
</div>
<div className="flex-1 overflow-y-auto pad-top-10">
{enforceType === TABLE_ENFORCE_TYPE && TableOutput ? (
{(enforceType === TABLE_ENFORCE_TYPE ||
enforceType === RECORD_ENFORCE_TYPE) &&
TableOutput ? (
<TableOutput
output={promptOutputData?.output}
pagination={10}
Expand Down

0 comments on commit 175c288

Please sign in to comment.