Skip to content

Commit

Permalink
debug flag
Browse files Browse the repository at this point in the history
  • Loading branch information
toyamarinyon committed Oct 21, 2024
1 parent a6e8332 commit bfb2224
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export interface FeatureFlags {
uploadFileToPromptNodeFlag: boolean;
webSearchNodeFlag: boolean;
debugFlag: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type GiselleNodeProps = (GiselleNodeBlueprint | GiselleNodeType) & {
resultPortHandle?: FC<PortHandleProps>;
incomingConnections?: ConnectorObject[];
outgoingConnections?: ConnectorObject[];
debug?: boolean;
};

type TargetParameterProps = {
Expand Down Expand Up @@ -203,7 +204,7 @@ export function GiselleNode(props: GiselleNodeProps) {
</div>
</div>
</div>
{props.object === "node" && (
{props.debug && props.object === "node" && (
<div className="absolute top-[calc(100%+8px)] left-[8px] right-[8px] font-mono text-[8px] py-[4px] px-[8px] bg-black-100/30 border border-black-70 text-black--30">
<div className="flex flex-col gap-[4px]">
<div>Debug info</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
import clsx from "clsx/lite";
import type { FC } from "react";
import type { ConnectorObject } from "../connector/types";
import { useFeatureFlags } from "../feature-flags/context";
import { GiselleNode } from "../giselle-node/components";
import {
type GiselleNode as GiselleNodeType,
Expand All @@ -24,6 +25,7 @@ export type ReactFlowNode = Node<GiselleNodeType>;

export const ReactFlowNode: FC<NodeProps<ReactFlowNode>> = ({ data }) => {
const edges = useEdges<ReactFlowEdge>();
const { debugFlag } = useFeatureFlags();
return (
<GiselleNode
{...data}
Expand Down Expand Up @@ -52,6 +54,7 @@ export const ReactFlowNode: FC<NodeProps<ReactFlowNode>> = ({ data }) => {
.filter((edge) => edge.source === data.id)
.map((edge) => edge.data)
.filter((connector) => connector != null)}
debug={debugFlag}
/>
);
};
Expand Down
8 changes: 7 additions & 1 deletion app/(playground)/p/[agentId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import "@xyflow/react/dist/style.css";
import { getTeamMembershipByAgentId } from "@/app/(auth)/lib/get-team-membership-by-agent-id";
import { agents, db } from "@/drizzle";
import {
debugFlag as getDebugFlag,
uploadFileToPromptNodeFlag as getUploadFileToPromptNodeFlag,
webSearchNodeFlag as getWebSearchNodeFlag,
} from "@/flags";
Expand Down Expand Up @@ -32,14 +33,19 @@ export default async function AgentPlaygroundPage({

const uploadFileToPromptNodeFlag = await getUploadFileToPromptNodeFlag();
const webSearchNodeFlag = await getWebSearchNodeFlag();
const debugFlag = await getDebugFlag();

const agent = await getAgent(agentId);

return (
<Playground
agentId={agentId}
graph={agent.graphv2}
featureFlags={{ uploadFileToPromptNodeFlag, webSearchNodeFlag }}
featureFlags={{
uploadFileToPromptNodeFlag,
webSearchNodeFlag,
debugFlag,
}}
/>
);
}
13 changes: 13 additions & 0 deletions flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,16 @@ export const webSearchNodeFlag = flag<boolean>({
{ value: true, label: "Enable" },
],
});

export const debugFlag = flag<boolean>({
key: "debug",
async decide() {
return false;
},
description: "Enable debug mode",
defaultValue: false,
options: [
{ value: false, label: "disable" },
{ value: true, label: "Enable" },
],
});

0 comments on commit bfb2224

Please sign in to comment.