{"version":3,"file":"index.cjs","names":["Serializable","OpenAIClient"],"sources":["../../../src/experimental/openai_files/index.ts"],"sourcesContent":["import { OpenAIClient, type ClientOptions } from \"@langchain/openai\";\nimport { Serializable } from \"@langchain/core/load/serializable\";\n\nexport type OpenAIFilesInput = {\n  client?: OpenAIClient;\n  clientOptions?: ClientOptions;\n};\n\nexport class OpenAIFiles extends Serializable {\n  lc_namespace = [\"langchain\", \"experimental\"];\n\n  private oaiClient: OpenAIClient;\n\n  constructor(fields?: OpenAIFilesInput) {\n    super(fields);\n    this.oaiClient = fields?.client ?? new OpenAIClient(fields?.clientOptions);\n  }\n\n  /**\n   * Upload file\n   * Upload a file that can be used across various endpoints. The size of all the files uploaded by one organization can be up to 100 GB.\n   *\n   * @note The size of individual files can be a maximum of 512 MB. See the Assistants Tools guide to learn more about the types of files supported. The Fine-tuning API only supports .jsonl files.\n   *\n   * @link {https://platform.openai.com/docs/api-reference/files/create}\n   * @param {OpenAIClient.FileCreateParams['file']} file\n   * @param {OpenAIClient.FileCreateParams['purpose']} purpose\n   * @param {OpenAIClient.RequestOptions | undefined} options\n   * @returns {Promise<OpenAIClient.Files.FileObject>}\n   */\n  async createFile({\n    file,\n    purpose,\n    options,\n  }: OpenAIClient.FileCreateParams & {\n    options?: OpenAIClient.RequestOptions;\n  }) {\n    return this.oaiClient.files.create({ file, purpose }, options);\n  }\n\n  /**\n   * Delete a file.\n   *\n   * @link {https://platform.openai.com/docs/api-reference/files/delete}\n   * @param {string} fileId\n   * @param {OpenAIClient.RequestOptions | undefined} options\n   * @returns {Promise<OpenAIClient.Files.FileDeleted>}\n   */\n  async deleteFile({\n    fileId,\n    options,\n  }: {\n    fileId: string;\n    options?: OpenAIClient.RequestOptions;\n  }) {\n    return this.oaiClient.files.delete(fileId, options);\n  }\n\n  /**\n   * List files\n   * Returns a list of files that belong to the user's organization.\n   *\n   * @link {https://platform.openai.com/docs/api-reference/files/list}\n   * @param {OpenAIClient.Files.FileListParams | undefined} query\n   * @param {OpenAIClient.RequestOptions | undefined} options\n   * @returns {Promise<OpenAIClient.Files.FileObjectsPage>}\n   */\n  async listFiles(props?: {\n    query?: OpenAIClient.Files.FileListParams;\n    options?: OpenAIClient.RequestOptions;\n  }) {\n    return this.oaiClient.files.list(props?.query, props?.options);\n  }\n\n  /**\n   * Retrieve file\n   * Returns information about a specific file.\n   *\n   * @link {https://platform.openai.com/docs/api-reference/files/retrieve}\n   * @param {string} fileId\n   * @param {OpenAIClient.RequestOptions | undefined} options\n   * @returns {Promise<OpenAIClient.Files.FileObject>}\n   */\n  async retrieveFile({\n    fileId,\n    options,\n  }: {\n    fileId: string;\n    options?: OpenAIClient.RequestOptions;\n  }) {\n    return this.oaiClient.files.retrieve(fileId, options);\n  }\n\n  /**\n   * Retrieve file content\n   * Returns the contents of the specified file.\n   *\n   * @note You can't retrieve the contents of a file that was uploaded with the \"purpose\": \"assistants\" API.\n   *\n   * @link {https://platform.openai.com/docs/api-reference/files/retrieve-contents}\n   * @param {string} fileId\n   * @param {OpenAIClient.RequestOptions | undefined} options\n   * @returns {Promise<string>}\n   */\n  async retrieveFileContent({\n    fileId,\n    options,\n  }: {\n    fileId: string;\n    options?: OpenAIClient.RequestOptions;\n  }) {\n    return this.oaiClient.files.retrieve(fileId, options);\n  }\n}\n"],"mappings":";;;;;;AAQA,IAAa,cAAb,cAAiCA,kCAAAA,aAAa;CAC5C,eAAe,CAAC,aAAa,cAAc;CAE3C;CAEA,YAAY,QAA2B;EACrC,MAAM,MAAM;EACZ,KAAK,YAAY,QAAQ,UAAU,IAAIC,kBAAAA,aAAa,QAAQ,aAAa;CAC3E;;;;;;;;;;;;;CAcA,MAAM,WAAW,EACf,MACA,SACA,WAGC;EACD,OAAO,KAAK,UAAU,MAAM,OAAO;GAAE;GAAM;EAAQ,GAAG,OAAO;CAC/D;;;;;;;;;CAUA,MAAM,WAAW,EACf,QACA,WAIC;EACD,OAAO,KAAK,UAAU,MAAM,OAAO,QAAQ,OAAO;CACpD;;;;;;;;;;CAWA,MAAM,UAAU,OAGb;EACD,OAAO,KAAK,UAAU,MAAM,KAAK,OAAO,OAAO,OAAO,OAAO;CAC/D;;;;;;;;;;CAWA,MAAM,aAAa,EACjB,QACA,WAIC;EACD,OAAO,KAAK,UAAU,MAAM,SAAS,QAAQ,OAAO;CACtD;;;;;;;;;;;;CAaA,MAAM,oBAAoB,EACxB,QACA,WAIC;EACD,OAAO,KAAK,UAAU,MAAM,SAAS,QAAQ,OAAO;CACtD;AACF"}