mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-17 22:05:50 +00:00
style: 完成所有文件的lint
This commit is contained in:
@@ -15,9 +15,18 @@ import { logEvent } from '../services/analytics/index.js'
|
||||
import type { AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS } from '../services/analytics/metadata.js'
|
||||
import { getAPIMetadata } from '../services/api/claude.js'
|
||||
import { getAnthropicClient } from '../services/api/client.js'
|
||||
import { createTrace, createChildSpan, endTrace, recordLLMObservation } from '../services/langfuse/index.js'
|
||||
import {
|
||||
createTrace,
|
||||
createChildSpan,
|
||||
endTrace,
|
||||
recordLLMObservation,
|
||||
} from '../services/langfuse/index.js'
|
||||
import type { LangfuseSpan } from '../services/langfuse/index.js'
|
||||
import { convertMessagesToLangfuse, convertOutputToLangfuse, convertToolsToLangfuse } from '../services/langfuse/convert.js'
|
||||
import {
|
||||
convertMessagesToLangfuse,
|
||||
convertOutputToLangfuse,
|
||||
convertToolsToLangfuse,
|
||||
} from '../services/langfuse/convert.js'
|
||||
import { getModelBetas, modelSupportsStructuredOutputs } from './betas.js'
|
||||
import { logForDebugging } from './debug.js'
|
||||
import { errorMessage } from './errors.js'
|
||||
@@ -245,7 +254,11 @@ export async function sideQuery(opts: SideQueryOptions): Promise<BetaMessage> {
|
||||
{ signal },
|
||||
)
|
||||
} catch (error) {
|
||||
endTrace(langfuseTrace, { error: errorMessage(error) }, opts.optional ? 'interrupted' : 'error')
|
||||
endTrace(
|
||||
langfuseTrace,
|
||||
{ error: errorMessage(error) },
|
||||
opts.optional ? 'interrupted' : 'error',
|
||||
)
|
||||
throw error
|
||||
}
|
||||
|
||||
@@ -273,33 +286,43 @@ export async function sideQuery(opts: SideQueryOptions): Promise<BetaMessage> {
|
||||
// Record LLM observation in Langfuse (no-op if not configured).
|
||||
// Wrap SDK types into the internal message format expected by converters.
|
||||
const wrappedInput = messages.map(m => ({
|
||||
type: m.role === 'assistant' ? 'assistant' as const : 'user' as const,
|
||||
type: m.role === 'assistant' ? ('assistant' as const) : ('user' as const),
|
||||
message: { role: m.role, content: m.content },
|
||||
})) as unknown as Parameters<typeof convertMessagesToLangfuse>[0]
|
||||
const wrappedOutput = [{
|
||||
type: 'assistant' as const,
|
||||
message: { role: 'assistant' as const, content: response.content },
|
||||
}] as unknown as Parameters<typeof convertOutputToLangfuse>[0]
|
||||
const wrappedOutput = [
|
||||
{
|
||||
type: 'assistant' as const,
|
||||
message: { role: 'assistant' as const, content: response.content },
|
||||
},
|
||||
] as unknown as Parameters<typeof convertOutputToLangfuse>[0]
|
||||
recordLLMObservation(langfuseTrace, {
|
||||
model: normalizedModel,
|
||||
provider,
|
||||
input: convertMessagesToLangfuse(wrappedInput, systemBlocks.length > 0 ? systemBlocks.map(b => b.text) : undefined),
|
||||
input: convertMessagesToLangfuse(
|
||||
wrappedInput,
|
||||
systemBlocks.length > 0 ? systemBlocks.map(b => b.text) : undefined,
|
||||
),
|
||||
output: convertOutputToLangfuse(wrappedOutput),
|
||||
usage: {
|
||||
input_tokens: response.usage.input_tokens,
|
||||
output_tokens: response.usage.output_tokens,
|
||||
cache_creation_input_tokens: response.usage.cache_creation_input_tokens ?? undefined,
|
||||
cache_read_input_tokens: response.usage.cache_read_input_tokens ?? undefined,
|
||||
cache_creation_input_tokens:
|
||||
response.usage.cache_creation_input_tokens ?? undefined,
|
||||
cache_read_input_tokens:
|
||||
response.usage.cache_read_input_tokens ?? undefined,
|
||||
},
|
||||
startTime: new Date(start),
|
||||
endTime: new Date(),
|
||||
...(tools && { tools: convertToolsToLangfuse(tools as unknown[]) }),
|
||||
...(thinkingConfig && thinkingConfig.type !== 'disabled' && {
|
||||
thinking: {
|
||||
type: thinkingConfig.type,
|
||||
...(thinkingConfig.type === 'enabled' && { budgetTokens: thinkingConfig.budget_tokens }),
|
||||
},
|
||||
}),
|
||||
...(thinkingConfig &&
|
||||
thinkingConfig.type !== 'disabled' && {
|
||||
thinking: {
|
||||
type: thinkingConfig.type,
|
||||
...(thinkingConfig.type === 'enabled' && {
|
||||
budgetTokens: thinkingConfig.budget_tokens,
|
||||
}),
|
||||
},
|
||||
}),
|
||||
})
|
||||
endTrace(langfuseTrace)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user