Skip to content
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

[Fix] Table output component for record type #753

Merged
merged 2 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading