Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
18 changes: 2 additions & 16 deletions apps/sim/app/api/tools/search/route.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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
Expand Down Expand Up @@ -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`)
Expand All @@ -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', {
Expand Down Expand Up @@ -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,
Expand All @@ -119,7 +106,6 @@ export async function POST(request: NextRequest) {
userId,
resultCount: results.length,
cost: cost.total,
isBYOK,
})

return NextResponse.json({
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/app/api/workspaces/[id]/byok-keys/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -47,8 +48,9 @@ export function ErrorUI({
</div>
</div>

{/* Panel */}
<Panel />
<ReactFlowProvider>
<Panel />
</ReactFlowProvider>
</div>
</div>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 (
<div className='flex items-center justify-between gap-[12px] rounded-[8px] border p-[12px]'>
<div className='flex items-center justify-between gap-[12px] rounded-[8px] p-[12px]'>
<div className='flex items-center gap-[12px]'>
<Skeleton className='h-[32px] w-[32px] rounded-[6px]' />
<div className='flex flex-col gap-[4px]'>
<Skeleton className='h-[16px] w-[80px]' />
<Skeleton className='h-[14px] w-[160px]' />
<Skeleton className='h-9 w-9 flex-shrink-0 rounded-[6px]' />
<div className='flex flex-col justify-center gap-[1px]'>
<Skeleton className='h-[14px] w-[100px]' />
<Skeleton className='h-[13px] w-[200px]' />
</div>
</div>
<Skeleton className='h-[32px] w-[80px] rounded-[6px]' />
<Skeleton className='h-[32px] w-[72px] rounded-[6px]' />
</div>
)
}
Expand Down Expand Up @@ -168,11 +161,11 @@ export function BYOK() {
return (
<div
key={provider.id}
className='flex items-center justify-between gap-[12px] rounded-[8px] border p-[12px]'
className='flex items-center justify-between gap-[12px] rounded-[8px] p-[12px]'
>
<div className='flex items-center gap-[12px]'>
<div className='flex h-[32px] w-[32px] items-center justify-center rounded-[6px] bg-[var(--surface-3)]'>
<Icon className='h-[18px] w-[18px]' />
<div className='flex h-9 w-9 flex-shrink-0 items-center justify-center overflow-hidden rounded-[6px] bg-[var(--surface-6)]'>
<Icon className='h-4 w-4' />
</div>
<div className='flex flex-col gap-[2px]'>
<span className='font-medium text-[14px]'>{provider.name}</span>
Expand Down
5 changes: 4 additions & 1 deletion apps/sim/app/workspace/[workspaceId]/w/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -69,7 +70,9 @@ export default function WorkflowsPage() {
}}
/>
</div>
<Panel />
<ReactFlowProvider>
<Panel />
</ReactFlowProvider>
</div>
<Terminal />
</div>
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/hooks/queries/byok-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/lib/api-key/byok.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion apps/sim/tools/search/tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export const searchTool: ToolConfig<SearchParams, SearchResponse> = {
}),
body: (params) => ({
query: params.query,
workspaceId: params._context?.workspaceId,
}),
},

Expand Down
5 changes: 0 additions & 5 deletions apps/sim/tools/search/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading