@langchain/openai 0.3.3 → 0.3.4
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.
- package/dist/chat_models.cjs +4 -15
- package/dist/chat_models.d.ts +4 -1
- package/dist/chat_models.js +4 -15
- package/package.json +1 -1
package/dist/chat_models.cjs
CHANGED
|
@@ -458,7 +458,10 @@ function _convertChatOpenAIToolTypeToOpenAITool(tool, fields) {
|
|
|
458
458
|
* rating: z.number().optional().describe("How funny the joke is, from 1 to 10")
|
|
459
459
|
* }).describe('Joke to tell user.');
|
|
460
460
|
*
|
|
461
|
-
* const structuredLlm = llm.withStructuredOutput(Joke, {
|
|
461
|
+
* const structuredLlm = llm.withStructuredOutput(Joke, {
|
|
462
|
+
* name: "Joke",
|
|
463
|
+
* strict: true, // Optionally enable OpenAI structured outputs
|
|
464
|
+
* });
|
|
462
465
|
* const jokeResult = await structuredLlm.invoke("Tell me a joke about cats");
|
|
463
466
|
* console.log(jokeResult);
|
|
464
467
|
* ```
|
|
@@ -1105,20 +1108,6 @@ class ChatOpenAI extends chat_models_1.BaseChatModel {
|
|
|
1105
1108
|
stream: true,
|
|
1106
1109
|
};
|
|
1107
1110
|
let defaultRole;
|
|
1108
|
-
if (params.response_format &&
|
|
1109
|
-
params.response_format.type === "json_schema") {
|
|
1110
|
-
console.warn(`OpenAI does not yet support streaming with "response_format" set to "json_schema". Falling back to non-streaming mode.`);
|
|
1111
|
-
const res = await this._generate(messages, options, runManager);
|
|
1112
|
-
const chunk = new outputs_1.ChatGenerationChunk({
|
|
1113
|
-
message: new messages_1.AIMessageChunk({
|
|
1114
|
-
...res.generations[0].message,
|
|
1115
|
-
}),
|
|
1116
|
-
text: res.generations[0].text,
|
|
1117
|
-
generationInfo: res.generations[0].generationInfo,
|
|
1118
|
-
});
|
|
1119
|
-
yield chunk;
|
|
1120
|
-
return runManager?.handleLLMNewToken(res.generations[0].text ?? "", undefined, undefined, undefined, undefined, { chunk });
|
|
1121
|
-
}
|
|
1122
1111
|
const streamIterable = await this.completionWithRetry(params, options);
|
|
1123
1112
|
let usage;
|
|
1124
1113
|
for await (const data of streamIterable) {
|
package/dist/chat_models.d.ts
CHANGED
|
@@ -334,7 +334,10 @@ export interface ChatOpenAIFields extends Partial<OpenAIChatInput>, Partial<Azur
|
|
|
334
334
|
* rating: z.number().optional().describe("How funny the joke is, from 1 to 10")
|
|
335
335
|
* }).describe('Joke to tell user.');
|
|
336
336
|
*
|
|
337
|
-
* const structuredLlm = llm.withStructuredOutput(Joke, {
|
|
337
|
+
* const structuredLlm = llm.withStructuredOutput(Joke, {
|
|
338
|
+
* name: "Joke",
|
|
339
|
+
* strict: true, // Optionally enable OpenAI structured outputs
|
|
340
|
+
* });
|
|
338
341
|
* const jokeResult = await structuredLlm.invoke("Tell me a joke about cats");
|
|
339
342
|
* console.log(jokeResult);
|
|
340
343
|
* ```
|
package/dist/chat_models.js
CHANGED
|
@@ -453,7 +453,10 @@ function _convertChatOpenAIToolTypeToOpenAITool(tool, fields) {
|
|
|
453
453
|
* rating: z.number().optional().describe("How funny the joke is, from 1 to 10")
|
|
454
454
|
* }).describe('Joke to tell user.');
|
|
455
455
|
*
|
|
456
|
-
* const structuredLlm = llm.withStructuredOutput(Joke, {
|
|
456
|
+
* const structuredLlm = llm.withStructuredOutput(Joke, {
|
|
457
|
+
* name: "Joke",
|
|
458
|
+
* strict: true, // Optionally enable OpenAI structured outputs
|
|
459
|
+
* });
|
|
457
460
|
* const jokeResult = await structuredLlm.invoke("Tell me a joke about cats");
|
|
458
461
|
* console.log(jokeResult);
|
|
459
462
|
* ```
|
|
@@ -1100,20 +1103,6 @@ export class ChatOpenAI extends BaseChatModel {
|
|
|
1100
1103
|
stream: true,
|
|
1101
1104
|
};
|
|
1102
1105
|
let defaultRole;
|
|
1103
|
-
if (params.response_format &&
|
|
1104
|
-
params.response_format.type === "json_schema") {
|
|
1105
|
-
console.warn(`OpenAI does not yet support streaming with "response_format" set to "json_schema". Falling back to non-streaming mode.`);
|
|
1106
|
-
const res = await this._generate(messages, options, runManager);
|
|
1107
|
-
const chunk = new ChatGenerationChunk({
|
|
1108
|
-
message: new AIMessageChunk({
|
|
1109
|
-
...res.generations[0].message,
|
|
1110
|
-
}),
|
|
1111
|
-
text: res.generations[0].text,
|
|
1112
|
-
generationInfo: res.generations[0].generationInfo,
|
|
1113
|
-
});
|
|
1114
|
-
yield chunk;
|
|
1115
|
-
return runManager?.handleLLMNewToken(res.generations[0].text ?? "", undefined, undefined, undefined, undefined, { chunk });
|
|
1116
|
-
}
|
|
1117
1106
|
const streamIterable = await this.completionWithRetry(params, options);
|
|
1118
1107
|
let usage;
|
|
1119
1108
|
for await (const data of streamIterable) {
|