UNPKG

@langchain/openai

Version:
1 lines 4.57 kB
{"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 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 = \"dalle_api_wrapper\";\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//# sourceMappingURL=dalle.d.ts.map"],"mappings":";;;;;;;;AAMA;AAIiBQ,KAJLH,kBAAAA,GAAqBJ,QAAAA,CAAaK,UAIR,GAAA,CAAA,MAAA,GAJ+BC,WAI/B,CAAA,OAAA,CAAA,CAAA;;;;AAAmB,UAAxCC,qBAAAA,SAA8BL,UAAU,CAAA;EA8EpCM;;;;EA0BKC,YAAAA,CAAAA,EAAAA,MAAAA;EA1BmBR;AAAI;;;;;;;;;;cA7DjCG;;;;;;UAMJA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAuDSI,eAAAA,SAAwBP,IAAAA;;;;oBAIvBD;;;;;;;;;uBASGO;;;;;;;;;;;;;wBAaCE,iBAAiBN"}