@langchain/openai 0.6.16 → 1.0.0-alpha.2
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 +8 -8
- package/dist/_virtual/rolldown_runtime.cjs +25 -0
- package/dist/azure/chat_models.cjs +661 -808
- package/dist/azure/chat_models.cjs.map +1 -0
- package/dist/azure/chat_models.d.cts +449 -0
- package/dist/azure/chat_models.d.cts.map +1 -0
- package/dist/azure/chat_models.d.ts +32 -28
- package/dist/azure/chat_models.d.ts.map +1 -0
- package/dist/azure/chat_models.js +660 -804
- package/dist/azure/chat_models.js.map +1 -0
- package/dist/azure/embeddings.cjs +81 -130
- package/dist/azure/embeddings.cjs.map +1 -0
- package/dist/azure/embeddings.d.cts +27 -0
- package/dist/azure/embeddings.d.cts.map +1 -0
- package/dist/azure/embeddings.d.ts +25 -20
- package/dist/azure/embeddings.d.ts.map +1 -0
- package/dist/azure/embeddings.js +80 -126
- package/dist/azure/embeddings.js.map +1 -0
- package/dist/azure/llms.cjs +109 -168
- package/dist/azure/llms.cjs.map +1 -0
- package/dist/azure/llms.d.cts +33 -0
- package/dist/azure/llms.d.cts.map +1 -0
- package/dist/azure/llms.d.ts +31 -25
- package/dist/azure/llms.d.ts.map +1 -0
- package/dist/azure/llms.js +108 -164
- package/dist/azure/llms.js.map +1 -0
- package/dist/chat_models.cjs +1959 -2789
- package/dist/chat_models.cjs.map +1 -0
- package/dist/chat_models.d.cts +931 -0
- package/dist/chat_models.d.cts.map +1 -0
- package/dist/chat_models.d.ts +367 -351
- package/dist/chat_models.d.ts.map +1 -0
- package/dist/chat_models.js +1954 -2779
- package/dist/chat_models.js.map +1 -0
- package/dist/embeddings.cjs +140 -206
- package/dist/embeddings.cjs.map +1 -0
- package/dist/embeddings.d.cts +120 -0
- package/dist/embeddings.d.cts.map +1 -0
- package/dist/embeddings.d.ts +93 -86
- package/dist/embeddings.d.ts.map +1 -0
- package/dist/embeddings.js +138 -201
- package/dist/embeddings.js.map +1 -0
- package/dist/index.cjs +47 -34
- package/dist/index.d.cts +16 -0
- package/dist/index.d.ts +16 -13
- package/dist/index.js +17 -13
- package/dist/langchain-core/dist/types/_internal.d.cts +11 -0
- package/dist/langchain-core/dist/types/_internal.d.cts.map +1 -0
- package/dist/langchain-core/dist/types/_internal.d.ts +11 -0
- package/dist/langchain-core/dist/types/_internal.d.ts.map +1 -0
- package/dist/langchain-core/dist/utils/stream.d.cts +26 -0
- package/dist/langchain-core/dist/utils/stream.d.cts.map +1 -0
- package/dist/langchain-core/dist/utils/stream.d.ts +26 -0
- package/dist/langchain-core/dist/utils/stream.d.ts.map +1 -0
- package/dist/llms.cjs +312 -468
- package/dist/llms.cjs.map +1 -0
- package/dist/llms.d.cts +123 -0
- package/dist/llms.d.cts.map +1 -0
- package/dist/llms.d.ts +93 -87
- package/dist/llms.d.ts.map +1 -0
- package/dist/llms.js +309 -462
- package/dist/llms.js.map +1 -0
- package/dist/tools/custom.cjs +25 -26
- package/dist/tools/custom.cjs.map +1 -0
- package/dist/tools/custom.d.cts +10 -0
- package/dist/tools/custom.d.cts.map +1 -0
- package/dist/tools/custom.d.ts +8 -3
- package/dist/tools/custom.d.ts.map +1 -0
- package/dist/tools/custom.js +24 -23
- package/dist/tools/custom.js.map +1 -0
- package/dist/tools/dalle.cjs +104 -194
- package/dist/tools/dalle.cjs.map +1 -0
- package/dist/tools/dalle.d.cts +123 -0
- package/dist/tools/dalle.d.cts.map +1 -0
- package/dist/tools/dalle.d.ts +111 -104
- package/dist/tools/dalle.d.ts.map +1 -0
- package/dist/tools/dalle.js +102 -189
- package/dist/tools/dalle.js.map +1 -0
- package/dist/tools/index.cjs +1 -17
- package/dist/tools/index.js +1 -1
- package/dist/types.d.cts +263 -0
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.ts +244 -246
- package/dist/types.d.ts.map +1 -0
- package/dist/utils/azure.cjs +86 -47
- package/dist/utils/azure.cjs.map +1 -0
- package/dist/utils/azure.d.cts +76 -0
- package/dist/utils/azure.d.cts.map +1 -0
- package/dist/utils/azure.d.ts +51 -9
- package/dist/utils/azure.d.ts.map +1 -0
- package/dist/utils/azure.js +85 -45
- package/dist/utils/azure.js.map +1 -0
- package/dist/utils/client.cjs +25 -0
- package/dist/utils/client.cjs.map +1 -0
- package/dist/utils/client.d.cts +5 -0
- package/dist/utils/client.d.cts.map +1 -0
- package/dist/utils/client.d.ts +5 -0
- package/dist/utils/client.d.ts.map +1 -0
- package/dist/utils/client.js +24 -0
- package/dist/utils/client.js.map +1 -0
- package/dist/utils/errors.cjs +9 -8
- package/dist/utils/errors.cjs.map +1 -0
- package/dist/utils/errors.js +9 -6
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/message_inputs.cjs +139 -0
- package/dist/utils/message_inputs.cjs.map +1 -0
- package/dist/utils/message_inputs.d.cts +9 -0
- package/dist/utils/message_inputs.d.cts.map +1 -0
- package/dist/utils/message_inputs.d.ts +9 -0
- package/dist/utils/message_inputs.d.ts.map +1 -0
- package/dist/utils/message_inputs.js +137 -0
- package/dist/utils/message_inputs.js.map +1 -0
- package/dist/utils/misc.cjs +32 -0
- package/dist/utils/misc.cjs.map +1 -0
- package/dist/utils/misc.d.cts +9 -0
- package/dist/utils/misc.d.cts.map +1 -0
- package/dist/utils/misc.d.ts +9 -0
- package/dist/utils/misc.d.ts.map +1 -0
- package/dist/utils/misc.js +29 -0
- package/dist/utils/misc.js.map +1 -0
- package/dist/utils/output.cjs +106 -45
- package/dist/utils/output.cjs.map +1 -0
- package/dist/utils/output.js +104 -43
- package/dist/utils/output.js.map +1 -0
- package/dist/utils/prompts.cjs +39 -38
- package/dist/utils/prompts.cjs.map +1 -0
- package/dist/utils/prompts.d.cts +42 -0
- package/dist/utils/prompts.d.cts.map +1 -0
- package/dist/utils/prompts.d.ts +10 -4
- package/dist/utils/prompts.d.ts.map +1 -0
- package/dist/utils/prompts.js +40 -36
- package/dist/utils/prompts.js.map +1 -0
- package/dist/utils/standard.cjs +315 -0
- package/dist/utils/standard.cjs.map +1 -0
- package/dist/utils/standard.js +313 -0
- package/dist/utils/standard.js.map +1 -0
- package/dist/utils/tools.cjs +150 -127
- package/dist/utils/tools.cjs.map +1 -0
- package/dist/utils/tools.d.cts +13 -0
- package/dist/utils/tools.d.cts.map +1 -0
- package/dist/utils/tools.d.ts +12 -42
- package/dist/utils/tools.d.ts.map +1 -0
- package/dist/utils/tools.js +146 -123
- package/dist/utils/tools.js.map +1 -0
- package/package.json +51 -60
- package/dist/tools/index.d.ts +0 -1
- package/dist/types.cjs +0 -2
- package/dist/types.js +0 -1
- package/dist/utils/errors.d.ts +0 -2
- package/dist/utils/headers.cjs +0 -39
- package/dist/utils/headers.d.ts +0 -8
- package/dist/utils/headers.js +0 -35
- package/dist/utils/openai-format-fndef.cjs +0 -80
- package/dist/utils/openai-format-fndef.d.ts +0 -44
- package/dist/utils/openai-format-fndef.js +0 -77
- package/dist/utils/openai.cjs +0 -127
- package/dist/utils/openai.d.ts +0 -15
- package/dist/utils/openai.js +0 -119
- package/dist/utils/output.d.ts +0 -11
- package/index.cjs +0 -1
- package/index.d.cts +0 -1
- package/index.d.ts +0 -1
- package/index.js +0 -1
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { OpenAI as OpenAI$1 } from "openai";
|
|
2
|
+
import { MessageContentComplex } from "@langchain/core/messages";
|
|
3
|
+
import { Tool, ToolParams } from "@langchain/core/tools";
|
|
4
|
+
|
|
5
|
+
//#region src/tools/dalle.d.ts
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @see https://platform.openai.com/docs/api-reference/images/create
|
|
9
|
+
*/
|
|
10
|
+
type OpenAIImageModelId = OpenAI$1.ImageModel | (string & NonNullable<unknown>);
|
|
11
|
+
/**
|
|
12
|
+
* An interface for the Dall-E API Wrapper.
|
|
13
|
+
*/
|
|
14
|
+
interface DallEAPIWrapperParams extends ToolParams {
|
|
15
|
+
/**
|
|
16
|
+
* The OpenAI API key
|
|
17
|
+
* Alias for `apiKey`
|
|
18
|
+
*/
|
|
19
|
+
openAIApiKey?: string;
|
|
20
|
+
/**
|
|
21
|
+
* The OpenAI API key
|
|
22
|
+
*/
|
|
23
|
+
apiKey?: string;
|
|
24
|
+
/**
|
|
25
|
+
* The model to use.
|
|
26
|
+
* Alias for `model`
|
|
27
|
+
* @params "dall-e-2" | "dall-e-3"
|
|
28
|
+
* @default "dall-e-3"
|
|
29
|
+
* @deprecated Use `model` instead.
|
|
30
|
+
*/
|
|
31
|
+
modelName?: OpenAIImageModelId;
|
|
32
|
+
/**
|
|
33
|
+
* The model to use.
|
|
34
|
+
* @params "dall-e-2" | "dall-e-3"
|
|
35
|
+
* @default "dall-e-3"
|
|
36
|
+
*/
|
|
37
|
+
model?: OpenAIImageModelId;
|
|
38
|
+
/**
|
|
39
|
+
* The style of the generated images. Must be one of vivid or natural.
|
|
40
|
+
* Vivid causes the model to lean towards generating hyper-real and dramatic images.
|
|
41
|
+
* Natural causes the model to produce more natural, less hyper-real looking images.
|
|
42
|
+
* @default "vivid"
|
|
43
|
+
*/
|
|
44
|
+
style?: "natural" | "vivid";
|
|
45
|
+
/**
|
|
46
|
+
* The quality of the image that will be generated. ‘hd’ creates images with finer
|
|
47
|
+
* details and greater consistency across the image.
|
|
48
|
+
* @default "standard"
|
|
49
|
+
*/
|
|
50
|
+
quality?: "standard" | "hd";
|
|
51
|
+
/**
|
|
52
|
+
* The number of images to generate.
|
|
53
|
+
* Must be between 1 and 10.
|
|
54
|
+
* For dall-e-3, only `n: 1` is supported.
|
|
55
|
+
* @default 1
|
|
56
|
+
*/
|
|
57
|
+
n?: number;
|
|
58
|
+
/**
|
|
59
|
+
* The size of the generated images.
|
|
60
|
+
* Must be one of 256x256, 512x512, or 1024x1024 for DALL·E-2 models.
|
|
61
|
+
* Must be one of 1024x1024, 1792x1024, or 1024x1792 for DALL·E-3 models.
|
|
62
|
+
* @default "1024x1024"
|
|
63
|
+
*/
|
|
64
|
+
size?: "256x256" | "512x512" | "1024x1024" | "1792x1024" | "1024x1792";
|
|
65
|
+
/**
|
|
66
|
+
* The format in which the generated images are returned.
|
|
67
|
+
* Must be one of "url" or "b64_json".
|
|
68
|
+
* @default "url"
|
|
69
|
+
*/
|
|
70
|
+
dallEResponseFormat?: "url" | "b64_json";
|
|
71
|
+
/**
|
|
72
|
+
* @deprecated Use dallEResponseFormat instead for the Dall-E response type.
|
|
73
|
+
*/
|
|
74
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
75
|
+
responseFormat?: any;
|
|
76
|
+
/**
|
|
77
|
+
* A unique identifier representing your end-user, which will help
|
|
78
|
+
* OpenAI to monitor and detect abuse.
|
|
79
|
+
*/
|
|
80
|
+
user?: string;
|
|
81
|
+
/**
|
|
82
|
+
* The organization to use
|
|
83
|
+
*/
|
|
84
|
+
organization?: string;
|
|
85
|
+
/**
|
|
86
|
+
* The base URL of the OpenAI API.
|
|
87
|
+
*/
|
|
88
|
+
baseUrl?: string;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* A tool for generating images with Open AIs Dall-E 2 or 3 API.
|
|
92
|
+
*/
|
|
93
|
+
declare class DallEAPIWrapper extends Tool {
|
|
94
|
+
static lc_name(): string;
|
|
95
|
+
name: string;
|
|
96
|
+
description: string;
|
|
97
|
+
protected client: OpenAI$1;
|
|
98
|
+
static readonly toolName: string;
|
|
99
|
+
private model;
|
|
100
|
+
private style;
|
|
101
|
+
private quality;
|
|
102
|
+
private n;
|
|
103
|
+
private size;
|
|
104
|
+
private dallEResponseFormat;
|
|
105
|
+
private user?;
|
|
106
|
+
constructor(fields?: DallEAPIWrapperParams);
|
|
107
|
+
/**
|
|
108
|
+
* Processes the API response if multiple images are generated.
|
|
109
|
+
* Returns a list of MessageContentImageUrl objects. If the response
|
|
110
|
+
* format is `url`, then the `image_url` field will contain the URL.
|
|
111
|
+
* If it is `b64_json`, then the `image_url` field will contain an object
|
|
112
|
+
* with a `url` field with the base64 encoded image.
|
|
113
|
+
*
|
|
114
|
+
* @param {OpenAIClient.Images.ImagesResponse[]} response The API response
|
|
115
|
+
* @returns {MessageContentImageUrl[]}
|
|
116
|
+
*/
|
|
117
|
+
private processMultipleGeneratedUrls;
|
|
118
|
+
/** @ignore */
|
|
119
|
+
_call(input: string): Promise<string | MessageContentComplex[]>;
|
|
120
|
+
}
|
|
121
|
+
//#endregion
|
|
122
|
+
export { DallEAPIWrapper, DallEAPIWrapperParams, OpenAIImageModelId };
|
|
123
|
+
//# sourceMappingURL=dalle.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dalle.d.cts","names":["OpenAI","OpenAIClient","Tool","ToolParams","MessageContentComplex","OpenAIImageModelId","ImageModel","NonNullable","DallEAPIWrapperParams","DallEAPIWrapper","Promise"],"sources":["../../src/tools/dalle.d.ts"],"sourcesContent":["import { OpenAI as OpenAIClient } from \"openai\";\nimport { Tool, ToolParams } from \"@langchain/core/tools\";\nimport { MessageContentComplex } from \"@langchain/core/messages\";\n/**\n * @see https://platform.openai.com/docs/api-reference/images/create\n */\nexport type OpenAIImageModelId = OpenAIClient.ImageModel | (string & NonNullable<unknown>);\n/**\n * An interface for the Dall-E API Wrapper.\n */\nexport interface DallEAPIWrapperParams extends ToolParams {\n /**\n * The OpenAI API key\n * Alias for `apiKey`\n */\n openAIApiKey?: string;\n /**\n * The OpenAI API key\n */\n apiKey?: string;\n /**\n * The model to use.\n * Alias for `model`\n * @params \"dall-e-2\" | \"dall-e-3\"\n * @default \"dall-e-3\"\n * @deprecated Use `model` instead.\n */\n modelName?: OpenAIImageModelId;\n /**\n * The model to use.\n * @params \"dall-e-2\" | \"dall-e-3\"\n * @default \"dall-e-3\"\n */\n model?: OpenAIImageModelId;\n /**\n * The style of the generated images. Must be one of vivid or natural.\n * Vivid causes the model to lean towards generating hyper-real and dramatic images.\n * Natural causes the model to produce more natural, less hyper-real looking images.\n * @default \"vivid\"\n */\n style?: \"natural\" | \"vivid\";\n /**\n * The quality of the image that will be generated. ‘hd’ creates images with finer\n * details and greater consistency across the image.\n * @default \"standard\"\n */\n quality?: \"standard\" | \"hd\";\n /**\n * The number of images to generate.\n * Must be between 1 and 10.\n * For dall-e-3, only `n: 1` is supported.\n * @default 1\n */\n n?: number;\n /**\n * The size of the generated images.\n * Must be one of 256x256, 512x512, or 1024x1024 for DALL·E-2 models.\n * Must be one of 1024x1024, 1792x1024, or 1024x1792 for DALL·E-3 models.\n * @default \"1024x1024\"\n */\n size?: \"256x256\" | \"512x512\" | \"1024x1024\" | \"1792x1024\" | \"1024x1792\";\n /**\n * The format in which the generated images are returned.\n * Must be one of \"url\" or \"b64_json\".\n * @default \"url\"\n */\n dallEResponseFormat?: \"url\" | \"b64_json\";\n /**\n * @deprecated Use dallEResponseFormat instead for the Dall-E response type.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n responseFormat?: any;\n /**\n * A unique identifier representing your end-user, which will help\n * OpenAI to monitor and detect abuse.\n */\n user?: string;\n /**\n * The organization to use\n */\n organization?: string;\n /**\n * The base URL of the OpenAI API.\n */\n baseUrl?: string;\n}\n/**\n * A tool for generating images with Open AIs Dall-E 2 or 3 API.\n */\nexport declare class DallEAPIWrapper extends Tool {\n static lc_name(): string;\n name: string;\n description: string;\n protected client: OpenAIClient;\n static readonly toolName: string;\n private model;\n private style;\n private quality;\n private n;\n private size;\n private dallEResponseFormat;\n private user?;\n constructor(fields?: DallEAPIWrapperParams);\n /**\n * Processes the API response if multiple images are generated.\n * Returns a list of MessageContentImageUrl objects. If the response\n * format is `url`, then the `image_url` field will contain the URL.\n * If it is `b64_json`, then the `image_url` field will contain an object\n * with a `url` field with the base64 encoded image.\n *\n * @param {OpenAIClient.Images.ImagesResponse[]} response The API response\n * @returns {MessageContentImageUrl[]}\n */\n private processMultipleGeneratedUrls;\n /** @ignore */\n _call(input: string): Promise<string | MessageContentComplex[]>;\n}\n"],"mappings":";;;;;;;;AAMA;AAA8B,KAAlBK,kBAAAA,GAAqBJ,QAAAA,CAAaK,UAAhB,GAAA,CAAA,MAAA,GAAuCC,WAAvC,CAAA,OAAA,CAAA,CAAA;;;AAAkD;AAI/DC,UAAAA,qBAAAA,SAA8BL,UAAT,CAAA;EAAA;;;;EAAmB,YAAA,CAAA,EAAA,MAAA;EA+EpCM;;;EAIa,MASTD,CAAAA,EAAAA,MAAAA;EAAqB;;;AAbG;;;;cA9DjCH;;;;;;UAMJA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAwDSI,eAAAA,SAAwBP,IAAAA;;;;oBAIvBD;;;;;;;;;uBASGO;;;;;;;;;;;;;wBAaCE,iBAAiBN"}
|
package/dist/tools/dalle.d.ts
CHANGED
|
@@ -1,116 +1,123 @@
|
|
|
1
|
-
import { OpenAI as
|
|
2
|
-
import { Tool, ToolParams } from "@langchain/core/tools";
|
|
1
|
+
import { OpenAI as OpenAI$1 } from "openai";
|
|
3
2
|
import { MessageContentComplex } from "@langchain/core/messages";
|
|
3
|
+
import { Tool, ToolParams } from "@langchain/core/tools";
|
|
4
|
+
|
|
5
|
+
//#region src/tools/dalle.d.ts
|
|
6
|
+
|
|
4
7
|
/**
|
|
5
8
|
* @see https://platform.openai.com/docs/api-reference/images/create
|
|
6
9
|
*/
|
|
7
|
-
|
|
10
|
+
type OpenAIImageModelId = OpenAI$1.ImageModel | (string & NonNullable<unknown>);
|
|
8
11
|
/**
|
|
9
12
|
* An interface for the Dall-E API Wrapper.
|
|
10
13
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
14
|
+
interface DallEAPIWrapperParams extends ToolParams {
|
|
15
|
+
/**
|
|
16
|
+
* The OpenAI API key
|
|
17
|
+
* Alias for `apiKey`
|
|
18
|
+
*/
|
|
19
|
+
openAIApiKey?: string;
|
|
20
|
+
/**
|
|
21
|
+
* The OpenAI API key
|
|
22
|
+
*/
|
|
23
|
+
apiKey?: string;
|
|
24
|
+
/**
|
|
25
|
+
* The model to use.
|
|
26
|
+
* Alias for `model`
|
|
27
|
+
* @params "dall-e-2" | "dall-e-3"
|
|
28
|
+
* @default "dall-e-3"
|
|
29
|
+
* @deprecated Use `model` instead.
|
|
30
|
+
*/
|
|
31
|
+
modelName?: OpenAIImageModelId;
|
|
32
|
+
/**
|
|
33
|
+
* The model to use.
|
|
34
|
+
* @params "dall-e-2" | "dall-e-3"
|
|
35
|
+
* @default "dall-e-3"
|
|
36
|
+
*/
|
|
37
|
+
model?: OpenAIImageModelId;
|
|
38
|
+
/**
|
|
39
|
+
* The style of the generated images. Must be one of vivid or natural.
|
|
40
|
+
* Vivid causes the model to lean towards generating hyper-real and dramatic images.
|
|
41
|
+
* Natural causes the model to produce more natural, less hyper-real looking images.
|
|
42
|
+
* @default "vivid"
|
|
43
|
+
*/
|
|
44
|
+
style?: "natural" | "vivid";
|
|
45
|
+
/**
|
|
46
|
+
* The quality of the image that will be generated. ‘hd’ creates images with finer
|
|
47
|
+
* details and greater consistency across the image.
|
|
48
|
+
* @default "standard"
|
|
49
|
+
*/
|
|
50
|
+
quality?: "standard" | "hd";
|
|
51
|
+
/**
|
|
52
|
+
* The number of images to generate.
|
|
53
|
+
* Must be between 1 and 10.
|
|
54
|
+
* For dall-e-3, only `n: 1` is supported.
|
|
55
|
+
* @default 1
|
|
56
|
+
*/
|
|
57
|
+
n?: number;
|
|
58
|
+
/**
|
|
59
|
+
* The size of the generated images.
|
|
60
|
+
* Must be one of 256x256, 512x512, or 1024x1024 for DALL·E-2 models.
|
|
61
|
+
* Must be one of 1024x1024, 1792x1024, or 1024x1792 for DALL·E-3 models.
|
|
62
|
+
* @default "1024x1024"
|
|
63
|
+
*/
|
|
64
|
+
size?: "256x256" | "512x512" | "1024x1024" | "1792x1024" | "1024x1792";
|
|
65
|
+
/**
|
|
66
|
+
* The format in which the generated images are returned.
|
|
67
|
+
* Must be one of "url" or "b64_json".
|
|
68
|
+
* @default "url"
|
|
69
|
+
*/
|
|
70
|
+
dallEResponseFormat?: "url" | "b64_json";
|
|
71
|
+
/**
|
|
72
|
+
* @deprecated Use dallEResponseFormat instead for the Dall-E response type.
|
|
73
|
+
*/
|
|
74
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
75
|
+
responseFormat?: any;
|
|
76
|
+
/**
|
|
77
|
+
* A unique identifier representing your end-user, which will help
|
|
78
|
+
* OpenAI to monitor and detect abuse.
|
|
79
|
+
*/
|
|
80
|
+
user?: string;
|
|
81
|
+
/**
|
|
82
|
+
* The organization to use
|
|
83
|
+
*/
|
|
84
|
+
organization?: string;
|
|
85
|
+
/**
|
|
86
|
+
* The base URL of the OpenAI API.
|
|
87
|
+
*/
|
|
88
|
+
baseUrl?: string;
|
|
85
89
|
}
|
|
86
90
|
/**
|
|
87
91
|
* A tool for generating images with Open AIs Dall-E 2 or 3 API.
|
|
88
92
|
*/
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
93
|
+
declare class DallEAPIWrapper extends Tool {
|
|
94
|
+
static lc_name(): string;
|
|
95
|
+
name: string;
|
|
96
|
+
description: string;
|
|
97
|
+
protected client: OpenAI$1;
|
|
98
|
+
static readonly toolName: string;
|
|
99
|
+
private model;
|
|
100
|
+
private style;
|
|
101
|
+
private quality;
|
|
102
|
+
private n;
|
|
103
|
+
private size;
|
|
104
|
+
private dallEResponseFormat;
|
|
105
|
+
private user?;
|
|
106
|
+
constructor(fields?: DallEAPIWrapperParams);
|
|
107
|
+
/**
|
|
108
|
+
* Processes the API response if multiple images are generated.
|
|
109
|
+
* Returns a list of MessageContentImageUrl objects. If the response
|
|
110
|
+
* format is `url`, then the `image_url` field will contain the URL.
|
|
111
|
+
* If it is `b64_json`, then the `image_url` field will contain an object
|
|
112
|
+
* with a `url` field with the base64 encoded image.
|
|
113
|
+
*
|
|
114
|
+
* @param {OpenAIClient.Images.ImagesResponse[]} response The API response
|
|
115
|
+
* @returns {MessageContentImageUrl[]}
|
|
116
|
+
*/
|
|
117
|
+
private processMultipleGeneratedUrls;
|
|
118
|
+
/** @ignore */
|
|
119
|
+
_call(input: string): Promise<string | MessageContentComplex[]>;
|
|
116
120
|
}
|
|
121
|
+
//#endregion
|
|
122
|
+
export { DallEAPIWrapper, DallEAPIWrapperParams, OpenAIImageModelId };
|
|
123
|
+
//# sourceMappingURL=dalle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dalle.d.ts","names":["OpenAI","OpenAIClient","Tool","ToolParams","MessageContentComplex","OpenAIImageModelId","ImageModel","NonNullable","DallEAPIWrapperParams","DallEAPIWrapper","Promise"],"sources":["../../src/tools/dalle.d.ts"],"sourcesContent":["import { OpenAI as OpenAIClient } from \"openai\";\nimport { Tool, ToolParams } from \"@langchain/core/tools\";\nimport { MessageContentComplex } from \"@langchain/core/messages\";\n/**\n * @see https://platform.openai.com/docs/api-reference/images/create\n */\nexport type OpenAIImageModelId = OpenAIClient.ImageModel | (string & NonNullable<unknown>);\n/**\n * An interface for the Dall-E API Wrapper.\n */\nexport interface DallEAPIWrapperParams extends ToolParams {\n /**\n * The OpenAI API key\n * Alias for `apiKey`\n */\n openAIApiKey?: string;\n /**\n * The OpenAI API key\n */\n apiKey?: string;\n /**\n * The model to use.\n * Alias for `model`\n * @params \"dall-e-2\" | \"dall-e-3\"\n * @default \"dall-e-3\"\n * @deprecated Use `model` instead.\n */\n modelName?: OpenAIImageModelId;\n /**\n * The model to use.\n * @params \"dall-e-2\" | \"dall-e-3\"\n * @default \"dall-e-3\"\n */\n model?: OpenAIImageModelId;\n /**\n * The style of the generated images. Must be one of vivid or natural.\n * Vivid causes the model to lean towards generating hyper-real and dramatic images.\n * Natural causes the model to produce more natural, less hyper-real looking images.\n * @default \"vivid\"\n */\n style?: \"natural\" | \"vivid\";\n /**\n * The quality of the image that will be generated. ‘hd’ creates images with finer\n * details and greater consistency across the image.\n * @default \"standard\"\n */\n quality?: \"standard\" | \"hd\";\n /**\n * The number of images to generate.\n * Must be between 1 and 10.\n * For dall-e-3, only `n: 1` is supported.\n * @default 1\n */\n n?: number;\n /**\n * The size of the generated images.\n * Must be one of 256x256, 512x512, or 1024x1024 for DALL·E-2 models.\n * Must be one of 1024x1024, 1792x1024, or 1024x1792 for DALL·E-3 models.\n * @default \"1024x1024\"\n */\n size?: \"256x256\" | \"512x512\" | \"1024x1024\" | \"1792x1024\" | \"1024x1792\";\n /**\n * The format in which the generated images are returned.\n * Must be one of \"url\" or \"b64_json\".\n * @default \"url\"\n */\n dallEResponseFormat?: \"url\" | \"b64_json\";\n /**\n * @deprecated Use dallEResponseFormat instead for the Dall-E response type.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n responseFormat?: any;\n /**\n * A unique identifier representing your end-user, which will help\n * OpenAI to monitor and detect abuse.\n */\n user?: string;\n /**\n * The organization to use\n */\n organization?: string;\n /**\n * The base URL of the OpenAI API.\n */\n baseUrl?: string;\n}\n/**\n * A tool for generating images with Open AIs Dall-E 2 or 3 API.\n */\nexport declare class DallEAPIWrapper extends Tool {\n static lc_name(): string;\n name: string;\n description: string;\n protected client: OpenAIClient;\n static readonly toolName: string;\n private model;\n private style;\n private quality;\n private n;\n private size;\n private dallEResponseFormat;\n private user?;\n constructor(fields?: DallEAPIWrapperParams);\n /**\n * Processes the API response if multiple images are generated.\n * Returns a list of MessageContentImageUrl objects. If the response\n * format is `url`, then the `image_url` field will contain the URL.\n * If it is `b64_json`, then the `image_url` field will contain an object\n * with a `url` field with the base64 encoded image.\n *\n * @param {OpenAIClient.Images.ImagesResponse[]} response The API response\n * @returns {MessageContentImageUrl[]}\n */\n private processMultipleGeneratedUrls;\n /** @ignore */\n _call(input: string): Promise<string | MessageContentComplex[]>;\n}\n"],"mappings":";;;;;;;;AAMA;AAA8B,KAAlBK,kBAAAA,GAAqBJ,QAAAA,CAAaK,UAAhB,GAAA,CAAA,MAAA,GAAuCC,WAAvC,CAAA,OAAA,CAAA,CAAA;;;AAAkD;AAI/DC,UAAAA,qBAAAA,SAA8BL,UAAT,CAAA;EAAA;;;;EAAmB,YAAA,CAAA,EAAA,MAAA;EA+EpCM;;;EAIa,MASTD,CAAAA,EAAAA,MAAAA;EAAqB;;;AAbG;;;;cA9DjCH;;;;;;UAMJA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAwDSI,eAAAA,SAAwBP,IAAAA;;;;oBAIvBD;;;;;;;;;uBASGO;;;;;;;;;;;;;wBAaCE,iBAAiBN"}
|