{"version":3,"sources":["jsdelivr-header.js","/npm/@aiapi/dify@0.0.1/dist/index.common.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACNA,aAEA,QAAQ,iCACR,OAAO,eAAe,QAAS,aAAc,CAC3C,OAAO,IAET,IAAI,MAAQ,QAAQ,SACpB,SAAS,sBAAsB,GAC7B,OAAO,GAAkB,iBAAN,GAAkB,YAAa,EAAI,EAAI,CACxD,QAAW,EAEf,CACA,IAAI,eAA8B,sBAAsB,OACxD,IAAI,OAAS,CACX,WAAY,eAUd,SAAS,aAAa,GAChB,SAAoC,EAAK,aAC3C,OAAO,WAAa,EAAK,WAE7B,CACA,SAAS,mBACP,OAAO,MACT,CAiBA,SAAS,eAAe,GACtB,MAAM,MACJ,EAAK,UACL,EAAS,OACT,EAAM,cACN,EAAa,KACb,EAAI,eACJ,GACE,EACJ,OAAO,IAAI,SAAQ,CAAC,EAAS,KAC3B,MAAM,EAAW,KAAK,UAAU,CAC9B,OAAQ,QAAuC,EAAS,CAAC,EACzD,MAAO,EACP,cAAe,QAAqD,EAAgB,WACpF,KAAM,QAAmC,EAAO,KAAK,SAAS,SAAS,IAAI,MAAM,GACjF,gBAAiB,QAAuD,OAAiB,IAErF,EAAU,CACd,SAAU,mBAAmB,WAC7B,KAAM,oBACN,OAAQ,OACR,QAAS,CACP,cAAiB,UAAU,IAC3B,eAAgB,kCAChB,iBAAkB,OAAO,WAAW,KAGlC,EAAM,eAAwB,QAAE,QAAQ,GAAS,IACrD,IAAI,EAAO,GACX,EAAI,YAAY,SAChB,EAAI,GAAG,QAAQ,IACb,GAAQ,CAAK,IAEf,EAAI,GAAG,OAAO,KACZ,EAAQ,KAAK,MAAM,GAAM,GACzB,IAEJ,EAAI,GAAG,SAAS,IACd,EAAO,EAAM,IAEf,EAAI,MAAM,GACV,EAAI,KAAK,GAEb,CACA,QAAQ,eAAiB,eACzB,QAAQ,aAAe","file":"/npm/@aiapi/dify@0.0.1/dist/index.common.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@aiapi/dify@0.0.1/dist/index.common.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","'use strict';\n\nrequire(\"core-js/modules/es.promise.js\");\nObject.defineProperty(exports, '__esModule', {\n  value: true\n});\nvar https = require('https');\nfunction _interopDefaultLegacy(e) {\n  return e && typeof e === 'object' && 'default' in e ? e : {\n    'default': e\n  };\n}\nvar https__default = /*#__PURE__*/_interopDefaultLegacy(https);\nlet config = {\n  customHost: 'api.dify.ai'\n};\n/**\n * ### Dify Custom Configuration\n * Setup dify-compatible service with custom host settings\n *\n * @param {DifyAppApiConfig} conf - Configuration parameters\n * @return {void}\n *\n */\nfunction setupDifyApi(conf) {\n  if (conf !== null && conf !== void 0 && conf.customHost) {\n    config.customHost = conf.customHost;\n  }\n}\nfunction getDifyApiConfig() {\n  return config;\n}\n\n/**\n * ### Dify Completion API【Experimental Version】\n * Returns a Promise that resolves to a string using the provided parameters.\n *\n * @param {DifyCompletionCallParamsExp} params - Parameters for the API call.\n *\n * @param {string} params.query - The text content to be supplemented\n * @param {string} params.bearerKey - AIDA application AppId\n * @param {object} params.inputs - Variable content, formatted as a key-value pair object\n * @param {string} params.response_mode - Response mode, default is 'blocking'\n * @param {string} params.user - Username, if not filled, a random string will be generated\n * @param {string} params.conversationId - Conversation ID, if not filled, a random one will be generated\n * @return {Promise<string>} A Promise that resolves to a string, representing the API's response.\n *\n */\nfunction difyCompletion(params) {\n  const {\n    query,\n    bearerKey,\n    inputs,\n    response_mode,\n    user,\n    conversationId\n  } = params;\n  return new Promise((resolve, reject) => {\n    const postData = JSON.stringify({\n      inputs: inputs !== null && inputs !== void 0 ? inputs : {},\n      query: query,\n      response_mode: response_mode !== null && response_mode !== void 0 ? response_mode : 'blocking',\n      user: user !== null && user !== void 0 ? user : Math.random().toString(36).slice(3),\n      conversation_id: conversationId !== null && conversationId !== void 0 ? conversationId : undefined\n    });\n    const options = {\n      hostname: getDifyApiConfig().customHost,\n      path: '/v1/chat-messages',\n      method: 'POST',\n      headers: {\n        'Authorization': `Bearer ${bearerKey}`,\n        'Content-Type': 'application/json; chatset=utf-8',\n        'Content-Length': Buffer.byteLength(postData)\n      }\n    };\n    const req = https__default[\"default\"].request(options, res => {\n      let data = '';\n      res.setEncoding('utf-8');\n      res.on('data', chunk => {\n        data += chunk;\n      });\n      res.on('end', () => {\n        resolve(JSON.parse(data));\n      });\n    });\n    req.on('error', error => {\n      reject(error);\n    });\n    req.write(postData);\n    req.end();\n  });\n}\nexports.difyCompletion = difyCompletion;\nexports.setupDifyApi = setupDifyApi;\n"]}