From 66766a9d81dcb209731f85e30fc9dc5eb28ae8cd Mon Sep 17 00:00:00 2001 From: Vikhyath Mondreti Date: Wed, 24 Dec 2025 19:26:48 -0800 Subject: [PATCH] improvement(byok): remove web search block exa (#2579) * remove exa from byok * improvement(byok): remove web search block exa * fix autolayout * fix type --- apps/sim/app/api/tools/search/route.ts | 18 ++----------- .../api/workspaces/[id]/byok-keys/route.ts | 2 +- .../w/[workflowId]/components/error/index.tsx | 6 +++-- .../w/[workflowId]/hooks/use-auto-layout.ts | 8 +++--- .../settings-modal/components/byok/byok.tsx | 27 +++++++------------ .../app/workspace/[workspaceId]/w/page.tsx | 5 +++- apps/sim/hooks/queries/byok-keys.ts | 2 +- apps/sim/lib/api-key/byok.ts | 2 +- apps/sim/tools/search/tool.ts | 1 - apps/sim/tools/search/types.ts | 5 ---- 10 files changed, 28 insertions(+), 48 deletions(-) diff --git a/apps/sim/app/api/tools/search/route.ts b/apps/sim/app/api/tools/search/route.ts index e09f66e5c..52fffc61b 100644 --- a/apps/sim/app/api/tools/search/route.ts +++ b/apps/sim/app/api/tools/search/route.ts @@ -1,6 +1,5 @@ import { type NextRequest, NextResponse } from 'next/server' import { z } from 'zod' -import { getBYOKKey } from '@/lib/api-key/byok' import { checkHybridAuth } from '@/lib/auth/hybrid' import { SEARCH_TOOL_COST } from '@/lib/billing/constants' import { env } from '@/lib/core/config/env' @@ -11,7 +10,6 @@ const logger = createLogger('search') const SearchRequestSchema = z.object({ query: z.string().min(1), - workspaceId: z.string().optional(), }) export const maxDuration = 60 @@ -41,17 +39,7 @@ export async function POST(request: NextRequest) { const body = await request.json() const validated = SearchRequestSchema.parse(body) - let exaApiKey = env.EXA_API_KEY - let isBYOK = false - - if (validated.workspaceId) { - const byokResult = await getBYOKKey(validated.workspaceId, 'exa') - if (byokResult) { - exaApiKey = byokResult.apiKey - isBYOK = true - logger.info(`[${requestId}] Using workspace BYOK key for Exa search`) - } - } + const exaApiKey = env.EXA_API_KEY if (!exaApiKey) { logger.error(`[${requestId}] No Exa API key available`) @@ -64,7 +52,6 @@ export async function POST(request: NextRequest) { logger.info(`[${requestId}] Executing search`, { userId, query: validated.query, - isBYOK, }) const result = await executeTool('exa_search', { @@ -100,7 +87,7 @@ export async function POST(request: NextRequest) { const cost = { input: 0, output: 0, - total: isBYOK ? 0 : SEARCH_TOOL_COST, + total: SEARCH_TOOL_COST, tokens: { input: 0, output: 0, @@ -119,7 +106,6 @@ export async function POST(request: NextRequest) { userId, resultCount: results.length, cost: cost.total, - isBYOK, }) return NextResponse.json({ diff --git a/apps/sim/app/api/workspaces/[id]/byok-keys/route.ts b/apps/sim/app/api/workspaces/[id]/byok-keys/route.ts index 424e17d8e..f2e9a031f 100644 --- a/apps/sim/app/api/workspaces/[id]/byok-keys/route.ts +++ b/apps/sim/app/api/workspaces/[id]/byok-keys/route.ts @@ -12,7 +12,7 @@ import { getUserEntityPermissions } from '@/lib/workspaces/permissions/utils' const logger = createLogger('WorkspaceBYOKKeysAPI') -const VALID_PROVIDERS = ['openai', 'anthropic', 'google', 'mistral', 'exa'] as const +const VALID_PROVIDERS = ['openai', 'anthropic', 'google', 'mistral'] as const const UpsertKeySchema = z.object({ providerId: z.enum(VALID_PROVIDERS), diff --git a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/error/index.tsx b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/error/index.tsx index fb7f29269..8b99955a1 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/error/index.tsx +++ b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/error/index.tsx @@ -1,6 +1,7 @@ 'use client' import { Component, type ReactNode, useEffect } from 'react' +import { ReactFlowProvider } from 'reactflow' import { createLogger } from '@/lib/logs/console/logger' import { Panel } from '@/app/workspace/[workspaceId]/w/[workflowId]/components' import { Sidebar } from '@/app/workspace/[workspaceId]/w/components/sidebar/sidebar' @@ -47,8 +48,9 @@ export function ErrorUI({ - {/* Panel */} - + + + ) diff --git a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-auto-layout.ts b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-auto-layout.ts index beb110853..98b338d2a 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-auto-layout.ts +++ b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-auto-layout.ts @@ -9,9 +9,11 @@ export type { AutoLayoutOptions } const logger = createLogger('useAutoLayout') /** - * Hook providing auto-layout functionality for workflows - * Binds workflowId context and provides memoized callback for React components - * Includes automatic fitView animation after successful layout + * Hook providing auto-layout functionality for workflows. + * Binds workflowId context and provides memoized callback for React components. + * Includes automatic fitView animation after successful layout. + * + * Note: This hook requires a ReactFlowProvider ancestor. */ export function useAutoLayout(workflowId: string | null) { const { fitView } = useReactFlow() diff --git a/apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/settings-modal/components/byok/byok.tsx b/apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/settings-modal/components/byok/byok.tsx index beb650155..81b6cbf9e 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/settings-modal/components/byok/byok.tsx +++ b/apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/settings-modal/components/byok/byok.tsx @@ -13,7 +13,7 @@ import { ModalHeader, Trash, } from '@/components/emcn' -import { AnthropicIcon, ExaAIIcon, GeminiIcon, MistralIcon, OpenAIIcon } from '@/components/icons' +import { AnthropicIcon, GeminiIcon, MistralIcon, OpenAIIcon } from '@/components/icons' import { Skeleton } from '@/components/ui' import { createLogger } from '@/lib/logs/console/logger' import { @@ -61,26 +61,19 @@ const PROVIDERS: { description: 'LLM calls and Knowledge Base OCR', placeholder: 'Enter your API key', }, - { - id: 'exa', - name: 'Exa', - icon: ExaAIIcon, - description: 'Web Search block', - placeholder: 'Enter your API key', - }, ] function BYOKKeySkeleton() { return ( -
+
- -
- - + +
+ +
- +
) } @@ -168,11 +161,11 @@ export function BYOK() { return (
-
- +
+
{provider.name} diff --git a/apps/sim/app/workspace/[workspaceId]/w/page.tsx b/apps/sim/app/workspace/[workspaceId]/w/page.tsx index 93288d107..5ab1a636f 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/page.tsx +++ b/apps/sim/app/workspace/[workspaceId]/w/page.tsx @@ -2,6 +2,7 @@ import { useEffect, useState } from 'react' import { useParams, useRouter } from 'next/navigation' +import { ReactFlowProvider } from 'reactflow' import { createLogger } from '@/lib/logs/console/logger' import { Panel, Terminal } from '@/app/workspace/[workspaceId]/w/[workflowId]/components' import { useWorkflows } from '@/hooks/queries/workflows' @@ -69,7 +70,9 @@ export default function WorkflowsPage() { }} />
- + + +
diff --git a/apps/sim/hooks/queries/byok-keys.ts b/apps/sim/hooks/queries/byok-keys.ts index 42c29b13d..487b9a28f 100644 --- a/apps/sim/hooks/queries/byok-keys.ts +++ b/apps/sim/hooks/queries/byok-keys.ts @@ -4,7 +4,7 @@ import { API_ENDPOINTS } from '@/stores/constants' const logger = createLogger('BYOKKeysQueries') -export type BYOKProviderId = 'openai' | 'anthropic' | 'google' | 'mistral' | 'exa' +export type BYOKProviderId = 'openai' | 'anthropic' | 'google' | 'mistral' export interface BYOKKey { id: string diff --git a/apps/sim/lib/api-key/byok.ts b/apps/sim/lib/api-key/byok.ts index 4e8ba3529..1483b0974 100644 --- a/apps/sim/lib/api-key/byok.ts +++ b/apps/sim/lib/api-key/byok.ts @@ -6,7 +6,7 @@ import { createLogger } from '@/lib/logs/console/logger' const logger = createLogger('BYOKKeys') -export type BYOKProviderId = 'openai' | 'anthropic' | 'google' | 'mistral' | 'exa' +export type BYOKProviderId = 'openai' | 'anthropic' | 'google' | 'mistral' export interface BYOKKeyResult { apiKey: string diff --git a/apps/sim/tools/search/tool.ts b/apps/sim/tools/search/tool.ts index 5495e6292..4f6f9e3a5 100644 --- a/apps/sim/tools/search/tool.ts +++ b/apps/sim/tools/search/tool.ts @@ -25,7 +25,6 @@ export const searchTool: ToolConfig = { }), body: (params) => ({ query: params.query, - workspaceId: params._context?.workspaceId, }), }, diff --git a/apps/sim/tools/search/types.ts b/apps/sim/tools/search/types.ts index e23309ee0..73bfe038c 100644 --- a/apps/sim/tools/search/types.ts +++ b/apps/sim/tools/search/types.ts @@ -2,11 +2,6 @@ import type { ToolResponse } from '@/tools/types' export interface SearchParams { query: string - _context?: { - workflowId?: string - workspaceId?: string - executionId?: string - } } export interface SearchResponse extends ToolResponse {