@langchain/openai 0.5.18 → 0.6.1
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/README.md +2 -2
- package/dist/azure/chat_models.cjs +1 -1
- package/dist/azure/chat_models.d.ts +6 -6
- package/dist/azure/chat_models.js +2 -2
- package/dist/chat_models.cjs +2032 -2091
- package/dist/chat_models.d.ts +235 -233
- package/dist/chat_models.js +2031 -2059
- package/dist/types.d.ts +0 -7
- package/dist/utils/openai.cjs +49 -0
- package/dist/utils/openai.d.ts +6 -0
- package/dist/utils/openai.js +49 -1
- package/dist/utils/prompts.cjs +1 -1
- package/dist/utils/prompts.d.ts +1 -1
- package/dist/utils/prompts.js +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -53,7 +53,7 @@ import { ChatOpenAI } from "@langchain/openai";
|
|
|
53
53
|
|
|
54
54
|
const model = new ChatOpenAI({
|
|
55
55
|
apiKey: process.env.OPENAI_API_KEY,
|
|
56
|
-
|
|
56
|
+
model: "gpt-4-1106-preview",
|
|
57
57
|
});
|
|
58
58
|
const response = await model.invoke(new HumanMessage("Hello world!"));
|
|
59
59
|
```
|
|
@@ -65,7 +65,7 @@ import { ChatOpenAI } from "@langchain/openai";
|
|
|
65
65
|
|
|
66
66
|
const model = new ChatOpenAI({
|
|
67
67
|
apiKey: process.env.OPENAI_API_KEY,
|
|
68
|
-
|
|
68
|
+
model: "gpt-4-1106-preview",
|
|
69
69
|
});
|
|
70
70
|
const response = await model.stream(new HumanMessage("Hello world!"));
|
|
71
71
|
```
|
|
@@ -347,7 +347,7 @@ const headers_js_1 = require("../utils/headers.cjs");
|
|
|
347
347
|
* <summary><strong>Logprobs</strong></summary>
|
|
348
348
|
*
|
|
349
349
|
* ```typescript
|
|
350
|
-
* const logprobsLlm = new ChatOpenAI({ logprobs: true });
|
|
350
|
+
* const logprobsLlm = new ChatOpenAI({ model: "gpt-4o-mini", logprobs: true });
|
|
351
351
|
* const aiMsgForLogprobs = await logprobsLlm.invoke(input);
|
|
352
352
|
* console.log(aiMsgForLogprobs.response_metadata.logprobs);
|
|
353
353
|
* ```
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { type ClientOptions } from "openai";
|
|
2
2
|
import { LangSmithParams, type BaseChatModelParams } from "@langchain/core/language_models/chat_models";
|
|
3
|
-
import { BaseLanguageModelInput } from "@langchain/core/language_models/base";
|
|
3
|
+
import { BaseLanguageModelInput, StructuredOutputMethodOptions } from "@langchain/core/language_models/base";
|
|
4
4
|
import { BaseMessage } from "@langchain/core/messages";
|
|
5
5
|
import { Runnable } from "@langchain/core/runnables";
|
|
6
6
|
import { InteropZodType } from "@langchain/core/utils/types";
|
|
7
|
-
import { ChatOpenAI
|
|
7
|
+
import { ChatOpenAI } from "../chat_models.js";
|
|
8
8
|
import { AzureOpenAIInput, OpenAIChatInput, OpenAICoreRequestOptions } from "../types.js";
|
|
9
9
|
export type { AzureOpenAIInput };
|
|
10
10
|
/**
|
|
@@ -348,7 +348,7 @@ export type { AzureOpenAIInput };
|
|
|
348
348
|
* <summary><strong>Logprobs</strong></summary>
|
|
349
349
|
*
|
|
350
350
|
* ```typescript
|
|
351
|
-
* const logprobsLlm = new ChatOpenAI({ logprobs: true });
|
|
351
|
+
* const logprobsLlm = new ChatOpenAI({ model: "gpt-4o-mini", logprobs: true });
|
|
352
352
|
* const aiMsgForLogprobs = await logprobsLlm.invoke(input);
|
|
353
353
|
* console.log(aiMsgForLogprobs.response_metadata.logprobs);
|
|
354
354
|
* ```
|
|
@@ -444,12 +444,12 @@ export declare class AzureChatOpenAI extends ChatOpenAI {
|
|
|
444
444
|
getLsParams(options: this["ParsedCallOptions"]): LangSmithParams;
|
|
445
445
|
protected _getClientOptions(options: OpenAICoreRequestOptions | undefined): OpenAICoreRequestOptions;
|
|
446
446
|
toJSON(): any;
|
|
447
|
-
withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput> | Record<string, any>, config?:
|
|
448
|
-
withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput> | Record<string, any>, config?:
|
|
447
|
+
withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput> | Record<string, any>, config?: StructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;
|
|
448
|
+
withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput> | Record<string, any>, config?: StructuredOutputMethodOptions<true>): Runnable<BaseLanguageModelInput, {
|
|
449
449
|
raw: BaseMessage;
|
|
450
450
|
parsed: RunOutput;
|
|
451
451
|
}>;
|
|
452
|
-
withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput> | Record<string, any>, config?:
|
|
452
|
+
withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput> | Record<string, any>, config?: StructuredOutputMethodOptions<boolean>): Runnable<BaseLanguageModelInput, RunOutput> | Runnable<BaseLanguageModelInput, {
|
|
453
453
|
raw: BaseMessage;
|
|
454
454
|
parsed: RunOutput;
|
|
455
455
|
}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AzureOpenAI as AzureOpenAIClient } from "openai";
|
|
2
2
|
import { getEnv, getEnvironmentVariable } from "@langchain/core/utils/env";
|
|
3
|
-
import { ChatOpenAI
|
|
3
|
+
import { ChatOpenAI } from "../chat_models.js";
|
|
4
4
|
import { getEndpoint } from "../utils/azure.js";
|
|
5
5
|
import { normalizeHeaders } from "../utils/headers.js";
|
|
6
6
|
/**
|
|
@@ -344,7 +344,7 @@ import { normalizeHeaders } from "../utils/headers.js";
|
|
|
344
344
|
* <summary><strong>Logprobs</strong></summary>
|
|
345
345
|
*
|
|
346
346
|
* ```typescript
|
|
347
|
-
* const logprobsLlm = new ChatOpenAI({ logprobs: true });
|
|
347
|
+
* const logprobsLlm = new ChatOpenAI({ model: "gpt-4o-mini", logprobs: true });
|
|
348
348
|
* const aiMsgForLogprobs = await logprobsLlm.invoke(input);
|
|
349
349
|
* console.log(aiMsgForLogprobs.response_metadata.logprobs);
|
|
350
350
|
* ```
|