Skip to content

Commit 4dcc934

Browse files
committed
Fix web search: pass api key through
1 parent 4eb2191 commit 4dcc934

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

packages/agent-runtime/src/llm-api/codebuff-web-api.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { withTimeout } from '@codebuff/common/util/promise'
22
import { env } from '@codebuff/common/env'
3-
43
import type { Logger } from '@codebuff/common/types/contracts/logger'
54

65
const FETCH_TIMEOUT_MS = 30_000
@@ -68,7 +67,8 @@ export async function callWebSearchAPI(params: {
6867
if (data && typeof data.result === 'string') {
6968
return {
7069
result: data.result,
71-
creditsUsed: typeof data.creditsUsed === 'number' ? data.creditsUsed : undefined,
70+
creditsUsed:
71+
typeof data.creditsUsed === 'number' ? data.creditsUsed : undefined,
7272
}
7373
}
7474
if (data && typeof data.error === 'string') return { error: data.error }
@@ -154,7 +154,8 @@ export async function callDocsSearchAPI(params: {
154154
if (data && typeof data.documentation === 'string') {
155155
return {
156156
documentation: data.documentation,
157-
creditsUsed: typeof data.creditsUsed === 'number' ? data.creditsUsed : undefined,
157+
creditsUsed:
158+
typeof data.creditsUsed === 'number' ? data.creditsUsed : undefined,
158159
}
159160
}
160161
if (data && typeof data.error === 'string') return { error: data.error }

packages/agent-runtime/src/tools/handlers/handler-function-type.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export type CodebuffToolHandlerFunction<T extends ToolName = ToolName> = (
3030
repoUrl: string | undefined
3131
repoId: string | undefined
3232
fileContext: ProjectFileContext
33+
apiKey: string
3334

3435
signal: AbortSignal
3536

packages/agent-runtime/src/tools/handlers/tool/web-search.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const handleWebSearch = ((params: {
1212
previousToolCallFinished: Promise<void>
1313
toolCall: CodebuffToolCall<'web_search'>
1414
logger: Logger
15+
apiKey: string
1516

1617
agentStepId: string
1718
clientSessionId: string
@@ -36,6 +37,7 @@ export const handleWebSearch = ((params: {
3637
repoUrl,
3738
state,
3839
fetch,
40+
apiKey
3941
} = params
4042
const { query, depth } = toolCall.input
4143
const { userId, fingerprintId, repoId } = state
@@ -63,6 +65,7 @@ export const handleWebSearch = ((params: {
6365
repoUrl: repoUrl ?? null,
6466
fetch,
6567
logger,
68+
apiKey
6669
})
6770

6871
if (webApi.error) {

0 commit comments

Comments
 (0)