diff --git a/backend/packages/harness/deerflow/community/ragflow/tools.py b/backend/packages/harness/deerflow/community/ragflow/tools.py index 09b6e2ec98..d35328a7a0 100644 --- a/backend/packages/harness/deerflow/community/ragflow/tools.py +++ b/backend/packages/harness/deerflow/community/ragflow/tools.py @@ -337,15 +337,6 @@ async def resolve_ragflow_datasets( return await _resolve_datasets(client, settings, requested_dataset_ids) -def _group_searchable_datasets(datasets: list[_ResolvedDataset]) -> list[tuple[str, list[str]]]: - groups: dict[str, list[str]] = {} - for dataset in datasets: - if dataset.chunk_count == 0: - continue - groups.setdefault(dataset.embedding_model, []).append(dataset.dataset_id) - return sorted(groups.items()) - - async def _validate_document_filters( client: RAGFlowClient, document_filters: list[dict[str, Any]], diff --git a/frontend/package.json b/frontend/package.json index ae3c2aa917..4fc7ab9fe6 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -59,7 +59,6 @@ "@uiw/codemirror-theme-basic": "^4.25.4", "@uiw/codemirror-theme-monokai": "^4.25.4", "@uiw/react-codemirror": "^4.25.4", - "@xyflow/react": "^12.10.0", "ai": "^6.0.33", "best-effort-json-parser": "^1.2.1", "canvas-confetti": "^1.9.4", @@ -99,7 +98,6 @@ "sonner": "^2.0.7", "streamdown": "2.5.0", "tailwind-merge": "^3.4.0", - "tokenlens": "^1.3.1", "unist-util-visit": "^5.0.0", "use-stick-to-bottom": "^1.1.1", "uuid": "^14.0.0", diff --git a/frontend/pnpm-lock.yaml b/frontend/pnpm-lock.yaml index 8da3a8ec0f..350642abad 100644 --- a/frontend/pnpm-lock.yaml +++ b/frontend/pnpm-lock.yaml @@ -124,9 +124,6 @@ importers: '@uiw/react-codemirror': specifier: ^4.25.4 version: 4.25.4(@babel/runtime@7.28.6)(@codemirror/autocomplete@6.20.0)(@codemirror/language@6.12.1)(@codemirror/lint@6.9.3)(@codemirror/search@6.6.0)(@codemirror/state@6.5.4)(@codemirror/theme-one-dark@6.1.3)(@codemirror/view@6.39.13)(codemirror@6.0.2)(react-dom@19.2.4(react@19.2.4))(react@19.2.4) - '@xyflow/react': - specifier: ^12.10.0 - version: 12.10.0(@types/react@19.2.13)(react-dom@19.2.4(react@19.2.4))(react@19.2.4) ai: specifier: ^6.0.33 version: 6.0.78(zod@4.6.7) @@ -244,9 +241,6 @@ importers: tailwind-merge: specifier: ^3.4.0 version: 3.4.0 - tokenlens: - specifier: ^1.3.1 - version: 1.3.1 unist-util-visit: specifier: ^5.0.0 version: 5.1.0 @@ -2391,18 +2385,6 @@ packages: '@theguild/remark-npm2yarn@0.3.3': resolution: {integrity: sha512-ma6DvR03gdbvwqfKx1omqhg9May/VYGdMHvTzB4VuxkyS7KzfZ/lzrj43hmcsggpMje0x7SADA/pcMph0ejRnA==} - '@tokenlens/core@1.3.0': - resolution: {integrity: sha512-d8YNHNC+q10bVpi95fELJwJyPVf1HfvBEI18eFQxRSZTdByXrP+f/ZtlhSzkx0Jl0aEmYVeBA5tPeeYRioLViQ==} - - '@tokenlens/fetch@1.3.0': - resolution: {integrity: sha512-RONDRmETYly9xO8XMKblmrZjKSwCva4s5ebJwQNfNlChZoA5kplPoCgnWceHnn1J1iRjLVlrCNB43ichfmGBKQ==} - - '@tokenlens/helpers@1.3.1': - resolution: {integrity: sha512-t6yL8N6ES8337E6eVSeH4hCKnPdWkZRFpupy9w5E66Q9IeqQ9IO7XQ6gh12JKjvWiRHuyyJ8MBP5I549Cr41EQ==} - - '@tokenlens/models@1.3.0': - resolution: {integrity: sha512-9mx7ZGeewW4ndXAiD7AT1bbCk4OpJeortbjHHyNkgap+pMPPn1chY6R5zqe1ggXIUzZ2l8VOAKfPqOvpcrisJw==} - '@ts-morph/common@0.28.1': resolution: {integrity: sha512-W74iWf7ILp1ZKNYXY5qbddNaml7e9Sedv5lvU1V8lftlitkc9Pq1A+jlH23ltDgWYeZFFEqGCD1Ies9hqu3O+g==} @@ -2846,15 +2828,6 @@ packages: resolution: {integrity: sha512-5AXjrcMClTryPe9LgZrygpB1lj7s0S9E0+W+AHaVKAVyHanafK86iPSvG5xHVSp/jC+VH1UXu0TAEmY279xH7A==} engines: {node: '>=14.6'} - '@xyflow/react@12.10.0': - resolution: {integrity: sha512-eOtz3whDMWrB4KWVatIBrKuxECHqip6PfA8fTpaS2RUGVpiEAe+nqDKsLqkViVWxDGreq0lWX71Xth/SPAzXiw==} - peerDependencies: - react: '>=17' - react-dom: '>=17' - - '@xyflow/system@0.0.74': - resolution: {integrity: sha512-7v7B/PkiVrkdZzSbL+inGAo6tkR/WQHHG0/jhSvLQToCsfa8YubOGmBYd1s08tpKpihdHDZFwzQZeR69QSBb4Q==} - acorn-jsx@5.3.2: resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==} peerDependencies: @@ -3103,9 +3076,6 @@ packages: class-variance-authority@0.7.1: resolution: {integrity: sha512-Ka+9Trutv7G8M6WT6SeiRWz792K5qEqIGEGzXKhAE6xOWAY6pPH8U+9IY3oCMv6kqTmLsv7Xh/2w2RigkePMsg==} - classcat@5.0.5: - resolution: {integrity: sha512-JhZUT7JFcQy/EzW605k/ktHtncoo9vnyW/2GspNYwFlN1C/WmjuV/xtS04e9SOkL2sTdw0VAZ2UGCcQ9lR6p6w==} - client-only@0.0.1: resolution: {integrity: sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA==} @@ -5614,9 +5584,6 @@ packages: resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} engines: {node: '>=8.0'} - tokenlens@1.3.1: - resolution: {integrity: sha512-7oxmsS5PNCX3z+b+z07hL5vCzlgHKkCGrEQjQmWl5l+v5cUrtL7S1cuST4XThaL1XyjbTX8J5hfP0cjDJRkaLA==} - totalist@3.0.1: resolution: {integrity: sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==} engines: {node: '>=6'} @@ -6038,21 +6005,6 @@ packages: zod@4.6.7: resolution: {integrity: sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==} - zustand@4.5.7: - resolution: {integrity: sha512-CHOUy7mu3lbD6o6LJLfllpjkzhHXSBlX8B9+qPddUsIfeF5S/UZ5q0kmCsnRqT1UHFQZchNFDDzMbQsuesHWlw==} - engines: {node: '>=12.7.0'} - peerDependencies: - '@types/react': '>=16.8' - immer: '>=9.0.6' - react: '>=16.8' - peerDependenciesMeta: - '@types/react': - optional: true - immer: - optional: true - react: - optional: true - zustand@5.0.12: resolution: {integrity: sha512-i77ae3aZq4dhMlRhJVCYgMLKuSiZAaUPAct2AksxQ+gOtimhGMdXljRT21P5BNpeT4kXlLIckvkPM029OljD7g==} engines: {node: '>=12.20.0'} @@ -8103,21 +8055,6 @@ snapshots: npm-to-yarn: 3.0.1 unist-util-visit: 5.1.0 - '@tokenlens/core@1.3.0': {} - - '@tokenlens/fetch@1.3.0': - dependencies: - '@tokenlens/core': 1.3.0 - - '@tokenlens/helpers@1.3.1': - dependencies: - '@tokenlens/core': 1.3.0 - '@tokenlens/fetch': 1.3.0 - - '@tokenlens/models@1.3.0': - dependencies: - '@tokenlens/core': 1.3.0 - '@ts-morph/common@0.28.1': dependencies: minimatch: 10.2.5 @@ -8617,29 +8554,6 @@ snapshots: '@xmldom/xmldom@0.9.12': {} - '@xyflow/react@12.10.0(@types/react@19.2.13)(react-dom@19.2.4(react@19.2.4))(react@19.2.4)': - dependencies: - '@xyflow/system': 0.0.74 - classcat: 5.0.5 - react: 19.2.4 - react-dom: 19.2.4(react@19.2.4) - zustand: 4.5.7(@types/react@19.2.13)(react@19.2.4) - transitivePeerDependencies: - - '@types/react' - - immer - - '@xyflow/system@0.0.74': - dependencies: - '@types/d3-drag': 3.0.7 - '@types/d3-interpolate': 3.0.4 - '@types/d3-selection': 3.0.11 - '@types/d3-transition': 3.0.9 - '@types/d3-zoom': 3.0.8 - d3-drag: 3.0.0 - d3-interpolate: 3.0.1 - d3-selection: 3.0.0 - d3-zoom: 3.0.0 - acorn-jsx@5.3.2(acorn@8.15.0): dependencies: acorn: 8.15.0 @@ -8909,8 +8823,6 @@ snapshots: dependencies: clsx: 2.1.1 - classcat@5.0.5: {} - client-only@0.0.1: {} clipboardy@4.0.0: @@ -12244,13 +12156,6 @@ snapshots: dependencies: is-number: 7.0.0 - tokenlens@1.3.1: - dependencies: - '@tokenlens/core': 1.3.0 - '@tokenlens/fetch': 1.3.0 - '@tokenlens/helpers': 1.3.1 - '@tokenlens/models': 1.3.0 - totalist@3.0.1: {} trim-lines@3.0.1: {} @@ -12660,13 +12565,6 @@ snapshots: zod@4.6.7: {} - zustand@4.5.7(@types/react@19.2.13)(react@19.2.4): - dependencies: - use-sync-external-store: 1.6.0(react@19.2.4) - optionalDependencies: - '@types/react': 19.2.13 - react: 19.2.4 - zustand@5.0.12(@types/react@19.2.13)(react@19.2.4)(use-sync-external-store@1.6.0(react@19.2.4)): optionalDependencies: '@types/react': 19.2.13 diff --git a/frontend/src/components/ai-elements/canvas.tsx b/frontend/src/components/ai-elements/canvas.tsx deleted file mode 100644 index 5aa83cb5e7..0000000000 --- a/frontend/src/components/ai-elements/canvas.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import { Background, ReactFlow, type ReactFlowProps } from "@xyflow/react"; -import type { ReactNode } from "react"; -import "@xyflow/react/dist/style.css"; - -type CanvasProps = ReactFlowProps & { - children?: ReactNode; -}; - -export const Canvas = ({ children, ...props }: CanvasProps) => ( - - - {children} - -); diff --git a/frontend/src/components/ai-elements/checkpoint.tsx b/frontend/src/components/ai-elements/checkpoint.tsx deleted file mode 100644 index 6d912fec14..0000000000 --- a/frontend/src/components/ai-elements/checkpoint.tsx +++ /dev/null @@ -1,71 +0,0 @@ -"use client"; - -import { Button } from "@/components/ui/button"; -import { Separator } from "@/components/ui/separator"; -import { - Tooltip, - TooltipContent, - TooltipTrigger, -} from "@/components/ui/tooltip"; -import { cn } from "@/lib/utils"; -import { BookmarkIcon, type LucideProps } from "lucide-react"; -import type { ComponentProps, HTMLAttributes } from "react"; - -export type CheckpointProps = HTMLAttributes; - -export const Checkpoint = ({ - className, - children, - ...props -}: CheckpointProps) => ( - - {children} - - -); - -export type CheckpointIconProps = LucideProps; - -export const CheckpointIcon = ({ - className, - children, - ...props -}: CheckpointIconProps) => - children ?? ( - - ); - -export type CheckpointTriggerProps = ComponentProps & { - tooltip?: string; -}; - -export const CheckpointTrigger = ({ - children, - className, - variant = "ghost", - size = "sm", - tooltip, - ...props -}: CheckpointTriggerProps) => - tooltip ? ( - - - - {children} - - - - {tooltip} - - - ) : ( - - {children} - - ); diff --git a/frontend/src/components/ai-elements/connection.tsx b/frontend/src/components/ai-elements/connection.tsx deleted file mode 100644 index bb73356d67..0000000000 --- a/frontend/src/components/ai-elements/connection.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import type { ConnectionLineComponent } from "@xyflow/react"; - -const HALF = 0.5; - -export const Connection: ConnectionLineComponent = ({ - fromX, - fromY, - toX, - toY, -}) => ( - - - - -); diff --git a/frontend/src/components/ai-elements/context.tsx b/frontend/src/components/ai-elements/context.tsx deleted file mode 100644 index 7385d06839..0000000000 --- a/frontend/src/components/ai-elements/context.tsx +++ /dev/null @@ -1,408 +0,0 @@ -"use client"; - -import { Button } from "@/components/ui/button"; -import { - HoverCard, - HoverCardContent, - HoverCardTrigger, -} from "@/components/ui/hover-card"; -import { Progress } from "@/components/ui/progress"; -import { cn } from "@/lib/utils"; -import type { LanguageModelUsage } from "ai"; -import { type ComponentProps, createContext, useContext } from "react"; -import { getUsage } from "tokenlens"; - -const PERCENT_MAX = 100; -const ICON_RADIUS = 10; -const ICON_VIEWBOX = 24; -const ICON_CENTER = 12; -const ICON_STROKE_WIDTH = 2; - -type ModelId = string; - -type ContextSchema = { - usedTokens: number; - maxTokens: number; - usage?: LanguageModelUsage; - modelId?: ModelId; -}; - -const ContextContext = createContext(null); - -const useContextValue = () => { - const context = useContext(ContextContext); - - if (!context) { - throw new Error("Context components must be used within Context"); - } - - return context; -}; - -export type ContextProps = ComponentProps & ContextSchema; - -export const Context = ({ - usedTokens, - maxTokens, - usage, - modelId, - ...props -}: ContextProps) => ( - - - -); - -const ContextIcon = () => { - const { usedTokens, maxTokens } = useContextValue(); - const circumference = 2 * Math.PI * ICON_RADIUS; - const usedPercent = usedTokens / maxTokens; - const dashOffset = circumference * (1 - usedPercent); - - return ( - - - - - ); -}; - -export type ContextTriggerProps = ComponentProps; - -export const ContextTrigger = ({ children, ...props }: ContextTriggerProps) => { - const { usedTokens, maxTokens } = useContextValue(); - const usedPercent = usedTokens / maxTokens; - const renderedPercent = new Intl.NumberFormat("en-US", { - style: "percent", - maximumFractionDigits: 1, - }).format(usedPercent); - - return ( - - {children ?? ( - - - {renderedPercent} - - - - )} - - ); -}; - -export type ContextContentProps = ComponentProps; - -export const ContextContent = ({ - className, - ...props -}: ContextContentProps) => ( - -); - -export type ContextContentHeaderProps = ComponentProps<"div">; - -export const ContextContentHeader = ({ - children, - className, - ...props -}: ContextContentHeaderProps) => { - const { usedTokens, maxTokens } = useContextValue(); - const usedPercent = usedTokens / maxTokens; - const displayPct = new Intl.NumberFormat("en-US", { - style: "percent", - maximumFractionDigits: 1, - }).format(usedPercent); - const used = new Intl.NumberFormat("en-US", { - notation: "compact", - }).format(usedTokens); - const total = new Intl.NumberFormat("en-US", { - notation: "compact", - }).format(maxTokens); - - return ( - - {children ?? ( - <> - - {displayPct} - - {used} / {total} - - - - - - > - )} - - ); -}; - -export type ContextContentBodyProps = ComponentProps<"div">; - -export const ContextContentBody = ({ - children, - className, - ...props -}: ContextContentBodyProps) => ( - - {children} - -); - -export type ContextContentFooterProps = ComponentProps<"div">; - -export const ContextContentFooter = ({ - children, - className, - ...props -}: ContextContentFooterProps) => { - const { modelId, usage } = useContextValue(); - const costUSD = modelId - ? getUsage({ - modelId, - usage: { - input: usage?.inputTokens ?? 0, - output: usage?.outputTokens ?? 0, - }, - }).costUSD?.totalUSD - : undefined; - const totalCost = new Intl.NumberFormat("en-US", { - style: "currency", - currency: "USD", - }).format(costUSD ?? 0); - - return ( - - {children ?? ( - <> - Total cost - {totalCost} - > - )} - - ); -}; - -export type ContextInputUsageProps = ComponentProps<"div">; - -export const ContextInputUsage = ({ - className, - children, - ...props -}: ContextInputUsageProps) => { - const { usage, modelId } = useContextValue(); - const inputTokens = usage?.inputTokens ?? 0; - - if (children) { - return children; - } - - if (!inputTokens) { - return null; - } - - const inputCost = modelId - ? getUsage({ - modelId, - usage: { input: inputTokens, output: 0 }, - }).costUSD?.totalUSD - : undefined; - const inputCostText = new Intl.NumberFormat("en-US", { - style: "currency", - currency: "USD", - }).format(inputCost ?? 0); - - return ( - - Input - - - ); -}; - -export type ContextOutputUsageProps = ComponentProps<"div">; - -export const ContextOutputUsage = ({ - className, - children, - ...props -}: ContextOutputUsageProps) => { - const { usage, modelId } = useContextValue(); - const outputTokens = usage?.outputTokens ?? 0; - - if (children) { - return children; - } - - if (!outputTokens) { - return null; - } - - const outputCost = modelId - ? getUsage({ - modelId, - usage: { input: 0, output: outputTokens }, - }).costUSD?.totalUSD - : undefined; - const outputCostText = new Intl.NumberFormat("en-US", { - style: "currency", - currency: "USD", - }).format(outputCost ?? 0); - - return ( - - Output - - - ); -}; - -export type ContextReasoningUsageProps = ComponentProps<"div">; - -export const ContextReasoningUsage = ({ - className, - children, - ...props -}: ContextReasoningUsageProps) => { - const { usage, modelId } = useContextValue(); - const reasoningTokens = usage?.reasoningTokens ?? 0; - - if (children) { - return children; - } - - if (!reasoningTokens) { - return null; - } - - const reasoningCost = modelId - ? getUsage({ - modelId, - usage: { reasoningTokens }, - }).costUSD?.totalUSD - : undefined; - const reasoningCostText = new Intl.NumberFormat("en-US", { - style: "currency", - currency: "USD", - }).format(reasoningCost ?? 0); - - return ( - - Reasoning - - - ); -}; - -export type ContextCacheUsageProps = ComponentProps<"div">; - -export const ContextCacheUsage = ({ - className, - children, - ...props -}: ContextCacheUsageProps) => { - const { usage, modelId } = useContextValue(); - const cacheTokens = usage?.cachedInputTokens ?? 0; - - if (children) { - return children; - } - - if (!cacheTokens) { - return null; - } - - const cacheCost = modelId - ? getUsage({ - modelId, - usage: { cacheReads: cacheTokens, input: 0, output: 0 }, - }).costUSD?.totalUSD - : undefined; - const cacheCostText = new Intl.NumberFormat("en-US", { - style: "currency", - currency: "USD", - }).format(cacheCost ?? 0); - - return ( - - Cache - - - ); -}; - -const TokensWithCost = ({ - tokens, - costText, -}: { - tokens?: number; - costText?: string; -}) => ( - - {tokens === undefined - ? "—" - : new Intl.NumberFormat("en-US", { - notation: "compact", - }).format(tokens)} - {costText ? ( - • {costText} - ) : null} - -); diff --git a/frontend/src/components/ai-elements/controls.tsx b/frontend/src/components/ai-elements/controls.tsx deleted file mode 100644 index 0fd25629cb..0000000000 --- a/frontend/src/components/ai-elements/controls.tsx +++ /dev/null @@ -1,18 +0,0 @@ -"use client"; - -import { cn } from "@/lib/utils"; -import { Controls as ControlsPrimitive } from "@xyflow/react"; -import type { ComponentProps } from "react"; - -export type ControlsProps = ComponentProps; - -export const Controls = ({ className, ...props }: ControlsProps) => ( - button]:hover:bg-secondary! [&>button]:rounded-md [&>button]:border-none! [&>button]:bg-transparent!", - className, - )} - {...props} - /> -); diff --git a/frontend/src/components/ai-elements/edge.tsx b/frontend/src/components/ai-elements/edge.tsx deleted file mode 100644 index 17dfcebc18..0000000000 --- a/frontend/src/components/ai-elements/edge.tsx +++ /dev/null @@ -1,140 +0,0 @@ -import { - BaseEdge, - type EdgeProps, - getBezierPath, - getSimpleBezierPath, - type InternalNode, - type Node, - Position, - useInternalNode, -} from "@xyflow/react"; - -const Temporary = ({ - id, - sourceX, - sourceY, - targetX, - targetY, - sourcePosition, - targetPosition, -}: EdgeProps) => { - const [edgePath] = getSimpleBezierPath({ - sourceX, - sourceY, - sourcePosition, - targetX, - targetY, - targetPosition, - }); - - return ( - - ); -}; - -const getHandleCoordsByPosition = ( - node: InternalNode, - handlePosition: Position, -) => { - // Choose the handle type based on position - Left is for target, Right is for source - const handleType = handlePosition === Position.Left ? "target" : "source"; - - const handle = node.internals.handleBounds?.[handleType]?.find( - (h) => h.position === handlePosition, - ); - - if (!handle) { - return [0, 0] as const; - } - - let offsetX = handle.width / 2; - let offsetY = handle.height / 2; - - // this is a tiny detail to make the markerEnd of an edge visible. - // The handle position that gets calculated has the origin top-left, so depending which side we are using, we add a little offset - // when the handlePosition is Position.Right for example, we need to add an offset as big as the handle itself in order to get the correct position - switch (handlePosition) { - case Position.Left: - offsetX = 0; - break; - case Position.Right: - offsetX = handle.width; - break; - case Position.Top: - offsetY = 0; - break; - case Position.Bottom: - offsetY = handle.height; - break; - default: - throw new Error(`Invalid handle position: ${handlePosition}`); - } - - const x = node.internals.positionAbsolute.x + handle.x + offsetX; - const y = node.internals.positionAbsolute.y + handle.y + offsetY; - - return [x, y] as const; -}; - -const getEdgeParams = ( - source: InternalNode, - target: InternalNode, -) => { - const sourcePos = Position.Right; - const [sx, sy] = getHandleCoordsByPosition(source, sourcePos); - const targetPos = Position.Left; - const [tx, ty] = getHandleCoordsByPosition(target, targetPos); - - return { - sx, - sy, - tx, - ty, - sourcePos, - targetPos, - }; -}; - -const Animated = ({ id, source, target, markerEnd, style }: EdgeProps) => { - const sourceNode = useInternalNode(source); - const targetNode = useInternalNode(target); - - if (!(sourceNode && targetNode)) { - return null; - } - - const { sx, sy, tx, ty, sourcePos, targetPos } = getEdgeParams( - sourceNode, - targetNode, - ); - - const [edgePath] = getBezierPath({ - sourceX: sx, - sourceY: sy, - sourcePosition: sourcePos, - targetX: tx, - targetY: ty, - targetPosition: targetPos, - }); - - return ( - <> - - - - - > - ); -}; - -export const Edge = { - Temporary, - Animated, -}; diff --git a/frontend/src/components/ai-elements/image.tsx b/frontend/src/components/ai-elements/image.tsx deleted file mode 100644 index f79b55b64f..0000000000 --- a/frontend/src/components/ai-elements/image.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import { cn } from "@/lib/utils"; -import type { Experimental_GeneratedImage } from "ai"; - -export type ImageProps = Experimental_GeneratedImage & { - className?: string; - alt?: string; -}; - -export const Image = ({ - base64, - uint8Array, - mediaType, - ...props -}: ImageProps) => ( - -); diff --git a/frontend/src/components/ai-elements/node.tsx b/frontend/src/components/ai-elements/node.tsx deleted file mode 100644 index f329a8b381..0000000000 --- a/frontend/src/components/ai-elements/node.tsx +++ /dev/null @@ -1,71 +0,0 @@ -import { - Card, - CardAction, - CardContent, - CardDescription, - CardFooter, - CardHeader, - CardTitle, -} from "@/components/ui/card"; -import { cn } from "@/lib/utils"; -import { Handle, Position } from "@xyflow/react"; -import type { ComponentProps } from "react"; - -export type NodeProps = ComponentProps & { - handles: { - target: boolean; - source: boolean; - }; -}; - -export const Node = ({ handles, className, ...props }: NodeProps) => ( - - {handles.target && } - {handles.source && } - {props.children} - -); - -export type NodeHeaderProps = ComponentProps; - -export const NodeHeader = ({ className, ...props }: NodeHeaderProps) => ( - -); - -export type NodeTitleProps = ComponentProps; - -export const NodeTitle = (props: NodeTitleProps) => ; - -export type NodeDescriptionProps = ComponentProps; - -export const NodeDescription = (props: NodeDescriptionProps) => ( - -); - -export type NodeActionProps = ComponentProps; - -export const NodeAction = (props: NodeActionProps) => ; - -export type NodeContentProps = ComponentProps; - -export const NodeContent = ({ className, ...props }: NodeContentProps) => ( - -); - -export type NodeFooterProps = ComponentProps; - -export const NodeFooter = ({ className, ...props }: NodeFooterProps) => ( - -); diff --git a/frontend/src/components/ai-elements/open-in-chat.tsx b/frontend/src/components/ai-elements/open-in-chat.tsx deleted file mode 100644 index b86e93db51..0000000000 --- a/frontend/src/components/ai-elements/open-in-chat.tsx +++ /dev/null @@ -1,365 +0,0 @@ -"use client"; - -import { Button } from "@/components/ui/button"; -import { - DropdownMenu, - DropdownMenuContent, - DropdownMenuItem, - DropdownMenuLabel, - DropdownMenuSeparator, - DropdownMenuTrigger, -} from "@/components/ui/dropdown-menu"; -import { cn } from "@/lib/utils"; -import { - ChevronDownIcon, - ExternalLinkIcon, - MessageCircleIcon, -} from "lucide-react"; -import { type ComponentProps, createContext, useContext } from "react"; - -const providers = { - github: { - title: "Open in GitHub", - createUrl: (url: string) => url, - icon: ( - - GitHub - - - ), - }, - scira: { - title: "Open in Scira", - createUrl: (q: string) => - `https://scira.ai/?${new URLSearchParams({ - q, - })}`, - icon: ( - - Scira AI - - - - - - - - - ), - }, - chatgpt: { - title: "Open in ChatGPT", - createUrl: (prompt: string) => - `https://chatgpt.com/?${new URLSearchParams({ - hints: "search", - prompt, - })}`, - icon: ( - - OpenAI - - - ), - }, - claude: { - title: "Open in Claude", - createUrl: (q: string) => - `https://claude.ai/new?${new URLSearchParams({ - q, - })}`, - icon: ( - - Claude - - - ), - }, - t3: { - title: "Open in T3 Chat", - createUrl: (q: string) => - `https://t3.chat/new?${new URLSearchParams({ - q, - })}`, - icon: , - }, - v0: { - title: "Open in v0", - createUrl: (q: string) => - `https://v0.app?${new URLSearchParams({ - q, - })}`, - icon: ( - - v0 - - - - ), - }, - cursor: { - title: "Open in Cursor", - createUrl: (text: string) => { - const url = new URL("https://cursor.com/link/prompt"); - url.searchParams.set("text", text); - return url.toString(); - }, - icon: ( - - Cursor - - - ), - }, -}; - -const OpenInContext = createContext<{ query: string } | undefined>(undefined); - -const useOpenInContext = () => { - const context = useContext(OpenInContext); - if (!context) { - throw new Error("OpenIn components must be used within an OpenIn provider"); - } - return context; -}; - -export type OpenInProps = ComponentProps & { - query: string; -}; - -export const OpenIn = ({ query, ...props }: OpenInProps) => ( - - - -); - -export type OpenInContentProps = ComponentProps; - -export const OpenInContent = ({ className, ...props }: OpenInContentProps) => ( - -); - -export type OpenInItemProps = ComponentProps; - -export const OpenInItem = (props: OpenInItemProps) => ( - -); - -export type OpenInLabelProps = ComponentProps; - -export const OpenInLabel = (props: OpenInLabelProps) => ( - -); - -export type OpenInSeparatorProps = ComponentProps; - -export const OpenInSeparator = (props: OpenInSeparatorProps) => ( - -); - -export type OpenInTriggerProps = ComponentProps; - -export const OpenInTrigger = ({ children, ...props }: OpenInTriggerProps) => ( - - {children ?? ( - - Open in chat - - - )} - -); - -export type OpenInChatGPTProps = ComponentProps; - -export const OpenInChatGPT = (props: OpenInChatGPTProps) => { - const { query } = useOpenInContext(); - return ( - - - {providers.chatgpt.icon} - {providers.chatgpt.title} - - - - ); -}; - -export type OpenInClaudeProps = ComponentProps; - -export const OpenInClaude = (props: OpenInClaudeProps) => { - const { query } = useOpenInContext(); - return ( - - - {providers.claude.icon} - {providers.claude.title} - - - - ); -}; - -export type OpenInT3Props = ComponentProps; - -export const OpenInT3 = (props: OpenInT3Props) => { - const { query } = useOpenInContext(); - return ( - - - {providers.t3.icon} - {providers.t3.title} - - - - ); -}; - -export type OpenInSciraProps = ComponentProps; - -export const OpenInScira = (props: OpenInSciraProps) => { - const { query } = useOpenInContext(); - return ( - - - {providers.scira.icon} - {providers.scira.title} - - - - ); -}; - -export type OpenInv0Props = ComponentProps; - -export const OpenInv0 = (props: OpenInv0Props) => { - const { query } = useOpenInContext(); - return ( - - - {providers.v0.icon} - {providers.v0.title} - - - - ); -}; - -export type OpenInCursorProps = ComponentProps; - -export const OpenInCursor = (props: OpenInCursorProps) => { - const { query } = useOpenInContext(); - return ( - - - {providers.cursor.icon} - {providers.cursor.title} - - - - ); -}; diff --git a/frontend/src/components/ai-elements/panel.tsx b/frontend/src/components/ai-elements/panel.tsx deleted file mode 100644 index a0b8c1d72c..0000000000 --- a/frontend/src/components/ai-elements/panel.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import { cn } from "@/lib/utils"; -import { Panel as PanelPrimitive } from "@xyflow/react"; -import type { ComponentProps } from "react"; - -type PanelProps = ComponentProps; - -export const Panel = ({ className, ...props }: PanelProps) => ( - -); diff --git a/frontend/src/components/ai-elements/plan.tsx b/frontend/src/components/ai-elements/plan.tsx deleted file mode 100644 index be04d883be..0000000000 --- a/frontend/src/components/ai-elements/plan.tsx +++ /dev/null @@ -1,142 +0,0 @@ -"use client"; - -import { Button } from "@/components/ui/button"; -import { - Card, - CardAction, - CardContent, - CardDescription, - CardFooter, - CardHeader, - CardTitle, -} from "@/components/ui/card"; -import { - Collapsible, - CollapsibleContent, - CollapsibleTrigger, -} from "@/components/ui/collapsible"; -import { cn } from "@/lib/utils"; -import { ChevronsUpDownIcon } from "lucide-react"; -import type { ComponentProps } from "react"; -import { createContext, useContext } from "react"; -import { Shimmer } from "./shimmer"; - -type PlanContextValue = { - isStreaming: boolean; -}; - -const PlanContext = createContext(null); - -const usePlan = () => { - const context = useContext(PlanContext); - if (!context) { - throw new Error("Plan components must be used within Plan"); - } - return context; -}; - -export type PlanProps = ComponentProps & { - isStreaming?: boolean; -}; - -export const Plan = ({ - className, - isStreaming = false, - children, - ...props -}: PlanProps) => ( - - - {children} - - -); - -export type PlanHeaderProps = ComponentProps; - -export const PlanHeader = ({ className, ...props }: PlanHeaderProps) => ( - -); - -export type PlanTitleProps = Omit< - ComponentProps, - "children" -> & { - children: string; -}; - -export const PlanTitle = ({ children, ...props }: PlanTitleProps) => { - const { isStreaming } = usePlan(); - - return ( - - {isStreaming ? {children} : children} - - ); -}; - -export type PlanDescriptionProps = Omit< - ComponentProps, - "children" -> & { - children: string; -}; - -export const PlanDescription = ({ - className, - children, - ...props -}: PlanDescriptionProps) => { - const { isStreaming } = usePlan(); - - return ( - - {isStreaming ? {children} : children} - - ); -}; - -export type PlanActionProps = ComponentProps; - -export const PlanAction = (props: PlanActionProps) => ( - -); - -export type PlanContentProps = ComponentProps; - -export const PlanContent = (props: PlanContentProps) => ( - - - -); - -export type PlanFooterProps = ComponentProps<"div">; - -export const PlanFooter = (props: PlanFooterProps) => ( - -); - -export type PlanTriggerProps = ComponentProps; - -export const PlanTrigger = ({ className, ...props }: PlanTriggerProps) => ( - - - - Toggle plan - - -); diff --git a/frontend/src/components/ai-elements/sources.tsx b/frontend/src/components/ai-elements/sources.tsx deleted file mode 100644 index dd0aa623c5..0000000000 --- a/frontend/src/components/ai-elements/sources.tsx +++ /dev/null @@ -1,77 +0,0 @@ -"use client"; - -import { - Collapsible, - CollapsibleContent, - CollapsibleTrigger, -} from "@/components/ui/collapsible"; -import { cn } from "@/lib/utils"; -import { BookIcon, ChevronDownIcon } from "lucide-react"; -import type { ComponentProps } from "react"; - -export type SourcesProps = ComponentProps<"div">; - -export const Sources = ({ className, ...props }: SourcesProps) => ( - -); - -export type SourcesTriggerProps = ComponentProps & { - count: number; -}; - -export const SourcesTrigger = ({ - className, - count, - children, - ...props -}: SourcesTriggerProps) => ( - - {children ?? ( - <> - Used {count} sources - - > - )} - -); - -export type SourcesContentProps = ComponentProps; - -export const SourcesContent = ({ - className, - ...props -}: SourcesContentProps) => ( - -); - -export type SourceProps = ComponentProps<"a">; - -export const Source = ({ href, title, children, ...props }: SourceProps) => ( - - {children ?? ( - <> - - {title} - > - )} - -); diff --git a/frontend/src/components/ai-elements/toolbar.tsx b/frontend/src/components/ai-elements/toolbar.tsx deleted file mode 100644 index 1152a59dad..0000000000 --- a/frontend/src/components/ai-elements/toolbar.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import { cn } from "@/lib/utils"; -import { NodeToolbar, Position } from "@xyflow/react"; -import type { ComponentProps } from "react"; - -type ToolbarProps = ComponentProps; - -export const Toolbar = ({ className, ...props }: ToolbarProps) => ( - -); diff --git a/frontend/src/components/ai-elements/web-preview.tsx b/frontend/src/components/ai-elements/web-preview.tsx deleted file mode 100644 index a263fe0363..0000000000 --- a/frontend/src/components/ai-elements/web-preview.tsx +++ /dev/null @@ -1,263 +0,0 @@ -"use client"; - -import { Button } from "@/components/ui/button"; -import { - Collapsible, - CollapsibleContent, - CollapsibleTrigger, -} from "@/components/ui/collapsible"; -import { Input } from "@/components/ui/input"; -import { - Tooltip, - TooltipContent, - TooltipProvider, - TooltipTrigger, -} from "@/components/ui/tooltip"; -import { cn } from "@/lib/utils"; -import { ChevronDownIcon } from "lucide-react"; -import type { ComponentProps, ReactNode } from "react"; -import { createContext, useContext, useEffect, useState } from "react"; - -export type WebPreviewContextValue = { - url: string; - setUrl: (url: string) => void; - consoleOpen: boolean; - setConsoleOpen: (open: boolean) => void; -}; - -const WebPreviewContext = createContext(null); - -const useWebPreview = () => { - const context = useContext(WebPreviewContext); - if (!context) { - throw new Error("WebPreview components must be used within a WebPreview"); - } - return context; -}; - -export type WebPreviewProps = ComponentProps<"div"> & { - defaultUrl?: string; - onUrlChange?: (url: string) => void; -}; - -export const WebPreview = ({ - className, - children, - defaultUrl = "", - onUrlChange, - ...props -}: WebPreviewProps) => { - const [url, setUrl] = useState(defaultUrl); - const [consoleOpen, setConsoleOpen] = useState(false); - - const handleUrlChange = (newUrl: string) => { - setUrl(newUrl); - onUrlChange?.(newUrl); - }; - - const contextValue: WebPreviewContextValue = { - url, - setUrl: handleUrlChange, - consoleOpen, - setConsoleOpen, - }; - - return ( - - - {children} - - - ); -}; - -export type WebPreviewNavigationProps = ComponentProps<"div">; - -export const WebPreviewNavigation = ({ - className, - children, - ...props -}: WebPreviewNavigationProps) => ( - - {children} - -); - -export type WebPreviewNavigationButtonProps = ComponentProps & { - tooltip?: string; -}; - -export const WebPreviewNavigationButton = ({ - onClick, - disabled, - tooltip, - children, - ...props -}: WebPreviewNavigationButtonProps) => ( - - - - - {children} - - - - {tooltip} - - - -); - -export type WebPreviewUrlProps = ComponentProps; - -export const WebPreviewUrl = ({ - value, - onChange, - onKeyDown, - ...props -}: WebPreviewUrlProps) => { - const { url, setUrl } = useWebPreview(); - const [inputValue, setInputValue] = useState(url); - - // Sync input value with context URL when it changes externally - useEffect(() => { - setInputValue(url); - }, [url]); - - const handleChange = (event: React.ChangeEvent) => { - setInputValue(event.target.value); - onChange?.(event); - }; - - const handleKeyDown = (event: React.KeyboardEvent) => { - if (event.key === "Enter") { - const target = event.target as HTMLInputElement; - setUrl(target.value); - } - onKeyDown?.(event); - }; - - return ( - - ); -}; - -export type WebPreviewBodyProps = ComponentProps<"iframe"> & { - loading?: ReactNode; -}; - -export const WebPreviewBody = ({ - className, - loading, - src, - ...props -}: WebPreviewBodyProps) => { - const { url } = useWebPreview(); - - return ( - - - {loading} - - ); -}; - -export type WebPreviewConsoleProps = ComponentProps<"div"> & { - logs?: Array<{ - level: "log" | "warn" | "error"; - message: string; - timestamp: Date; - }>; -}; - -export const WebPreviewConsole = ({ - className, - logs = [], - children, - ...props -}: WebPreviewConsoleProps) => { - const { consoleOpen, setConsoleOpen } = useWebPreview(); - - return ( - - - - Console - - - - - - {logs.length === 0 ? ( - No console output - ) : ( - logs.map((log, index) => ( - - - {log.timestamp.toLocaleTimeString()} - {" "} - {log.message} - - )) - )} - {children} - - - - ); -};
{displayPct}
- {used} / {total} -
Used {count} sources
{tooltip}
No console output