@langchain/openai 0.0.10 → 0.0.11
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 +20 -3
- package/dist/chat_models.d.ts +2 -0
- package/dist/chat_models.js +20 -3
- package/dist/types.d.ts +10 -0
- package/dist/utils/azure.d.ts +2 -2
- package/dist/utils/openai.d.ts +2 -1
- package/package.json +2 -2
package/dist/chat_models.cjs
CHANGED
|
@@ -266,6 +266,18 @@ class ChatOpenAI extends chat_models_1.BaseChatModel {
|
|
|
266
266
|
writable: true,
|
|
267
267
|
value: void 0
|
|
268
268
|
});
|
|
269
|
+
Object.defineProperty(this, "logprobs", {
|
|
270
|
+
enumerable: true,
|
|
271
|
+
configurable: true,
|
|
272
|
+
writable: true,
|
|
273
|
+
value: void 0
|
|
274
|
+
});
|
|
275
|
+
Object.defineProperty(this, "topLogprobs", {
|
|
276
|
+
enumerable: true,
|
|
277
|
+
configurable: true,
|
|
278
|
+
writable: true,
|
|
279
|
+
value: void 0
|
|
280
|
+
});
|
|
269
281
|
Object.defineProperty(this, "openAIApiKey", {
|
|
270
282
|
enumerable: true,
|
|
271
283
|
configurable: true,
|
|
@@ -351,6 +363,8 @@ class ChatOpenAI extends chat_models_1.BaseChatModel {
|
|
|
351
363
|
this.frequencyPenalty = fields?.frequencyPenalty ?? this.frequencyPenalty;
|
|
352
364
|
this.presencePenalty = fields?.presencePenalty ?? this.presencePenalty;
|
|
353
365
|
this.maxTokens = fields?.maxTokens;
|
|
366
|
+
this.logprobs = fields?.logprobs;
|
|
367
|
+
this.topLogprobs = fields?.topLogprobs;
|
|
354
368
|
this.n = fields?.n ?? this.n;
|
|
355
369
|
this.logitBias = fields?.logitBias;
|
|
356
370
|
this.stop = fields?.stop;
|
|
@@ -396,6 +410,8 @@ class ChatOpenAI extends chat_models_1.BaseChatModel {
|
|
|
396
410
|
frequency_penalty: this.frequencyPenalty,
|
|
397
411
|
presence_penalty: this.presencePenalty,
|
|
398
412
|
max_tokens: this.maxTokens === -1 ? undefined : this.maxTokens,
|
|
413
|
+
logprobs: this.logprobs,
|
|
414
|
+
top_logprobs: this.topLogprobs,
|
|
399
415
|
n: this.n,
|
|
400
416
|
logit_bias: this.logitBias,
|
|
401
417
|
stop: options?.stop ?? this.stop,
|
|
@@ -526,9 +542,10 @@ class ChatOpenAI extends chat_models_1.BaseChatModel {
|
|
|
526
542
|
text,
|
|
527
543
|
message: openAIResponseToChatMessage(part.message ?? { role: "assistant" }),
|
|
528
544
|
};
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
545
|
+
generation.generationInfo = {
|
|
546
|
+
...(part.finish_reason ? { finish_reason: part.finish_reason } : {}),
|
|
547
|
+
...(part.logprobs ? { logprobs: part.logprobs } : {}),
|
|
548
|
+
};
|
|
532
549
|
generations.push(generation);
|
|
533
550
|
}
|
|
534
551
|
return {
|
package/dist/chat_models.d.ts
CHANGED
|
@@ -81,6 +81,8 @@ export declare class ChatOpenAI<CallOptions extends ChatOpenAICallOptions = Chat
|
|
|
81
81
|
timeout?: number;
|
|
82
82
|
streaming: boolean;
|
|
83
83
|
maxTokens?: number;
|
|
84
|
+
logprobs?: boolean;
|
|
85
|
+
topLogprobs?: number;
|
|
84
86
|
openAIApiKey?: string;
|
|
85
87
|
azureOpenAIApiVersion?: string;
|
|
86
88
|
azureOpenAIApiKey?: string;
|
package/dist/chat_models.js
CHANGED
|
@@ -262,6 +262,18 @@ export class ChatOpenAI extends BaseChatModel {
|
|
|
262
262
|
writable: true,
|
|
263
263
|
value: void 0
|
|
264
264
|
});
|
|
265
|
+
Object.defineProperty(this, "logprobs", {
|
|
266
|
+
enumerable: true,
|
|
267
|
+
configurable: true,
|
|
268
|
+
writable: true,
|
|
269
|
+
value: void 0
|
|
270
|
+
});
|
|
271
|
+
Object.defineProperty(this, "topLogprobs", {
|
|
272
|
+
enumerable: true,
|
|
273
|
+
configurable: true,
|
|
274
|
+
writable: true,
|
|
275
|
+
value: void 0
|
|
276
|
+
});
|
|
265
277
|
Object.defineProperty(this, "openAIApiKey", {
|
|
266
278
|
enumerable: true,
|
|
267
279
|
configurable: true,
|
|
@@ -347,6 +359,8 @@ export class ChatOpenAI extends BaseChatModel {
|
|
|
347
359
|
this.frequencyPenalty = fields?.frequencyPenalty ?? this.frequencyPenalty;
|
|
348
360
|
this.presencePenalty = fields?.presencePenalty ?? this.presencePenalty;
|
|
349
361
|
this.maxTokens = fields?.maxTokens;
|
|
362
|
+
this.logprobs = fields?.logprobs;
|
|
363
|
+
this.topLogprobs = fields?.topLogprobs;
|
|
350
364
|
this.n = fields?.n ?? this.n;
|
|
351
365
|
this.logitBias = fields?.logitBias;
|
|
352
366
|
this.stop = fields?.stop;
|
|
@@ -392,6 +406,8 @@ export class ChatOpenAI extends BaseChatModel {
|
|
|
392
406
|
frequency_penalty: this.frequencyPenalty,
|
|
393
407
|
presence_penalty: this.presencePenalty,
|
|
394
408
|
max_tokens: this.maxTokens === -1 ? undefined : this.maxTokens,
|
|
409
|
+
logprobs: this.logprobs,
|
|
410
|
+
top_logprobs: this.topLogprobs,
|
|
395
411
|
n: this.n,
|
|
396
412
|
logit_bias: this.logitBias,
|
|
397
413
|
stop: options?.stop ?? this.stop,
|
|
@@ -522,9 +538,10 @@ export class ChatOpenAI extends BaseChatModel {
|
|
|
522
538
|
text,
|
|
523
539
|
message: openAIResponseToChatMessage(part.message ?? { role: "assistant" }),
|
|
524
540
|
};
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
541
|
+
generation.generationInfo = {
|
|
542
|
+
...(part.finish_reason ? { finish_reason: part.finish_reason } : {}),
|
|
543
|
+
...(part.logprobs ? { logprobs: part.logprobs } : {}),
|
|
544
|
+
};
|
|
528
545
|
generations.push(generation);
|
|
529
546
|
}
|
|
530
547
|
return {
|
package/dist/types.d.ts
CHANGED
|
@@ -83,6 +83,16 @@ export interface LegacyOpenAIInput {
|
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
85
|
export interface OpenAIChatInput extends OpenAIBaseInput {
|
|
86
|
+
/**
|
|
87
|
+
* Whether to return log probabilities of the output tokens or not.
|
|
88
|
+
* If true, returns the log probabilities of each output token returned in the content of message.
|
|
89
|
+
*/
|
|
90
|
+
logprobs?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* An integer between 0 and 5 specifying the number of most likely tokens to return at each token position,
|
|
93
|
+
* each with an associated log probability. logprobs must be set to true if this parameter is used.
|
|
94
|
+
*/
|
|
95
|
+
topLogprobs?: number;
|
|
86
96
|
/** ChatGPT messages to pass as a prefix to the prompt */
|
|
87
97
|
prefixMessages?: OpenAIClient.Chat.CreateChatCompletionRequestMessage[];
|
|
88
98
|
}
|
package/dist/utils/azure.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export interface OpenAIEndpointConfig {
|
|
|
3
3
|
azureOpenAIApiInstanceName?: string;
|
|
4
4
|
azureOpenAIApiKey?: string;
|
|
5
5
|
azureOpenAIBasePath?: string;
|
|
6
|
-
baseURL?: string;
|
|
6
|
+
baseURL?: string | null;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
9
|
* This function generates an endpoint URL for (Azure) OpenAI
|
|
@@ -27,4 +27,4 @@ export interface OpenAIEndpointConfig {
|
|
|
27
27
|
*
|
|
28
28
|
* @returns {string | undefined} The generated (Azure) OpenAI endpoint URL.
|
|
29
29
|
*/
|
|
30
|
-
export declare function getEndpoint(config: OpenAIEndpointConfig): string | undefined;
|
|
30
|
+
export declare function getEndpoint(config: OpenAIEndpointConfig): string | null | undefined;
|
package/dist/utils/openai.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type OpenAI as OpenAIClient } from "openai";
|
|
2
2
|
import type { StructuredToolInterface } from "@langchain/core/tools";
|
|
3
|
+
import type { FunctionDefinition } from "@langchain/core/language_models/base";
|
|
3
4
|
export declare function wrapOpenAIClientError(e: any): any;
|
|
4
5
|
/**
|
|
5
6
|
* Formats a `StructuredTool` instance into a format that is compatible
|
|
@@ -7,6 +8,6 @@ export declare function wrapOpenAIClientError(e: any): any;
|
|
|
7
8
|
* function to convert the schema of the `StructuredTool` into a JSON
|
|
8
9
|
* schema, which is then used as the parameters for the OpenAI function.
|
|
9
10
|
*/
|
|
10
|
-
export declare function formatToOpenAIFunction(tool: StructuredToolInterface):
|
|
11
|
+
export declare function formatToOpenAIFunction(tool: StructuredToolInterface): FunctionDefinition;
|
|
11
12
|
export declare function formatToOpenAITool(tool: StructuredToolInterface): OpenAIClient.Chat.ChatCompletionTool;
|
|
12
13
|
export declare function formatToOpenAIAssistantTool(tool: StructuredToolInterface): OpenAIClient.Beta.AssistantCreateParams.AssistantToolsFunction;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@langchain/openai",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"description": "OpenAI integrations for LangChain.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@langchain/core": "~0.1.9",
|
|
39
39
|
"js-tiktoken": "^1.0.7",
|
|
40
|
-
"openai": "^4.
|
|
40
|
+
"openai": "^4.24.2",
|
|
41
41
|
"zod": "^3.22.3",
|
|
42
42
|
"zod-to-json-schema": "3.20.3"
|
|
43
43
|
},
|