@langchain/openai 0.6.8 → 1.0.0-alpha.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.
Files changed (162) hide show
  1. package/README.md +8 -8
  2. package/dist/_virtual/rolldown_runtime.cjs +25 -0
  3. package/dist/azure/chat_models.cjs +661 -808
  4. package/dist/azure/chat_models.cjs.map +1 -0
  5. package/dist/azure/chat_models.d.cts +449 -0
  6. package/dist/azure/chat_models.d.cts.map +1 -0
  7. package/dist/azure/chat_models.d.ts +32 -28
  8. package/dist/azure/chat_models.d.ts.map +1 -0
  9. package/dist/azure/chat_models.js +660 -804
  10. package/dist/azure/chat_models.js.map +1 -0
  11. package/dist/azure/embeddings.cjs +81 -130
  12. package/dist/azure/embeddings.cjs.map +1 -0
  13. package/dist/azure/embeddings.d.cts +27 -0
  14. package/dist/azure/embeddings.d.cts.map +1 -0
  15. package/dist/azure/embeddings.d.ts +25 -20
  16. package/dist/azure/embeddings.d.ts.map +1 -0
  17. package/dist/azure/embeddings.js +80 -126
  18. package/dist/azure/embeddings.js.map +1 -0
  19. package/dist/azure/llms.cjs +109 -168
  20. package/dist/azure/llms.cjs.map +1 -0
  21. package/dist/azure/llms.d.cts +33 -0
  22. package/dist/azure/llms.d.cts.map +1 -0
  23. package/dist/azure/llms.d.ts +31 -25
  24. package/dist/azure/llms.d.ts.map +1 -0
  25. package/dist/azure/llms.js +108 -164
  26. package/dist/azure/llms.js.map +1 -0
  27. package/dist/chat_models.cjs +1951 -2763
  28. package/dist/chat_models.cjs.map +1 -0
  29. package/dist/chat_models.d.cts +930 -0
  30. package/dist/chat_models.d.cts.map +1 -0
  31. package/dist/chat_models.d.ts +365 -336
  32. package/dist/chat_models.d.ts.map +1 -0
  33. package/dist/chat_models.js +1946 -2753
  34. package/dist/chat_models.js.map +1 -0
  35. package/dist/embeddings.cjs +136 -193
  36. package/dist/embeddings.cjs.map +1 -0
  37. package/dist/embeddings.d.cts +115 -0
  38. package/dist/embeddings.d.cts.map +1 -0
  39. package/dist/embeddings.d.ts +88 -81
  40. package/dist/embeddings.d.ts.map +1 -0
  41. package/dist/embeddings.js +134 -188
  42. package/dist/embeddings.js.map +1 -0
  43. package/dist/index.cjs +47 -34
  44. package/dist/index.d.cts +16 -0
  45. package/dist/index.d.ts +16 -13
  46. package/dist/index.js +17 -13
  47. package/dist/langchain-core/dist/types/_internal.d.cts +11 -0
  48. package/dist/langchain-core/dist/types/_internal.d.cts.map +1 -0
  49. package/dist/langchain-core/dist/types/_internal.d.ts +11 -0
  50. package/dist/langchain-core/dist/types/_internal.d.ts.map +1 -0
  51. package/dist/langchain-core/dist/utils/stream.d.cts +26 -0
  52. package/dist/langchain-core/dist/utils/stream.d.cts.map +1 -0
  53. package/dist/langchain-core/dist/utils/stream.d.ts +26 -0
  54. package/dist/langchain-core/dist/utils/stream.d.ts.map +1 -0
  55. package/dist/llms.cjs +312 -468
  56. package/dist/llms.cjs.map +1 -0
  57. package/dist/llms.d.cts +123 -0
  58. package/dist/llms.d.cts.map +1 -0
  59. package/dist/llms.d.ts +93 -87
  60. package/dist/llms.d.ts.map +1 -0
  61. package/dist/llms.js +309 -462
  62. package/dist/llms.js.map +1 -0
  63. package/dist/tools/custom.cjs +25 -26
  64. package/dist/tools/custom.cjs.map +1 -0
  65. package/dist/tools/custom.d.cts +10 -0
  66. package/dist/tools/custom.d.cts.map +1 -0
  67. package/dist/tools/custom.d.ts +8 -3
  68. package/dist/tools/custom.d.ts.map +1 -0
  69. package/dist/tools/custom.js +24 -23
  70. package/dist/tools/custom.js.map +1 -0
  71. package/dist/tools/dalle.cjs +104 -194
  72. package/dist/tools/dalle.cjs.map +1 -0
  73. package/dist/tools/dalle.d.cts +123 -0
  74. package/dist/tools/dalle.d.cts.map +1 -0
  75. package/dist/tools/dalle.d.ts +111 -104
  76. package/dist/tools/dalle.d.ts.map +1 -0
  77. package/dist/tools/dalle.js +102 -189
  78. package/dist/tools/dalle.js.map +1 -0
  79. package/dist/tools/index.cjs +1 -17
  80. package/dist/tools/index.js +1 -1
  81. package/dist/types.d.cts +263 -0
  82. package/dist/types.d.cts.map +1 -0
  83. package/dist/types.d.ts +244 -234
  84. package/dist/types.d.ts.map +1 -0
  85. package/dist/utils/azure.cjs +86 -47
  86. package/dist/utils/azure.cjs.map +1 -0
  87. package/dist/utils/azure.d.cts +76 -0
  88. package/dist/utils/azure.d.cts.map +1 -0
  89. package/dist/utils/azure.d.ts +51 -9
  90. package/dist/utils/azure.d.ts.map +1 -0
  91. package/dist/utils/azure.js +85 -45
  92. package/dist/utils/azure.js.map +1 -0
  93. package/dist/utils/client.cjs +25 -0
  94. package/dist/utils/client.cjs.map +1 -0
  95. package/dist/utils/client.d.cts +5 -0
  96. package/dist/utils/client.d.cts.map +1 -0
  97. package/dist/utils/client.d.ts +5 -0
  98. package/dist/utils/client.d.ts.map +1 -0
  99. package/dist/utils/client.js +24 -0
  100. package/dist/utils/client.js.map +1 -0
  101. package/dist/utils/errors.cjs +9 -8
  102. package/dist/utils/errors.cjs.map +1 -0
  103. package/dist/utils/errors.js +9 -6
  104. package/dist/utils/errors.js.map +1 -0
  105. package/dist/utils/message_inputs.cjs +139 -0
  106. package/dist/utils/message_inputs.cjs.map +1 -0
  107. package/dist/utils/message_inputs.d.cts +9 -0
  108. package/dist/utils/message_inputs.d.cts.map +1 -0
  109. package/dist/utils/message_inputs.d.ts +9 -0
  110. package/dist/utils/message_inputs.d.ts.map +1 -0
  111. package/dist/utils/message_inputs.js +137 -0
  112. package/dist/utils/message_inputs.js.map +1 -0
  113. package/dist/utils/misc.cjs +30 -0
  114. package/dist/utils/misc.cjs.map +1 -0
  115. package/dist/utils/misc.d.cts +9 -0
  116. package/dist/utils/misc.d.cts.map +1 -0
  117. package/dist/utils/misc.d.ts +9 -0
  118. package/dist/utils/misc.d.ts.map +1 -0
  119. package/dist/utils/misc.js +27 -0
  120. package/dist/utils/misc.js.map +1 -0
  121. package/dist/utils/output.cjs +74 -0
  122. package/dist/utils/output.cjs.map +1 -0
  123. package/dist/utils/output.js +72 -0
  124. package/dist/utils/output.js.map +1 -0
  125. package/dist/utils/prompts.cjs +39 -38
  126. package/dist/utils/prompts.cjs.map +1 -0
  127. package/dist/utils/prompts.d.cts +42 -0
  128. package/dist/utils/prompts.d.cts.map +1 -0
  129. package/dist/utils/prompts.d.ts +10 -4
  130. package/dist/utils/prompts.d.ts.map +1 -0
  131. package/dist/utils/prompts.js +40 -36
  132. package/dist/utils/prompts.js.map +1 -0
  133. package/dist/utils/standard.cjs +113 -0
  134. package/dist/utils/standard.cjs.map +1 -0
  135. package/dist/utils/standard.js +111 -0
  136. package/dist/utils/standard.js.map +1 -0
  137. package/dist/utils/tools.cjs +150 -127
  138. package/dist/utils/tools.cjs.map +1 -0
  139. package/dist/utils/tools.d.cts +13 -0
  140. package/dist/utils/tools.d.cts.map +1 -0
  141. package/dist/utils/tools.d.ts +12 -42
  142. package/dist/utils/tools.d.ts.map +1 -0
  143. package/dist/utils/tools.js +146 -123
  144. package/dist/utils/tools.js.map +1 -0
  145. package/package.json +33 -41
  146. package/dist/tools/index.d.ts +0 -1
  147. package/dist/types.cjs +0 -2
  148. package/dist/types.js +0 -1
  149. package/dist/utils/errors.d.ts +0 -2
  150. package/dist/utils/headers.cjs +0 -39
  151. package/dist/utils/headers.d.ts +0 -8
  152. package/dist/utils/headers.js +0 -35
  153. package/dist/utils/openai-format-fndef.cjs +0 -80
  154. package/dist/utils/openai-format-fndef.d.ts +0 -44
  155. package/dist/utils/openai-format-fndef.js +0 -77
  156. package/dist/utils/openai.cjs +0 -127
  157. package/dist/utils/openai.d.ts +0 -15
  158. package/dist/utils/openai.js +0 -119
  159. package/index.cjs +0 -1
  160. package/index.d.cts +0 -1
  161. package/index.d.ts +0 -1
  162. 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"}
