mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-17 22:05:50 +00:00
fix: 修复类型问题
This commit is contained in:
@@ -14,6 +14,7 @@ import {
|
||||
normalizeContentFromAPI,
|
||||
normalizeMessagesForAPI,
|
||||
} from '../../../utils/messages.js'
|
||||
import type { SDKAssistantMessageError } from '../../../entrypoints/agentSdkTypes.js'
|
||||
import type { SystemPrompt } from '../../../utils/systemPromptType.js'
|
||||
import type { ThinkingConfig } from '../../../utils/thinking.js'
|
||||
import type { Options } from '../claude.js'
|
||||
@@ -186,7 +187,7 @@ export async function* queryModelGemini(
|
||||
yield createAssistantAPIErrorMessage({
|
||||
content: `API Error: ${errorMessage}`,
|
||||
apiError: 'api_error',
|
||||
error: (error instanceof Error ? error : new Error(String(error))) as Error,
|
||||
error: (error instanceof Error ? error : new Error(String(error))) as unknown as SDKAssistantMessageError,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ export function getGrokClient(options?: {
|
||||
maxRetries: options?.maxRetries ?? 0,
|
||||
timeout: parseInt(process.env.API_TIMEOUT_MS || String(600 * 1000), 10),
|
||||
dangerouslyAllowBrowser: true,
|
||||
fetchOptions: getProxyFetchOptions({ forAnthropicAPI: false }) as RequestInit,
|
||||
fetchOptions: getProxyFetchOptions({ forAnthropicAPI: false }),
|
||||
...(options?.fetchOverride && { fetch: options.fetchOverride }),
|
||||
})
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import { anthropicToolsToOpenAI, anthropicToolChoiceToOpenAI } from '../openai/c
|
||||
import { adaptOpenAIStreamToAnthropic } from '../openai/streamAdapter.js'
|
||||
import { resolveGrokModel } from './modelMapping.js'
|
||||
import { normalizeMessagesForAPI } from '../../../utils/messages.js'
|
||||
import type { SDKAssistantMessageError } from '../../../entrypoints/agentSdkTypes.js'
|
||||
import { toolToAPISchema } from '../../../utils/api.js'
|
||||
import { logForDebugging } from '../../../utils/debug.js'
|
||||
import { addToTotalSessionCost } from '../../../cost-tracker.js'
|
||||
@@ -190,7 +191,7 @@ export async function* queryModelGrok(
|
||||
yield createAssistantAPIErrorMessage({
|
||||
content: `API Error: ${errorMessage}`,
|
||||
apiError: 'api_error',
|
||||
error: (error instanceof Error ? error : new Error(String(error))) as Error,
|
||||
error: (error instanceof Error ? error : new Error(String(error))) as unknown as SDKAssistantMessageError,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ describe('buildOpenAIRequestBody — thinking params', () => {
|
||||
messages: [{ role: 'user', content: 'hello' }],
|
||||
tools: [] as any[],
|
||||
toolChoice: undefined as any,
|
||||
}
|
||||
} as any
|
||||
|
||||
test('includes official DeepSeek API thinking format when enabled', () => {
|
||||
const body = buildOpenAIRequestBody({ ...baseParams, enableThinking: true })
|
||||
|
||||
@@ -31,7 +31,7 @@ export function getOpenAIClient(options?: {
|
||||
dangerouslyAllowBrowser: true,
|
||||
...(process.env.OPENAI_ORG_ID && { organization: process.env.OPENAI_ORG_ID }),
|
||||
...(process.env.OPENAI_PROJECT_ID && { project: process.env.OPENAI_PROJECT_ID }),
|
||||
fetchOptions: getProxyFetchOptions({ forAnthropicAPI: false }) as RequestInit,
|
||||
fetchOptions: getProxyFetchOptions({ forAnthropicAPI: false }),
|
||||
...(options?.fetchOverride && { fetch: options.fetchOverride }),
|
||||
})
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ import {
|
||||
createAssistantAPIErrorMessage,
|
||||
normalizeContentFromAPI,
|
||||
} from '../../../utils/messages.js'
|
||||
import type { SDKAssistantMessageError } from '../../../entrypoints/agentSdkTypes.js'
|
||||
import {
|
||||
isToolSearchEnabled,
|
||||
extractDiscoveredToolNames,
|
||||
@@ -87,7 +88,11 @@ export function buildOpenAIRequestBody(params: {
|
||||
toolChoice: any
|
||||
enableThinking: boolean
|
||||
temperatureOverride?: number
|
||||
}): ChatCompletionCreateParamsStreaming {
|
||||
}): ChatCompletionCreateParamsStreaming & {
|
||||
thinking?: { type: string }
|
||||
enable_thinking?: boolean
|
||||
chat_template_kwargs?: { thinking: boolean }
|
||||
} {
|
||||
const { model, messages, tools, toolChoice, enableThinking, temperatureOverride } = params
|
||||
return {
|
||||
model,
|
||||
@@ -220,7 +225,7 @@ export async function* queryModelOpenAI(
|
||||
// 10. Get client and make streaming request
|
||||
const client = getOpenAIClient({
|
||||
maxRetries: 0,
|
||||
fetchOverride: options.fetchOverride,
|
||||
fetchOverride: options.fetchOverride as unknown as typeof fetch,
|
||||
source: options.querySource,
|
||||
})
|
||||
|
||||
@@ -354,7 +359,7 @@ export async function* queryModelOpenAI(
|
||||
yield createAssistantAPIErrorMessage({
|
||||
content: `API Error: ${errorMessage}`,
|
||||
apiError: 'api_error',
|
||||
error: (error instanceof Error ? error : new Error(String(error))) as Error,
|
||||
error: (error instanceof Error ? error : new Error(String(error))) as unknown as SDKAssistantMessageError,
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user