mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-07 22:24:06 -05:00
improvement(byok): remove web search block exa (#2579)
* remove exa from byok * improvement(byok): remove web search block exa * fix autolayout * fix type
This commit is contained in:
committed by
GitHub
parent
47a259b428
commit
66766a9d81
@@ -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({
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Panel */}
|
||||
<Panel />
|
||||
<ReactFlowProvider>
|
||||
<Panel />
|
||||
</ReactFlowProvider>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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 (
|
||||
<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>
|
||||
)
|
||||
}
|
||||
@@ -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>
|
||||
|
||||
@@ -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() {
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<Panel />
|
||||
<ReactFlowProvider>
|
||||
<Panel />
|
||||
</ReactFlowProvider>
|
||||
</div>
|
||||
<Terminal />
|
||||
</div>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -25,7 +25,6 @@ export const searchTool: ToolConfig<SearchParams, SearchResponse> = {
|
||||
}),
|
||||
body: (params) => ({
|
||||
query: params.query,
|
||||
workspaceId: params._context?.workspaceId,
|
||||
}),
|
||||
},
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user