@langchain/openai 0.3.15 → 0.3.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -72,13 +72,15 @@ function openAIResponseToChatMessage(message, rawResponse, includeRawResponse) {
72
72
  if (includeRawResponse !== undefined) {
73
73
  additional_kwargs.__raw_response = rawResponse;
74
74
  }
75
- let response_metadata;
76
- if (rawResponse.system_fingerprint) {
77
- response_metadata = {
78
- usage: { ...rawResponse.usage },
79
- system_fingerprint: rawResponse.system_fingerprint,
80
- };
81
- }
75
+ const response_metadata = {
76
+ model_name: rawResponse.model,
77
+ ...(rawResponse.system_fingerprint
78
+ ? {
79
+ usage: { ...rawResponse.usage },
80
+ system_fingerprint: rawResponse.system_fingerprint,
81
+ }
82
+ : {}),
83
+ };
82
84
  if (message.audio) {
83
85
  additional_kwargs.audio = message.audio;
84
86
  }
@@ -1113,6 +1115,9 @@ class ChatOpenAI extends chat_models_1.BaseChatModel {
1113
1115
  // Streaming usage is not supported by Azure deployments, so default to false
1114
1116
  this.streamUsage = false;
1115
1117
  }
1118
+ if (this.model === "o1") {
1119
+ this.disableStreaming = true;
1120
+ }
1116
1121
  this.streaming = fields?.streaming ?? false;
1117
1122
  this.streamUsage = fields?.streamUsage ?? this.streamUsage;
1118
1123
  this.clientConfig = {
@@ -1277,6 +1282,7 @@ class ChatOpenAI extends chat_models_1.BaseChatModel {
1277
1282
  // Only include system fingerprint in the last chunk for now
1278
1283
  // to avoid concatenation issues
1279
1284
  generationInfo.system_fingerprint = data.system_fingerprint;
1285
+ generationInfo.model_name = data.model;
1280
1286
  }
1281
1287
  if (this.logprobs) {
1282
1288
  generationInfo.logprobs = choice.logprobs;
@@ -1456,9 +1462,7 @@ class ChatOpenAI extends chat_models_1.BaseChatModel {
1456
1462
  }
1457
1463
  // Fields are not serialized unless passed to the constructor
1458
1464
  // Doing this ensures all fields on the message are serialized
1459
- generation.message = new messages_1.AIMessage({
1460
- ...generation.message,
1461
- });
1465
+ generation.message = new messages_1.AIMessage(Object.fromEntries(Object.entries(generation.message).filter(([key]) => !key.startsWith("lc_"))));
1462
1466
  generations.push(generation);
1463
1467
  }
1464
1468
  return {
@@ -68,13 +68,15 @@ function openAIResponseToChatMessage(message, rawResponse, includeRawResponse) {
68
68
  if (includeRawResponse !== undefined) {
69
69
  additional_kwargs.__raw_response = rawResponse;
70
70
  }
71
- let response_metadata;
72
- if (rawResponse.system_fingerprint) {
73
- response_metadata = {
74
- usage: { ...rawResponse.usage },
75
- system_fingerprint: rawResponse.system_fingerprint,
76
- };
77
- }
71
+ const response_metadata = {
72
+ model_name: rawResponse.model,
73
+ ...(rawResponse.system_fingerprint
74
+ ? {
75
+ usage: { ...rawResponse.usage },
76
+ system_fingerprint: rawResponse.system_fingerprint,
77
+ }
78
+ : {}),
79
+ };
78
80
  if (message.audio) {
79
81
  additional_kwargs.audio = message.audio;
80
82
  }
@@ -1108,6 +1110,9 @@ export class ChatOpenAI extends BaseChatModel {
1108
1110
  // Streaming usage is not supported by Azure deployments, so default to false
1109
1111
  this.streamUsage = false;
1110
1112
  }
1113
+ if (this.model === "o1") {
1114
+ this.disableStreaming = true;
1115
+ }
1111
1116
  this.streaming = fields?.streaming ?? false;
1112
1117
  this.streamUsage = fields?.streamUsage ?? this.streamUsage;
1113
1118
  this.clientConfig = {
@@ -1272,6 +1277,7 @@ export class ChatOpenAI extends BaseChatModel {
1272
1277
  // Only include system fingerprint in the last chunk for now
1273
1278
  // to avoid concatenation issues
1274
1279
  generationInfo.system_fingerprint = data.system_fingerprint;
1280
+ generationInfo.model_name = data.model;
1275
1281
  }
1276
1282
  if (this.logprobs) {
1277
1283
  generationInfo.logprobs = choice.logprobs;
@@ -1451,9 +1457,7 @@ export class ChatOpenAI extends BaseChatModel {
1451
1457
  }
1452
1458
  // Fields are not serialized unless passed to the constructor
1453
1459
  // Doing this ensures all fields on the message are serialized
1454
- generation.message = new AIMessage({
1455
- ...generation.message,
1456
- });
1460
+ generation.message = new AIMessage(Object.fromEntries(Object.entries(generation.message).filter(([key]) => !key.startsWith("lc_"))));
1457
1461
  generations.push(generation);
1458
1462
  }
1459
1463
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/openai",
3
- "version": "0.3.15",
3
+ "version": "0.3.17",
4
4
  "description": "OpenAI integrations for LangChain.js",
5
5
  "type": "module",
6
6
  "engines": {
@@ -41,7 +41,7 @@
41
41
  "zod-to-json-schema": "^3.22.3"
42
42
  },
43
43
  "peerDependencies": {
44
- "@langchain/core": ">=0.2.26 <0.4.0"
44
+ "@langchain/core": ">=0.3.29 <0.4.0"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@azure/identity": "^4.2.1",