@langchain/openai 0.0.8 → 0.0.10
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
CHANGED
|
@@ -17,18 +17,18 @@ You can do so by adding appropriate fields to your project's `package.json` like
|
|
|
17
17
|
"name": "your-project",
|
|
18
18
|
"version": "0.0.0",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@langchain/openai": "^0.0.
|
|
20
|
+
"@langchain/openai": "^0.0.9",
|
|
21
21
|
"langchain": "0.0.207"
|
|
22
22
|
},
|
|
23
23
|
"resolutions": {
|
|
24
|
-
"@langchain/core": "0.1.
|
|
24
|
+
"@langchain/core": "0.1.5"
|
|
25
25
|
},
|
|
26
26
|
"overrides": {
|
|
27
|
-
"@langchain/core": "0.1.
|
|
27
|
+
"@langchain/core": "0.1.5"
|
|
28
28
|
},
|
|
29
29
|
"pnpm": {
|
|
30
30
|
"overrides": {
|
|
31
|
-
"@langchain/core": "0.1.
|
|
31
|
+
"@langchain/core": "0.1.5"
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
}
|
package/dist/legacy.cjs
CHANGED
|
@@ -8,6 +8,8 @@ const llms_1 = require("@langchain/core/language_models/llms");
|
|
|
8
8
|
const azure_js_1 = require("./utils/azure.cjs");
|
|
9
9
|
const openai_js_1 = require("./utils/openai.cjs");
|
|
10
10
|
/**
|
|
11
|
+
* @deprecated For legacy compatibility. Use ChatOpenAI instead.
|
|
12
|
+
*
|
|
11
13
|
* Wrapper around OpenAI large language models that use the Chat endpoint.
|
|
12
14
|
*
|
|
13
15
|
* To use you should have the `openai` package installed, with the
|
package/dist/legacy.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ export interface OpenAIChatCallOptions extends OpenAICallOptions {
|
|
|
13
13
|
promptIndex?: number;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
+
* @deprecated For legacy compatibility. Use ChatOpenAI instead.
|
|
17
|
+
*
|
|
16
18
|
* Wrapper around OpenAI large language models that use the Chat endpoint.
|
|
17
19
|
*
|
|
18
20
|
* To use you should have the `openai` package installed, with the
|
package/dist/legacy.js
CHANGED
|
@@ -5,6 +5,8 @@ import { LLM } from "@langchain/core/language_models/llms";
|
|
|
5
5
|
import { getEndpoint } from "./utils/azure.js";
|
|
6
6
|
import { wrapOpenAIClientError } from "./utils/openai.js";
|
|
7
7
|
/**
|
|
8
|
+
* @deprecated For legacy compatibility. Use ChatOpenAI instead.
|
|
9
|
+
*
|
|
8
10
|
* Wrapper around OpenAI large language models that use the Chat endpoint.
|
|
9
11
|
*
|
|
10
12
|
* To use you should have the `openai` package installed, with the
|
|
@@ -207,7 +207,10 @@ test("Test OpenAI with signal in call options", async () => {
|
|
|
207
207
|
}).rejects.toThrow();
|
|
208
208
|
}, 5000);
|
|
209
209
|
test("Test OpenAI with signal in call options and node adapter", async () => {
|
|
210
|
-
const model = new ChatOpenAI({
|
|
210
|
+
const model = new ChatOpenAI({
|
|
211
|
+
maxTokens: 5,
|
|
212
|
+
modelName: "gpt-3.5-turbo-instruct",
|
|
213
|
+
});
|
|
211
214
|
const controller = new AbortController();
|
|
212
215
|
await expect(() => {
|
|
213
216
|
const ret = model.call([new HumanMessage("Print hello world")], {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { test, expect } from "@jest/globals";
|
|
2
|
+
import { OpenAIEmbeddings } from "../embeddings.js";
|
|
3
|
+
test("Test OpenAIEmbeddings.embedQuery", async () => {
|
|
4
|
+
const embeddings = new OpenAIEmbeddings();
|
|
5
|
+
const res = await embeddings.embedQuery("Hello world");
|
|
6
|
+
expect(typeof res[0]).toBe("number");
|
|
7
|
+
});
|
|
8
|
+
test("Test OpenAIEmbeddings.embedDocuments", async () => {
|
|
9
|
+
const embeddings = new OpenAIEmbeddings();
|
|
10
|
+
const res = await embeddings.embedDocuments(["Hello world", "Bye bye"]);
|
|
11
|
+
expect(res).toHaveLength(2);
|
|
12
|
+
expect(typeof res[0][0]).toBe("number");
|
|
13
|
+
expect(typeof res[1][0]).toBe("number");
|
|
14
|
+
});
|
|
15
|
+
test("Test OpenAIEmbeddings concurrency", async () => {
|
|
16
|
+
const embeddings = new OpenAIEmbeddings({
|
|
17
|
+
batchSize: 1,
|
|
18
|
+
maxConcurrency: 2,
|
|
19
|
+
});
|
|
20
|
+
const res = await embeddings.embedDocuments([
|
|
21
|
+
"Hello world",
|
|
22
|
+
"Bye bye",
|
|
23
|
+
"Hello world",
|
|
24
|
+
"Bye bye",
|
|
25
|
+
"Hello world",
|
|
26
|
+
"Bye bye",
|
|
27
|
+
]);
|
|
28
|
+
expect(res).toHaveLength(6);
|
|
29
|
+
expect(res.find((embedding) => typeof embedding[0] !== "number")).toBe(undefined);
|
|
30
|
+
});
|
|
31
|
+
test("Test timeout error thrown from SDK", async () => {
|
|
32
|
+
await expect(async () => {
|
|
33
|
+
const model = new OpenAIEmbeddings({
|
|
34
|
+
timeout: 1,
|
|
35
|
+
});
|
|
36
|
+
await model.embedDocuments([
|
|
37
|
+
"Hello world",
|
|
38
|
+
"Bye bye",
|
|
39
|
+
"Hello world",
|
|
40
|
+
"Bye bye",
|
|
41
|
+
"Hello world",
|
|
42
|
+
"Bye bye",
|
|
43
|
+
]);
|
|
44
|
+
}).rejects.toThrow();
|
|
45
|
+
});
|
|
46
|
+
test("Test OpenAI embeddings with an invalid org throws", async () => {
|
|
47
|
+
await expect(async () => {
|
|
48
|
+
const model = new OpenAIEmbeddings({
|
|
49
|
+
configuration: {
|
|
50
|
+
organization: "NOT_REAL",
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
await model.embedDocuments([
|
|
54
|
+
"Hello world",
|
|
55
|
+
"Bye bye",
|
|
56
|
+
"Hello world",
|
|
57
|
+
"Bye bye",
|
|
58
|
+
"Hello world",
|
|
59
|
+
"Bye bye",
|
|
60
|
+
]);
|
|
61
|
+
}).rejects.toThrow();
|
|
62
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@langchain/openai",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"description": "OpenAI integrations for LangChain.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"author": "LangChain",
|
|
36
36
|
"license": "MIT",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@langchain/core": "~0.1.
|
|
38
|
+
"@langchain/core": "~0.1.9",
|
|
39
39
|
"js-tiktoken": "^1.0.7",
|
|
40
40
|
"openai": "^4.19.0",
|
|
41
41
|
"zod": "^3.22.3",
|