@@ -1,116 +1,123 @@
1
- import { OpenAI as OpenAIClient } from "openai";
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
- export type OpenAIImageModelId = OpenAIClient.ImageModel | (string & NonNullable<unknown>);
10
+ type OpenAIImageModelId = OpenAI$1.ImageModel | (string & NonNullable<unknown>);
8
11
  /**
9
12
  * An interface for the Dall-E API Wrapper.
10
13
  */
11
- export interface DallEAPIWrapperParams extends ToolParams {
12
- /**
13
- * The OpenAI API key
14
- * Alias for `apiKey`
15
- */
16
- openAIApiKey?: string;
17
- /**
18
- * The OpenAI API key
19
- */
20
- apiKey?: string;
21
- /**
22
- * The model to use.
23
- * Alias for `model`
24
- * @params "dall-e-2" | "dall-e-3"
25
- * @default "dall-e-3"
26
- * @deprecated Use `model` instead.
27
- */
28
- modelName?: OpenAIImageModelId;
29
- /**
30
- * The model to use.
31
- * @params "dall-e-2" | "dall-e-3"
32
- * @default "dall-e-3"
33
- */
34
- model?: OpenAIImageModelId;
35
- /**
36
- * The style of the generated images. Must be one of vivid or natural.
37
- * Vivid causes the model to lean towards generating hyper-real and dramatic images.
38
- * Natural causes the model to produce more natural, less hyper-real looking images.
39
- * @default "vivid"
40
- */
41
- style?: "natural" | "vivid";
42
- /**
43
- * The quality of the image that will be generated. ‘hd’ creates images with finer
44
- * details and greater consistency across the image.
45
- * @default "standard"
46
- */
47
- quality?: "standard" | "hd";
48
- /**
49
- * The number of images to generate.
50
- * Must be between 1 and 10.
51
- * For dall-e-3, only `n: 1` is supported.
52
- * @default 1
53
- */
54
- n?: number;
55
- /**
56
- * The size of the generated images.
57
- * Must be one of 256x256, 512x512, or 1024x1024 for DALL·E-2 models.
58
- * Must be one of 1024x1024, 1792x1024, or 1024x1792 for DALL·E-3 models.
59
- * @default "1024x1024"
60
- */
61
- size?: "256x256" | "512x512" | "1024x1024" | "1792x1024" | "1024x1792";
62
- /**
63
- * The format in which the generated images are returned.
64
- * Must be one of "url" or "b64_json".
65
- * @default "url"
66
- */
67
- dallEResponseFormat?: "url" | "b64_json";
68
- /**
69
- * @deprecated Use dallEResponseFormat instead for the Dall-E response type.
70
- */
71
- responseFormat?: any;
72
- /**
73
- * A unique identifier representing your end-user, which will help
74
- * OpenAI to monitor and detect abuse.
75
- */
76
- user?: string;
77
- /**
78
- * The organization to use
79
- */
80
- organization?: string;
81
- /**
82
- * The base URL of the OpenAI API.
83
- */
84
- baseUrl?: string;
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
- export declare class DallEAPIWrapper extends Tool {
90
- static lc_name(): string;
91
- name: string;
92
- description: string;
93
- protected client: OpenAIClient;
94
- static readonly toolName = "dalle_api_wrapper";
95
- private model;
96
- private style;
97
- private quality;
98
- private n;
99
- private size;
100
- private dallEResponseFormat;
101
- private user?;
102
- constructor(fields?: DallEAPIWrapperParams);
103
- /**
104
- * Processes the API response if multiple images are generated.
105
- * Returns a list of MessageContentImageUrl objects. If the response
106
- * format is `url`, then the `image_url` field will contain the URL.
107
- * If it is `b64_json`, then the `image_url` field will contain an object
108
- * with a `url` field with the base64 encoded image.
109
- *
110
- * @param {OpenAIClient.Images.ImagesResponse[]} response The API response
111
- * @returns {MessageContentImageUrl[]}
112
- */
113
- private processMultipleGeneratedUrls;
114
- /** @ignore */
115
- _call(input: string): Promise<string | MessageContentComplex[]>;
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"}