Skip to content

Commit 64addfa

Browse files
committed
move types
1 parent cb92f73 commit 64addfa

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

packages/core/src/tracing/langchain/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ export interface LangChainMessage {
4747
// LangChain serialized format
4848
lc?: number;
4949
id?: string[];
50+
response_metadata?: {
51+
model_name?: string;
52+
finish_reason?: string;
53+
};
5054
kwargs?: {
5155
[key: string]: unknown;
5256
content?: string;
@@ -70,6 +74,7 @@ export interface LangChainLLMResult {
7074
finish_reason?: string;
7175
logprobs?: unknown;
7276
};
77+
// v1+ uses generationInfo instead of generation_info
7378
generationInfo?: {
7479
[key: string]: unknown;
7580
finish_reason?: string;

packages/core/src/tracing/langchain/utils.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -419,19 +419,11 @@ export function extractLlmResponseAttributes(
419419

420420
addTokenUsageAttributes(llmResult.llmOutput, attrs);
421421

422-
const llmOutput = llmResult.llmOutput as { model_name?: string; model?: string; id?: string; stop_reason?: string };
422+
const llmOutput = llmResult.llmOutput;
423423

424424
// Extract from v1 generations structure if available
425425
const firstGeneration = llmResult.generations?.[0]?.[0];
426-
const v1Message = firstGeneration?.message as
427-
| {
428-
id?: string;
429-
response_metadata?: {
430-
model_name?: string;
431-
finish_reason?: string;
432-
};
433-
}
434-
| undefined;
426+
const v1Message = firstGeneration?.message;
435427

436428
// Provider model identifier: `model_name` (OpenAI-style) or `model` (others)
437429
// v1 stores this in message.response_metadata.model_name

0 commit comments

Comments
 (0)