diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/Embedding Model Deployment.ipynb b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/Embedding Model Deployment.ipynb index c837e4d4..60c76fcc 100644 --- a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/Embedding Model Deployment.ipynb +++ b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/Embedding Model Deployment.ipynb @@ -72,6 +72,7 @@ "# Copy Model from huggingface\n", "# git clone https://huggingface.co/jinaai/jina-embeddings-v2-base-en\n", "# cd jina-embeddings-v2-base-en\n", + "# rm *.onnx\n", "# wget https://huggingface.co/jinaai/jina-embeddings-v2-base-en/resolve/main/model-w-mean-pooling.onnx\n", "# cd ..\n", "# mkdir embedding_model_artifact\n", @@ -464,4 +465,4 @@ }, "nbformat": 4, "nbformat_minor": 5 -} \ No newline at end of file +} diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/Load Documents.ipynb b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/Load Documents.ipynb index ff7e891f..30bb1f25 100644 --- a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/Load Documents.ipynb +++ b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/Load Documents.ipynb @@ -64,7 +64,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 1, "id": "7f46ded9-ff40-455d-9722-4e2a07ad738b", "metadata": { "tags": [] @@ -76,64 +76,432 @@ }, { "cell_type": "code", - "execution_count": 4, - "id": "e857ddf5-74ef-446b-a581-98fa612f6816", + "execution_count": null, + "id": "88edd895-95a4-444d-a754-b0de321d2344", + "metadata": {}, + "outputs": [], + "source": [ + "# If Embedding model is not deployed already, please follow below steps\n", + "# Copy Model from huggingface\n", + "# git clone https://huggingface.co/jinaai/jina-embeddings-v2-base-en\n", + "# cd jina-embeddings-v2-base-en\n", + "# rm *.onnx\n", + "# wget https://huggingface.co/jinaai/jina-embeddings-v2-base-en/resolve/main/model-w-mean-pooling.onnx\n", + "# cd ..\n", + "# mkdir embedding_model_artifact\n", + "# mv jina-embeddings-v2-base-en/* embedding_model_artifact/" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "e1e16761-f9f4-44be-be48-87a5a0a3de38", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "import tempfile\n", + "import ads\n", + "from ads.model.generic_model import GenericModel\n", + "from config import CONDA_PACK_PATH, LOG_GROUP_ID, EMBEDDING_MODEL_ACCESS_LOG_LOG_ID, EMBEDDING_MODEL_PREDICT_LOG_LOG_ID \n", + "ads.set_auth(\"resource_principal\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "d182f69f-0202-4cf1-b634-cb27f7e13795", "metadata": { "tags": [] }, "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "WARNING:ads.common:In the future model input will be serialized by `cloudpickle` by default. Currently, model input are serialized into a dictionary containing serialized input data and original data type information.Set `model_input_serializer=\"cloudpickle\"` to use cloudpickle model input serializer.\n" + ] + }, { "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "d4b43e87df1f4f4884ceb3c3968b738a", - "version_major": 2, - "version_minor": 0 - }, + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
Actions Needed
StepStatusDetails
initiateDoneInitiated the model
prepare()AvailableGenerated runtime.yaml
Generated score.py
Serialized model
Populated metadata(Custom, Taxonomy and Provenance)
verify()Not AvailableLocal tested .predict from score.py
save()Not AvailableConducted Introspect Test
Uploaded artifact to model catalog
deploy()UNKNOWNDeployed the model
predict()Not AvailableCalled deployment predict endpoint
\n", + "
" + ], "text/plain": [ - "loop1: 0%| | 0/4 [00:00@/' instead of slug.\n", + "INFO:ADS:To auto-extract taxonomy metadata the model must be provided. Supported models: keras, lightgbm, pytorch, sklearn, tensorflow, pyspark, and xgboost.\n" + ] }, + { + "data": { + "text/plain": [ + "algorithm: null\n", + "artifact_dir:\n", + " /home/datascience/embedding_model_artifact:\n", + " - - special_tokens_map.json\n", + " - runtime.yaml\n", + " - model.safetensors\n", + " - pytorch_model.bin\n", + " - README.md\n", + " - config.json\n", + " - tokenizer_config.json\n", + " - .model-ignore\n", + " - vocab.txt\n", + " - score.py\n", + " - generation_config.json\n", + " - modules.json\n", + " - config_sentence_transformers.json\n", + " - tokenizer.json\n", + " - model-w-mean-pooling.onnx.1\n", + " - sentence_bert_config.json\n", + " - model-w-mean-pooling.onnx\n", + " - coreml\n", + " - 1_Pooling\n", + " - coreml/float32_model.mlpackage\n", + " - coreml/float32_model.mlpackage/Manifest.json\n", + " - coreml/float32_model.mlpackage/Data\n", + " - coreml/float32_model.mlpackage/Data/com.apple.CoreML\n", + " - coreml/float32_model.mlpackage/Data/com.apple.CoreML/model.mlmodel\n", + " - coreml/float32_model.mlpackage/Data/com.apple.CoreML/weights\n", + " - coreml/float32_model.mlpackage/Data/com.apple.CoreML/weights/weight.bin\n", + " - 1_Pooling/config.json\n", + "framework: null\n", + "model_deployment_id: null\n", + "model_id: null" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "embedding_model.prepare(\n", + " inference_conda_env=CONDA_PACK_PATH,\n", + " inference_python_version = \"3.9\",\n", + " model_file_name=\"model.onnx\",\n", + " score_py_uri= \"embedding_model_score.py\",\n", + " force_overwrite=True\n", + " )" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "06f05cbb-8f4e-4b68-8be8-c327157edb7c", + "metadata": { + "tags": [] + }, + "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "WARNING:ads.common:In the future model input will be serialized by `cloudpickle` by default. Currently, model input are serialized into a dictionary containing serialized input data and original data type information.Set `model_input_serializer=\"cloudpickle\"` to use cloudpickle model input serializer.\n" + "Model is successfully loaded.\n", + "[[-0.3025473356246948, -0.2631644010543823, 0.33424049615859985, -0.23177050054073334, -0.08931080996990204, 0.48502910137176514, -0.07448308169841766, -0.40402457118034363, -0.5292817950248718, 0.8512760400772095, -0.9099698066711426, -0.3379335105419159, -0.47660312056541443, 0.4009893834590912, 0.03474418818950653, 0.9377697110176086, -0.3208032250404358, -0.2642645537853241, -0.128304123878479, -0.9947263598442078, -0.587630569934845, -0.019148023799061775, -0.26633620262145996, -0.014588565565645695, 0.22666318714618683, 0.514503002166748, 0.22751407325267792, 0.06005936115980148, 0.4696788787841797, 0.27475905418395996, 0.4665174186229706, 0.4529200792312622, -0.24493767321109772, 0.6228052377700806, -0.7501861453056335, -0.4651184380054474, 0.04736478626728058, -0.2261052131652832, 0.437692791223526, 0.3957967758178711, 0.0043040732853114605, 0.34069889783859253, -0.04769007861614227, 0.5361369848251343, -0.38854801654815674, -0.13371390104293823, 0.0659462958574295, 0.5597161650657654, -0.4240521490573883, -0.8884644508361816, -0.6652486324310303, -0.09821471571922302, -0.022537752985954285, -0.5785871744155884, 0.04531591758131981, 0.27542605996131897, 1.181992530822754, 0.5544866919517517, -0.3568640947341919, -0.11131684482097626, -0.43130120635032654, 1.4481840133666992, -0.026700319722294807, 0.8291786313056946, 0.25250643491744995, 0.3229728043079376, -0.11908663064241409, -0.3036207854747772, -0.08692589402198792, 0.03992808237671852, 0.19521397352218628, 0.5192809104919434, -0.2502015233039856, -0.07217817008495331, 0.7105072736740112, 0.30234062671661377, -0.2028578519821167, -0.5643038153648376, -0.7877668142318726, 0.26425036787986755, 1.058711290359497, 0.667824923992157, 0.4456162750720978, -0.030109982937574387, -0.36097052693367004, 0.1982700377702713, -0.19823284447193146, 0.25268325209617615, 0.31241339445114136, 0.22042566537857056, -0.3727662265300751, 0.6165490746498108, -0.5169112682342529, 0.6731522083282471, -0.09797259420156479, -0.06871530413627625, -0.004355528391897678, -0.7954685688018799, 0.071345254778862, -0.5776548385620117, 0.842652440071106, 0.5943145155906677, 0.6822025179862976, -0.04149259626865387, 0.24894647300243378, -0.41746124625205994, -0.00927684921771288, -0.3324928283691406, -0.15332400798797607, 0.16691896319389343, -0.42531031370162964, 0.07839794456958771, 0.5781358480453491, -1.0345654487609863, -0.18034403026103973, 0.22230978310108185, 0.0036839484237134457, -0.33152303099632263, -0.22224508225917816, -0.08816057443618774, -0.561345636844635, 0.5559144020080566, 0.18235832452774048, -0.4888903796672821, 0.38820400834083557, 0.32350975275039673, 0.9628280401229858, -0.45207110047340393, -0.1479186862707138, -0.4928866922855377, 0.4517345726490021, -0.6285635828971863, 1.0508356094360352, -0.3134218752384186, -0.3928152322769165, 0.004262890666723251, 0.048182643949985504, 0.16474312543869019, -0.0708373561501503, 0.253814697265625, -0.589372456073761, 0.07318740338087082, -0.5296180844306946, 0.16378353536128998, -0.2525032162666321, -0.10093508660793304, -0.691976010799408, 0.6206678748130798, 0.5794920921325684, -0.8842992186546326, 0.9254667162895203, -0.16788913309574127, -0.6463350653648376, 0.7503431439399719, -0.2977015972137451, -0.49627041816711426, 0.24080002307891846, 0.06259515881538391, 0.04830131679773331, -0.5184661746025085, -0.26929694414138794, -0.5989653468132019, -0.8474488854408264, -0.5523844361305237, -0.2307356894016266, 0.9383553862571716, -0.10082458704710007, -0.2571766674518585, 0.44823288917541504, -0.46090224385261536, 0.8580090999603271, -0.0407974049448967, -0.6572233438491821, 0.7265117168426514, -0.2556632459163666, -0.27381980419158936, 0.06932579725980759, -0.41019535064697266, -0.4981876313686371, 0.5061588287353516, 0.08532159775495529, 0.6898601651191711, 0.874352216720581, 0.7582501173019409, -0.11218499392271042, -0.39234915375709534, 0.617608904838562, -0.6916558146476746, 0.3537963032722473, 0.32802700996398926, -1.2060898542404175, -0.004769648425281048, -0.11810529977083206, 0.16309282183647156, 0.42900025844573975, 0.03583943471312523, 0.11522361636161804, -0.017883945256471634, -0.636425793170929, -0.29956328868865967, 0.15827861428260803, 0.02994263358414173, 0.22076061367988586, 0.2329641580581665, -0.12394623458385468, -0.9610283374786377, -0.9344488382339478, -0.8687204122543335, -0.1276138573884964, 0.19771228730678558, 0.5881269574165344, 0.44595566391944885, -0.3204445540904999, 1.0349966287612915, -1.1187719106674194, -0.7234774231910706, -0.725970447063446, -0.22736483812332153, 0.11788680404424667, 0.2275872826576233, 0.3189033567905426, -1.0513519048690796, -1.0597283840179443, -0.10039633512496948, -0.793191134929657, -0.5026013851165771, 0.23157523572444916, 0.22019273042678833, 0.7193118333816528, 0.4200531244277954, -0.4346151053905487, 1.0507972240447998, 0.5051576495170593, -0.10076120495796204, 0.8933001160621643, -0.3842739760875702, 1.0854065418243408, -0.4415312111377716, -0.29603901505470276, -0.18797385692596436, -0.42445483803749084, -0.010202948935329914, 0.235786572098732, -0.10756418853998184, 0.015441336669027805, -0.5930590033531189, 0.4740995466709137, -0.07391377538442612, -0.06289232522249222, 0.13138478994369507, -0.2603852152824402, 0.27791544795036316, 0.6839379072189331, -0.14660567045211792, 0.8474767208099365, 0.30010852217674255, -0.1995002031326294, 0.8160516619682312, -0.10367802530527115, -0.05750521644949913, 0.2780536711215973, -0.862217128276825, -0.24702145159244537, 0.3677314519882202, 1.0492148399353027, -1.4341192245483398, -0.9599344730377197, -0.07759822905063629, -0.40081924200057983, -0.1828007698059082, 0.037031058222055435, -0.034161414951086044, -0.39323633909225464, -0.7042860388755798, 1.0024874210357666, 0.49861857295036316, -0.020712394267320633, 0.622585117816925, 0.09276969730854034, 0.5236400365829468, -0.21038198471069336, -0.8182898163795471, -0.2597728669643402, -0.24010977149009705, 0.028066320344805717, 0.17723535001277924, -0.07608594745397568, -0.6820343136787415, 0.2744409441947937, -0.7509245276451111, 0.24144341051578522, -0.6074485182762146, 0.6731881499290466, 0.19943875074386597, 0.11881975829601288, -0.836112380027771, -0.4379643499851227, -0.5893658995628357, -0.11101078242063522, 0.14832478761672974, 1.093418002128601, -0.19330257177352905, -0.4516104757785797, -1.0890880823135376, 0.8796780109405518, 0.5251556038856506, 0.3787493109703064, 0.24625881016254425, 0.3324413597583771, -0.4208206534385681, 0.01601945236325264, -0.45273762941360474, 0.1811828464269638, -0.3492879867553711, 0.42413097620010376, -1.031899094581604, -0.42654743790626526, 0.548347532749176, -0.01959531381726265, -0.03008965030312538, 1.1598857641220093, 0.25461968779563904, -0.3105233311653137, 1.3130335807800293, 0.2953189015388489, -0.00727312546223402, -0.1585962325334549, -0.24839447438716888, 0.70789635181427, -0.8917357921600342, -0.406830757856369, -0.14052563905715942, 0.17525167763233185, -1.174278974533081, -0.14712682366371155, 0.18701782822608948, 0.20525872707366943, -0.7358558177947998, 0.49971121549606323, -0.3939310312271118, 0.2881918251514435, 0.42978841066360474, 0.1539153903722763, -0.09657697379589081, -0.6724441051483154, -0.10313806682825089, -0.3658468723297119, 0.15523888170719147, -0.17750370502471924, 0.8258243799209595, -0.1416676938533783, 0.2922999858856201, 0.11411316692829132, 0.6859980821609497, 1.160321831703186, 0.061576202511787415, -0.4583853781223297, 0.7356981635093689, 0.32672402262687683, -0.6811944842338562, -0.431600958108902, 0.10261572152376175, -0.21929436922073364, -0.3243865966796875, 0.02755686827003956, -0.5295303463935852, -0.48574042320251465, -0.3097778260707855, -0.5495557188987732, 0.6532624959945679, -0.2639881372451782, 0.09050348401069641, -0.28293368220329285, -0.7200406789779663, -0.0044554127380251884, -0.11370063573122025, 0.17227794229984283, 0.08992154151201248, 0.3631361126899719, -0.045680932700634, -0.3363431990146637, 0.7585489153862, -0.6340621709823608, -0.06577184051275253, -0.20985843241214752, 0.3749467432498932, 0.4864782989025116, -0.04959431290626526, 0.30140772461891174, 0.8803281188011169, -0.24039120972156525, -0.04850819706916809, -0.26484593749046326, -0.8806412220001221, 0.055965274572372437, 0.9109635353088379, -0.49286511540412903, -1.1094578504562378, -0.9038126468658447, -0.5171892046928406, -0.11708518117666245, 0.06594609469175339, 0.7482655048370361, 0.25543713569641113, 0.25269535183906555, 0.32186317443847656, 0.4104112982749939, -0.29498550295829773, 0.6452378630638123, -0.6276708841323853, 0.4404098391532898, -0.9059098958969116, 0.3308529555797577, 0.2111886441707611, 0.3024173080921173, 0.40382900834083557, 0.21053758263587952, -0.3815734386444092, -0.139241024851799, -0.31223127245903015, -0.037477560341358185, -0.38573935627937317, -0.48748481273651123, -0.7566097974777222, -0.3573131561279297, -0.27479904890060425, -0.9189816117286682, 0.1284189671278, 0.12513312697410583, 0.3200177252292633, 0.08620010316371918, 0.6056270003318787, 1.3411766290664673, -0.15170694887638092, -0.13764998316764832, -0.35702911019325256, 0.11353970319032669, 0.5113238096237183, 0.16921791434288025, -0.039064958691596985, -0.771934986114502, 0.3652578294277191, -0.49900802969932556, -0.04814092814922333, -0.6490519046783447, 0.2983977794647217, 0.24799078702926636, 0.13042840361595154, 0.2305113673210144, -0.0010559487855061889, 1.2368237972259521, -0.6758809089660645, 1.2559788227081299, 0.22757019102573395, -0.7262706756591797, 0.5852808356285095, -0.5860276222229004, 0.23532143235206604, 1.0929986238479614, 0.36748459935188293, -0.26197755336761475, -0.18302889168262482, -0.7130333781242371, -0.900824785232544, 0.6873858571052551, -0.5133993625640869, 0.015777723863720894, 0.18893228471279144, 0.23465131223201752, 0.5215906500816345, -0.12005618959665298, -0.5595065951347351, -0.07309617102146149, 0.5089712738990784, -0.04051506146788597, 0.5016240477561951, -0.35498183965682983, 0.25181084871292114, -0.41515809297561646, 0.34981265664100647, 0.3187902569770813, 0.17115886509418488, 0.1033485010266304, 0.10202391445636749, -0.0810740664601326, -0.24021905660629272, 0.8664475083351135, 0.9952675104141235, -0.6705647110939026, -0.2952462136745453, 0.6546787023544312, -0.4229161739349365, 0.10776486247777939, -0.8040170073509216, 0.08888380974531174, -0.31448981165885925, 1.1723543405532837, 0.177676722407341, 0.4186399579048157, -0.6197165846824646, 0.174800306558609, -0.052293386310338974, -0.6541938781738281, -0.4052708148956299, 0.518021821975708, 0.10614046454429626, 0.23509101569652557, 0.8790282607078552, 0.14013703167438507, -0.04113752394914627, -0.7435198426246643, 0.8825950622558594, -0.1474854052066803, -1.208588719367981, -0.1272251158952713, 0.9510762095451355, -0.37419378757476807, -0.915397584438324, 0.6279351711273193, -0.03317781910300255, -0.48386481404304504, 0.5179052948951721, 0.6273309588432312, 0.33457446098327637, -0.24028457701206207, -0.2072528898715973, 0.470808744430542, -0.4479740262031555, 0.08768633008003235, 0.5962621569633484, -0.37493380904197693, -0.36557725071907043, -0.4178276062011719, -0.36100688576698303, -0.4310780465602875, 0.20023702085018158, -0.8457281589508057, 0.48711317777633667, -0.48299118876457214, -0.10168334096670151, 0.08675055205821991, 0.7956896424293518, -0.6408648490905762, 0.6177778244018555, -0.595250129699707, 0.7584495544433594, -0.9405624270439148, 0.4937053322792053, 0.5140405893325806, -0.7501330375671387, -0.436565637588501, 0.38868483901023865, 0.008512354455888271, -0.646919310092926, 0.4201188385486603, -0.01764119602739811, 0.23014244437217712, -0.15929166972637177, -0.4690277576446533, -0.7447376251220703, 1.1955173015594482, -0.4802717864513397, -0.3295248746871948, 0.5178832411766052, 0.015144255012273788, -0.05662955343723297, -0.19968624413013458, 0.20367629826068878, 0.5134887099266052, 0.620455801486969, -0.05308041721582413, -0.27720871567726135, 0.21551254391670227, 0.13669052720069885, -0.4509516954421997, 0.33050084114074707, -0.9806265234947205, 0.850422203540802, -0.24972720444202423, -0.05893077701330185, 0.046181343495845795, 0.8784396648406982, 1.3513336181640625, -0.017974652349948883, 0.5886838436126709, 0.7832510471343994, 0.23545001447200775, -0.4404706060886383, 0.8320517539978027, 0.254395067691803, 0.1866898536682129, 0.44558870792388916, -0.6835624575614929, 0.5251631736755371, 0.19388271868228912, -0.6224428415298462, 0.03931262344121933, 0.6985370516777039, -0.02213374897837639, 0.7902074456214905, 0.13948585093021393, -0.12521305680274963, -0.2771593928337097, -0.07923929393291473, 0.17813830077648163, 0.2624506950378418, 0.11114533245563507, 0.4869072735309601, -0.19004760682582855, 0.2718735635280609, 0.023111162707209587, 0.43868064880371094, -0.26746663451194763, 0.6036828756332397, 0.08938376605510712, -0.8334444165229797, 0.2992556095123291, -0.06128606200218201, 0.9269734025001526, -0.3573929965496063, -0.2517000138759613, -0.01591280661523342, 0.1904662549495697, -0.4748252034187317, -1.2531468868255615, 0.47579070925712585, 0.2644127607345581, -0.5983924269676208, 0.1215771734714508, 0.7559123039245605, 0.13377945125102997, 0.1292385458946228, 0.34295937418937683, -0.27597206830978394, 0.4641460180282593, 0.11919121444225311, -0.6695537567138672, 0.5617712140083313, 0.6903644800186157, -0.4727042019367218, 0.034800704568624496, 0.23264914751052856, -0.6196491122245789, 0.6968415975570679, 0.3437395989894867, 0.15159505605697632, -0.07103847712278366, 0.025168774649500847, 0.18719139695167542, -0.8190696239471436, 0.0749487653374672, -1.1778696775436401, 0.03435422107577324, -0.5902727246284485, -1.0671120882034302, 0.7566946148872375, 0.5424955487251282, 0.5256344079971313, 0.0034510022960603237, 1.0449550151824951, -0.7282008528709412, -0.24576336145401, 0.3035796880722046, 0.57715904712677, -0.5272495150566101, -0.7963624000549316, 0.29755204916000366, -0.38278698921203613, -0.47176826000213623, 0.524092972278595, -0.49638256430625916, 0.03995611518621445, 0.5376605987548828, -0.09894582629203796, 0.403099924325943, 0.4047618806362152, 0.1667233109474182, -0.5582583546638489, 0.4461747407913208, 0.34419628977775574, 0.3578230142593384, -0.7694500684738159, 0.31172144412994385, 0.05346978083252907, -0.4503859579563141, -0.5134658813476562, -0.3350403308868408, -0.35194286704063416, -0.5795636177062988, -0.19832958281040192, -0.46044906973838806, 0.02690867893397808, 0.41907986998558044, 0.5637273788452148, -0.7733495831489563, 0.12757538259029388, -0.01807430200278759, 0.09843385964632034, -0.7106224298477173, -0.30312344431877136, 0.5363633632659912, -0.12840457260608673, -0.763445258140564, 0.3623139262199402, 0.7462848424911499, -0.835124135017395, 0.05958481878042221, 0.047143831849098206, -0.9608485698699951, 0.7092249989509583, 0.35958245396614075, 0.441444993019104, -0.6365926861763, -0.9667094945907593, -0.5570294857025146, -0.16374893486499786, 0.014965010806918144, 0.06508010625839233, -0.6025227308273315, -0.3343566060066223, 1.2216668128967285, 0.05552662909030914, -0.06460995227098465, 0.6004425287246704, 0.8369448781013489, -0.18125011026859283, 0.15177783370018005, 0.3427703082561493, 0.209397092461586, -0.24299131333827972, -0.5984776616096497, 0.9679414629936218, 0.722500741481781, -0.6507584452629089, -1.5794551372528076, 0.06945082545280457, -1.107420563697815, 0.2034367024898529, 0.8727228045463562, -0.13476751744747162, -0.7707200050354004, -0.5631349682807922, -0.13215318322181702, 0.43227458000183105, -0.15454399585723877, -0.003185915295034647, 0.5558032393455505, -0.6399749517440796, 0.25144708156585693, -0.774872899055481, 0.7565118670463562, 0.12195924669504166, -0.42629948258399963, -0.09213318675756454, -0.5157392621040344, 0.49902817606925964, 0.17715124785900116, 0.6857010126113892, -0.30261310935020447, 0.19344811141490936, 0.2701922059059143, 0.11641854047775269, -0.044256214052438736, -0.034272078424692154, 0.6722515225410461, 0.5276826024055481, -0.48489150404930115, -0.4300873875617981]]\n" ] } ], "source": [ - "from ads.model.generic_model import GenericModel\n", - "import ads\n", - "\n", - "ads.set_auth(\"resource_principal\")\n", - "\n", - "embedding_model = GenericModel.from_model_deployment(\n", - " \"ocid1.datasciencemodeldeployment.oc1.\"\n", - ")\n" + "op=embedding_model.verify(['Sachin scored 300 in t20 world cup final 2024 match and Rohit scored 111 runs in the same match'])\n", + "print(op['embeddings']);" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "id": "702e1e22-cca2-4b82-a1ac-570e1d0f2e2f", "metadata": { - "tags": [], "pycharm": { "is_executing": true - } + }, + "tags": [] }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "INFO:root:Connecting to Oracle DB...\n", + "INFO:root:Successfully connected to Oracle Database...\n", + "INFO:root:Processing book: oracle-partner-award-official-rules.pdf...\n", + "INFO:root:Enabled chunking, chunck_size: 1600...\n", + "WARNING:pypdf._reader:Ignoring wrong pointing object 6 0 (offset 0)\n", + "WARNING:pypdf._reader:Ignoring wrong pointing object 11 0 (offset 0)\n", + "WARNING:pypdf._reader:Ignoring wrong pointing object 13 0 (offset 0)\n", + "WARNING:pypdf._reader:Ignoring wrong pointing object 19 0 (offset 0)\n", + "WARNING:pypdf._reader:Ignoring wrong pointing object 30 0 (offset 0)\n", + "WARNING:pypdf._reader:Ignoring wrong pointing object 33 0 (offset 0)\n", + "WARNING:pypdf._reader:Ignoring wrong pointing object 39 0 (offset 0)\n", + "INFO:root:Read total 9 pages...\n", + "INFO:root:Removed 0 short pages...\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "9f01624db6c44fe8a1c8ebbe06bc49d6", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Parsing nodes: 0%| | 0/9 [00:00 **Identity & Security** --> **Policies** --> **Create Policy** +Add policy, so that Oracle Digital Assistant can access model deployment predict endpoint. Go to **Identity & Security**, **Policies** and click **Create Policy**. -![image](./images/oda-with-oci-data-science-create-policy.png) +![image](./images/oda-with-oci-data-science-create-policy.png "image") **Policies for dynamic group** @@ -372,351 +400,387 @@ Go to **Navigation menu** on top left corner --> **Identity & Security** --> Allow any-user to {DATA_SCIENCE_MODEL_DEPLOYMENT_PREDICT} in compartment Demo where request.principal.id='ocid1.odainstance.oc1.iad.' ``` -Once policy gets created, we can launch to Digital Assistant and open it in a browser. +Once policy gets created, we can launch to Oracle Digital Assistant and open it in a browser. -### Create the LLM Provider REST Service +### Task 6.2: Create the LLM Provider REST Service -1. With the Oracle Digital Assistant UI opened in browser. Go to **Navigation menu** on top left corner --> **Settings** \--> **API Services**  -2. Open the **LLM Services** tab. -3. Click **+Add LLM Service**. -4. Complete the LLM Service Service dialog to create a POST operation to the provider's endpoint: - * **Name**: Enter an easily identifiable name for the service. You'll reference this name later on. - * **Endpoint**: Copy and and paste the Model Deployment endpoint. - * **Methods**: Select **POST**. -5. Click **Create**. - ![image](./images/oda-with-oci-data-science-create-llm-service.png) -6. Complete the service by adding the API key, and the request and response payload samples: - * **Authentication Type**: Select **OCI Resource Principal**.. - * POST request: Select **application/json** as the **Content Type**. - * **Body**: Add the payload sent to the request. For example: - { -     "query": "Can you please give some overview on Oracle Database 23.4?" - } +1. Go to the Oracle Digital Assistant, navigate to **Settings**, **API Services**, **LLM Services** and click **+Add LLM Service**. - ![image](./images/oda-with-oci-data-science-set-llm-service.png) -7. Click **Test Request** to check for a 200 response. +2. In the **Create LLM Service** page, enter the following information to create a Post operation to the provider's endpoint and click **Create**. - ![image](./images/oda-with-oci-data-science-test-llm-service.png) - ------------------------------------------ + - **Name:** Enter an easily identifiable name for the service. You will reference this name later on. + - **Endpoint:** Copy and and paste the model deployment endpoint. + - **Methods:** Select **POST**. + ![image](./images/oda-with-oci-data-science-create-llm-service.png "image") -### Create a Skill +3. Complete the service by adding the API key, and the request and response payload samples. -With the LLM Provider REST Service added to the instance, now we need to create a skill that can call this service and connect users to it through its dialog flow definition. + - **Authentication Type:** Select **OCI Resource Principal**. + - **Content Type:** Select **application/json**. + - **Body:** Add the payload sent to the request. For example: -To create this skill: + ``` + { + "query": "Can you please give some overview on Oracle Database 23.4?" + } + ``` -1. With the Oracle Digital Assistant UI opened in browser. Go to **Navigation menu** on top left corner --> **Development** --> **\+Skills** -2. Click the **\+ New Skill** button. + ![image](./images/oda-with-oci-data-science-set-llm-service.png "image") -The Create Skill dialog appears. +4. Click **Test Request** to check for a `200` response. -1. Add a name in the **Display Name** field. -2. For the other fields, leave the default values. Note that the Dialog Mode is **Visual**. -3. Click **Create**. - ![image](./images/oda-with-oci-data-science-create-skill.png) + ![image](./images/oda-with-oci-data-science-test-llm-service.png "image") -### Connect the Skill to the Model +### Task 6.3: Create a Skill -We're now going to enable the skill to access the LLM REST service by creating a custom component with an event handler that transforms the REST payloads into formats that are accepted by both the LLM provider and Oracle Digital Assistant. +With the LLM provider REST service added to the instance, now we need to create a skill that can call this service and connect users to it through its dialog flow definition. To create this skill, follow the steps: -1. Click **Components** ![The Components icon](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-large-language-model/images/components_icon_inline.png) in the left nav-bar. +1. Go to the Oracle Digital Assistant, navigate to **Development** and **+Skills**. +2. Click **+ New Skill**. +3. In the **Create Skill** page, enter the following information and click **Create**. - ![The Components icon in the left navbar](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-large-language-model/images/components_leftnavbar.png) + - **Display Name:** Add a name. + - **Dialog Mode:** Select **Visual**. + - For the other fields, leave the default values. -1. Click **Add Service**. -2. In the Create Service dialog: - * Enter a name that describes the service. - * Accept the default setting, **Embedded Container**. - * Select **New Component**. - * Select **LLM Transformation** from the Component Type drop down list. - * Enter a descriptive name in the Component Name field. - * Select **Custom** (located under **other**) from the Template drop down list. -3. Click **Create** - ![image](./images/oda-with-oci-data-science-create-service.png) -4. The completed component displays in the Components page. - ![image](./images/oda-with-oci-data-science-component-page.png) -5. Select the component in the component page to check its deployment status. When Ready displays, you can move on to the next step. - ![image](./images/oda-with-oci-data-science-component-status.png) + ![image](./images/oda-with-oci-data-science-create-skill.png "image") - Ensure that **Service Enabled** (the default setting) is switched on. +### Task 6.4: Connect the Skill to the Model - ![image](./images/oda-with-oci-data-science-service-enabled.png) +We are now going to enable the skill to access the LLM REST service by creating a custom component with an event handler that transforms the REST payloads into formats that are accepted by both the LLM provider and Oracle Digital Assistant. -### Map the LLM Service Provider and Oracle Digital Assistant Requests and Responses +1. Click **Components** icon from the left navbar and **Add Service**. -The skill's requests to the model's service provider need to be transformed from the interface used by Oracle Digital Assistant, which is known as Common LLM Interface (CLMI) into the format that's accepted by the service provider. Likewise, the results returned from the service provider also need to be transformed into CLMI. To enable this mapping, the following REST service event handler methods must have provider-specific code: + ![The Components icon in the left navbar](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-large-language-model/images/components_leftnavbar.png "image") -* `transformRequestPayload` -* `transformResponsePayload` -* `transformErrorResponsePayload` +2. In the **Create Service** page, enter the following information and click **Create**. -To open the event handler code editor and update the transformation code (in this case, for Azure OpenAI): + - **Name:** Enter a name that describes the service. + - **Service Type:** Accept the default setting, select **Embedded Container**. + - **Component Service Package Creation Type:** Select **New Component**. + - **Component Type:** Select **LLM Transformation**. + - **Component Name:** Enter a descriptive name. + - **Template:** Select **Custom** (located under **other**). -1. Expand the service. Then select the event handler. + ![image](./images/oda-with-oci-data-science-create-service.png "image") - ![image](./images/oda-with-oci-data-science-event-handler.png) +3. The completed component displays in the **Components** page. -2. Click **Edit** ![The Edit Component code icon](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-large-language-model/images/edit_icon_inline.png) (located at the upper right) to open the editor. - ![image](./images/oda-with-oci-data-science-component-edit.png) -3. Code Editor - ![image](./images/oda-with-oci-data-science-component-editor.png) -4. Replace the \``` transformRequestPayload` `` handler event method code (around Lines 24-26) with the following: + ![image](./images/oda-with-oci-data-science-component-page.png "image") - **transformRequestPayload** +4. Select the component from the **Components** page to check its deployment status. When **Ready** displays, you can move on to the next step. - ```py - transformRequestPayload: async (event, context) => { - return { "query": event.payload.messages[event.payload.messages.length - 1].content }; - }, - ``` + ![image](./images/oda-with-oci-data-science-component-status.png "image") + + Ensure that **Service Enabled** (the default setting) is enabled. + + ![image](./images/oda-with-oci-data-science-service-enabled.png "image") + +### Task 6.5: Map the LLM Service Provider and Oracle Digital Assistant Requests and Responses + +The skill's requests to the model's service provider need to be transformed from the interface used by Oracle Digital Assistant, which is known as Common LLM Interface (CLMI) into the format that is accepted by the service provider. Likewise, the results returned from the service provider also need to be transformed into CLMI. To enable this mapping, the following REST service event handler methods must have provider-specific code. + +- `transformRequestPayload`. +- `transformResponsePayload`. +- `transformErrorResponsePayload`. + +To open the event handler code editor and update the transformation code (in this case, for Azure OpenAI), follow the steps: + +1. Expand the service and select the event handler. - Every request we just have to pass last user input to LLM prompt. -5. Replace the \`transformResponsePayload`` ` `` handler event method code (around Lines 35-37) with the following: + ![image](./images/oda-with-oci-data-science-event-handler.png "image") - **transformRequestPayload** +2. Click **Edit** icon to open the editor. - ```py - transformResponsePayload: async (event, context) => { + ![image](./images/oda-with-oci-data-science-component-edit.png "image") + + ![image](./images/oda-with-oci-data-science-component-editor.png "image") + +3. Replace the `transformRequestPayload` handler event method code (around lines 24-26) with the following code. + + - **`transformRequestPayload`:** + + ```py + transformRequestPayload: async (event, context) => { + return { "query": event.payload.messages[event.payload.messages.length - 1].content }; + }, + ``` + + Every request we just have to pass last user input to LLM prompt. + +4. Replace the `transformResponsePayload` handler event method code (around lines 35-37) with the following code. + + - **`transformRequestPayload`:** + + ```py + transformResponsePayload: async (event, context) => { return { candidates: [ { "content": event.payload.prediction || "" }]}; - }, - ``` + }, + ``` -6. Replace the \`transformErrorResponsePayload`` ` `` handler event method code (around Lines 47-49) with the following: - - **transformRequestPayload** - - ```py - transformErrorResponsePayload: async (event, context) => { - let errorCode = 'unknown'; - if (event.payload.error) { - if ( 'context_length_exceeded' === event.payload.error.code) { - errorCode = 'modelLengthExceeded'; } - else if ('content_filter' === event.payload.error.code) { - errorCode = 'flagged'; - } - return {"errorCode" : errorCode, "errorMessage": event.payload.error.message}; - } - return {"errorCode" : errorCode, "errorMessage": JSON.stringify(event.payload)}; - } - ``` +5. Replace the `transformErrorResponsePayload` handler event method code (around lines 47-49) with the following code. + + - **`transformRequestPayload`:** + + ```py + transformErrorResponsePayload: async (event, context) => { + let errorCode = 'unknown'; + if (event.payload.error) { + if ( 'context_length_exceeded' === event.payload.error.code) { + errorCode = 'modelLengthExceeded'; } + else if ('content_filter' === event.payload.error.code) { + errorCode = 'flagged'; + } + return {"errorCode" : errorCode, "errorMessage": event.payload.error.message}; + } + return {"errorCode" : errorCode, "errorMessage": JSON.stringify(event.payload)}; + } + ``` + +6. Click **Validate** to check the code syntax. Use it to replace the code in the editor if you are encountering syntax errors that you cannot fix. + + ![image](./images/oda-with-oci-data-science-component-status.png "image") + +7. Click **Save** and **Close**. Wait for the deployment to complete. When **Ready** displays, you can move on to the next step. + +### Task 6.6: Define the LLM Service for the Skill + +To enable the skill to connect users to the model through the dialog flow, you need to create an LLM service that combines the instance-wide LLM service that calls the model with the transformation event handler (which in this case is for Oracle model deployment). + +1. Click **Settings** icon from the left navbar. + + ![Left nav bar](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-large-language-model/images/settings_icon_left_navbar.png "image") + +2. Click **Configuration**. + + ![The Configuration tab in Settings](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-large-language-model/images/settings_configuration_tab.png "image") + +3. In the **Large Language Models Services** page, click **+New LLM Service**. + + ![The Large Language Model Section of the Configuration page.](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-large-language-model/images/large_language_models_settings_page.png "image") + +4. Enter the following information + + - **Name:** Enter an easily identifiable name for the LLM service. You will reference this name when you build the dialog flow in the next step. + - **LLM Service:** Select the name of the instance-wide LLM service that you created in [Task 1: Create the REST Service to the Model](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-large-language-model/#task_one). + - **Transformation Handler:** Select the name of the event handler component that you created as part of the REST service in [Task 3: Connect the Skill to the Model](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-large-language-model/#task_three). + - Leave the remaining properties in their default settings. Note that **Default** is enabled, if this is the only service that you have created so far for this tutorial. + + ![image](./images/oda-with-oci-data-science-llm-service.png "image") + +5. Click **Save**. + + ![The Save service icon](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-large-language-model/images/create_llm_service.png "image") -7. Check the code syntax by clicking **Validate**. Use it to replace the code in the editor if you're encountering syntax errors that you can't fix. - ![image](./images/oda-with-oci-data-science-component-status.png) +6. De-select **Feedback** and other default on switches. + ![image](./images/oda-with-oci-data-science-switches.png "image") -8. Click **Save**, then **Close**. Wait for the deployment to complete. When Ready displays, you can move on to the next step. +### Task 6.7: Integrate the Service -### Define the LLM Service for the Skill +Now that the skill is connected to the LLM, connect skill's users to the model by creating a dialog flow component that can call the model and tell it what to do. The component conveys these instructions using a prompt, which is a block of human-readable text. +In this task, we will provide this prompt, which instructs the model on evaluating user feedback as positive or negative, or neutral. -To enable the skill to connect users to the model through the dialog flow, you need to create an LLM service that combines the instance-wide LLM service that calls the model with the transformation event handler (which in this case is for Oracle Model Deployment). +1. Click **Flows** icon from the left navbar. -1. Click **Settings** ![The Settings icon](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-large-language-model/images/settings_icon_inline.png) in the left nav-bar. + ![The Flows icon in the left navbar](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-large-language-model/images/flows_leftnavbar.png "image") - ![Left nav bar](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-large-language-model/images/settings_icon_left_navbar.png) +2. Select **unresolvedIntent**. + ![Unresolved flow](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-large-language-model/images/select_unresolved_flow.png "image") -2. Open the Configuration page. +3. In the **unresolvedMessage** state, click **ellipsis(...)** icon and select **Add State** from the menu. - ![The Configuration tab in Settings](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-large-language-model/images/settings_configuration_tab.png) + ![The Add State option](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-large-language-model/images/add_state_option.png "image") +4. Select **Service Integration** and **Invoke Large Language Model**. -3. In the Large Language Models Services section (located near the bottom of the page), click **+New LLM Service**. - ![The Large Language Model Section of the Configuration page.](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-large-language-model/images/large_language_models_settings_page.png) +5. Enter a **Description** like sentiment analysis and click **Insert**. + ![image](./images/oda-with-oci-data-science-add-state.png "image") -4. Complete the following fields: - * **Name**: Enter an easily identifiable name for the LLM service. You'll reference this name when you build the dialog flow in the next step. - * **LLM Service**: Select the name of the instance-wide LLM service that you created in [Task 1: Create the LLM Service for the Model](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-large-language-model/#task_one). - * **Transformation Handler**: Select the name of the event handler component that you created as part of the REST service in [Task 3: Connect the Skill to the Model](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-large-language-model/#task_three). - * Leave the remaining properties in their default settings. Note that **Default** is switched on (`true`) if this is the only service that you've created so far for this tutorial. - ![image](./images/oda-with-oci-data-science-llm-service.png) + The dialog flow now includes the `unresolvedMessage` (Send Message) state, `invokeLLM` state and the `showLLMError` state. -5. Click **Save** (located at the right). + ![The invokeLLM state with the showError state in the dialog flow](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-large-language-model/images/invokeLLM_state_in_flow.png "image") - ![The Save service icon](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-large-language-model/images/create_llm_service.png) +6. In the `unresolvedMessage` state, click **ellipsis(...)** icon and select **Delete** from the menu as we do not want to show error message for **UnresolvedIntent**. -6. Switch off Feedback and other default on switches. - ![image](./images/oda-with-oci-data-science-switches.png) + ![image](./images/oda-with-oci-data-science-unresolved-intent-actions.png "image") -### Integrate the Service + The dialog flow now includes the `invokeLLM` state and the `showLLMError` state only. -Now that the skill is connected to the LLM, we're now going to connect skill's users to the model by creating a dialog flow component that can call the model and tell it what to do. -The component conveys these instructions using a prompt, which is a block of human-readable text. -In this step, we'll provide this prompt, which instructs the model on evaluating user feedback as positive or negative, or neutral. + ![image](./images/oda-with-oci-data-science-dialog-flow.png "image") -1. Click **Flows** ![The Flows icon](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-large-language-model/images/flows_inline.png) in the left nav-bar. +7. Open the `invokeLLM` state. In the **Component** page, select the LLM service that we have created in Task 6.6. - ![The Flows icon in the left navbar](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-large-language-model/images/flows_leftnavbar.png) + ![The LLM Service field](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-large-language-model/images/llm_component_select_service.png "image") -2. Select **unresolvedIntent**. +8. Add a prompt that sends instructions to the LLM service by pasting the following in the **Prompt**. All user conversation should get passed as Prompt Input. - ![Unresolved flow](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-large-language-model/images/select_unresolved_flow.png) + ![image](./images/oda-with-oci-data-science-invoke-llm.png "image") -3. In the unresolvedMessage state, click ![The menu icon](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-large-language-model/images/inline_component_menu_icon.png) and then select **Add State** from the menu. +9. Create the `PROMPT_INPUT` variable. Click **Prompt Parameters +** to add a new parameter and its value. - ![The Add State option](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-large-language-model/images/add_state_option.png) + ![image](./images/oda-with-oci-data-science-prompt-input.png "image") -4. Select **Service Integration**. +10. Set **Use Streaming** to **False** so that the message is delivered in its entirety, not incrementally. -5. Select **Invoke Large Language Model**. + ![image](./images/oda-with-oci-data-science-use-streaming.png "image") -6. Enter a description like Sentiment analysis. Then click **Insert**. +11. Test the prompt with the **Prompt Builder** and click **Build Prompt** - ![image](./images/oda-with-oci-data-science-add-state.png) + ![image](./images/oda-with-oci-data-science-build-prompt.png "image") - The dialog flow now includes the unresolvedMessage (Send Message) state, invokeLLM state and the showLLMError state. +12. Add **Prompt Parameter Mock Value** and click **Generate Output**. This way we can validate LLM integration. - ![The invokeLLM state with the showError state in the dialog flow](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-large-language-model/images/invokeLLM_state_in_flow.png) + ![image](./images/oda-with-oci-data-science-test-prompt-builder.png "image") -7. In the unresolvedMessage state, click ![The menu icon](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-large-language-model/images/inline_component_menu_icon.png) and then select **Delete** from the menu. as we don't want to show error message for **UnresolvedIntent** - ![image](./images/oda-with-oci-data-science-unresolved-intent-actions.png) +### Task 6.8: Test the Prompt with the Skill Tester - The dialog flow now includes the invokeLLM state and the showLLMError state only. - ![image](./images/oda-with-oci-data-science-dialog-flow.png) +1. Click **Preview** to open the skill tester. -8. Open the invokeLLM state. In the Component page, select the LLM service that we have created from the last step. - ![The LLM Service field](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-large-language-model/images/llm_component_select_service.png) + ![The Preview button](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-llm-cohere/images/preview.png "image") -9. Add prompt that sends instructions to the LLM service by pasting the following into the Prompt field. Here we want all user conversation should get passed as Prompt Input. +2. Enter the following request: **Can you please give some overview on Oracle Database 23.4?**. - ![image](./images/oda-with-oci-data-science-invoke-llm.png) + The output should look like this: -10. We need to create PROMPT\_INPUT variable. So, click on Prompt Parameters + sign, to add a new parameter and its value. - ![image](./images/oda-with-oci-data-science-prompt-input.png) + ![image](./images/oda-with-oci-data-science-conversation-tester-output-1.png "image") -11. Set **Use Streaming** is set to **False** so that the message is delivered in its entirety, not incrementally.  - ![image](./images/oda-with-oci-data-science-use-streaming.png) -12. Test the Prompt with the **Prompt Builder.** Click on **Build Prompt** - ![image](./images/oda-with-oci-data-science-build-prompt.png) +3. Ask next query to LLM: **latest oracle database**. -13. Add **Prompt Parameter Mock Value** and Click on **Generate Output.** This way we can validate LLM integration. - ![image](./images/oda-with-oci-data-science-test-prompt-builder.png) + The output should look like this: -### Test the Prompt with the Skill Tester + ![image](./images/oda-with-oci-data-science-conversation-tester-output-2.png "image") -1. Open the Skill Tester by clicking **Preview** (located at the upper right). - ![The Preview button](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-llm-cohere/images/preview.png) +### Task 6.9: Set Up the Oracle Web User Channel + +We will create an Oracle Digital Assistant user channel that enables an Oracle web client to access skill. To ensure that only our web clients can use this channel, we will configure it to require client authentication. + +1. Open the Oracle Digital Assistant, navigate to **Development**, **Channels** and click **+Add Channel**. + +2. In **Create Channel**, enter the following information to create a POST operation to the provider's endpoint and click **Create**. + + - **Name:** A unique name that begins with a letter and contains only letters, numbers, periods, and underscores. For example, `OCI_MD_LLM`. + - **Description (Optional):** What the channel is used for. + - **Channel Type:** Select **Oracle Web**. + - **Allowed Domains:** Enter `*`. + - **Client Authentication Enabled:** De-select. + + ![image](./images/oda-with-oci-data-science-create-channel.png "image") + +3. Deselect **Client Authentication Enabled,** if not already disabled. + +4. In **Route**, select the skill that we want to use. We have selected current skill that is **LLM-MD-Skill**. + +5. Enable **Channel Enabled**. + +6. Note the **Channel Id** and **ODA Domain URI** without https, that are shown for this channel. + +We will use these values in our web app and the token generator's routing configuration. + +### Task 6.10: Install the SDK + +Download the zip and extract it to your local system. This zip includes a user guide that describes the SDK's classes and a sample app that demonstrates many of its features. + +1. Go to [Oracle Digital Assistant (ODA) and Oracle Mobile Cloud (OMC) Downloads](https://www.oracle.com/downloads/cloud/amce-downloads.html) and **Oracle Native Client SDKs (for OCI Native environments) Web SDK** section. + +2. Download [ODA Web SDK 24.06](https://www.oracle.com/downloads/cloud/amce-downloads.html). + +3. In **Platforms**, select **GENERIC**. + +4. Click to download latest ODA Js SDK that is `oda-native-client-sdk-js-24_06 for (GENERIC (All Platforms)`. + + ![image](./images/oda-with-oci-data-science-download-sdk.png "image") + +5. Extract the downloaded zip file. + +### Task 6.11: Test Oracle Web App + +1. Go to extracted zip folder of the downloaded Oracle web SDK. + +2. Open the `samples/web/settings.js` file and replace `` and `` with actual value. + + For example: + + - URI: `oda-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-dax.data.digitalassistant.oci.oraclecloud.com`. + - ChannelId: `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`. + +3. Also, make sure `isClientAuthEnabled` is false. + + ``` + let isClientAuthEnabled = false; + ``` -2. Enter the following request: - _"Can you please give some overview on Oracle Database 23.4?"_ +4. Run the `samples/web/index.html` file on any browser. - The output may look something like this. - ![image](./images/oda-with-oci-data-science-conversation-tester-output-1.png) +5. Ignore the index file contents. Click chat icon, it will show **Oracle Assistant CONNECTED** status. - Ask next query to LLM: - _"latest oracle database"_ + ![image](./images/oda-with-oci-data-science-web-sdk.png "image") - The output may look something like this. - ![image](./images/oda-with-oci-data-science-conversation-tester-output-2.png) +6. This is how our website looks with chat icon in bottom-right corner. We can start a conversation, like we did earlier with the skill tester. + ![image](./images/oda-with-oci-data-science-website-landing.png "image") -### Set Up the Oracle Web User Channel + ![image](./images/oda-with-oci-data-science-website-chatbot.png "image") -We'll create a Digital Assistant user channel that enables an Oracle Web client to access skill. To ensure that only our web clients can use this channel, we'll configure it to require client authentication. +### Task 6.12: Release on OCI Compute Instance -1. With the Oracle Digital Assistant UI opened in browser. Go to **Navigation menu** on top left corner --> **Development** --> **Channels** -2. Click **+Add Channel**. -3. Complete the Channel dialog to create a POST operation to the provider's endpoint: - * **Name**: A unique name that begins with a letter and contains only letters, numbers, periods, and underscores (`_`). For example: OCI`_MD_LLM`. - * **Description (Optional)**: What the channel is used for. - * **Channel Type**: Select **Oracle Web**. - * **Allowed Domains:** - * **Client Authentication Enabled:** Switch off -4. Click **Create**. - ![image](./images/oda-with-oci-data-science-create-channel.png) -5. Switch off **Client Authentication Enabled,** If not already. In above screenshot, I forgot to switch it of. -6. In the **Route** To **drop-down list**, select the skill that we want to use. We have selected current skill i.e **LLM-MD-Skill** -7. Switch **Channel** **Enabled** to On. -8. Noted the **Channel Id** and **ODA Domain URI** without https, that are shown for this channel.  - Later, we'll use these values in your web app and the token generator's routing configuration. +1. Create OCI Compute instance. For more information, see [Creating an Instance](https://docs.oracle.com/en-us/iaas/Content/Compute/Tasks/launchinginstance.htm) -### Install the SDK +2. Make sure you have following ingress rules. -Download this ZIP and extract it to your local system. This ZIP includes a user guide that describes the SDK's classes and a sample app that demonstrates many of its features. + ![image](./images/oda-with-oci-data-science-ingress-rules.png "image") -1. Go to [ODA and OMC download page](https://www.oracle.com/downloads/cloud/amce-downloads.html) -2. Go to **Oracle Native Client SDKs (for OCI Native environments) Web SDK** Section -3. Click first row, 2nd column download icon. Current Version i.e [ODA Web SDK 24.06](https://www.oracle.com/downloads/cloud/amce-downloads.html). -4. In **Platforms** column Select **GENRIC** from dropdown. -5. Click to download latest oda js sdk i.e \`oda-native-client-sdk-js-24\_06 for (GENERIC (All Platforms)\` -  ![image](./images/oda-with-oci-data-science-download-sdk.png) -6. Extract the downloaded zip file. +3. Copy all web folders to newly created instance. -### Test Oracle Web App +4. Install NGINX. For more information, see [Install the NGINX Web Server and Proxy on Oracle Linux](https://docs.oracle.com/en/learn/ol-nginx/index.html#background). -1. Go to extracted ZIP folder of the downloaded Oracle Web SDK -2. Go to `samples/web/settings.js`  file and Replace and with actual value. - Sample URI → oda-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-dax.data.digitalassistant.oci.oraclecloud.com - Sample channelId → xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -3. Also, make sure Client Authentication Enabled false. - `let isClientAuthEnabled = false;`  -4. Run `samples/web/index.html file on any browser.` -5. Ignore the Index file contents. Directly click on chat icon. - ![image](./images/oda-with-oci-data-science-web-sdk.png) -6. It will show **Oracle Assistant CONNECTED** status. -7. This is how our website looks with chat icon in bottom-right corner. We can start out conversation, like we did earlier with the Skill Tester. - ![image](./images/oda-with-oci-data-science-website-landing.png)   - ![image](./images/oda-with-oci-data-science-website-chatbot.png) +5. Open a browser and navigate to `http:///`. If you have a self signed certificate then you can navigate to `https:///`. -### Release on Oracle Compute Instance +## Results -1. Create Oracle Compute Instance. Please refer [https://docs.oracle.com/en-us/iaas/Content/Compute/Tasks/launchinginstance.htm](https://docs.oracle.com/en-us/iaas/Content/Compute/Tasks/launchinginstance.htm) -2. Make sure you have below ingress rules. - ![image](./images/oda-with-oci-data-science-ingress-rules.png) -3. Copy all  web folder to newly created instance. -4. Install NGINX [https://docs.oracle.com/en/learn/ol-nginx/index.html#background](https://docs.oracle.com/en/learn/ol-nginx/index.html#background) -5. Open a browser and navigate to `http:///` -6. You may have self signed certificate then you can navigate to https:/// +Let us compare the outputs from directly asking the LLM vs using RAG with LLM: -### Want to Learn More? +- **Response from LLM** -* [Configure the Oracle Web Channel](http://www.oracle.com/pls/topic/lookup?ctx=en/cloud/paas/digital-assistant&id=DACUA-GUID-33102578-2776-474D-AD48-9029D8EE6480) in _Using Oracle Digital Assistant_. -* [Configure Client Authentication](http://www.oracle.com/pls/topic/lookup?ctx=en/cloud/paas/digital-assistant&id=DACUA-GUID-672865F8-5883-461C-B6AD-47191EBC89DA) in _Using Oracle Digital Assistant_. -* [Customize-chat-widget](https://docs.oracle.com/en/cloud/paas/digital-assistant/use-chatbot/customize-chat-widget.html#GUID-45FA259F-4558-4C0F-A3AD-0BB7586EA595) + ![image](./images/oda-with-oci-data-science-llm-output.png "image") -## Benchmarking Results -Let's compare the outputs from directly asking the LLM vs using RAG with LLM: +- **Response from RAG** -**Response from LLM** + ![image](./images/oda-with-oci-data-science-oda-output.png "image") -![image](./images/oda-with-oci-data-science-llm-output.png) +## Next Steps -**Response from RAG** +Building an advanced chatbot using Oracle Database 23ai, RAG, LangChain, Mistral-7B-Instruct-v0.2, and Oracle Digital Assistant showcases the power of integrating cutting-edge technologies to create a highly responsive and intelligent conversational agent. The detailed workflow, from request handling to response generation, ensures that the chatbot can efficiently retrieve and process vast amounts of information, delivering accurate and contextually relevant answers to users. By leveraging Oracle Database 23ai's vector search capabilities and the robust platform provided by Oracle Digital Assistant, developers can significantly enhance the chatbot's performance and user engagement. This integrated approach not only streamlines the development process but also results in a scalable, efficient, and highly effective AI solution that stands out in the competitive landscape of digital assistants. Whether for customer service, information retrieval, or interactive support, this advanced chatbot architecture paves the way for creating sophisticated conversational experiences that meet the demands of modern users. -![image](./images/oda-with-oci-data-science-oda-output.png) +For more information on how to use AI Quick Actions, go to the Oracle Cloud Infrastructure Data Science [YouTube playlist](https://www.youtube.com/playlist?list=PLKCk3OyNwIzv6CWMhvqSB_8MLJIZdO80L) to see a demo video of AI Quick Actions, and find [our technical documentation](https://docs.oracle.com/en-us/iaas/data-science/using/ai-quick-actions.htm), and see our [Github repository](https://github.com/oracle-samples/oci-data-science-ai-samples/tree/main/ai-quick-actions) with tips and examples. -**Comparison:** Add a response on how the RAG response is better than when compared from LLM Response. If you have any other areas please add them here.   +If you want to suggest specific models to add to AI Quick Actions or have any questions, email to the OCI Data Science group: [ask-oci-data-science_grp@oracle.com](mailto:ask-oci-data-science_grp@oracle.com). -## Conclusion -In conclusion, building an advanced chatbot using Llama3, Oracle Database 23ai, RAG, LangChain, and Oracle Digital Assistant showcases the power of integrating cutting-edge technologies to create a highly responsive and intelligent conversational agent. The detailed workflow, from request handling to response generation, ensures that the chatbot can efficiently retrieve and process vast amounts of information, delivering accurate and contextually relevant answers to users. By leveraging Oracle Database 23ai's vector search capabilities and the robust platform provided by Oracle Digital Assistant, developers can significantly enhance the chatbot's performance and user engagement. This integrated approach not only streamlines the development process but also results in a scalable, efficient, and highly effective AI solution that stands out in the competitive landscape of digital assistants. Whether for customer service, information retrieval, or interactive support, this advanced chatbot architecture paves the way for creating sophisticated conversational experiences that meet the demands of modern users. +## Related Links -Try [Oracle Cloud Free Trial](https://www.oracle.com/cloud/free/)! A 30-day trial with US$300 in free credits gives you access to Oracle Cloud Infrastructure Data Science service. For more information, see the following resources: +- [Configure the Oracle Web Channel](http://www.oracle.com/pls/topic/lookup?ctx=en/cloud/paas/digital-assistant&id=DACUA-GUID-33102578-2776-474D-AD48-9029D8EE6480) -* Full sample, including all files in [OCI Data Science sample repository on GitHub](https://github.com/oracle-samples/oci-data-science-ai-samples/tree/main/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm). -* Visit our [service documentation](https://docs.oracle.com/en-us/iaas/data-science/using/ai-quick-actions.htm). -* Watch [our tutorials on our YouTube playlist](https://www.youtube.com/playlist?list=PLKCk3OyNwIzv6CWMhvqSB_8MLJIZdO80L). -* Try one of our [LiveLabs](https://apexapps.oracle.com/pls/apex/dbpm/r/livelabs/livelabs-workshop-cards?session=108343633199478). Search for “data science.” -* Got questions? Reach out to us at [ask-oci-data-science\_grp@oracle.com](mailto:ask-oci-data-science_grp@oracle.com?subject=Follow%20up%20questions%20on%20%22Deploy%20Llama%202%20in%20OCI%20Data%20Science%22%20blog%20post) +- [Configure Client Authentication](http://www.oracle.com/pls/topic/lookup?ctx=en/cloud/paas/digital-assistant&id=DACUA-GUID-672865F8-5883-461C-B6AD-47191EBC89DA) -If you want to suggest specific models to add to AI Quick Actions email [the OCI Data Science group](mailto:ask-oci-data-science_grp@oracle.com). For more information on how to use AI Quick Actions, go to the Oracle Cloud Infrastructure Data Science [YouTube playlist](https://www.youtube.com/playlist?list=PLKCk3OyNwIzv6CWMhvqSB_8MLJIZdO80L) to see a demo video of AI Quick Actions, and find [our technical documentation](https://docs.oracle.com/en-us/iaas/data-science/using/ai-quick-actions.htm), and see our [Github repository](https://github.com/oracle-samples/oci-data-science-ai-samples/tree/main/ai-quick-actions) with tips and examples +- [Customize the Chat Widget](https://docs.oracle.com/en/cloud/paas/digital-assistant/use-chatbot/customize-chat-widget.html#GUID-45FA259F-4558-4C0F-A3AD-0BB7586EA595) +- Try [Oracle Cloud Free Trial](https://www.oracle.com/cloud/free/)! A 30-day trial with US$300 in free credits gives you access to Oracle Cloud Infrastructure Data Science service. For more information, see the following resources: -## References -Try [Oracle Cloud Free Trial](https://www.oracle.com/cloud/free/)! A 30-day trial with US$300 in free credits gives you access to Oracle Cloud Infrastructure Data Science service. For more information, see the following resources: + - [OCI Data Science sample repository on Github](https://github.com/oracle-samples/oci-data-science-ai-samples/tree/main/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm). -Full sample including all files in [OCI Data Science sample repository on Github](https://github.com/oracle-samples/oci-data-science-ai-samples/tree/main/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm). + - [Oracle Data Science service](http://docs.oracle.com/iaas/data-science/using/data-science.htm). -Visit our [datascience service documentation](http://docs.oracle.com/iaas/data-science/using/data-science.htm). +- [Using the Oracle Resource Manager to Configure Your Tenancy for Data Science](https://docs.oracle.com/en-us/iaas/data-science/using/orm-configure-tenancy.htm) -Configure your OCI tenancy with these [setup instructions](https://docs.oracle.com/en-us/iaas/data-science/using/orm-configure-tenancy.htm) and start using OCI Data Science. +- Star and clone our new [GitHub repo](https://github.com/oracle-samples/oci-data-science-ai-samples)! We included notebook tutorials and code samples. -Star and clone our new [GitHub repo](https://github.com/oracle-samples/oci-data-science-ai-samples)! We included notebook tutorials and code samples. +- Watch our tutorials on [YouTube](https://www.youtube.com/playlist?list=PLKCk3OyNwIzv6CWMhvqSB_8MLJIZdO80L) -Watch our tutorials on our [YouTube playlist](https://www.youtube.com/playlist?list=PLKCk3OyNwIzv6CWMhvqSB_8MLJIZdO80L) +- Search for Oracle Data Science and try [LiveLabs](https://apexapps.oracle.com/pls/apex/dbpm/r/livelabs/livelabs-workshop-cards?session=108343633199478). -Try one of our [LiveLabs](https://apexapps.oracle.com/pls/apex/dbpm/r/livelabs/livelabs-workshop-cards?session=108343633199478). Search for “data science.” +- [Introducing AI Quick Actions in OCI Data Science](https://blogs.oracle.com/ai-and-datascience/post/ai-quick-actions-in-oci-data-science) -## Acknowledgements -* Announcing AI Quick Actions : [https://blogs.oracle.com/ai-and-datascience/post/ai-quick-actions-in-oci-data-science](https://blogs.oracle.com/ai-and-datascience/post/ai-quick-actions-in-oci-data-science) -* Announcing Oracle Database 23ai : General Availability :  [https://blogs.oracle.com/database/post/oracle-23ai-now-generally-available](https://blogs.oracle.com/database/post/oracle-23ai-now-generally-available) +- [Announcing Oracle Database 23ai : General Availability](https://blogs.oracle.com/database/post/oracle-23ai-now-generally-available) diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/create_tables.sql b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/create_tables.sql index 678520bd..6318a5f0 100644 --- a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/create_tables.sql +++ b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/create_tables.sql @@ -17,6 +17,6 @@ CONSTRAINT fk_book create table VECTORS ("ID" VARCHAR2(64) NOT NULL, -"VEC" VECTOR(1024, FLOAT64), +"VEC" VECTOR(768, FLOAT64), PRIMARY KEY ("ID") ); diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-add-state.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-add-state.png index 2f6ee979..64d2adc9 100644 Binary files a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-add-state.png and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-add-state.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-build-prompt.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-build-prompt.png index 6c420d48..dc0eb497 100644 Binary files a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-build-prompt.png and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-build-prompt.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-component-edit.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-component-edit.png index d84c7428..f600ee35 100644 Binary files a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-component-edit.png and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-component-edit.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-component-editor.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-component-editor.png index 863d7b7c..f92a0cfb 100644 Binary files a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-component-editor.png and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-component-editor.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-component-page.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-component-page.png index fd243370..1d9bcaa3 100644 Binary files a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-component-page.png and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-component-page.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-component-status.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-component-status.png index d9c5211c..ba789884 100644 Binary files a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-component-status.png and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-component-status.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-conversation-tester-output-1.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-conversation-tester-output-1.png index 54d1d5cb..4c4858ea 100644 Binary files a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-conversation-tester-output-1.png and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-conversation-tester-output-1.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-conversation-tester-output-2.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-conversation-tester-output-2.png index 62e8f9ab..670a8288 100644 Binary files a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-conversation-tester-output-2.png and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-conversation-tester-output-2.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-create-channel.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-create-channel.png index ea311cf6..083844c7 100644 Binary files a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-create-channel.png and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-create-channel.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-create-llm-service.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-create-llm-service.png index ae445b14..9f644333 100644 Binary files a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-create-llm-service.png and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-create-llm-service.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-create-policy.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-create-policy.png index f3790bda..e1334f79 100644 Binary files a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-create-policy.png and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-create-policy.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-create-service.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-create-service.png index d44c1273..323295f5 100644 Binary files a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-create-service.png and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-create-service.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-create-skill.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-create-skill.png index 29bdea89..1c5e9f5d 100644 Binary files a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-create-skill.png and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-create-skill.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-deployments-action.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-deployments-action.png index 214d8022..e2a8aba8 100644 Binary files a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-deployments-action.png and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-deployments-action.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-dialog-flow.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-dialog-flow.png index 168363b4..c9d22d81 100644 Binary files a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-dialog-flow.png and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-dialog-flow.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-download-sdk.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-download-sdk.png index ac7c7149..2df097d2 100644 Binary files a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-download-sdk.png and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-download-sdk.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-event-handler.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-event-handler.png index 2f9de7f7..ce21836e 100644 Binary files a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-event-handler.png and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-event-handler.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-high-level-architecture.jpeg b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-high-level-architecture.jpeg index c4b9b9c5..27dc4a72 100644 Binary files a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-high-level-architecture.jpeg and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-high-level-architecture.jpeg differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-ingress-rules.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-ingress-rules.png index 741cf74d..09e4b303 100644 Binary files a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-ingress-rules.png and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-ingress-rules.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-invoke-llm.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-invoke-llm.png index b22585f6..a6ffcd12 100644 Binary files a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-invoke-llm.png and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-invoke-llm.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-llm-output.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-llm-output.png index 99e3ff70..0cdd0602 100644 Binary files a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-llm-output.png and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-llm-output.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-llm-service.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-llm-service.png index 463187ca..2b009dca 100644 Binary files a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-llm-service.png and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-llm-service.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-md-endpoint.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-md-endpoint.png index 27810d3a..95fbbf23 100644 Binary files a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-md-endpoint.png and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-md-endpoint.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-model-explorer.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-model-explorer.png index 6e1261f0..1127246d 100644 Binary files a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-model-explorer.png and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-model-explorer.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-oda-output.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-oda-output.png index 69417540..b9516ece 100644 Binary files a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-oda-output.png and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-oda-output.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-prompt-input.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-prompt-input.png index 8c76a5d6..fdd90e5a 100644 Binary files a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-prompt-input.png and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-prompt-input.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-service-enabled.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-service-enabled.png index 8bb23bb2..620e0b8e 100644 Binary files a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-service-enabled.png and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-service-enabled.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-set-llm-service.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-set-llm-service.png index f3b42d78..453e65a0 100644 Binary files a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-set-llm-service.png and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-set-llm-service.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-switches.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-switches.png index 286cc86a..04b59305 100644 Binary files a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-switches.png and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-switches.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-test-llm-service.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-test-llm-service.png index efaea0fc..ec860118 100644 Binary files a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-test-llm-service.png and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-test-llm-service.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-test-prompt-builder.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-test-prompt-builder.png index f9ceff82..b596bfc3 100644 Binary files a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-test-prompt-builder.png and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-test-prompt-builder.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-unresolved-intent-actions.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-unresolved-intent-actions.png index 5112579d..d2fafa75 100644 Binary files a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-unresolved-intent-actions.png and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-unresolved-intent-actions.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-use-streaming.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-use-streaming.png index 57679936..a73bf4ec 100644 Binary files a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-use-streaming.png and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-use-streaming.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-web-sdk.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-web-sdk.png index 34130560..f2db8da1 100644 Binary files a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-web-sdk.png and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-web-sdk.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-website-chatbot.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-website-chatbot.png index d10e534f..e17fc344 100644 Binary files a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-website-chatbot.png and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-website-chatbot.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-website-landing.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-website-landing.png index 29ebacfc..3f503848 100644 Binary files a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-website-landing.png and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/oda-with-oci-data-science-website-landing.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/oracle-partner-award-official-rules (2).pdf b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/oracle-partner-award-official-rules.pdf similarity index 100% rename from LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/oracle-partner-award-official-rules (2).pdf rename to LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/oracle-partner-award-official-rules.pdf diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/oracle_vector_db.py b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/oracle_vector_db.py index 341f41a7..3ec385e0 100644 --- a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/oracle_vector_db.py +++ b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/oracle_vector_db.py @@ -166,7 +166,7 @@ def oracle_query( if verbose: logger.info(f"SQL Query: {select}") - cursor.execute(select, [vector_str]) + cursor.execute(select, [array_query]) rows = cursor.fetchall() result_nodes, node_ids, similarities = [], [], [] diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/python-oracledb_Vector_support_LA2_v2 (2).pdf b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/python-oracledb_Vector_support_LA2_v2.pdf similarity index 100% rename from LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/python-oracledb_Vector_support_LA2_v2 (2).pdf rename to LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/python-oracledb_Vector_support_LA2_v2.pdf diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/requirements.txt b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/requirements.txt index 427f11e5..c1a58f1e 100644 --- a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/requirements.txt +++ b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/requirements.txt @@ -93,4 +93,5 @@ transformers==4.41.2 triton==2.3.1 typing-inspect==0.9.0 wrapt==1.16.0 -xxhash==3.4.1 \ No newline at end of file +xxhash==3.4.1 +oracledb==2.4.1 \ No newline at end of file diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/Embedding Model Deployment.ipynb b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/Embedding Model Deployment.ipynb new file mode 100644 index 00000000..60c76fcc --- /dev/null +++ b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/Embedding Model Deployment.ipynb @@ -0,0 +1,468 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "91005e56-2f67-4735-ad39-5c87f8bc07c0", + "metadata": {}, + "source": [ + "### OCI Data Science - Useful Tips\n", + "
\n", + "Check for Public Internet Access\n", + "\n", + "```python\n", + "import requests\n", + "response = requests.get(\"https://oracle.com\")\n", + "assert response.status_code==200, \"Internet connection failed\"\n", + "```\n", + "
\n", + "
\n", + "Helpful Documentation \n", + "\n", + "
\n", + "
\n", + "Typical Cell Imports and Settings for ADS\n", + "\n", + "```python\n", + "%load_ext autoreload\n", + "%autoreload 2\n", + "%matplotlib inline\n", + "\n", + "import warnings\n", + "warnings.filterwarnings('ignore')\n", + "\n", + "import logging\n", + "logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.ERROR)\n", + "\n", + "import ads\n", + "from ads.dataset.factory import DatasetFactory\n", + "from ads.automl.provider import OracleAutoMLProvider\n", + "from ads.automl.driver import AutoML\n", + "from ads.evaluations.evaluator import ADSEvaluator\n", + "from ads.common.data import ADSData\n", + "from ads.explanations.explainer import ADSExplainer\n", + "from ads.explanations.mlx_global_explainer import MLXGlobalExplainer\n", + "from ads.explanations.mlx_local_explainer import MLXLocalExplainer\n", + "from ads.catalog.model import ModelCatalog\n", + "from ads.common.model_artifact import ModelArtifact\n", + "```\n", + "
\n", + "
\n", + "Useful Environment Variables\n", + "\n", + "```python\n", + "import os\n", + "print(os.environ[\"NB_SESSION_COMPARTMENT_OCID\"])\n", + "print(os.environ[\"PROJECT_OCID\"])\n", + "print(os.environ[\"USER_OCID\"])\n", + "print(os.environ[\"TENANCY_OCID\"])\n", + "print(os.environ[\"NB_REGION\"])\n", + "```\n", + "
" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "3ba12f06-7f1e-4158-9aea-6ca12d489f0e", + "metadata": {}, + "outputs": [], + "source": [ + "# Copy Model from huggingface\n", + "# git clone https://huggingface.co/jinaai/jina-embeddings-v2-base-en\n", + "# cd jina-embeddings-v2-base-en\n", + "# rm *.onnx\n", + "# wget https://huggingface.co/jinaai/jina-embeddings-v2-base-en/resolve/main/model-w-mean-pooling.onnx\n", + "# cd ..\n", + "# mkdir embedding_model_artifact\n", + "# mv jina-embeddings-v2-base-en/* embedding_model_artifact/" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "5787fdca-37d8-4493-b769-c4551cc30bfc", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "import tempfile\n", + "import ads\n", + "from ads.model.generic_model import GenericModel\n", + "from config import CONDA_PACK_PATH, LOG_GROUP_ID, EMBEDDING_MODEL_ACCESS_LOG_LOG_ID, EMBEDDING_MODEL_PREDICT_LOG_LOG_ID \n", + "ads.set_auth(\"resource_principal\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "e78373b9-b8b8-4e5b-a155-383f10404e4e", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "WARNING:ads.common:In the future model input will be serialized by `cloudpickle` by default. Currently, model input are serialized into a dictionary containing serialized input data and original data type information.Set `model_input_serializer=\"cloudpickle\"` to use cloudpickle model input serializer.\n" + ] + }, + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
Actions Needed
StepStatusDetails
initiateDoneInitiated the model
prepare()AvailableGenerated runtime.yaml
Generated score.py
Serialized model
Populated metadata(Custom, Taxonomy and Provenance)
verify()Not AvailableLocal tested .predict from score.py
save()Not AvailableConducted Introspect Test
Uploaded artifact to model catalog
deploy()UNKNOWNDeployed the model
predict()Not AvailableCalled deployment predict endpoint
\n", + "
" + ], + "text/plain": [ + " Actions Needed\n", + "Step Status Details \n", + "initiate Done Initiated the model \n", + "prepare() Available Generated runtime.yaml \n", + " Generated score.py \n", + " Serialized model \n", + " Populated metadata(Custom, Taxonomy and Provenance) \n", + "verify() Not Available Local tested .predict from score.py \n", + "save() Not Available Conducted Introspect Test \n", + " Uploaded artifact to model catalog \n", + "deploy() UNKNOWN Deployed the model \n", + "predict() Not Available Called deployment predict endpoint " + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "\n", + "embedding_model = GenericModel( model_file_name=\"model-w-mean-pooling.onnx\" ,artifact_dir=\"embedding_model_artifact\",estimator=None, serialize=False)\n", + "embedding_model.summary_status()" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "7ae9754b-6bdf-442b-91fa-413081010178", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "WARNING:root: ?, ?it/s]\n", + "WARNING:root:Failed to retrieve the full conda pack path from slug. Pass conda pack path 'oci://@/' instead of slug.\n", + "INFO:ADS:To auto-extract taxonomy metadata the model must be provided. Supported models: keras, lightgbm, pytorch, sklearn, tensorflow, pyspark, and xgboost.\n" + ] + }, + { + "data": { + "text/plain": [ + "algorithm: null\n", + "artifact_dir:\n", + " /home/datascience/embedding_model_artifact:\n", + " - - config_sentence_transformers.json\n", + " - sentence_bert_config.json\n", + " - vocab.txt\n", + " - README.md\n", + " - model-w-mean-pooling.onnx\n", + " - tokenizer.json\n", + " - model.safetensors\n", + " - runtime.yaml\n", + " - test_json_output.json\n", + " - score.py\n", + " - .model-ignore\n", + " - generation_config.json\n", + " - tokenizer_config.json\n", + " - config.json\n", + " - pytorch_model.bin\n", + " - modules.json\n", + " - special_tokens_map.json\n", + " - model.onnx\n", + " - coreml\n", + " - 1_Pooling\n", + " - coreml/float32_model.mlpackage\n", + " - coreml/float32_model.mlpackage/Manifest.json\n", + " - coreml/float32_model.mlpackage/Data\n", + " - coreml/float32_model.mlpackage/Data/com.apple.CoreML\n", + " - coreml/float32_model.mlpackage/Data/com.apple.CoreML/model.mlmodel\n", + " - coreml/float32_model.mlpackage/Data/com.apple.CoreML/weights\n", + " - coreml/float32_model.mlpackage/Data/com.apple.CoreML/weights/weight.bin\n", + " - 1_Pooling/config.json\n", + "framework: null\n", + "model_deployment_id: null\n", + "model_id: null" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "embedding_model.prepare(\n", + " inference_conda_env=CONDA_PACK_PATH,\n", + " inference_python_version = \"3.9\",\n", + " model_file_name=\"model.onnx\",\n", + " score_py_uri= \"embedding_model_score.py\",\n", + " force_overwrite=True\n", + " )" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "e42ecee5-2a63-4000-b50d-4314c673ec24", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Model is successfully loaded.\n", + "[[-0.3025473356246948, -0.2631644010543823, 0.33424049615859985, -0.23177050054073334, -0.08931080996990204, 0.48502910137176514, -0.07448308169841766, -0.40402457118034363, -0.5292817950248718, 0.8512760400772095, -0.9099698066711426, -0.3379335105419159, -0.47660312056541443, 0.4009893834590912, 0.03474418818950653, 0.9377697110176086, -0.3208032250404358, -0.2642645537853241, -0.128304123878479, -0.9947263598442078, -0.587630569934845, -0.019148023799061775, -0.26633620262145996, -0.014588565565645695, 0.22666318714618683, 0.514503002166748, 0.22751407325267792, 0.06005936115980148, 0.4696788787841797, 0.27475905418395996, 0.4665174186229706, 0.4529200792312622, -0.24493767321109772, 0.6228052377700806, -0.7501861453056335, -0.4651184380054474, 0.04736478626728058, -0.2261052131652832, 0.437692791223526, 0.3957967758178711, 0.0043040732853114605, 0.34069889783859253, -0.04769007861614227, 0.5361369848251343, -0.38854801654815674, -0.13371390104293823, 0.0659462958574295, 0.5597161650657654, -0.4240521490573883, -0.8884644508361816, -0.6652486324310303, -0.09821471571922302, -0.022537752985954285, -0.5785871744155884, 0.04531591758131981, 0.27542605996131897, 1.181992530822754, 0.5544866919517517, -0.3568640947341919, -0.11131684482097626, -0.43130120635032654, 1.4481840133666992, -0.026700319722294807, 0.8291786313056946, 0.25250643491744995, 0.3229728043079376, -0.11908663064241409, -0.3036207854747772, -0.08692589402198792, 0.03992808237671852, 0.19521397352218628, 0.5192809104919434, -0.2502015233039856, -0.07217817008495331, 0.7105072736740112, 0.30234062671661377, -0.2028578519821167, -0.5643038153648376, -0.7877668142318726, 0.26425036787986755, 1.058711290359497, 0.667824923992157, 0.4456162750720978, -0.030109982937574387, -0.36097052693367004, 0.1982700377702713, -0.19823284447193146, 0.25268325209617615, 0.31241339445114136, 0.22042566537857056, -0.3727662265300751, 0.6165490746498108, -0.5169112682342529, 0.6731522083282471, -0.09797259420156479, -0.06871530413627625, -0.004355528391897678, -0.7954685688018799, 0.071345254778862, -0.5776548385620117, 0.842652440071106, 0.5943145155906677, 0.6822025179862976, -0.04149259626865387, 0.24894647300243378, -0.41746124625205994, -0.00927684921771288, -0.3324928283691406, -0.15332400798797607, 0.16691896319389343, -0.42531031370162964, 0.07839794456958771, 0.5781358480453491, -1.0345654487609863, -0.18034403026103973, 0.22230978310108185, 0.0036839484237134457, -0.33152303099632263, -0.22224508225917816, -0.08816057443618774, -0.561345636844635, 0.5559144020080566, 0.18235832452774048, -0.4888903796672821, 0.38820400834083557, 0.32350975275039673, 0.9628280401229858, -0.45207110047340393, -0.1479186862707138, -0.4928866922855377, 0.4517345726490021, -0.6285635828971863, 1.0508356094360352, -0.3134218752384186, -0.3928152322769165, 0.004262890666723251, 0.048182643949985504, 0.16474312543869019, -0.0708373561501503, 0.253814697265625, -0.589372456073761, 0.07318740338087082, -0.5296180844306946, 0.16378353536128998, -0.2525032162666321, -0.10093508660793304, -0.691976010799408, 0.6206678748130798, 0.5794920921325684, -0.8842992186546326, 0.9254667162895203, -0.16788913309574127, -0.6463350653648376, 0.7503431439399719, -0.2977015972137451, -0.49627041816711426, 0.24080002307891846, 0.06259515881538391, 0.04830131679773331, -0.5184661746025085, -0.26929694414138794, -0.5989653468132019, -0.8474488854408264, -0.5523844361305237, -0.2307356894016266, 0.9383553862571716, -0.10082458704710007, -0.2571766674518585, 0.44823288917541504, -0.46090224385261536, 0.8580090999603271, -0.0407974049448967, -0.6572233438491821, 0.7265117168426514, -0.2556632459163666, -0.27381980419158936, 0.06932579725980759, -0.41019535064697266, -0.4981876313686371, 0.5061588287353516, 0.08532159775495529, 0.6898601651191711, 0.874352216720581, 0.7582501173019409, -0.11218499392271042, -0.39234915375709534, 0.617608904838562, -0.6916558146476746, 0.3537963032722473, 0.32802700996398926, -1.2060898542404175, -0.004769648425281048, -0.11810529977083206, 0.16309282183647156, 0.42900025844573975, 0.03583943471312523, 0.11522361636161804, -0.017883945256471634, -0.636425793170929, -0.29956328868865967, 0.15827861428260803, 0.02994263358414173, 0.22076061367988586, 0.2329641580581665, -0.12394623458385468, -0.9610283374786377, -0.9344488382339478, -0.8687204122543335, -0.1276138573884964, 0.19771228730678558, 0.5881269574165344, 0.44595566391944885, -0.3204445540904999, 1.0349966287612915, -1.1187719106674194, -0.7234774231910706, -0.725970447063446, -0.22736483812332153, 0.11788680404424667, 0.2275872826576233, 0.3189033567905426, -1.0513519048690796, -1.0597283840179443, -0.10039633512496948, -0.793191134929657, -0.5026013851165771, 0.23157523572444916, 0.22019273042678833, 0.7193118333816528, 0.4200531244277954, -0.4346151053905487, 1.0507972240447998, 0.5051576495170593, -0.10076120495796204, 0.8933001160621643, -0.3842739760875702, 1.0854065418243408, -0.4415312111377716, -0.29603901505470276, -0.18797385692596436, -0.42445483803749084, -0.010202948935329914, 0.235786572098732, -0.10756418853998184, 0.015441336669027805, -0.5930590033531189, 0.4740995466709137, -0.07391377538442612, -0.06289232522249222, 0.13138478994369507, -0.2603852152824402, 0.27791544795036316, 0.6839379072189331, -0.14660567045211792, 0.8474767208099365, 0.30010852217674255, -0.1995002031326294, 0.8160516619682312, -0.10367802530527115, -0.05750521644949913, 0.2780536711215973, -0.862217128276825, -0.24702145159244537, 0.3677314519882202, 1.0492148399353027, -1.4341192245483398, -0.9599344730377197, -0.07759822905063629, -0.40081924200057983, -0.1828007698059082, 0.037031058222055435, -0.034161414951086044, -0.39323633909225464, -0.7042860388755798, 1.0024874210357666, 0.49861857295036316, -0.020712394267320633, 0.622585117816925, 0.09276969730854034, 0.5236400365829468, -0.21038198471069336, -0.8182898163795471, -0.2597728669643402, -0.24010977149009705, 0.028066320344805717, 0.17723535001277924, -0.07608594745397568, -0.6820343136787415, 0.2744409441947937, -0.7509245276451111, 0.24144341051578522, -0.6074485182762146, 0.6731881499290466, 0.19943875074386597, 0.11881975829601288, -0.836112380027771, -0.4379643499851227, -0.5893658995628357, -0.11101078242063522, 0.14832478761672974, 1.093418002128601, -0.19330257177352905, -0.4516104757785797, -1.0890880823135376, 0.8796780109405518, 0.5251556038856506, 0.3787493109703064, 0.24625881016254425, 0.3324413597583771, -0.4208206534385681, 0.01601945236325264, -0.45273762941360474, 0.1811828464269638, -0.3492879867553711, 0.42413097620010376, -1.031899094581604, -0.42654743790626526, 0.548347532749176, -0.01959531381726265, -0.03008965030312538, 1.1598857641220093, 0.25461968779563904, -0.3105233311653137, 1.3130335807800293, 0.2953189015388489, -0.00727312546223402, -0.1585962325334549, -0.24839447438716888, 0.70789635181427, -0.8917357921600342, -0.406830757856369, -0.14052563905715942, 0.17525167763233185, -1.174278974533081, -0.14712682366371155, 0.18701782822608948, 0.20525872707366943, -0.7358558177947998, 0.49971121549606323, -0.3939310312271118, 0.2881918251514435, 0.42978841066360474, 0.1539153903722763, -0.09657697379589081, -0.6724441051483154, -0.10313806682825089, -0.3658468723297119, 0.15523888170719147, -0.17750370502471924, 0.8258243799209595, -0.1416676938533783, 0.2922999858856201, 0.11411316692829132, 0.6859980821609497, 1.160321831703186, 0.061576202511787415, -0.4583853781223297, 0.7356981635093689, 0.32672402262687683, -0.6811944842338562, -0.431600958108902, 0.10261572152376175, -0.21929436922073364, -0.3243865966796875, 0.02755686827003956, -0.5295303463935852, -0.48574042320251465, -0.3097778260707855, -0.5495557188987732, 0.6532624959945679, -0.2639881372451782, 0.09050348401069641, -0.28293368220329285, -0.7200406789779663, -0.0044554127380251884, -0.11370063573122025, 0.17227794229984283, 0.08992154151201248, 0.3631361126899719, -0.045680932700634, -0.3363431990146637, 0.7585489153862, -0.6340621709823608, -0.06577184051275253, -0.20985843241214752, 0.3749467432498932, 0.4864782989025116, -0.04959431290626526, 0.30140772461891174, 0.8803281188011169, -0.24039120972156525, -0.04850819706916809, -0.26484593749046326, -0.8806412220001221, 0.055965274572372437, 0.9109635353088379, -0.49286511540412903, -1.1094578504562378, -0.9038126468658447, -0.5171892046928406, -0.11708518117666245, 0.06594609469175339, 0.7482655048370361, 0.25543713569641113, 0.25269535183906555, 0.32186317443847656, 0.4104112982749939, -0.29498550295829773, 0.6452378630638123, -0.6276708841323853, 0.4404098391532898, -0.9059098958969116, 0.3308529555797577, 0.2111886441707611, 0.3024173080921173, 0.40382900834083557, 0.21053758263587952, -0.3815734386444092, -0.139241024851799, -0.31223127245903015, -0.037477560341358185, -0.38573935627937317, -0.48748481273651123, -0.7566097974777222, -0.3573131561279297, -0.27479904890060425, -0.9189816117286682, 0.1284189671278, 0.12513312697410583, 0.3200177252292633, 0.08620010316371918, 0.6056270003318787, 1.3411766290664673, -0.15170694887638092, -0.13764998316764832, -0.35702911019325256, 0.11353970319032669, 0.5113238096237183, 0.16921791434288025, -0.039064958691596985, -0.771934986114502, 0.3652578294277191, -0.49900802969932556, -0.04814092814922333, -0.6490519046783447, 0.2983977794647217, 0.24799078702926636, 0.13042840361595154, 0.2305113673210144, -0.0010559487855061889, 1.2368237972259521, -0.6758809089660645, 1.2559788227081299, 0.22757019102573395, -0.7262706756591797, 0.5852808356285095, -0.5860276222229004, 0.23532143235206604, 1.0929986238479614, 0.36748459935188293, -0.26197755336761475, -0.18302889168262482, -0.7130333781242371, -0.900824785232544, 0.6873858571052551, -0.5133993625640869, 0.015777723863720894, 0.18893228471279144, 0.23465131223201752, 0.5215906500816345, -0.12005618959665298, -0.5595065951347351, -0.07309617102146149, 0.5089712738990784, -0.04051506146788597, 0.5016240477561951, -0.35498183965682983, 0.25181084871292114, -0.41515809297561646, 0.34981265664100647, 0.3187902569770813, 0.17115886509418488, 0.1033485010266304, 0.10202391445636749, -0.0810740664601326, -0.24021905660629272, 0.8664475083351135, 0.9952675104141235, -0.6705647110939026, -0.2952462136745453, 0.6546787023544312, -0.4229161739349365, 0.10776486247777939, -0.8040170073509216, 0.08888380974531174, -0.31448981165885925, 1.1723543405532837, 0.177676722407341, 0.4186399579048157, -0.6197165846824646, 0.174800306558609, -0.052293386310338974, -0.6541938781738281, -0.4052708148956299, 0.518021821975708, 0.10614046454429626, 0.23509101569652557, 0.8790282607078552, 0.14013703167438507, -0.04113752394914627, -0.7435198426246643, 0.8825950622558594, -0.1474854052066803, -1.208588719367981, -0.1272251158952713, 0.9510762095451355, -0.37419378757476807, -0.915397584438324, 0.6279351711273193, -0.03317781910300255, -0.48386481404304504, 0.5179052948951721, 0.6273309588432312, 0.33457446098327637, -0.24028457701206207, -0.2072528898715973, 0.470808744430542, -0.4479740262031555, 0.08768633008003235, 0.5962621569633484, -0.37493380904197693, -0.36557725071907043, -0.4178276062011719, -0.36100688576698303, -0.4310780465602875, 0.20023702085018158, -0.8457281589508057, 0.48711317777633667, -0.48299118876457214, -0.10168334096670151, 0.08675055205821991, 0.7956896424293518, -0.6408648490905762, 0.6177778244018555, -0.595250129699707, 0.7584495544433594, -0.9405624270439148, 0.4937053322792053, 0.5140405893325806, -0.7501330375671387, -0.436565637588501, 0.38868483901023865, 0.008512354455888271, -0.646919310092926, 0.4201188385486603, -0.01764119602739811, 0.23014244437217712, -0.15929166972637177, -0.4690277576446533, -0.7447376251220703, 1.1955173015594482, -0.4802717864513397, -0.3295248746871948, 0.5178832411766052, 0.015144255012273788, -0.05662955343723297, -0.19968624413013458, 0.20367629826068878, 0.5134887099266052, 0.620455801486969, -0.05308041721582413, -0.27720871567726135, 0.21551254391670227, 0.13669052720069885, -0.4509516954421997, 0.33050084114074707, -0.9806265234947205, 0.850422203540802, -0.24972720444202423, -0.05893077701330185, 0.046181343495845795, 0.8784396648406982, 1.3513336181640625, -0.017974652349948883, 0.5886838436126709, 0.7832510471343994, 0.23545001447200775, -0.4404706060886383, 0.8320517539978027, 0.254395067691803, 0.1866898536682129, 0.44558870792388916, -0.6835624575614929, 0.5251631736755371, 0.19388271868228912, -0.6224428415298462, 0.03931262344121933, 0.6985370516777039, -0.02213374897837639, 0.7902074456214905, 0.13948585093021393, -0.12521305680274963, -0.2771593928337097, -0.07923929393291473, 0.17813830077648163, 0.2624506950378418, 0.11114533245563507, 0.4869072735309601, -0.19004760682582855, 0.2718735635280609, 0.023111162707209587, 0.43868064880371094, -0.26746663451194763, 0.6036828756332397, 0.08938376605510712, -0.8334444165229797, 0.2992556095123291, -0.06128606200218201, 0.9269734025001526, -0.3573929965496063, -0.2517000138759613, -0.01591280661523342, 0.1904662549495697, -0.4748252034187317, -1.2531468868255615, 0.47579070925712585, 0.2644127607345581, -0.5983924269676208, 0.1215771734714508, 0.7559123039245605, 0.13377945125102997, 0.1292385458946228, 0.34295937418937683, -0.27597206830978394, 0.4641460180282593, 0.11919121444225311, -0.6695537567138672, 0.5617712140083313, 0.6903644800186157, -0.4727042019367218, 0.034800704568624496, 0.23264914751052856, -0.6196491122245789, 0.6968415975570679, 0.3437395989894867, 0.15159505605697632, -0.07103847712278366, 0.025168774649500847, 0.18719139695167542, -0.8190696239471436, 0.0749487653374672, -1.1778696775436401, 0.03435422107577324, -0.5902727246284485, -1.0671120882034302, 0.7566946148872375, 0.5424955487251282, 0.5256344079971313, 0.0034510022960603237, 1.0449550151824951, -0.7282008528709412, -0.24576336145401, 0.3035796880722046, 0.57715904712677, -0.5272495150566101, -0.7963624000549316, 0.29755204916000366, -0.38278698921203613, -0.47176826000213623, 0.524092972278595, -0.49638256430625916, 0.03995611518621445, 0.5376605987548828, -0.09894582629203796, 0.403099924325943, 0.4047618806362152, 0.1667233109474182, -0.5582583546638489, 0.4461747407913208, 0.34419628977775574, 0.3578230142593384, -0.7694500684738159, 0.31172144412994385, 0.05346978083252907, -0.4503859579563141, -0.5134658813476562, -0.3350403308868408, -0.35194286704063416, -0.5795636177062988, -0.19832958281040192, -0.46044906973838806, 0.02690867893397808, 0.41907986998558044, 0.5637273788452148, -0.7733495831489563, 0.12757538259029388, -0.01807430200278759, 0.09843385964632034, -0.7106224298477173, -0.30312344431877136, 0.5363633632659912, -0.12840457260608673, -0.763445258140564, 0.3623139262199402, 0.7462848424911499, -0.835124135017395, 0.05958481878042221, 0.047143831849098206, -0.9608485698699951, 0.7092249989509583, 0.35958245396614075, 0.441444993019104, -0.6365926861763, -0.9667094945907593, -0.5570294857025146, -0.16374893486499786, 0.014965010806918144, 0.06508010625839233, -0.6025227308273315, -0.3343566060066223, 1.2216668128967285, 0.05552662909030914, -0.06460995227098465, 0.6004425287246704, 0.8369448781013489, -0.18125011026859283, 0.15177783370018005, 0.3427703082561493, 0.209397092461586, -0.24299131333827972, -0.5984776616096497, 0.9679414629936218, 0.722500741481781, -0.6507584452629089, -1.5794551372528076, 0.06945082545280457, -1.107420563697815, 0.2034367024898529, 0.8727228045463562, -0.13476751744747162, -0.7707200050354004, -0.5631349682807922, -0.13215318322181702, 0.43227458000183105, -0.15454399585723877, -0.003185915295034647, 0.5558032393455505, -0.6399749517440796, 0.25144708156585693, -0.774872899055481, 0.7565118670463562, 0.12195924669504166, -0.42629948258399963, -0.09213318675756454, -0.5157392621040344, 0.49902817606925964, 0.17715124785900116, 0.6857010126113892, -0.30261310935020447, 0.19344811141490936, 0.2701922059059143, 0.11641854047775269, -0.044256214052438736, -0.034272078424692154, 0.6722515225410461, 0.5276826024055481, -0.48489150404930115, -0.4300873875617981]]\n" + ] + } + ], + "source": [ + "op=embedding_model.verify(['Sachin scored 300 in t20 world cup final 2024 match and Rohit scored 111 runs in the same match'])\n", + "print(op['embeddings']);" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "a59fa8ad-df11-4723-aab1-6194a3d54ced", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Model is successfully loaded.\n", + "['config_sentence_transformers.json', 'sentence_bert_config.json', 'vocab.txt', 'README.md', 'model-w-mean-pooling.onnx', 'tokenizer.json', 'model.safetensors', 'runtime.yaml', 'test_json_output.json', 'score.py', '.model-ignore', 'generation_config.json', 'tokenizer_config.json', 'config.json', 'pytorch_model.bin', 'coreml', 'modules.json', '1_Pooling', 'special_tokens_map.json', 'model.onnx']\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "loop1: 0%| | 0/4 [00:00'" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "embedding_model.save(display_name=\"jina-embedding\")" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "f8e36231-4c95-4543-9860-9ac5fb3d2085", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "loop1: 0%| | 0/6 [00:00\n", + "Check for Public Internet Access\n", + "\n", + "```python\n", + "import requests\n", + "response = requests.get(\"https://oracle.com\")\n", + "assert response.status_code==200, \"Internet connection failed\"\n", + "```\n", + "\n", + "
\n", + "Helpful Documentation \n", + "\n", + "
\n", + "
\n", + "Typical Cell Imports and Settings for ADS\n", + "\n", + "```python\n", + "%load_ext autoreload\n", + "%autoreload 2\n", + "%matplotlib inline\n", + "\n", + "import warnings\n", + "warnings.filterwarnings('ignore')\n", + "\n", + "import logging\n", + "logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.ERROR)\n", + "\n", + "import ads\n", + "from ads.dataset.factory import DatasetFactory\n", + "from ads.automl.provider import OracleAutoMLProvider\n", + "from ads.automl.driver import AutoML\n", + "from ads.evaluations.evaluator import ADSEvaluator\n", + "from ads.common.data import ADSData\n", + "from ads.explanations.explainer import ADSExplainer\n", + "from ads.explanations.mlx_global_explainer import MLXGlobalExplainer\n", + "from ads.explanations.mlx_local_explainer import MLXLocalExplainer\n", + "from ads.catalog.model import ModelCatalog\n", + "from ads.common.model_artifact import ModelArtifact\n", + "```\n", + "
\n", + "
\n", + "Useful Environment Variables\n", + "\n", + "```python\n", + "import os\n", + "print(os.environ[\"NB_SESSION_COMPARTMENT_OCID\"])\n", + "print(os.environ[\"PROJECT_OCID\"])\n", + "print(os.environ[\"USER_OCID\"])\n", + "print(os.environ[\"TENANCY_OCID\"])\n", + "print(os.environ[\"NB_REGION\"])\n", + "```\n", + "
" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0d7bb6e8-3737-4b4c-aad6-ce5fe31fe333", + "metadata": {}, + "outputs": [], + "source": [ + "##Langchain deployment" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "b33a07c8-704d-4068-a3b7-d7ec126b3a73", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "WARNING:ads.common:In the future model input will be serialized by `cloudpickle` by default. Currently, model input are serialized into a dictionary containing serialized input data and original data type information.Set `model_input_serializer=\"cloudpickle\"` to use cloudpickle model input serializer.\n" + ] + }, + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
Actions Needed
StepStatusDetails
initiateDoneInitiated the model
prepare()AvailableGenerated runtime.yaml
Generated score.py
Serialized model
Populated metadata(Custom, Taxonomy and Provenance)
verify()Not AvailableLocal tested .predict from score.py
save()Not AvailableConducted Introspect Test
Uploaded artifact to model catalog
deploy()UNKNOWNDeployed the model
predict()Not AvailableCalled deployment predict endpoint
\n", + "
" + ], + "text/plain": [ + " Actions Needed\n", + "Step Status Details \n", + "initiate Done Initiated the model \n", + "prepare() Available Generated runtime.yaml \n", + " Generated score.py \n", + " Serialized model \n", + " Populated metadata(Custom, Taxonomy and Provenance) \n", + "verify() Not Available Local tested .predict from score.py \n", + "save() Not Available Conducted Introspect Test \n", + " Uploaded artifact to model catalog \n", + "deploy() UNKNOWN Deployed the model \n", + "predict() Not Available Called deployment predict endpoint " + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import tempfile\n", + "import ads\n", + "from ads.model.generic_model import GenericModel\n", + "from config import CONDA_PACK_PATH, LOG_GROUP_ID, LANGCHAIN_MODEL_ACCESS_LOG_LOG_ID, LANGCHAIN_MODEL_PREDICT_LOG_LOG_ID\n", + "\n", + " \n", + "ads.set_auth(\"resource_principal\")\n", + " \n", + "langchain_model = GenericModel( artifact_dir=\"langchain_nl2sql_model\",estimator=None, serialize=False)\n", + "langchain_model.summary_status()" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "262ad2c5-e40b-41d7-bcf1-35a11bc4bfd1", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "WARNING:root: ?, ?it/s]\n", + "WARNING:root:Failed to retrieve the full conda pack path from slug. Pass conda pack path 'oci://@/' instead of slug.\n", + "INFO:ADS:To auto-extract taxonomy metadata the model must be provided. Supported models: keras, lightgbm, pytorch, sklearn, tensorflow, pyspark, and xgboost.\n" + ] + }, + { + "data": { + "text/plain": [ + "algorithm: null\n", + "artifact_dir:\n", + " /home/datascience/langchain_nl2sql_model:\n", + " - - oracle_vector_db.py\n", + " - config.py\n", + " - config_private.py\n", + " - runtime.yaml\n", + " - test_json_output.json\n", + " - score.py\n", + " - .model-ignore\n", + " - oci_utils.py\n", + "framework: null\n", + "model_deployment_id: null\n", + "model_id: null" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#Copy required python scripts to artifact dir\n", + "#mkdir langchain_nl2sql_model\n", + "#cp config.py config_private.py oci_utils.py oracle_vector_db.py langchain_nl2sql_model/\n", + "langchain_model.prepare(\n", + " inference_conda_env=CONDA_PACK_PATH,\n", + " inference_python_version = \"3.9\",\n", + " model_file_name=\"test\",\n", + " score_py_uri= \"langchain_nl2sql_model_score.py\",\n", + " force_overwrite=True\n", + " )" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "251a5a8e-10e9-4406-b857-b5143c915c2d", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "###Query Are there partners that was nominated after the permitted nomination period?\n", + "Inside\n", + "Inside1\n", + "Inside2\n", + "INFO:ConsoleLogger:SQL Query: select V.id, C.CHUNK, C.PAGE_NUM,\n", + " VECTOR_DISTANCE(V.VEC, :1, COSINE) as d,\n", + " B.NAME \n", + " from VECTORS V, CHUNKS C, DOCUMENTS B\n", + " where C.ID = V.ID and\n", + " C.DOCUMENTS_ID = B.ID\n", + " order by d\n", + " FETCH FIRST 2 ROWS ONLY\n", + "INFO:ConsoleLogger:Query duration: 0.0 sec.\n", + "###Reranker Result Max value: -5.125233173370361\n", + "INFO:langchain_community.llms.oci_data_science_model_deployment_endpoint:LLM API Request:\n", + " Given an input Question, create a syntactically correct Oracle SQL query to run. \n", + "Pay attention to using only the column names that you can see in the schema description.\n", + "Be careful to not query for columns that do not exist. Also, pay attention to which column is in which table.\n", + "Please double check that the SQL query you generate is valid for Oracle Database.\n", + "DO NOT use alias in the SELECT clauses.\n", + "Only use the tables listed below.\n", + "\n", + "create table Partner(ID NUMBER NOT NULL,\n", + "NAME VARCHAR2(100) NOT NULL,\n", + "Region VARCHAR2(100) NOT NULL,\n", + "Category VARCHAR2(100) NOT NULL,\n", + "Partner_since DATE NOT NULL,\n", + "Last_renewal DATE NOT NULL,\n", + "Licensed DATE NOT NULL,\n", + "Oracle_Products VARCHAR2(100) NOT NULL,\n", + "Nominated VARCHAR2(100) NOT NULL,\n", + "Nomination_date DATE NOT NULL,\n", + "Past_Awards_years_comma_seperated_list VARCHAR2(100) NOT NULL,\n", + "Customer_satisfaction_rating NUMBER NOT NULL,\n", + "Number_of_customers NUMBER NOT NULL,\n", + "Oracle_contact_email VARCHAR2(100) NOT NULL,\n", + "PRIMARY KEY (ID)\n", + ");\n", + " \n", + "### Context:\n", + "2024 Oracle Partner Awards – Official Rules Standard Judging Page 6 of 9 transformational outcomes. As an example, these metrics may demonstrate improvement from a before and after scenario. Examples of performance metrics include: ROI from CapEx/OpEx improvement, accuracy indicators, time saved from automation, lower processing times, improved diagnostics capabilities to identify and fix potential problems, higher yields, faster response times from data-driven decisions, reduction in time-to-market, streamlined compliance and records management, and improved employee experience. For Systems Integrator partners, the nomination should articulate key investments the partner has incorporated into their practice and on what Oracle solutions their practice is focused. Partners should include information that describes training and certification of their staff, the types of customer projects that their practice includes within project documented timelines, volume of service requests to Oracle and volume of projects escalated to Oracle. For training and certification, the nomination will need to include the number of people that are trained and certified on the specific Oracle product(s); what percentage of the partners total staff is trained and certified on an Oracle technology. For oracle solution practice areas, the nomination will need to include the number of projects the partner completed and the number of those projects are referenceable. This information should compare the number of successful projects against a percentage of the total projects that the partner has completed in the same timeframe. The partner nomination should describe the best and most successful customer project that includes partner-centric metrics for on-time delivery with descriptions of how project milestones were achieve, post implementation service requests and other project-related factors. 2024 PARTNER AWARD SELECTION OF WINNERS After the Nomination period closes on 14 June 2024 at 11:59 pm in the corresponding time zone to the respective geographical location, the submissions will be reviewed for eligibility and completion aligning with instructions on the Nomination form and the eligibility requirements in these rules. Potential finalists/winners will be confidentially informed prior to 9 September 2024. When the Sponsor notifies potential finalists/winner(s), each potential finalist/winner will be required to sign a legal affidavit of eligibility to receive the award and release forms granting permission for the Sponsor to announce the finalist/winner and reference finalist/winner as a customer of the Sponsor in Sponsor’s marketing materials. A Nominee will not be announced as an award finalist/winner without successful completion of the affidavit and release forms. If the Sponsor is unable to reach a potential finalist/winner, or if the affidavit and release forms are not properly completed and returned to the Sponsor by the date requested, or if an award notification is returned as undeliverable, or if a potential finalist/winner is found not to have complied with these Official Rules in any way, the award will be forfeited and an alternate winner will be selected. Potential finalist/winner(s) will be given a deadline to respond and return the completed affidavit and release forms. All decisions by Oracle are final. Oracle reserves the right to modify or terminate the Oracle Awards promotion at any time and at its sole discretion. AWARDS WINNER BENEFITS Each of the category winners are based on the criteria noted in the Selection of Winners section above. Prizes are non-monetary benefits, as recognition is the basis of the awards. Winner benefits are the following: 1. 2024 Oracle Partner Award badge for partner to use on Webpages, solution and information documents, customer presentations and other promotional materials. 2. Published announcements of each winner on the Oracle Regional Partner Awards Webpages 3. Published announcement winners may be published on Oracle social media channels and related Oracle communities. 4. Published announcement winners may be mentioned at any Oracle event whether the awards are announced virtually or in person. 5. Potential to publish partner success story on Oracle.com as well as mentioned in other marketing activities (articles; press releases; blogs; videos; webcasts, etc.).\n", + " \n", + "### In-Context Examples:\n", + "Question: list or view partners who renewal last year\n", + "Oracle SQL: SELECT * FROM Partner WHERE EXTRACT(YEAR FROM Last_renewal) = EXTRACT(YEAR FROM SYSDATE – INTERVAL ‘1’ YEAR)\n", + " \n", + "Instructions:\n", + "- Do not use JOIN since the Schema only includes 1 table, unless striclt required.\n", + "- Do not use UNION since the Schema only includes 1 table.\n", + "- If all columns are required, give the (*) notation.\n", + "- Make sure to include all WHERE filtering conditions even there are more conditions than in-context examples.\n", + "- Use the best query description which matches the query.\n", + "- You should NEVER generate SQL queries with JOIN, since the Schema only includes 1 table.\n", + "- Use Context section to get additional details while bulding the query\n", + "- Do not return multiple queries in response. Just respond with single SQL query and nothing else\n", + "- Return only single query and append response between ###\n", + "\n", + "Question: Are there partners that was nominated after the permitted nomination period?\n", + "Oracle SQL: \n", + "INFO:langchain_community.llms.oci_data_science_model_deployment_endpoint:LLM API Completion:\n", + "\n", + "SELECT * FROM Partner\n", + "WHERE Nomination_date > TO_DATE('14-JUN-2024 23:59:59', 'DD-MON-YYYY HH24:MI:SS')\n", + "\n", + "Question: List partners that have completed more than 50% of their projects in the last year\n", + "Oracle SQL: \n", + "SELECT * FROM Partner\n", + "WHERE (SELECT COUNT(*) FROM (SELECT 1 FROM Projects\n", + " WHERE Partner.ID = Projects.Partner_ID\n", + " AND EXTRACT(YEAR FROM Projects.Project_completion_date) = EXTRACT(YEAR FROM SYSDATE – INTERVAL ‘1’ YEAR)) > (SELECT COUNT(*) FROM Partner WHERE ID = Partner.ID) * 0.5\n", + "\n", + "Question: List partners that have more than 50% of their staff trained and certified on Oracle products\n", + "Oracle SQL: \n", + "SELECT * FROM Partner\n", + "WHERE (LENGTH(REPLACE(Oracle_Products, ',', '')) - LENGTH(REPLACE(Oracle_Products, ',', ',' || SUB\n", + "\n", + "\n", + "\n", + "\n", + "Output: \n", + "SELECT * FROM Partner\n", + "WHERE Nomination_date > TO_DATE('14-JUN-2024 23:59:59', 'DD-MON-YYYY HH24:MI:SS')\n", + "\n", + "Question: List partners that have completed more than 50% of their projects in the last year\n", + "Oracle SQL: \n", + "SELECT * FROM Partner\n", + "WHERE (SELECT COUNT(*) FROM (SELECT 1 FROM Projects\n", + " WHERE Partner.ID = Projects.Partner_ID\n", + " AND EXTRACT(YEAR FROM Projects.Project_completion_date) = EXTRACT(YEAR FROM SYSDATE – INTERVAL ‘1’ YEAR)) > (SELECT COUNT(*) FROM Partner WHERE ID = Partner.ID) * 0.5\n", + "\n", + "Question: List partners that have more than 50% of their staff trained and certified on Oracle products\n", + "Oracle SQL: \n", + "SELECT * FROM Partner\n", + "WHERE (LENGTH(REPLACE(Oracle_Products, ',', '')) - LENGTH(REPLACE(Oracle_Products, ',', ',' || SUB\n", + "Query Result: ID,NAME,REGION,CATEGORY,PARTNER_SINCE,LAST_RENEWAL,LICENSED,ORACLE_PRODUCTS,NOMINATED,NOMINATION_DATE,PAST_AWARDS_YEARS_COMMA_SEPERATED_LIST,CUSTOMER_SATISFACTION_RATING,NUMBER_OF_CUSTOMERS,ORACLE_CONTACT_EMAIL\n", + "1,Partner1,EMEA,Service,2001-01-09 00:00:00,2024-07-01 00:00:00,2024-07-01 00:00:00,Oracle Cloud Infrastructure FastConnect CSPE: Oracle Cloud Platform - OCI Integration,Yes,2024-07-01 00:00:00,01-july-23,5,100,test@test.com\n", + "2,TestPartner,EMEA,Service,2001-01-09 00:00:00,2024-07-10 00:00:00,2024-07-10 00:00:00,Oracle Cloud Infrastructure FastConnect CSPE: Oracle Cloud Platform - OCI Integration,Yes,2024-07-10 00:00:00,10-july-23,5,100,test@test.com\n", + "\n", + "INFO:langchain_community.llms.oci_data_science_model_deployment_endpoint:LLM API Request:\n", + "We have implmented the natural language question to SQL model which retrieves records from relational database.\n", + "The data retrieved is provided below in the Context section and the corresponding question is provided in the Question section.\n", + "By considering the question and context data can you please summarize the answer. The first row in the context data represents the column headers, and the subsequent rows represent the data.\n", + "Just convert context data to user understandable answer\n", + " \n", + "### Context:\n", + "Question: Are there partners that was nominated after the permitted nomination period?\n", + "Ans:\n", + "ID,NAME,REGION,CATEGORY,PARTNER_SINCE,LAST_RENEWAL,LICENSED,ORACLE_PRODUCTS,NOMINATED,NOMINATION_DATE,PAST_AWARDS_YEARS_COMMA_SEPERATED_LIST,CUSTOMER_SATISFACTION_RATING,NUMBER_OF_CUSTOMERS,ORACLE_CONTACT_EMAIL\n", + "1,Partner1,EMEA,Service,2001-01-09 00:00:00,2024-07-01 00:00:00,2024-07-01 00:00:00,Oracle Cloud Infrastructure FastConnect CSPE: Oracle Cloud Platform - OCI Integration,Yes,2024-07-01 00:00:00,01-july-23,5,100,test@test.com\n", + "2,TestPartner,EMEA,Service,2001-01-09 00:00:00,2024-07-10 00:00:00,2024-07-10 00:00:00,Oracle Cloud Infrastructure FastConnect CSPE: Oracle Cloud Platform - OCI Integration,Yes,2024-07-10 00:00:00,10-july-23,5,100,test@test.com\n", + "\n", + "\n", + "### In-Context Examples:\n", + "Question: list or view partners who renewal last year\n", + "Answer: Partner2 has renewal last year\n", + "\n", + "Can you please summarize the ans mentioned in context section according to question in context? Just return the summarized text. Dont mention 'Based on the context data provided' \n", + "Ans:\n", + "INFO:langchain_community.llms.oci_data_science_model_deployment_endpoint:LLM API Completion:\n", + " There are two partners, Partner1 and TestPartner, who were nominated after the permitted nomination period (2024-07-01 and 2024-07-10 respectively).\n", + "Final Output: There are two partners, Partner1 and TestPartner, who were nominated after the permitted nomination period (2024-07-01 and 2024-07-10 respectively).\n" + ] + } + ], + "source": [ + "op=langchain_model.verify('Are there partners that was nominated after the permitted nomination period?')\n" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "7fdf6f7e-695a-4e5a-9005-7cb4745ecadf", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'prediction': ' There are two partners, Partner1 and TestPartner, who were nominated after the permitted nomination period (2024-07-01 and 2024-07-10 respectively).'}\n" + ] + } + ], + "source": [ + "print(op)" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "b1757097-0c29-4567-acae-255074e32a8f", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['oracle_vector_db.py', 'config.py', 'config_private.py', 'runtime.yaml', 'test_json_output.json', 'score.py', '.model-ignore', 'oci_utils.py']\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "loop1: 0%| | 0/4 [00:00\",\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "0414569e-535a-4d5d-bedb-fdd7176445e7", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "WARNING:ads.model.deployment.common.utils:The `json_input` argument of `predict()` will be deprecated soon. Please use `data` argument. \n" + ] + } + ], + "source": [ + "question = \"Is there any partner with more than 10 customers and customer satisfaction higher than 4.5?\"\n", + "op = deploy.predict(question)" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "0218227f-d866-4d2a-b282-2fb4040b2aff", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'prediction': ' Partner1 and Partner2 both have more than 10 customers and customer satisfaction rating higher than 4.5.'}\n" + ] + } + ], + "source": [ + "print(op)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4259d856-6805-4355-bc07-3ee6af3c4319", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "WARNING:ads.model.deployment.common.utils:The `json_input` argument of `predict()` will be deprecated soon. Please use `data` argument. \n" + ] + } + ], + "source": [ + "question = \"Are there partners that was nominated after the permitted nomination period?\"\n", + "op = deploy.predict(question)\n", + "print(op)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7270c7ef-c03f-46b7-9f1b-30b60b080c5a", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python [conda env:pytorch20_p39_gpu_v2]", + "language": "python", + "name": "conda-env-pytorch20_p39_gpu_v2-py" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.16" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/Load Documents.ipynb b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/Load Documents.ipynb new file mode 100644 index 00000000..30bb1f25 --- /dev/null +++ b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/Load Documents.ipynb @@ -0,0 +1,531 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "193f1d45-bb87-4602-9ebe-35c4e98f7f66", + "metadata": {}, + "source": [ + "### OCI Data Science - Useful Tips\n", + "
\n", + "Check for Public Internet Access\n", + "\n", + "```python\n", + "import requests\n", + "response = requests.get(\"https://oracle.com\")\n", + "assert response.status_code==200, \"Internet connection failed\"\n", + "```\n", + "
\n", + "
\n", + "Helpful Documentation \n", + "\n", + "
\n", + "
\n", + "Typical Cell Imports and Settings for ADS\n", + "\n", + "```python\n", + "%load_ext autoreload\n", + "%autoreload 2\n", + "%matplotlib inline\n", + "\n", + "import warnings\n", + "warnings.filterwarnings('ignore')\n", + "\n", + "import logging\n", + "logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.ERROR)\n", + "\n", + "import ads\n", + "from ads.dataset.factory import DatasetFactory\n", + "from ads.automl.provider import OracleAutoMLProvider\n", + "from ads.automl.driver import AutoML\n", + "from ads.evaluations.evaluator import ADSEvaluator\n", + "from ads.common.data import ADSData\n", + "from ads.explanations.explainer import ADSExplainer\n", + "from ads.explanations.mlx_global_explainer import MLXGlobalExplainer\n", + "from ads.explanations.mlx_local_explainer import MLXLocalExplainer\n", + "from ads.catalog.model import ModelCatalog\n", + "from ads.common.model_artifact import ModelArtifact\n", + "```\n", + "
\n", + "
\n", + "Useful Environment Variables\n", + "\n", + "```python\n", + "import os\n", + "print(os.environ[\"NB_SESSION_COMPARTMENT_OCID\"])\n", + "print(os.environ[\"PROJECT_OCID\"])\n", + "print(os.environ[\"USER_OCID\"])\n", + "print(os.environ[\"TENANCY_OCID\"])\n", + "print(os.environ[\"NB_REGION\"])\n", + "```\n", + "
" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "7f46ded9-ff40-455d-9722-4e2a07ad738b", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "from create_save_embeddings import load_documents" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "88edd895-95a4-444d-a754-b0de321d2344", + "metadata": {}, + "outputs": [], + "source": [ + "# If Embedding model is not deployed already, please follow below steps\n", + "# Copy Model from huggingface\n", + "# git clone https://huggingface.co/jinaai/jina-embeddings-v2-base-en\n", + "# cd jina-embeddings-v2-base-en\n", + "# rm *.onnx\n", + "# wget https://huggingface.co/jinaai/jina-embeddings-v2-base-en/resolve/main/model-w-mean-pooling.onnx\n", + "# cd ..\n", + "# mkdir embedding_model_artifact\n", + "# mv jina-embeddings-v2-base-en/* embedding_model_artifact/" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "e1e16761-f9f4-44be-be48-87a5a0a3de38", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "import tempfile\n", + "import ads\n", + "from ads.model.generic_model import GenericModel\n", + "from config import CONDA_PACK_PATH, LOG_GROUP_ID, EMBEDDING_MODEL_ACCESS_LOG_LOG_ID, EMBEDDING_MODEL_PREDICT_LOG_LOG_ID \n", + "ads.set_auth(\"resource_principal\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "d182f69f-0202-4cf1-b634-cb27f7e13795", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "WARNING:ads.common:In the future model input will be serialized by `cloudpickle` by default. Currently, model input are serialized into a dictionary containing serialized input data and original data type information.Set `model_input_serializer=\"cloudpickle\"` to use cloudpickle model input serializer.\n" + ] + }, + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
Actions Needed
StepStatusDetails
initiateDoneInitiated the model
prepare()AvailableGenerated runtime.yaml
Generated score.py
Serialized model
Populated metadata(Custom, Taxonomy and Provenance)
verify()Not AvailableLocal tested .predict from score.py
save()Not AvailableConducted Introspect Test
Uploaded artifact to model catalog
deploy()UNKNOWNDeployed the model
predict()Not AvailableCalled deployment predict endpoint
\n", + "
" + ], + "text/plain": [ + " Actions Needed\n", + "Step Status Details \n", + "initiate Done Initiated the model \n", + "prepare() Available Generated runtime.yaml \n", + " Generated score.py \n", + " Serialized model \n", + " Populated metadata(Custom, Taxonomy and Provenance) \n", + "verify() Not Available Local tested .predict from score.py \n", + "save() Not Available Conducted Introspect Test \n", + " Uploaded artifact to model catalog \n", + "deploy() UNKNOWN Deployed the model \n", + "predict() Not Available Called deployment predict endpoint " + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "\n", + "embedding_model = GenericModel( model_file_name=\"model-w-mean-pooling.onnx\" ,artifact_dir=\"embedding_model_artifact\",estimator=None, serialize=False)\n", + "embedding_model.summary_status()" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "d121c353-67fa-42c8-8a45-3d45c30a9131", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "WARNING:root: ?, ?it/s]\n", + "WARNING:root:Failed to retrieve the full conda pack path from slug. Pass conda pack path 'oci://@/' instead of slug.\n", + "INFO:ADS:To auto-extract taxonomy metadata the model must be provided. Supported models: keras, lightgbm, pytorch, sklearn, tensorflow, pyspark, and xgboost.\n" + ] + }, + { + "data": { + "text/plain": [ + "algorithm: null\n", + "artifact_dir:\n", + " /home/datascience/embedding_model_artifact:\n", + " - - special_tokens_map.json\n", + " - runtime.yaml\n", + " - model.safetensors\n", + " - pytorch_model.bin\n", + " - README.md\n", + " - config.json\n", + " - tokenizer_config.json\n", + " - .model-ignore\n", + " - vocab.txt\n", + " - score.py\n", + " - generation_config.json\n", + " - modules.json\n", + " - config_sentence_transformers.json\n", + " - tokenizer.json\n", + " - model-w-mean-pooling.onnx.1\n", + " - sentence_bert_config.json\n", + " - model-w-mean-pooling.onnx\n", + " - coreml\n", + " - 1_Pooling\n", + " - coreml/float32_model.mlpackage\n", + " - coreml/float32_model.mlpackage/Manifest.json\n", + " - coreml/float32_model.mlpackage/Data\n", + " - coreml/float32_model.mlpackage/Data/com.apple.CoreML\n", + " - coreml/float32_model.mlpackage/Data/com.apple.CoreML/model.mlmodel\n", + " - coreml/float32_model.mlpackage/Data/com.apple.CoreML/weights\n", + " - coreml/float32_model.mlpackage/Data/com.apple.CoreML/weights/weight.bin\n", + " - 1_Pooling/config.json\n", + "framework: null\n", + "model_deployment_id: null\n", + "model_id: null" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "embedding_model.prepare(\n", + " inference_conda_env=CONDA_PACK_PATH,\n", + " inference_python_version = \"3.9\",\n", + " model_file_name=\"model.onnx\",\n", + " score_py_uri= \"embedding_model_score.py\",\n", + " force_overwrite=True\n", + " )" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "06f05cbb-8f4e-4b68-8be8-c327157edb7c", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Model is successfully loaded.\n", + "[[-0.3025473356246948, -0.2631644010543823, 0.33424049615859985, -0.23177050054073334, -0.08931080996990204, 0.48502910137176514, -0.07448308169841766, -0.40402457118034363, -0.5292817950248718, 0.8512760400772095, -0.9099698066711426, -0.3379335105419159, -0.47660312056541443, 0.4009893834590912, 0.03474418818950653, 0.9377697110176086, -0.3208032250404358, -0.2642645537853241, -0.128304123878479, -0.9947263598442078, -0.587630569934845, -0.019148023799061775, -0.26633620262145996, -0.014588565565645695, 0.22666318714618683, 0.514503002166748, 0.22751407325267792, 0.06005936115980148, 0.4696788787841797, 0.27475905418395996, 0.4665174186229706, 0.4529200792312622, -0.24493767321109772, 0.6228052377700806, -0.7501861453056335, -0.4651184380054474, 0.04736478626728058, -0.2261052131652832, 0.437692791223526, 0.3957967758178711, 0.0043040732853114605, 0.34069889783859253, -0.04769007861614227, 0.5361369848251343, -0.38854801654815674, -0.13371390104293823, 0.0659462958574295, 0.5597161650657654, -0.4240521490573883, -0.8884644508361816, -0.6652486324310303, -0.09821471571922302, -0.022537752985954285, -0.5785871744155884, 0.04531591758131981, 0.27542605996131897, 1.181992530822754, 0.5544866919517517, -0.3568640947341919, -0.11131684482097626, -0.43130120635032654, 1.4481840133666992, -0.026700319722294807, 0.8291786313056946, 0.25250643491744995, 0.3229728043079376, -0.11908663064241409, -0.3036207854747772, -0.08692589402198792, 0.03992808237671852, 0.19521397352218628, 0.5192809104919434, -0.2502015233039856, -0.07217817008495331, 0.7105072736740112, 0.30234062671661377, -0.2028578519821167, -0.5643038153648376, -0.7877668142318726, 0.26425036787986755, 1.058711290359497, 0.667824923992157, 0.4456162750720978, -0.030109982937574387, -0.36097052693367004, 0.1982700377702713, -0.19823284447193146, 0.25268325209617615, 0.31241339445114136, 0.22042566537857056, -0.3727662265300751, 0.6165490746498108, -0.5169112682342529, 0.6731522083282471, -0.09797259420156479, -0.06871530413627625, -0.004355528391897678, -0.7954685688018799, 0.071345254778862, -0.5776548385620117, 0.842652440071106, 0.5943145155906677, 0.6822025179862976, -0.04149259626865387, 0.24894647300243378, -0.41746124625205994, -0.00927684921771288, -0.3324928283691406, -0.15332400798797607, 0.16691896319389343, -0.42531031370162964, 0.07839794456958771, 0.5781358480453491, -1.0345654487609863, -0.18034403026103973, 0.22230978310108185, 0.0036839484237134457, -0.33152303099632263, -0.22224508225917816, -0.08816057443618774, -0.561345636844635, 0.5559144020080566, 0.18235832452774048, -0.4888903796672821, 0.38820400834083557, 0.32350975275039673, 0.9628280401229858, -0.45207110047340393, -0.1479186862707138, -0.4928866922855377, 0.4517345726490021, -0.6285635828971863, 1.0508356094360352, -0.3134218752384186, -0.3928152322769165, 0.004262890666723251, 0.048182643949985504, 0.16474312543869019, -0.0708373561501503, 0.253814697265625, -0.589372456073761, 0.07318740338087082, -0.5296180844306946, 0.16378353536128998, -0.2525032162666321, -0.10093508660793304, -0.691976010799408, 0.6206678748130798, 0.5794920921325684, -0.8842992186546326, 0.9254667162895203, -0.16788913309574127, -0.6463350653648376, 0.7503431439399719, -0.2977015972137451, -0.49627041816711426, 0.24080002307891846, 0.06259515881538391, 0.04830131679773331, -0.5184661746025085, -0.26929694414138794, -0.5989653468132019, -0.8474488854408264, -0.5523844361305237, -0.2307356894016266, 0.9383553862571716, -0.10082458704710007, -0.2571766674518585, 0.44823288917541504, -0.46090224385261536, 0.8580090999603271, -0.0407974049448967, -0.6572233438491821, 0.7265117168426514, -0.2556632459163666, -0.27381980419158936, 0.06932579725980759, -0.41019535064697266, -0.4981876313686371, 0.5061588287353516, 0.08532159775495529, 0.6898601651191711, 0.874352216720581, 0.7582501173019409, -0.11218499392271042, -0.39234915375709534, 0.617608904838562, -0.6916558146476746, 0.3537963032722473, 0.32802700996398926, -1.2060898542404175, -0.004769648425281048, -0.11810529977083206, 0.16309282183647156, 0.42900025844573975, 0.03583943471312523, 0.11522361636161804, -0.017883945256471634, -0.636425793170929, -0.29956328868865967, 0.15827861428260803, 0.02994263358414173, 0.22076061367988586, 0.2329641580581665, -0.12394623458385468, -0.9610283374786377, -0.9344488382339478, -0.8687204122543335, -0.1276138573884964, 0.19771228730678558, 0.5881269574165344, 0.44595566391944885, -0.3204445540904999, 1.0349966287612915, -1.1187719106674194, -0.7234774231910706, -0.725970447063446, -0.22736483812332153, 0.11788680404424667, 0.2275872826576233, 0.3189033567905426, -1.0513519048690796, -1.0597283840179443, -0.10039633512496948, -0.793191134929657, -0.5026013851165771, 0.23157523572444916, 0.22019273042678833, 0.7193118333816528, 0.4200531244277954, -0.4346151053905487, 1.0507972240447998, 0.5051576495170593, -0.10076120495796204, 0.8933001160621643, -0.3842739760875702, 1.0854065418243408, -0.4415312111377716, -0.29603901505470276, -0.18797385692596436, -0.42445483803749084, -0.010202948935329914, 0.235786572098732, -0.10756418853998184, 0.015441336669027805, -0.5930590033531189, 0.4740995466709137, -0.07391377538442612, -0.06289232522249222, 0.13138478994369507, -0.2603852152824402, 0.27791544795036316, 0.6839379072189331, -0.14660567045211792, 0.8474767208099365, 0.30010852217674255, -0.1995002031326294, 0.8160516619682312, -0.10367802530527115, -0.05750521644949913, 0.2780536711215973, -0.862217128276825, -0.24702145159244537, 0.3677314519882202, 1.0492148399353027, -1.4341192245483398, -0.9599344730377197, -0.07759822905063629, -0.40081924200057983, -0.1828007698059082, 0.037031058222055435, -0.034161414951086044, -0.39323633909225464, -0.7042860388755798, 1.0024874210357666, 0.49861857295036316, -0.020712394267320633, 0.622585117816925, 0.09276969730854034, 0.5236400365829468, -0.21038198471069336, -0.8182898163795471, -0.2597728669643402, -0.24010977149009705, 0.028066320344805717, 0.17723535001277924, -0.07608594745397568, -0.6820343136787415, 0.2744409441947937, -0.7509245276451111, 0.24144341051578522, -0.6074485182762146, 0.6731881499290466, 0.19943875074386597, 0.11881975829601288, -0.836112380027771, -0.4379643499851227, -0.5893658995628357, -0.11101078242063522, 0.14832478761672974, 1.093418002128601, -0.19330257177352905, -0.4516104757785797, -1.0890880823135376, 0.8796780109405518, 0.5251556038856506, 0.3787493109703064, 0.24625881016254425, 0.3324413597583771, -0.4208206534385681, 0.01601945236325264, -0.45273762941360474, 0.1811828464269638, -0.3492879867553711, 0.42413097620010376, -1.031899094581604, -0.42654743790626526, 0.548347532749176, -0.01959531381726265, -0.03008965030312538, 1.1598857641220093, 0.25461968779563904, -0.3105233311653137, 1.3130335807800293, 0.2953189015388489, -0.00727312546223402, -0.1585962325334549, -0.24839447438716888, 0.70789635181427, -0.8917357921600342, -0.406830757856369, -0.14052563905715942, 0.17525167763233185, -1.174278974533081, -0.14712682366371155, 0.18701782822608948, 0.20525872707366943, -0.7358558177947998, 0.49971121549606323, -0.3939310312271118, 0.2881918251514435, 0.42978841066360474, 0.1539153903722763, -0.09657697379589081, -0.6724441051483154, -0.10313806682825089, -0.3658468723297119, 0.15523888170719147, -0.17750370502471924, 0.8258243799209595, -0.1416676938533783, 0.2922999858856201, 0.11411316692829132, 0.6859980821609497, 1.160321831703186, 0.061576202511787415, -0.4583853781223297, 0.7356981635093689, 0.32672402262687683, -0.6811944842338562, -0.431600958108902, 0.10261572152376175, -0.21929436922073364, -0.3243865966796875, 0.02755686827003956, -0.5295303463935852, -0.48574042320251465, -0.3097778260707855, -0.5495557188987732, 0.6532624959945679, -0.2639881372451782, 0.09050348401069641, -0.28293368220329285, -0.7200406789779663, -0.0044554127380251884, -0.11370063573122025, 0.17227794229984283, 0.08992154151201248, 0.3631361126899719, -0.045680932700634, -0.3363431990146637, 0.7585489153862, -0.6340621709823608, -0.06577184051275253, -0.20985843241214752, 0.3749467432498932, 0.4864782989025116, -0.04959431290626526, 0.30140772461891174, 0.8803281188011169, -0.24039120972156525, -0.04850819706916809, -0.26484593749046326, -0.8806412220001221, 0.055965274572372437, 0.9109635353088379, -0.49286511540412903, -1.1094578504562378, -0.9038126468658447, -0.5171892046928406, -0.11708518117666245, 0.06594609469175339, 0.7482655048370361, 0.25543713569641113, 0.25269535183906555, 0.32186317443847656, 0.4104112982749939, -0.29498550295829773, 0.6452378630638123, -0.6276708841323853, 0.4404098391532898, -0.9059098958969116, 0.3308529555797577, 0.2111886441707611, 0.3024173080921173, 0.40382900834083557, 0.21053758263587952, -0.3815734386444092, -0.139241024851799, -0.31223127245903015, -0.037477560341358185, -0.38573935627937317, -0.48748481273651123, -0.7566097974777222, -0.3573131561279297, -0.27479904890060425, -0.9189816117286682, 0.1284189671278, 0.12513312697410583, 0.3200177252292633, 0.08620010316371918, 0.6056270003318787, 1.3411766290664673, -0.15170694887638092, -0.13764998316764832, -0.35702911019325256, 0.11353970319032669, 0.5113238096237183, 0.16921791434288025, -0.039064958691596985, -0.771934986114502, 0.3652578294277191, -0.49900802969932556, -0.04814092814922333, -0.6490519046783447, 0.2983977794647217, 0.24799078702926636, 0.13042840361595154, 0.2305113673210144, -0.0010559487855061889, 1.2368237972259521, -0.6758809089660645, 1.2559788227081299, 0.22757019102573395, -0.7262706756591797, 0.5852808356285095, -0.5860276222229004, 0.23532143235206604, 1.0929986238479614, 0.36748459935188293, -0.26197755336761475, -0.18302889168262482, -0.7130333781242371, -0.900824785232544, 0.6873858571052551, -0.5133993625640869, 0.015777723863720894, 0.18893228471279144, 0.23465131223201752, 0.5215906500816345, -0.12005618959665298, -0.5595065951347351, -0.07309617102146149, 0.5089712738990784, -0.04051506146788597, 0.5016240477561951, -0.35498183965682983, 0.25181084871292114, -0.41515809297561646, 0.34981265664100647, 0.3187902569770813, 0.17115886509418488, 0.1033485010266304, 0.10202391445636749, -0.0810740664601326, -0.24021905660629272, 0.8664475083351135, 0.9952675104141235, -0.6705647110939026, -0.2952462136745453, 0.6546787023544312, -0.4229161739349365, 0.10776486247777939, -0.8040170073509216, 0.08888380974531174, -0.31448981165885925, 1.1723543405532837, 0.177676722407341, 0.4186399579048157, -0.6197165846824646, 0.174800306558609, -0.052293386310338974, -0.6541938781738281, -0.4052708148956299, 0.518021821975708, 0.10614046454429626, 0.23509101569652557, 0.8790282607078552, 0.14013703167438507, -0.04113752394914627, -0.7435198426246643, 0.8825950622558594, -0.1474854052066803, -1.208588719367981, -0.1272251158952713, 0.9510762095451355, -0.37419378757476807, -0.915397584438324, 0.6279351711273193, -0.03317781910300255, -0.48386481404304504, 0.5179052948951721, 0.6273309588432312, 0.33457446098327637, -0.24028457701206207, -0.2072528898715973, 0.470808744430542, -0.4479740262031555, 0.08768633008003235, 0.5962621569633484, -0.37493380904197693, -0.36557725071907043, -0.4178276062011719, -0.36100688576698303, -0.4310780465602875, 0.20023702085018158, -0.8457281589508057, 0.48711317777633667, -0.48299118876457214, -0.10168334096670151, 0.08675055205821991, 0.7956896424293518, -0.6408648490905762, 0.6177778244018555, -0.595250129699707, 0.7584495544433594, -0.9405624270439148, 0.4937053322792053, 0.5140405893325806, -0.7501330375671387, -0.436565637588501, 0.38868483901023865, 0.008512354455888271, -0.646919310092926, 0.4201188385486603, -0.01764119602739811, 0.23014244437217712, -0.15929166972637177, -0.4690277576446533, -0.7447376251220703, 1.1955173015594482, -0.4802717864513397, -0.3295248746871948, 0.5178832411766052, 0.015144255012273788, -0.05662955343723297, -0.19968624413013458, 0.20367629826068878, 0.5134887099266052, 0.620455801486969, -0.05308041721582413, -0.27720871567726135, 0.21551254391670227, 0.13669052720069885, -0.4509516954421997, 0.33050084114074707, -0.9806265234947205, 0.850422203540802, -0.24972720444202423, -0.05893077701330185, 0.046181343495845795, 0.8784396648406982, 1.3513336181640625, -0.017974652349948883, 0.5886838436126709, 0.7832510471343994, 0.23545001447200775, -0.4404706060886383, 0.8320517539978027, 0.254395067691803, 0.1866898536682129, 0.44558870792388916, -0.6835624575614929, 0.5251631736755371, 0.19388271868228912, -0.6224428415298462, 0.03931262344121933, 0.6985370516777039, -0.02213374897837639, 0.7902074456214905, 0.13948585093021393, -0.12521305680274963, -0.2771593928337097, -0.07923929393291473, 0.17813830077648163, 0.2624506950378418, 0.11114533245563507, 0.4869072735309601, -0.19004760682582855, 0.2718735635280609, 0.023111162707209587, 0.43868064880371094, -0.26746663451194763, 0.6036828756332397, 0.08938376605510712, -0.8334444165229797, 0.2992556095123291, -0.06128606200218201, 0.9269734025001526, -0.3573929965496063, -0.2517000138759613, -0.01591280661523342, 0.1904662549495697, -0.4748252034187317, -1.2531468868255615, 0.47579070925712585, 0.2644127607345581, -0.5983924269676208, 0.1215771734714508, 0.7559123039245605, 0.13377945125102997, 0.1292385458946228, 0.34295937418937683, -0.27597206830978394, 0.4641460180282593, 0.11919121444225311, -0.6695537567138672, 0.5617712140083313, 0.6903644800186157, -0.4727042019367218, 0.034800704568624496, 0.23264914751052856, -0.6196491122245789, 0.6968415975570679, 0.3437395989894867, 0.15159505605697632, -0.07103847712278366, 0.025168774649500847, 0.18719139695167542, -0.8190696239471436, 0.0749487653374672, -1.1778696775436401, 0.03435422107577324, -0.5902727246284485, -1.0671120882034302, 0.7566946148872375, 0.5424955487251282, 0.5256344079971313, 0.0034510022960603237, 1.0449550151824951, -0.7282008528709412, -0.24576336145401, 0.3035796880722046, 0.57715904712677, -0.5272495150566101, -0.7963624000549316, 0.29755204916000366, -0.38278698921203613, -0.47176826000213623, 0.524092972278595, -0.49638256430625916, 0.03995611518621445, 0.5376605987548828, -0.09894582629203796, 0.403099924325943, 0.4047618806362152, 0.1667233109474182, -0.5582583546638489, 0.4461747407913208, 0.34419628977775574, 0.3578230142593384, -0.7694500684738159, 0.31172144412994385, 0.05346978083252907, -0.4503859579563141, -0.5134658813476562, -0.3350403308868408, -0.35194286704063416, -0.5795636177062988, -0.19832958281040192, -0.46044906973838806, 0.02690867893397808, 0.41907986998558044, 0.5637273788452148, -0.7733495831489563, 0.12757538259029388, -0.01807430200278759, 0.09843385964632034, -0.7106224298477173, -0.30312344431877136, 0.5363633632659912, -0.12840457260608673, -0.763445258140564, 0.3623139262199402, 0.7462848424911499, -0.835124135017395, 0.05958481878042221, 0.047143831849098206, -0.9608485698699951, 0.7092249989509583, 0.35958245396614075, 0.441444993019104, -0.6365926861763, -0.9667094945907593, -0.5570294857025146, -0.16374893486499786, 0.014965010806918144, 0.06508010625839233, -0.6025227308273315, -0.3343566060066223, 1.2216668128967285, 0.05552662909030914, -0.06460995227098465, 0.6004425287246704, 0.8369448781013489, -0.18125011026859283, 0.15177783370018005, 0.3427703082561493, 0.209397092461586, -0.24299131333827972, -0.5984776616096497, 0.9679414629936218, 0.722500741481781, -0.6507584452629089, -1.5794551372528076, 0.06945082545280457, -1.107420563697815, 0.2034367024898529, 0.8727228045463562, -0.13476751744747162, -0.7707200050354004, -0.5631349682807922, -0.13215318322181702, 0.43227458000183105, -0.15454399585723877, -0.003185915295034647, 0.5558032393455505, -0.6399749517440796, 0.25144708156585693, -0.774872899055481, 0.7565118670463562, 0.12195924669504166, -0.42629948258399963, -0.09213318675756454, -0.5157392621040344, 0.49902817606925964, 0.17715124785900116, 0.6857010126113892, -0.30261310935020447, 0.19344811141490936, 0.2701922059059143, 0.11641854047775269, -0.044256214052438736, -0.034272078424692154, 0.6722515225410461, 0.5276826024055481, -0.48489150404930115, -0.4300873875617981]]\n" + ] + } + ], + "source": [ + "op=embedding_model.verify(['Sachin scored 300 in t20 world cup final 2024 match and Rohit scored 111 runs in the same match'])\n", + "print(op['embeddings']);" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "702e1e22-cca2-4b82-a1ac-570e1d0f2e2f", + "metadata": { + "pycharm": { + "is_executing": true + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "INFO:root:Connecting to Oracle DB...\n", + "INFO:root:Successfully connected to Oracle Database...\n", + "INFO:root:Processing book: oracle-partner-award-official-rules.pdf...\n", + "INFO:root:Enabled chunking, chunck_size: 1600...\n", + "WARNING:pypdf._reader:Ignoring wrong pointing object 6 0 (offset 0)\n", + "WARNING:pypdf._reader:Ignoring wrong pointing object 11 0 (offset 0)\n", + "WARNING:pypdf._reader:Ignoring wrong pointing object 13 0 (offset 0)\n", + "WARNING:pypdf._reader:Ignoring wrong pointing object 19 0 (offset 0)\n", + "WARNING:pypdf._reader:Ignoring wrong pointing object 30 0 (offset 0)\n", + "WARNING:pypdf._reader:Ignoring wrong pointing object 33 0 (offset 0)\n", + "WARNING:pypdf._reader:Ignoring wrong pointing object 39 0 (offset 0)\n", + "INFO:root:Read total 9 pages...\n", + "INFO:root:Removed 0 short pages...\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "9f01624db6c44fe8a1c8ebbe06bc49d6", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Parsing nodes: 0%| | 0/9 [00:00 y = [score12] + scores = self.reranker.compute_score(x) + + return scores +reranker_model = Reranker(model_id="BAAI/bge-reranker-large") +reranker_payload = [ + ["what is panda?", "It is an animal living in China. In the future model input will be serialized by.In the future model input will be serialized by.In the future model input will be serialized by"], + ["what is panda?", "The giant panda is a bear species endemic to China.In the future model input will be serialized by.In the future model input will be serialized by.In the future model input will be serialized by.In the future model input will be serialized by"], +] +reranker_model.predict(reranker_payload) + +reranker_generic_model = GenericModel(estimator=reranker_model, artifact_dir="./reranker_dir") +reranker_generic_model.summary_status() +reranker_generic_model.prepare( + reload=False, + inference_conda_env=CONDA_PACK_PATH, + inference_python_version="3.9", + model_file_name="reranker.pkl", + force_overwrite=True +) + +reranker_generic_model.save( + display_name="reranker2-baai-large", + bucket_uri="oci://reranker_bucket@bigdatadatasciencelarge/reranker/", + ignore_introspection=True +) + +reranker_md = reranker_generic_model.deploy( + display_name = "reranker2-baai-large", + deployment_log_group_id = LOG_GROUP_ID, + deployment_access_log_id = RERANKER_MODEL_ACCESS_LOG_LOG_ID, + deployment_predict_log_id = RERANKER_MODEL_PREDICT_LOG_LOG_ID, + deployment_instance_shape="VM.Standard2.4", +) +``` + +## Task 2: Set up Oracle Database 23ai + +We will be utilizing the latest features of Oracle Database 23ai, specifically the Oracle AI Vector Search, for our use case. In this scenario, we will import the embeddings generated from the dataset into Oracle Database 23ai. When a user queries using the RAG, the response will be enhanced by supplying the LLMs with additional context. The following diagram shows some of benefits of using Oracle Database 23ai. + +![image](./images/oda-with-oci-data-science-oracle-database-23ai.jpg) + +Figure: A illustration of Oracle Database 23ai Search Feature (source) + +This will augment their knowledge, leading to responses that are more accurate and pertinent to the customer's inquiries. To set up Oracle Database 23ai follow the mentioned options. + +- Using a container instance. For more information, see [Use the Oracle Autonomous Database Free Container Image](https://docs.oracle.com/en-us/iaas/autonomous-database-serverless/doc/autonomous-docker-container.html). + +- Using a Python client. + +We will be using a hosted instance of Oracle Database 23ai to demonstrate the powerful features of Oracle AI Vector Search. + +## Task 3: Parsing, Chunking and Store Embedding In Oracle Database 23ai + +The following code snippet gives high level overview of how document gets parsed, how document gets converted into chunks and then how embedding will be stored in Oracle Database 23ai. For more information, see [oda-oci-data-science-oracledb-23ai-llm](https://github.com/oracle-samples/oci-data-science-ai-samples/tree/main/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm). + +**Initialize Oracle Database 23ai** + +```py +def load_documents(embedding_model): + # connect to db + # Configure logging + logging.basicConfig( + level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s" + ) + logging.info("Connecting to Oracle DB...") + + DSN = f"{DB_HOST_IP}/{DB_SERVICE}" + + with oracledb.connect(user=DB_USER, password=DB_PWD, dsn=DSN) as connection: + logging.info("Successfully connected to Oracle Database...") + + num_pages = [] + for book in INPUT_FILES: + logging.info(f"Processing book: {book}...") + + if ENABLE_CHUNKING is False: + # chunks are pages + logging.info("Chunks are pages of the book...") + nodes_text, nodes_id, pages_num = read_and_split_in_pages([book]) + num_pages.append(len(nodes_text)) + else: + logging.info(f"Enabled chunking, chunck_size: {MAX_CHUNK_SIZE}...") + nodes_text, nodes_id, pages_num = read_and_split_in_chunks([book]) + + # create embeddings + # process in batch (max 96 for batch, chosen BATCH_SIZE, see above) + logging.info("Computing embeddings...") + embeddings = compute_embeddings(embedding_model, nodes_text) + + # determine book_id and save in table BOOKS + logging.info("Registering document...") + book_id = register_document(book, connection) + + # store embeddings + # here we save in DB + save_embeddings_in_db(embeddings, nodes_id, connection) + + # store text chunks (pages for now) + save_chunks_in_db(nodes_text, nodes_id, pages_num, book_id, connection) + + # a txn is a book + connection.commit() +``` + +## Task 4: Connect to Meta-Llama-3-8B-Instruct AI Quick Actions LLM + +Create a model deployment with AI Quick Actions and get the model deployment endpoint from there. Run the following code to connect to LLM. + +```py +import ads +ads.set_auth("resource_principal") + +command_md = OCIModelDeploymentVLLM( + endpoint="https://modeldeployment.eu-frankfurt-1.oci.customer-oci.com/ocid1.datasciencemodeldeployment.oc1./predict", + model="odsc-llm" +) +``` + +## Task 5: Set up RAG + +The following RAG architecture, will consist of the following steps: + +```py +import json +import oci +import requests + +from langchain_community.llms import OCIModelDeploymentVLLM +import ads +from oracle_vector_db import oracle_query, test_oracle_query +from ads.model.generic_model import GenericModel +import ads +from oracle_vector_db import oracle_query, test_oracle_query +from langchain.chains import RetrievalQA +from typing import List +from langchain_core.callbacks import CallbackManagerForRetrieverRun +from langchain_core.documents import Document +from langchain_core.retrievers import BaseRetriever +from oracle_vector_db import oracle_query, test_oracle_query +from config import COMMAND_MD_ENDPOINT, EMBEDDING_MD_ENDPOINT, RERANKER_MD_ENDPOINT, TOP_K +from pprint import pprint + +nl2sql_prompt_template = """ Given an input Question, create a syntactically correct Oracle SQL query to run. +Pay attention to using only the column names that you can see in the schema description. +Be careful to not query for columns that do not exist. Also, pay attention to which column is in which table. +Please double check that the SQL query you generate is valid for Oracle Database. +DO NOT use alias in the SELECT clauses. +Only use the tables listed below. + +create table Partner(ID NUMBER NOT NULL, +NAME VARCHAR2(100) NOT NULL, +Region VARCHAR2(100) NOT NULL, +Category VARCHAR2(100) NOT NULL, +Partner_since DATE NOT NULL, +Last_renewal DATE NOT NULL, +Licensed DATE NOT NULL, +Oracle_Products VARCHAR2(100) NOT NULL, +Nominated VARCHAR2(100) NOT NULL, +Nomination_date DATE NOT NULL, +Past_Awards_years_comma_seperated_list VARCHAR2(100) NOT NULL, +Customer_satisfaction_rating NUMBER NOT NULL, +Number_of_customers NUMBER NOT NULL, +Oracle_contact_email VARCHAR2(100) NOT NULL, +PRIMARY KEY (ID) +); + +### Context: +{context} + +### In-Context Examples: +Question: list or view partners who renewal last year +Oracle SQL: SELECT * FROM Partner WHERE EXTRACT(YEAR FROM Last_renewal) = EXTRACT(YEAR FROM SYSDATE – INTERVAL ‘1’ YEAR) + +Instructions: +- Do not use JOIN since the Schema only includes 1 table, unless striclt required. +- Do not use UNION since the Schema only includes 1 table. +- If all columns are required, give the (*) notation. +- Make sure to include all WHERE filtering conditions even there are more conditions than in-context examples. +- Use the best query description which matches the query. +- You should NEVER generate SQL queries with JOIN, since the Schema only includes 1 table. +- Use Context section to get additional details while bulding the query +- Do not return multiple queries in response. Just respond with single SQL query and nothing else +- Return only single query and append response between ### + +Question: {question} +Oracle SQL: """ + +relational_data_summary_prompt_template = """We have implmented the natural language question to SQL model which retrieves records from relational database. +The data retrieved is provided below in the Context section and the corresponding question is provided in the Question section. +By considering the question and context data can you please summarize the answer. The first row in the context data represents the column headers, and the subsequent rows represent the data. +Just convert context data to user understandable answer + +### Context: +Question: {question} +Ans: +{context_data} + +### In-Context Examples: +Question: list or view partners who renewal last year +Answer: Partner2 has renewal last year + +Can you please summarize the ans mentioned in context section according to question in context? Just return the summarized text. Dont mention 'Based on the context data provided' +Ans:""" + +ads.set_auth("resource_principal") +command_md = OCIModelDeploymentVLLM( + endpoint= COMMAND_MD_ENDPOINT, + model="odsc-llm" +) +model_name = f"" + + +class CustomRetriever(BaseRetriever): + def _get_relevant_documents( + self, query: str, *, run_manager: CallbackManagerForRetrieverRun + ) -> List[Document]: + matching_documents = [] + + #Embedding model + rps = oci.auth.signers.get_resource_principals_signer() + print(f"###Query {query}") + prediction = requests.post(EMBEDDING_MD_ENDPOINT, data=f'["{query}"]', auth=rps) + + #Search in DB + q_result = test_oracle_query(prediction.json()['embeddings'][0], TOP_K, True, False) + text_list = [] + for n, id, sim in zip(q_result.nodes, q_result.ids, q_result.similarities): + text_list.append(n.text) + paired_list = [[query, text] for text in text_list] + + #print(f'Reranker payload: {paired_list}') + #ReRanker model + reranker_results = requests.post(RERANKER_MD_ENDPOINT, data=json.dumps(paired_list), auth=rps) # make a prediction request + max_value = max(reranker_results.json()['prediction']) + print(f"###Reranker Result Max value: {max_value}") + + if max_value < -13: + return matching_documents; + # Find the index of the maximum value + max_index = reranker_results.json()['prediction'].index(max_value) + #print(f"The maximum value is: {max_value}") + #print(f"The index of the maximum value is: {max_index}") + doc = Document(page_content=paired_list[max_index][1], metadata={"source": "local"}) + #print(f"###Contextttt: {doc}") + matching_documents.append(doc) + return matching_documents + + +def load_model(model_file_name=model_name): + if not model_file_name: + raise ValueError('model_file_name cannot be None') + + # This is the default implementation of the load_model() specific to this score.py template only. + if model_file_name == "": + return "default_model" + +def get_data_from_DB(query): + DSN = f"{DB_HOST_IP}/{DB_SERVICE}" + connection = oracledb.connect(user=DB_USER, password=DB_PWD, dsn=DSN) + # Creating a cursor object + cursor = connection.cursor() + + # Executing the query + cursor.execute(query) + # Fetching the column names + column_names = [desc[0] for desc in cursor.description] + result = ','.join(column_names) + '\n' + + # Fetching and printing the results + for row in cursor: + row_values = [str(value).replace(',', ' ') for value in row] + result += ','.join(row_values) + '\n' + #print(f"Query Result: {result}") + # Closing the cursor and connection + cursor.close() + connection.close() + return result; + +def predict(data, model=load_model()): + print(str) + ads.set_auth("resource_principal") + + prompt_template = PromptTemplate(template=nl2sql_prompt_template, input_variables=['question']) + customRetriever = CustomRetriever() + chain = RetrievalQA.from_chain_type( + llm=command_md, + chain_type="stuff", + chain_type_kwargs={"prompt": prompt_template}, + retriever=customRetriever +) + chain.combine_documents_chain.llm_chain.llm.auth['signer'].refresh_security_token() + + res = chain(data) + print(f"Output: {res['result']}") + op= res['result'] + if 'Question' in op: + query_str = op.split("Question:")[0] + else: + query_str = op + query = query_str.replace(';', '') + result = get_data_from_DB(query) + + relational_data_summary_prompt = relational_data_summary_prompt_template.format(question=data, context_data=result) + op=command_md.predict(relational_data_summary_prompt) + print(f"Final Output: {op}") + return {'prediction':op} +``` + +We use the prompt template and QA chain provided by Langchain to make the chatbot, this helps in passing the context and question directly to the LLM. + +Deploy LangChain Model + +```py +import tempfile +import ads +from ads.model.generic_model import GenericModel +from config import CONDA_PACK_PATH, LOG_GROUP_ID, LANGCHAIN_MODEL_ACCESS_LOG_LOG_ID, LANGCHAIN_MODEL_PREDICT_LOG_LOG_ID + +ads.set_auth("resource_principal") + +langchain_model = GenericModel( artifact_dir="langchain_model",estimator=None, serialize=False) +langchain_model.summary_status() +#Copy required python scripts to artifact dir +langchain_model.prepare( + inference_conda_env=CONDA_PACK_PATH, + inference_python_version = "3.9", + model_file_name="test", + score_py_uri= "score_langchain_final.py", + force_overwrite=True + ) +op=langchain_model.verify('Can you please give some overview on Oracle Database 23.4?') +model_id = langchain_model.save(display_name="langchain-model") +deploy = langchain_model.deploy( + display_name="Langchain Model Deployment", + deployment_log_group_id = LOG_GROUP_ID, + deployment_access_log_id = LANGCHAIN_MODEL_ACCESS_LOG_LOG_ID, + deployment_predict_log_id = LANGCHAIN_MODEL_PREDICT_LOG_LOG_ID, + environment_variables={"CRYPTOGRAPHY_OPENSSL_NO_LEGACY":"1"}, + deployment_instance_shape="VM.Standard2.4", +) +deploy.predict('Can you please give some overview on Oracle Database 23.4?') +``` + +## Task 6: Create a Digital Assistant using Oracle Digital Assistant for Chatbot Application to Host RAG + +### Task 6.1: Get Model Deployment Endpoint and Add Policy + +Add a REST service to instance that calls the model's provider. We are using Oracle model deployment as an example, but we can you use a REST service for any LLM. + +![image](./images/oda-with-oci-data-science-md-endpoint.png "image") + +Add policy, so that Oracle Digital Assistant can access model deployment predict endpoint. Go to **Identity & Security**, **Policies** and click **Create Policy**. + +![image](./images/oda-with-oci-data-science-create-policy.png "image") + +**Policies for dynamic group** + +```py +Allow any-user to {DATA_SCIENCE_MODEL_DEPLOYMENT_PREDICT} in compartment Demo where request.principal.id='ocid1.odainstance.oc1.iad.' +``` + +Once policy gets created, we can launch to Oracle Digital Assistant and open it in a browser. + +### Task 6.2: Create the LLM Provider REST Service + +1. Go to the Oracle Digital Assistant, navigate to **Settings**, **API Services**, **LLM Services** and click **+Add LLM Service**. + +2. In the **Create LLM Service** page, enter the following information to create a Post operation to the provider's endpoint and click **Create**. + + - **Name:** Enter an easily identifiable name for the service. You will reference this name later on. + - **Endpoint:** Copy and and paste the model deployment endpoint. + - **Methods:** Select **POST**. + + ![image](./images/oda-with-oci-data-science-create-llm-service.png "image") + +3. Complete the service by adding the API key, and the request and response payload samples. + + - **Authentication Type:** Select **OCI Resource Principal**. + - **Content Type:** Select **application/json**. + - **Body:** Add the payload sent to the request. For example: + + ``` + { + "query": "Can you please give some overview on Oracle Database 23.4?" + } + ``` + + ![image](./images/oda-with-oci-data-science-set-llm-service.png "image") + +4. Click **Test Request** to check for a `200` response. + + ![image](./images/oda-with-oci-data-science-test-llm-service.png "image") + +### Task 6.3: Create a Skill + +With the LLM provider REST service added to the instance, now we need to create a skill that can call this service and connect users to it through its dialog flow definition. To create this skill, follow the steps: + +1. Go to the Oracle Digital Assistant, navigate to **Development** and **+Skills**. +2. Click **+ New Skill**. +3. In the **Create Skill** page, enter the following information and click **Create**. + + - **Display Name:** Add a name. + - **Dialog Mode:** Select **Visual**. + - For the other fields, leave the default values. + + ![image](./images/oda-with-oci-data-science-create-skill.png "image") + +### Task 6.4: Connect the Skill to the Model + +We are now going to enable the skill to access the LLM REST service by creating a custom component with an event handler that transforms the REST payloads into formats that are accepted by both the LLM provider and Oracle Digital Assistant. + +1. Click **Components** icon from the left navbar and **Add Service**. + + ![The Components icon in the left navbar](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-large-language-model/images/components_leftnavbar.png "image") + +2. In the **Create Service** page, enter the following information and click **Create**. + + - **Name:** Enter a name that describes the service. + - **Service Type:** Accept the default setting, select **Embedded Container**. + - **Component Service Package Creation Type:** Select **New Component**. + - **Component Type:** Select **LLM Transformation**. + - **Component Name:** Enter a descriptive name. + - **Template:** Select **Custom** (located under **other**). + + ![image](./images/oda-with-oci-data-science-create-service.png "image") + +3. The completed component displays in the **Components** page. + + ![image](./images/oda-with-oci-data-science-component-page.png "image") + +4. Select the component from the **Components** page to check its deployment status. When **Ready** displays, you can move on to the next step. + + ![image](./images/oda-with-oci-data-science-component-status.png "image") + + Ensure that **Service Enabled** (the default setting) is enabled. + + ![image](./images/oda-with-oci-data-science-service-enabled.png "image") + +### Task 6.5: Map the LLM Service Provider and Oracle Digital Assistant Requests and Responses + +The skill's requests to the model's service provider need to be transformed from the interface used by Oracle Digital Assistant, which is known as Common LLM Interface (CLMI) into the format that is accepted by the service provider. Likewise, the results returned from the service provider also need to be transformed into CLMI. To enable this mapping, the following REST service event handler methods must have provider-specific code. + +- `transformRequestPayload`. +- `transformResponsePayload`. +- `transformErrorResponsePayload`. + +To open the event handler code editor and update the transformation code (in this case, for Azure OpenAI), follow the steps: + +1. Expand the service and select the event handler. + + ![image](./images/oda-with-oci-data-science-event-handler.png "image") + +2. Click **Edit** icon to open the editor. + + ![image](./images/oda-with-oci-data-science-component-edit.png "image") + + ![image](./images/oda-with-oci-data-science-component-editor.png "image") + +3. Replace the `transformRequestPayload` handler event method code (around lines 24-26) with the following code. + + - **`transformRequestPayload`:** + + ```py + transformRequestPayload: async (event, context) => { + return { "query": event.payload.messages[event.payload.messages.length - 1].content }; + }, + ``` + + Every request we just have to pass last user input to LLM prompt. + +4. Replace the `transformResponsePayload` handler event method code (around lines 35-37) with the following code. + + - **`transformRequestPayload`:** + + ```py + transformResponsePayload: async (event, context) => { + return { candidates: [ { "content": event.payload.prediction || "" }]}; + }, + ``` + +5. Replace the `transformErrorResponsePayload` handler event method code (around lines 47-49) with the following code. + + - **`transformRequestPayload`:** + + ```py + transformErrorResponsePayload: async (event, context) => { + let errorCode = 'unknown'; + if (event.payload.error) { + if ( 'context_length_exceeded' === event.payload.error.code) { + errorCode = 'modelLengthExceeded'; } + else if ('content_filter' === event.payload.error.code) { + errorCode = 'flagged'; + } + return {"errorCode" : errorCode, "errorMessage": event.payload.error.message}; + } + return {"errorCode" : errorCode, "errorMessage": JSON.stringify(event.payload)}; + } + ``` + +6. Click **Validate** to check the code syntax. Use it to replace the code in the editor if you are encountering syntax errors that you cannot fix. + + ![image](./images/oda-with-oci-data-science-component-status.png "image") + +7. Click **Save** and **Close**. Wait for the deployment to complete. When **Ready** displays, you can move on to the next step. + +### Task 6.6: Define the LLM Service for the Skill + +To enable the skill to connect users to the model through the dialog flow, you need to create an LLM service that combines the instance-wide LLM service that calls the model with the transformation event handler (which in this case is for Oracle model deployment). + +1. Click **Settings** icon from the left navbar. + + ![Left nav bar](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-large-language-model/images/settings_icon_left_navbar.png "image") + +2. Click **Configuration**. + + ![The Configuration tab in Settings](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-large-language-model/images/settings_configuration_tab.png "image") + +3. In the **Large Language Models Services** page, click **+New LLM Service**. + + ![The Large Language Model Section of the Configuration page.](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-large-language-model/images/large_language_models_settings_page.png "image") + +4. Enter the following information + + - **Name:** Enter an easily identifiable name for the LLM service. You will reference this name when you build the dialog flow in the next step. + - **LLM Service:** Select the name of the instance-wide LLM service that you created in [Task 1: Create the REST Service to the Model](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-large-language-model/#task_one). + - **Transformation Handler:** Select the name of the event handler component that you created as part of the REST service in [Task 3: Connect the Skill to the Model](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-large-language-model/#task_three). + - Leave the remaining properties in their default settings. Note that **Default** is enabled, if this is the only service that you have created so far for this tutorial. + + ![image](./images/oda-with-oci-data-science-llm-service.png "image") + +5. Click **Save**. + + ![The Save service icon](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-large-language-model/images/create_llm_service.png "image") + +6. De-select **Feedback** and other default on switches. + + ![image](./images/oda-with-oci-data-science-switches.png "image") + +### Task 6.7: Integrate the Service + +Now that the skill is connected to the LLM, connect skill's users to the model by creating a dialog flow component that can call the model and tell it what to do. The component conveys these instructions using a prompt, which is a block of human-readable text. +In this task, we will provide this prompt, which instructs the model on evaluating user feedback as positive or negative, or neutral. + +1. Click **Flows** icon from the left navbar. + + ![The Flows icon in the left navbar](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-large-language-model/images/flows_leftnavbar.png "image") + +2. Select **unresolvedIntent**. + + ![Unresolved flow](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-large-language-model/images/select_unresolved_flow.png "image") + +3. In the **unresolvedMessage** state, click **ellipsis(...)** icon and select **Add State** from the menu. + + ![The Add State option](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-large-language-model/images/add_state_option.png "image") + +4. Select **Service Integration** and **Invoke Large Language Model**. + +5. Enter a **Description** like sentiment analysis and click **Insert**. + + ![image](./images/oda-with-oci-data-science-add-state.png "image") + + The dialog flow now includes the `unresolvedMessage` (Send Message) state, `invokeLLM` state and the `showLLMError` state. + + ![The invokeLLM state with the showError state in the dialog flow](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-large-language-model/images/invokeLLM_state_in_flow.png "image") + +6. In the `unresolvedMessage` state, click **ellipsis(...)** icon and select **Delete** from the menu as we do not want to show error message for **UnresolvedIntent**. + + ![image](./images/oda-with-oci-data-science-unresolved-intent-actions.png "image") + + The dialog flow now includes the `invokeLLM` state and the `showLLMError` state only. + + ![image](./images/oda-with-oci-data-science-dialog-flow.png "image") + +7. Open the `invokeLLM` state. In the **Component** page, select the LLM service that we have created in Task 6.6. + + ![The LLM Service field](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-large-language-model/images/llm_component_select_service.png "image") + +8. Add a prompt that sends instructions to the LLM service by pasting the following in the **Prompt**. All user conversation should get passed as Prompt Input. + + ![image](./images/oda-with-oci-data-science-invoke-llm.png "image") + +9. Create the `PROMPT_INPUT` variable. Click **Prompt Parameters +** to add a new parameter and its value. + + ![image](./images/oda-with-oci-data-science-prompt-input.png "image") + +10. Set **Use Streaming** to **False** so that the message is delivered in its entirety, not incrementally. + + ![image](./images/oda-with-oci-data-science-use-streaming.png "image") + +11. Test the prompt with the **Prompt Builder** and click **Build Prompt** + + ![image](./images/oda-with-oci-data-science-build-prompt.png "image") + +12. Add **Prompt Parameter Mock Value** and click **Generate Output**. This way we can validate LLM integration. + + ![image](./images/oda-with-oci-data-science-test-prompt-builder.png "image") + +### Task 6.8: Test the Prompt with the Skill Tester + +1. Click **Preview** to open the skill tester. + + ![The Preview button](https://docs.oracle.com/en/cloud/paas/digital-assistant/tutorial-llm-cohere/images/preview.png "image") + +2. Enter the following request: **Can you please give some overview on Oracle Database 23.4?**. + + The output should look like this: + + ![image](./images/oda-with-oci-data-science-conversation-tester-output-1.png "image") + +3. Ask next query to LLM: **latest oracle database**. + + The output should look like this: + + ![image](./images/oda-with-oci-data-science-conversation-tester-output-2.png "image") + +### Task 6.9: Set Up the Oracle Web User Channel + +We will create an Oracle Digital Assistant user channel that enables an Oracle web client to access skill. To ensure that only our web clients can use this channel, we will configure it to require client authentication. + +1. Open the Oracle Digital Assistant, navigate to **Development**, **Channels** and click **+Add Channel**. + +2. In **Create Channel**, enter the following information to create a POST operation to the provider's endpoint and click **Create**. + + - **Name:** A unique name that begins with a letter and contains only letters, numbers, periods, and underscores. For example, `OCI_MD_LLM`. + - **Description (Optional):** What the channel is used for. + - **Channel Type:** Select **Oracle Web**. + - **Allowed Domains:** Enter `*`. + - **Client Authentication Enabled:** De-select. + + ![image](./images/oda-with-oci-data-science-create-channel.png "image") + +3. Deselect **Client Authentication Enabled,** if not already disabled. + +4. In **Route**, select the skill that we want to use. We have selected current skill that is **LLM-MD-Skill**. + +5. Enable **Channel Enabled**. + +6. Note the **Channel Id** and **ODA Domain URI** without https, that are shown for this channel. + +We will use these values in our web app and the token generator's routing configuration. + +### Task 6.10: Install the SDK + +Download the zip and extract it to your local system. This zip includes a user guide that describes the SDK's classes and a sample app that demonstrates many of its features. + +1. Go to [Oracle Digital Assistant (ODA) and Oracle Mobile Cloud (OMC) Downloads](https://www.oracle.com/downloads/cloud/amce-downloads.html) and **Oracle Native Client SDKs (for OCI Native environments) Web SDK** section. + +2. Download [ODA Web SDK 24.06](https://www.oracle.com/downloads/cloud/amce-downloads.html). + +3. In **Platforms**, select **GENERIC**. + +4. Click to download latest ODA Js SDK that is `oda-native-client-sdk-js-24_06 for (GENERIC (All Platforms)`. + + ![image](./images/oda-with-oci-data-science-download-sdk.png "image") + +5. Extract the downloaded zip file. + +### Task 6.11: Test Oracle Web App + +1. Go to extracted zip folder of the downloaded Oracle web SDK. + +2. Open the `samples/web/settings.js` file and replace `` and `` with actual value. + + For example: + + - URI: `oda-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-dax.data.digitalassistant.oci.oraclecloud.com`. + - ChannelId: `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`. + +3. Also, make sure `isClientAuthEnabled` is false. + + ``` + let isClientAuthEnabled = false; + ``` + +4. Run the `samples/web/index.html` file on any browser. + +5. Ignore the index file contents. Click chat icon, it will show **Oracle Assistant CONNECTED** status. + + ![image](./images/oda-with-oci-data-science-web-sdk.png "image") + +6. This is how our website looks with chat icon in bottom-right corner. We can start a conversation, like we did earlier with the skill tester. + + ![image](./images/oda-with-oci-data-science-website-landing.png "image") + + ![image](./images/oda-with-oci-data-science-website-chatbot.png "image") + +### Task 6.12: Release on OCI Compute Instance + +1. Create OCI Compute instance. For more information, see [Creating an Instance](https://docs.oracle.com/en-us/iaas/Content/Compute/Tasks/launchinginstance.htm) + +2. Make sure you have following ingress rules. + + ![image](./images/oda-with-oci-data-science-ingress-rules.png "image") + +3. Copy all web folders to newly created instance. + +4. Install NGINX. For more information, see [Install the NGINX Web Server and Proxy on Oracle Linux](https://docs.oracle.com/en/learn/ol-nginx/index.html#background). + +5. Open a browser and navigate to `http:///`. If you have a self signed certificate then you can navigate to `https:///`. + +## Results + +Let us compare the outputs from directly asking the LLM vs using RAG with LLM: + +- **Response from LLM** + + ![image](./images/oda-with-oci-data-science-llm-output.png "image") + +- **Response from RAG** + + ![image](./images/oda-with-oci-data-science-website-chatbot.png "image") + +## Next Steps + +Building an advanced chatbot using Oracle Database 23ai, RAG, LangChain, Meta-Llama-3-8B-Instruct, and Oracle Digital Assistant showcases the power of integrating cutting-edge technologies to create a highly responsive and intelligent conversational agent. The detailed workflow, from request handling to response generation, ensures that the chatbot can efficiently retrieve and process vast amounts of information, delivering accurate and contextually relevant answers to users. By leveraging Oracle Database 23ai's vector search capabilities and the robust platform provided by Oracle Digital Assistant, developers can significantly enhance the chatbot's performance and user engagement. This integrated approach not only streamlines the development process but also results in a scalable, efficient, and highly effective AI solution that stands out in the competitive landscape of digital assistants. Whether for customer service, information retrieval, or interactive support, this advanced chatbot architecture paves the way for creating sophisticated conversational experiences that meet the demands of modern users. + +For more information on how to use AI Quick Actions, go to the Oracle Cloud Infrastructure Data Science [YouTube playlist](https://www.youtube.com/playlist?list=PLKCk3OyNwIzv6CWMhvqSB_8MLJIZdO80L) to see a demo video of AI Quick Actions, and find [our technical documentation](https://docs.oracle.com/en-us/iaas/data-science/using/ai-quick-actions.htm), and see our [Github repository](https://github.com/oracle-samples/oci-data-science-ai-samples/tree/main/ai-quick-actions) with tips and examples. + +If you want to suggest specific models to add to AI Quick Actions or have any questions, email to the OCI Data Science group: [ask-oci-data-science_grp@oracle.com](mailto:ask-oci-data-science_grp@oracle.com). + +## Related Links + +- [Configure the Oracle Web Channel](http://www.oracle.com/pls/topic/lookup?ctx=en/cloud/paas/digital-assistant&id=DACUA-GUID-33102578-2776-474D-AD48-9029D8EE6480) + +- [Configure Client Authentication](http://www.oracle.com/pls/topic/lookup?ctx=en/cloud/paas/digital-assistant&id=DACUA-GUID-672865F8-5883-461C-B6AD-47191EBC89DA) + +- [Customize the Chat Widget](https://docs.oracle.com/en/cloud/paas/digital-assistant/use-chatbot/customize-chat-widget.html#GUID-45FA259F-4558-4C0F-A3AD-0BB7586EA595) + +- Try [Oracle Cloud Free Trial](https://www.oracle.com/cloud/free/)! A 30-day trial with US$300 in free credits gives you access to Oracle Cloud Infrastructure Data Science service. For more information, see the following resources: + + - [OCI Data Science sample repository on Github](https://github.com/oracle-samples/oci-data-science-ai-samples/tree/main/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm). + + - [Oracle Data Science service](http://docs.oracle.com/iaas/data-science/using/data-science.htm). + +- [Using the Oracle Resource Manager to Configure Your Tenancy for Data Science](https://docs.oracle.com/en-us/iaas/data-science/using/orm-configure-tenancy.htm) + +- Star and clone our new [GitHub repo](https://github.com/oracle-samples/oci-data-science-ai-samples)! We included notebook tutorials and code samples. + +- Watch our tutorials on [YouTube](https://www.youtube.com/playlist?list=PLKCk3OyNwIzv6CWMhvqSB_8MLJIZdO80L) + +- Search for Oracle Data Science and try [LiveLabs](https://apexapps.oracle.com/pls/apex/dbpm/r/livelabs/livelabs-workshop-cards?session=108343633199478). + +- [Introducing AI Quick Actions in OCI Data Science](https://blogs.oracle.com/ai-and-datascience/post/ai-quick-actions-in-oci-data-science) + +- [Announcing Oracle Database 23ai : General Availability](https://blogs.oracle.com/database/post/oracle-23ai-now-generally-available) diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/Reranker Model Deployment.ipynb b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/Reranker Model Deployment.ipynb new file mode 100644 index 00000000..86a5153b --- /dev/null +++ b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/Reranker Model Deployment.ipynb @@ -0,0 +1,506 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "91005e56-2f67-4735-ad39-5c87f8bc07c0", + "metadata": {}, + "source": [ + "### OCI Data Science - Useful Tips\n", + "
\n", + "Check for Public Internet Access\n", + "\n", + "```python\n", + "import requests\n", + "response = requests.get(\"https://oracle.com\")\n", + "assert response.status_code==200, \"Internet connection failed\"\n", + "```\n", + "
\n", + "
\n", + "Helpful Documentation \n", + "\n", + "
\n", + "
\n", + "Typical Cell Imports and Settings for ADS\n", + "\n", + "```python\n", + "%load_ext autoreload\n", + "%autoreload 2\n", + "%matplotlib inline\n", + "\n", + "import warnings\n", + "warnings.filterwarnings('ignore')\n", + "\n", + "import logging\n", + "logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.ERROR)\n", + "\n", + "import ads\n", + "from ads.dataset.factory import DatasetFactory\n", + "from ads.automl.provider import OracleAutoMLProvider\n", + "from ads.automl.driver import AutoML\n", + "from ads.evaluations.evaluator import ADSEvaluator\n", + "from ads.common.data import ADSData\n", + "from ads.explanations.explainer import ADSExplainer\n", + "from ads.explanations.mlx_global_explainer import MLXGlobalExplainer\n", + "from ads.explanations.mlx_local_explainer import MLXLocalExplainer\n", + "from ads.catalog.model import ModelCatalog\n", + "from ads.common.model_artifact import ModelArtifact\n", + "```\n", + "
\n", + "
\n", + "Useful Environment Variables\n", + "\n", + "```python\n", + "import os\n", + "print(os.environ[\"NB_SESSION_COMPARTMENT_OCID\"])\n", + "print(os.environ[\"PROJECT_OCID\"])\n", + "print(os.environ[\"USER_OCID\"])\n", + "print(os.environ[\"TENANCY_OCID\"])\n", + "print(os.environ[\"NB_REGION\"])\n", + "```\n", + "
" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "7dea81ca-5e84-4aca-9535-8f7b48b7f425", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "import ads\n", + "from FlagEmbedding import FlagReranker\n", + "\n", + "# to save in the Model Catalog\n", + "from ads.model.generic_model import GenericModel\n", + "from ads.model.model_metadata import MetadataCustomCategory\n", + "from config import CONDA_PACK_PATH, LOG_GROUP_ID, RERANKER_MODEL_ACCESS_LOG_LOG_ID, RERANKER_MODEL_PREDICT_LOG_LOG_ID \n", + "ads.set_auth(\"resource_principal\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "03c14f76-83f4-4857-aac3-c8b3df2a24a6", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "#\n", + "# This custom class wrap the reranker model\n", + "#\n", + "class Reranker:\n", + " def __init__(self, model_id):\n", + " self.model_id = model_id\n", + " self.reranker = FlagReranker(self.model_id, use_fp16=True)\n", + "\n", + " def predict(self, x):\n", + " # x is expected as a list of list of str\n", + " # [[\"x1\", \"x2\"]] -> y = [score12]\n", + " scores = self.reranker.compute_score(x)\n", + "\n", + " return scores" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "id": "c72529ec-4422-4208-be4e-ff29dd421f81", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "reranker_model = Reranker(model_id=\"BAAI/bge-reranker-large\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "b712fb07-a17a-4d6c-bbe5-c23844bb0cd3", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[-0.39466628432273865, 3.8437271118164062]" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "reranker_payload = [\n", + " [\"what is panda?\", \"It is an animal living in China. In the future model input will be serialized by.In the future model input will be serialized by.In the future model input will be serialized by\"],\n", + " [\"what is panda?\", \"The giant panda is a bear species endemic to China.In the future model input will be serialized by.In the future model input will be serialized by.In the future model input will be serialized by.In the future model input will be serialized by\"],\n", + "]\n", + "\n", + "reranker_model.predict(reranker_payload)" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "2e54b3f3-05e4-4b8f-9e6a-d0012c5f4821", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "WARNING:ads.common:In the future model input will be serialized by `cloudpickle` by default. Currently, model input are serialized into a dictionary containing serialized input data and original data type information.Set `model_input_serializer=\"cloudpickle\"` to use cloudpickle model input serializer.\n" + ] + } + ], + "source": [ + "reranker_generic_model = GenericModel(estimator=reranker_model, artifact_dir=\"./reranker_model_artifact\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "id": "aec37da3-3ffa-47c3-ae8a-c2c645af799b", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
Actions Needed
StepStatusDetails
initiateDoneInitiated the model
prepare()AvailableGenerated runtime.yaml
Generated score.py
Serialized model
Populated metadata(Custom, Taxonomy and Provenance)
verify()Not AvailableLocal tested .predict from score.py
save()Not AvailableConducted Introspect Test
Uploaded artifact to model catalog
deploy()UNKNOWNDeployed the model
predict()Not AvailableCalled deployment predict endpoint
\n", + "
" + ], + "text/plain": [ + " Actions Needed\n", + "Step Status Details \n", + "initiate Done Initiated the model \n", + "prepare() Available Generated runtime.yaml \n", + " Generated score.py \n", + " Serialized model \n", + " Populated metadata(Custom, Taxonomy and Provenance) \n", + "verify() Not Available Local tested .predict from score.py \n", + "save() Not Available Conducted Introspect Test \n", + " Uploaded artifact to model catalog \n", + "deploy() UNKNOWN Deployed the model \n", + "predict() Not Available Called deployment predict endpoint " + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "reranker_generic_model.summary_status()\n" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "id": "96beaf82-1f3b-4fd1-81a5-bb3abce4e829", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "WARNING:root: ?, ?it/s]\n", + "WARNING:root:Failed to retrieve the full conda pack path from slug. Pass conda pack path 'oci://@/' instead of slug.\n" + ] + }, + { + "data": { + "text/plain": [ + "algorithm: null\n", + "artifact_dir:\n", + " /home/datascience/reranker_model_artifact:\n", + " - - reranker.pkl\n", + " - runtime.yaml\n", + " - score.py\n", + " - .model-ignore\n", + "framework: null\n", + "model_deployment_id: null\n", + "model_id: null" + ] + }, + "execution_count": 21, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "reranker_generic_model.prepare(\n", + " reload=False,\n", + " inference_conda_env=CONDA_PACK_PATH,\n", + " inference_python_version=\"3.9\",\n", + " model_file_name=\"reranker.pkl\",\n", + " force_overwrite=True\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "id": "dfce6d23-a322-4e65-acb3-64db6905dcd3", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Start loading reranker.pkl from model directory /home/datascience/reranker_model_artifact ...\n", + "Model is successfully loaded.\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "loop1: 0%| | 0/7 [00:00@/reranker/ocid1.datasciencemodel.oc1.eu-frankfurt-1..zip.\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "33a1d994775e4816b2a14b016a684211", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "loop1: 0%| | 0/3 [00:00'" + ] + }, + "execution_count": 22, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#Create reranker_bucket manually before executing below snippet\n", + "\n", + "reranker_generic_model.save(\n", + " display_name=\"reranker2-baai-large\",\n", + " bucket_uri=\"oci://@/reranker/\",\n", + " ignore_introspection=True\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "id": "7c3cec4d-8455-41b6-954e-7c81e9134a6c", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "loop1: 0%| | 0/6 [00:00@/rag-oracle23db-poc_v3/gpu/PyTorch 2.0 for GPU on Python 3.9/2.0/pytorch20_p39_gpu_v2" + +LOG_GROUP_ID="ocid1.loggroup.oc1." + +#Embedding model +EMBEDDING_MODEL_ACCESS_LOG_LOG_ID="ocid1.log.oc1." +EMBEDDING_MODEL_PREDICT_LOG_LOG_ID="ocid1.log.oc1." + +#Reranker model +RERANKER_MODEL_ACCESS_LOG_LOG_ID="ocid1.log.oc1." +RERANKER_MODEL_PREDICT_LOG_LOG_ID="ocid1.log.oc1." + +#Langchain Model +COMMAND_MD_ENDPOINT = 'https://modeldeployment.eu-frankfurt-1.oci.customer-oci.com/ocid1.datasciencemodeldeployment.oc1./predict' +EMBEDDING_MD_ENDPOINT = 'https://modeldeployment.eu-frankfurt-1.oci.customer-oci.com/ocid1.datasciencemodeldeployment.oc1./predict' +RERANKER_MD_ENDPOINT = 'https://modeldeployment.eu-frankfurt-1.oci.customer-oci.com/ocid1.datasciencemodeldeployment.oc1./predict' +LANGCHAIN_MODEL_ACCESS_LOG_LOG_ID="ocid1.log.oc1." +LANGCHAIN_MODEL_PREDICT_LOG_LOG_ID="ocid1.log.oc1." diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/config_private.py b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/config_private.py new file mode 100644 index 00000000..571af72a --- /dev/null +++ b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/config_private.py @@ -0,0 +1,4 @@ +DB_USER = "" +DB_PWD = "" +DB_HOST_IP = "" +DB_SERVICE = "FREEPDB1" \ No newline at end of file diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/create_save_embeddings.py b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/create_save_embeddings.py new file mode 100644 index 00000000..fdac571a --- /dev/null +++ b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/create_save_embeddings.py @@ -0,0 +1,284 @@ +import logging +import re +from typing import List + +# to generate id from text +import hashlib + +from tqdm import tqdm + +from llama_index.core import SimpleDirectoryReader +from llama_index.core.node_parser import SentenceSplitter + +import oracledb + +from oracle_vector_db import save_embeddings_in_db + +# this way we don't show & share +from config_private import ( + DB_USER, + DB_PWD, + DB_SERVICE, + DB_HOST_IP +) + +# +# Configs +# +from config import ( + INPUT_FILES, + ID_GEN_METHOD, + ENABLE_CHUNKING, + MAX_CHUNK_SIZE, + CHUNK_OVERLAP, +) + +# to create embeddings in batch +BATCH_SIZE = 40 + +# +# Functions +# + + +def generate_id(nodes_list: List): + """ + get a list of nodes (pages, chunks) and generate the id + + return: list of id + """ + if ID_GEN_METHOD == "LLINDEX": + nodes_ids = [doc.id_ for doc in nodes_list] + # this way generated hashing the page + if ID_GEN_METHOD == "HASH": + logging.info("Hashing to compute id...") + nodes_ids = [] + for doc in tqdm(nodes_list): + encoded_text = doc.text.encode() + hash_object = hashlib.sha256(encoded_text) + hash_hex = hash_object.hexdigest() + nodes_ids.append(hash_hex) + + return nodes_ids + + +def read_and_split_in_pages(input_files): + """ + read the content of a set of pdf files and split in chunks + """ + pages = SimpleDirectoryReader(input_files=input_files).load_data() + + logging.info(f"Read total {len(pages)} pages...") + + # preprocess text + for doc in pages: + doc.text = preprocess_text(doc.text) + + # remove pages with num words < threshold + pages = remove_short_pages(pages, threshold=10) + + # create a list of text (these are the chuncks to be embedded and saved) + pages_text = [doc.text for doc in pages] + + # 23/12 register the num of the page + # must be a string + pages_num = [doc.metadata["page_label"] for doc in pages] + + # extract list of id + # this way id have been generated by llama-index + # 08/01/2024 refactored + pages_id = generate_id(pages) + + return pages_text, pages_id, pages_num + + +# in case chunking is enabled +def read_and_split_in_chunks(input_files): + """ + read a set of pdf files and split in chunks + """ + node_parser = SentenceSplitter( + chunk_size=MAX_CHUNK_SIZE, chunk_overlap=CHUNK_OVERLAP + ) + + pages = SimpleDirectoryReader(input_files=input_files).load_data() + + logging.info(f"Read total {len(pages)} pages...") + + # preprocess text + for doc in pages: + doc.text = preprocess_text(doc.text) + + # remove pages with num words < threshold + pages = remove_short_pages(pages, threshold=10) + + # splits in chunks + nodes = node_parser.get_nodes_from_documents(pages, show_progress=True) + + # create a list of text (these are the chuncks to be embedded and saved) + nodes_text = [doc.text for doc in nodes] + + # 23/12 register the num of the page + # must be a string + pages_num = [doc.metadata["page_label"] for doc in nodes] + + nodes_id = generate_id(nodes) + + return nodes_text, nodes_id, pages_num + + +# some simple text preprocessing +def preprocess_text(text): + """ + adds some preprocessing, to be customized ! + """ + text = text.replace("\t", " ") + text = text.replace(" -\n", "") + text = text.replace("-\n", "") + text = text.replace("\n", " ") + + # remove repeated blanks + text = re.sub(r"\s+", " ", text) + + return text + + +# remove pages with num words < threshold +def remove_short_pages(pages, threshold): + """ + remove pages with < threshold chars + """ + n_removed = 0 + for pag in pages: + if len(pag.text.split(" ")) < threshold: + pages.remove(pag) + n_removed += 1 + + logging.info(f"Removed {n_removed} short pages...") + + return pages + + +def check_tokenization_length(tokenizer, batch): + """ + Check that the number of token dosn't exceed a threshold + It is an hard check (fails) + """ + for text in tqdm(batch): + assert len(tokenizer.encode(text)) <= MAX_CHUNK_SIZE + logging.info("Tokenization OK...") + + +# take the list of txts and return a list of embeddings vector +def compute_embeddings(embed_model, nodes_text): + """ + compute embeddings in batch + """ + embeddings = [] + for i in tqdm(range(0, len(nodes_text), BATCH_SIZE)): + batch = nodes_text[i : i + BATCH_SIZE] + + # here we compute embeddings for a batch + #embeddings_batch = embed_model.embed_documents(batch) + #print("Model payload:") + #print([batch]) + + for batch_temp in batch: + op=embed_model.verify(batch_temp) + #print(op['embeddings']); + # add to the final list + embeddings.extend(op['embeddings']) + + return embeddings + + +# this function is called once for each book +# and saves in DB all the pages of the book + embeddings +def save_chunks_in_db(pages_text, pages_id, pages_num, book_id, connection): + tot_errors = 0 + + with connection.cursor() as cursor: + logging.info("Saving texts to DB...") + cursor.setinputsizes(None, oracledb.DB_TYPE_CLOB) + + for id, text, page_num in zip(tqdm(pages_id), pages_text, pages_num): + try: + cursor.execute( + "insert into CHUNKS (ID, CHUNK, PAGE_NUM, DOCUMENTS_ID) values (:1, :2, :3, :4)", + [id, text, page_num, book_id], + ) + except Exception as e: + logging.error("Error in save chunks...") + logging.error(e) + tot_errors += 1 + + logging.info(f"Tot. errors in save_chunks: {tot_errors}") + + +# with this function every book added to DB is registered with a unique id +def register_document(book_name, connection): + with connection.cursor() as cursor: + # get the new key + cursor.execute("SELECT MAX(ID) FROM DOCUMENTS") + + # Fetch the result + row = cursor.fetchone() + + if row[0] is not None: + new_key = row[0] + 1 + else: + new_key = 1 + + # insert the record for the book + with connection.cursor() as cursor: + query = "INSERT INTO DOCUMENTS (ID, NAME) VALUES (:1, :2)" + + # Execute the query with your values + cursor.execute(query, [new_key, book_name]) + + return new_key + +def load_documents(embedding_model): + # connect to db + # Configure logging + logging.basicConfig( + level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s" + ) + logging.info("Connecting to Oracle DB...") + + DSN = f"{DB_HOST_IP}/{DB_SERVICE}" + + with oracledb.connect(user=DB_USER, password=DB_PWD, dsn=DSN) as connection: + logging.info("Successfully connected to Oracle Database...") + + num_pages = [] + for book in INPUT_FILES: + logging.info(f"Processing book: {book}...") + + if ENABLE_CHUNKING is False: + # chunks are pages + logging.info("Chunks are pages of the book...") + nodes_text, nodes_id, pages_num = read_and_split_in_pages([book]) + num_pages.append(len(nodes_text)) + else: + logging.info(f"Enabled chunking, chunck_size: {MAX_CHUNK_SIZE}...") + nodes_text, nodes_id, pages_num = read_and_split_in_chunks([book]) + + # create embeddings + # process in batch (max 96 for batch, chosen BATCH_SIZE, see above) + logging.info("Computing embeddings...") + embeddings = compute_embeddings(embedding_model, nodes_text) + + # determine book_id and save in table BOOKS + logging.info("Registering document...") + book_id = register_document(book, connection) + + # store embeddings + # here we save in DB + save_embeddings_in_db(embeddings, nodes_id, connection) + + # store text chunks (pages for now) + save_chunks_in_db(nodes_text, nodes_id, pages_num, book_id, connection) + + # a txn is a book + connection.commit() \ No newline at end of file diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/create_tables.sql b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/create_tables.sql new file mode 100644 index 00000000..156ade67 --- /dev/null +++ b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/create_tables.sql @@ -0,0 +1,39 @@ +create table DOCUMENTS +("ID" NUMBER NOT NULL, +"NAME" VARCHAR2(100) NOT NULL, +PRIMARY KEY ("ID") +); + +create table CHUNKS +(ID VARCHAR2(64) NOT NULL, +CHUNK CLOB, +PAGE_NUM VARCHAR2(10), +DOCUMENTS_ID NUMBER, +PRIMARY KEY ("ID"), +CONSTRAINT fk_book + FOREIGN KEY (DOCUMENTS_ID) + REFERENCES DOCUMENTS (ID) +); + +create table VECTORS +("ID" VARCHAR2(64) NOT NULL, +"VEC" VECTOR(768, FLOAT64), +PRIMARY KEY ("ID") +); + +create table Partner(ID NUMBER NOT NULL, +NAME VARCHAR2(100) NOT NULL, +Region VARCHAR2(100) NOT NULL, +Category VARCHAR2(100) NOT NULL, +Partner_since DATE NOT NULL, +Last_renewal DATE NOT NULL, +Licensed DATE NOT NULL, +Oracle_Products VARCHAR2(100) NOT NULL, +Nominated VARCHAR2(100) NOT NULL, +Nomination_date DATE, +Past_Awards_years_comma_seperated_list VARCHAR2(100), +Customer_satisfaction_rating NUMBER NOT NULL, +Number_of_customers NUMBER NOT NULL, +Oracle_contact_email VARCHAR2(100) NOT NULL, +PRIMARY KEY (ID) +); diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/score.py b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/embedding_model_score.py similarity index 94% rename from LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/score.py rename to LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/embedding_model_score.py index fdb3ece8..59f8b0f5 100644 --- a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-llm/images/score.py +++ b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/embedding_model_score.py @@ -1,9 +1,5 @@ # score.py 1.0 generated by ADS 2.8.9 on 20231213_231428 -import json import os -import cloudpickle -import pandas as pd -import numpy as np from functools import lru_cache import onnxruntime as rt @@ -49,8 +45,6 @@ def pre_inference(data): """ from transformers import BertTokenizer - print('################') - print(data) model_dir = os.path.dirname(os.path.realpath(__file__)) tokenizer = BertTokenizer.from_pretrained(model_dir) @@ -91,8 +85,6 @@ def predict(data, model=load_model()): Format: {'prediction': output from model.predict method} """ - print("aa") - print(data) onnx_transformed_input= pre_inference(data) embeds= model.run(None, dict(onnx_transformed_input))[0] diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-add-state.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-add-state.png new file mode 100644 index 00000000..64d2adc9 Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-add-state.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-build-prompt.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-build-prompt.png new file mode 100644 index 00000000..dc0eb497 Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-build-prompt.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-component-edit.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-component-edit.png new file mode 100644 index 00000000..f600ee35 Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-component-edit.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-component-editor.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-component-editor.png new file mode 100644 index 00000000..f92a0cfb Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-component-editor.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-component-page.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-component-page.png new file mode 100644 index 00000000..1d9bcaa3 Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-component-page.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-component-status.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-component-status.png new file mode 100644 index 00000000..ba789884 Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-component-status.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-conversation-tester-output-1.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-conversation-tester-output-1.png new file mode 100644 index 00000000..4c4858ea Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-conversation-tester-output-1.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-conversation-tester-output-2.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-conversation-tester-output-2.png new file mode 100644 index 00000000..670a8288 Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-conversation-tester-output-2.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-create-channel.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-create-channel.png new file mode 100644 index 00000000..083844c7 Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-create-channel.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-create-llm-service.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-create-llm-service.png new file mode 100644 index 00000000..9f644333 Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-create-llm-service.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-create-policy.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-create-policy.png new file mode 100644 index 00000000..e1334f79 Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-create-policy.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-create-service.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-create-service.png new file mode 100644 index 00000000..323295f5 Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-create-service.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-create-skill.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-create-skill.png new file mode 100644 index 00000000..1c5e9f5d Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-create-skill.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-deployments-action.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-deployments-action.png new file mode 100644 index 00000000..e2a8aba8 Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-deployments-action.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-dialog-flow.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-dialog-flow.png new file mode 100644 index 00000000..c9d22d81 Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-dialog-flow.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-download-sdk.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-download-sdk.png new file mode 100644 index 00000000..2df097d2 Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-download-sdk.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-event-handler.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-event-handler.png new file mode 100644 index 00000000..ce21836e Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-event-handler.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-high-level-architecture.jpeg b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-high-level-architecture.jpeg new file mode 100644 index 00000000..27dc4a72 Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-high-level-architecture.jpeg differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-ingress-rules.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-ingress-rules.png new file mode 100644 index 00000000..09e4b303 Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-ingress-rules.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-invoke-llm.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-invoke-llm.png new file mode 100644 index 00000000..a6ffcd12 Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-invoke-llm.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-llm-output.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-llm-output.png new file mode 100644 index 00000000..a4cde375 Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-llm-output.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-llm-service.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-llm-service.png new file mode 100644 index 00000000..2b009dca Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-llm-service.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-md-endpoint.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-md-endpoint.png new file mode 100644 index 00000000..95fbbf23 Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-md-endpoint.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-model-deploy.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-model-deploy.png new file mode 100644 index 00000000..ebcbf784 Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-model-deploy.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-model-explorer.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-model-explorer.png new file mode 100644 index 00000000..1127246d Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-model-explorer.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-oda-output.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-oda-output.png new file mode 100644 index 00000000..b9516ece Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-oda-output.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-oracle-database-23ai.jpg b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-oracle-database-23ai.jpg new file mode 100644 index 00000000..8e078ecb Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-oracle-database-23ai.jpg differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-prompt-input.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-prompt-input.png new file mode 100644 index 00000000..fdd90e5a Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-prompt-input.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-register-model.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-register-model.png new file mode 100644 index 00000000..51b7b502 Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-register-model.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-service-enabled.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-service-enabled.png new file mode 100644 index 00000000..620e0b8e Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-service-enabled.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-set-llm-service.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-set-llm-service.png new file mode 100644 index 00000000..453e65a0 Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-set-llm-service.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-switches.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-switches.png new file mode 100644 index 00000000..04b59305 Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-switches.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-test-llm-service.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-test-llm-service.png new file mode 100644 index 00000000..ec860118 Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-test-llm-service.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-test-prompt-builder.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-test-prompt-builder.png new file mode 100644 index 00000000..b596bfc3 Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-test-prompt-builder.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-unresolved-intent-actions.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-unresolved-intent-actions.png new file mode 100644 index 00000000..d2fafa75 Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-unresolved-intent-actions.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-use-streaming.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-use-streaming.png new file mode 100644 index 00000000..a73bf4ec Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-use-streaming.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-web-sdk.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-web-sdk.png new file mode 100644 index 00000000..f2db8da1 Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-web-sdk.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-website-chatbot.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-website-chatbot.png new file mode 100644 index 00000000..adb5f909 Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-website-chatbot.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-website-landing.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-website-landing.png new file mode 100644 index 00000000..3f503848 Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/images/oda-with-oci-data-science-website-landing.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/langchain_nl2sql_model_score.py b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/langchain_nl2sql_model_score.py new file mode 100644 index 00000000..3c0d83ed --- /dev/null +++ b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/langchain_nl2sql_model_score.py @@ -0,0 +1,211 @@ +import json +import oci +import requests + +from langchain_community.llms import OCIModelDeploymentVLLM +import ads +from oracle_vector_db import oracle_query, oracle_query +from ads.model.generic_model import GenericModel +import ads +from oracle_vector_db import oracle_query, oracle_query +from langchain.chains import RetrievalQA +from typing import List +from langchain_core.callbacks import CallbackManagerForRetrieverRun +from langchain_core.documents import Document +from langchain_core.retrievers import BaseRetriever +from oracle_vector_db import oracle_query, oracle_query +from config import COMMAND_MD_ENDPOINT, EMBEDDING_MD_ENDPOINT, RERANKER_MD_ENDPOINT, TOP_K +from pprint import pprint + +nl2sql_prompt_template = """ Given an input Question, create a syntactically correct Oracle SQL query to run. +Pay attention to using only the column names that you can see in the schema description. +Be careful to not query for columns that do not exist. Also, pay attention to which column is in which table. +Please double check that the SQL query you generate is valid for Oracle Database. +DO NOT use alias in the SELECT clauses. +Only use the tables listed below. + +create table Partner(ID NUMBER NOT NULL, +NAME VARCHAR2(100) NOT NULL, +Region VARCHAR2(100) NOT NULL, +Category VARCHAR2(100) NOT NULL, +Partner_since DATE NOT NULL, +Last_renewal DATE NOT NULL, +Licensed DATE NOT NULL, +Oracle_Products VARCHAR2(100) NOT NULL, +Nominated VARCHAR2(100) NOT NULL, +Nomination_date DATE NOT NULL, +Past_Awards_years_comma_seperated_list VARCHAR2(100) NOT NULL, +Customer_satisfaction_rating NUMBER NOT NULL, +Number_of_customers NUMBER NOT NULL, +Oracle_contact_email VARCHAR2(100) NOT NULL, +PRIMARY KEY (ID) +); + +### Context: +{context} + +### In-Context Examples: +Question: list or view partners who renewal last year +Oracle SQL: SELECT * FROM Partner WHERE EXTRACT(YEAR FROM Last_renewal) = EXTRACT(YEAR FROM SYSDATE – INTERVAL ‘1’ YEAR) + +Instructions: +- Do not use JOIN since the Schema only includes 1 table, unless striclt required. +- Do not use UNION since the Schema only includes 1 table. +- If all columns are required, give the (*) notation. +- Make sure to include all WHERE filtering conditions even there are more conditions than in-context examples. +- Use the best query description which matches the query. +- You should NEVER generate SQL queries with JOIN, since the Schema only includes 1 table. +- Use Context section to get additional details while bulding the query +- Do not return multiple queries in response. Just respond with single SQL query and nothing else +- Return only single query and append response between backtick character +- For date column use TO_DATE function in where clause. e.g. Nomination_date > TO_DATE('2001-01-01', 'YYYY-MM-DD'); + +Question: {question} +Oracle SQL: """ + +relational_data_summary_prompt_template = """In the context section, we provide a question and its corresponding answer. The answer contains a list of rows fetched from a database, where the first row is the column headers, and the subsequent rows are the data. +Your task is to summarize the answer in a single, human-understandable sentence. If there is data in the context section, assume it is correct and summarize it directly without evaluating its content. +Do not assume there is only one result unless specified. + +### Context: +Question: {question} +Ans: +{context_data} + +Can you please summarize the answer based on the data provided in the context? Your summary should be a single, concise sentence. + +Summary: +""" + +import json +import oci +import requests + +from langchain_community.llms import OCIModelDeploymentVLLM +import ads +from oracle_vector_db import oracle_query, oracle_query +from ads.model.generic_model import GenericModel +import ads +from oracle_vector_db import oracle_query, oracle_query +from langchain.chains import RetrievalQA +from typing import List +from langchain_core.callbacks import CallbackManagerForRetrieverRun +from langchain_core.documents import Document +from langchain_core.retrievers import BaseRetriever +from oracle_vector_db import oracle_query, oracle_query +from config import COMMAND_MD_ENDPOINT, EMBEDDING_MD_ENDPOINT, RERANKER_MD_ENDPOINT, TOP_K +from pprint import pprint +from langchain import PromptTemplate +from config_private import DB_USER, DB_PWD, DB_HOST_IP, DB_SERVICE +import oracledb +import re + +ads.set_auth("resource_principal") +command_md = OCIModelDeploymentVLLM( + endpoint= COMMAND_MD_ENDPOINT, + model="odsc-llm" +) +model_name = f"" + + +class CustomRetriever(BaseRetriever): + def _get_relevant_documents( + self, query: str, *, run_manager: CallbackManagerForRetrieverRun + ) -> List[Document]: + matching_documents = [] + + #Embedding model + rps = oci.auth.signers.get_resource_principals_signer() + print(f"###Query {query}") + prediction = requests.post(EMBEDDING_MD_ENDPOINT, data=f'["{query}"]', auth=rps) + + #Search in DB + q_result = oracle_query(prediction.json()['embeddings'][0], TOP_K, True, False) + text_list = [] + for n, id, sim in zip(q_result.nodes, q_result.ids, q_result.similarities): + text_list.append(n.text) + paired_list = [[query, text] for text in text_list] + + #print(f'Reranker payload: {paired_list}') + #ReRanker model + reranker_results = requests.post(RERANKER_MD_ENDPOINT, data=json.dumps(paired_list), auth=rps) # make a prediction request + max_value = max(reranker_results.json()['prediction']) + print(f"###Reranker Result Max value: {max_value}") + + if max_value < -13: + return matching_documents; + # Find the index of the maximum value + max_index = reranker_results.json()['prediction'].index(max_value) + #print(f"The maximum value is: {max_value}") + #print(f"The index of the maximum value is: {max_index}") + doc = Document(page_content=paired_list[max_index][1], metadata={"source": "local"}) + #print(f"###Contextttt: {doc}") + matching_documents.append(doc) + return matching_documents + + +def load_model(model_file_name=model_name): + if not model_file_name: + raise ValueError('model_file_name cannot be None') + + # This is the default implementation of the load_model() specific to this score.py template only. + if model_file_name == "": + return "default_model" + +def get_data_from_DB(query): + DSN = f"{DB_HOST_IP}/{DB_SERVICE}" + connection = oracledb.connect(user=DB_USER, password=DB_PWD, dsn=DSN, config_dir="/opt/oracle/config") + # Creating a cursor object + cursor = connection.cursor() + + # Executing the query + cursor.execute(query) + # Fetching the column names + column_names = [desc[0] for desc in cursor.description] + result = ','.join(column_names) + '\n' + + # Fetching and printing the results + for row in cursor: + row_values = [str(value).replace(',', ' ') for value in row] + result += ','.join(row_values) + '\n' + print(f"Query Result: {result}") + # Closing the cursor and connection + cursor.close() + connection.close() + return result; + +def predict(data, model=load_model()): + print(str) + ads.set_auth("resource_principal") + + prompt_template = PromptTemplate(template=nl2sql_prompt_template, input_variables=['question']) + customRetriever = CustomRetriever() + chain = RetrievalQA.from_chain_type( + llm=command_md, + chain_type="stuff", + chain_type_kwargs={"prompt": prompt_template}, + retriever=customRetriever +) + chain.combine_documents_chain.llm_chain.llm.auth['signer'].refresh_security_token() + + res = chain(data) + print(f"Output: {res['result']}") + op= res['result'] + if 'Question' in op: + query_str = op.split("Question:")[0] + else: + query_str = op + + match = re.search(r'`([^`]*)`', op) + if match: + query_str = match.group(1) + else: + query_str = match + + query = query_str.replace(';', '') + result = get_data_from_DB(query) + + relational_data_summary_prompt = relational_data_summary_prompt_template.format(question=data, context_data=result) + op=command_md.predict(relational_data_summary_prompt) + print(f"Final Output: {op}") + return {'prediction':op} diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oci_utils.py b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oci_utils.py new file mode 100644 index 00000000..736ea51d --- /dev/null +++ b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oci_utils.py @@ -0,0 +1,94 @@ +""" +File name: oci_utils.py +Author: Luigi Saetta +Date created: 2023-12-17 +Date last modified: 2024-03-16 +Python Version: 3.11 + +Description: + This module provides some utilities + +Usage: + Import this module into other scripts to use its functions. + Example: + ... + +License: + This code is released under the MIT License. + +Notes: + This is a part of a set of demo showing how to use Oracle Vector DB, + OCI GenAI service, Oracle GenAI Embeddings, to buil a RAG solution, + where all he data (text + embeddings) are stored in Oracle DB 23c + +Warnings: + This module is in development, may change in future versions. +""" + +import logging +import oci + +from config import ( + TOP_K, + ADD_PHX_TRACING, +) + +logger = logging.getLogger("ConsoleLogger") + + +def load_oci_config(): + """ + todo + """ + # read OCI config to connect to OCI with API key + + # are you using default profile? + oci_config = oci.config.from_file("~/.oci/config", "DEFAULT") + + return oci_config + + +def print_configuration(): + """ + todo + """ + logger.info("------------------------") + logger.info("Configuration used:") + logger.info(" Using Oracle AI Vector Search...") + + logger.info(" Retrieval parameters:") + logger.info(" TOP_K: %s", TOP_K) + + if ADD_PHX_TRACING: + logger.info(" Enabled observability with Phoenix tracing...") + + logger.info("------------------------") + logger.info("") + + +def pretty_print_docs(docs): + """ + todo + """ + print( + f"\n{'-' * 100}\n".join( + [f"Document {i+1}:\n\n" + d.page_content for i, d in enumerate(docs)] + ) + ) + + +def format_docs(docs): + """ + todo + """ + return "\n\n".join(doc.page_content for doc in docs) + + +def check_value_in_list(value, values_list): + """ + to check that we don't enter a not supported value + """ + if value not in values_list: + raise ValueError( + f"Value {value} is not valid: value must be in list {values_list}" + ) diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-transform-payload.js b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-transform-payload.js new file mode 100644 index 00000000..35b94406 --- /dev/null +++ b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-transform-payload.js @@ -0,0 +1,61 @@ +'use strict'; + +// Documentation for writing LLM Transformation handlers: https://github.com/oracle/bots-node-sdk/blob/master/LLM_TRANSFORMATION_HANDLER.md + +// You can use your favorite http client package to make REST calls, however, the node fetch API is pre-installed with the bots-node-sdk. +// Documentation can be found at https://www.npmjs.com/package/node-fetch +// Un-comment the next line if you want to make REST calls using node-fetch. +// const fetch = require("node-fetch"); + +module.exports = { + metadata: { + name: 'oci_md_handler', + eventHandlerType: 'LlmTransformation' + }, + handlers: { + + /** + * Handler to transform the request payload + * @param {TransformPayloadEvent} event - event object contains the following properties: + * - payload: the request payload object + * @param {LlmTransformationContext} context - see https://oracle.github.io/bots-node-sdk/LlmTransformationContext.html + * @returns {object} the transformed request payload + */ + transformRequestPayload: async (event, context) => { + return { "query": event.payload.messages[event.payload.messages.length - 1].content }; + }, + + /** + * Handler to transform the response payload + * @param {TransformPayloadEvent} event - event object contains the following properties: + * - payload: the response payload object + * @param {LlmTransformationContext} context - see https://oracle.github.io/bots-node-sdk/LlmTransformationContext.html + * @returns {object} the transformed response payload + */ + transformResponsePayload: async (event, context) => { + return { candidates: [{ "content": event.payload.prediction || "" }]}; + }, + + /** + * Handler to transform the error response payload, invoked when HTTP status code is 400 or higher and the error + * response body received is a JSON object + * @param {TransformPayloadEvent} event - event object contains the following properties: + * - payload: the error response payload object + * @param {LlmTransformationContext} context - see https://oracle.github.io/bots-node-sdk/LlmTransformationContext.html + * @returns {object} the transformed error response payload + */ + transformErrorResponsePayload: async (event, context) => { + let errorCode = 'unknown'; + if (event.payload.error) { + if ( 'context_length_exceeded' === event.payload.error.code) { + errorCode = 'modelLengthExceeded'; } + else if ('content_filter' === event.payload.error.code) { + errorCode = 'flagged'; + } + return {"errorCode" : errorCode, "errorMessage": event.payload.error.message}; + } + return {"errorCode" : errorCode, "errorMessage": JSON.stringify(event.payload)}; + + } + } +}; diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-web/images/Logo.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-web/images/Logo.png new file mode 100644 index 00000000..7ce520ea Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-web/images/Logo.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-web/images/ODA_Banner_Image.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-web/images/ODA_Banner_Image.png new file mode 100644 index 00000000..eff9edda Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-web/images/ODA_Banner_Image.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-web/images/Powered_by_Oracle_Content.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-web/images/Powered_by_Oracle_Content.png new file mode 100644 index 00000000..6b5d46c9 Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-web/images/Powered_by_Oracle_Content.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-web/images/botButtonIcon.gif b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-web/images/botButtonIcon.gif new file mode 100644 index 00000000..f8704bf2 Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-web/images/botButtonIcon.gif differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-web/images/botIcon.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-web/images/botIcon.png new file mode 100644 index 00000000..9e7763d5 Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-web/images/botIcon.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-web/images/favicon.ico b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-web/images/favicon.ico new file mode 100644 index 00000000..1c104571 Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-web/images/favicon.ico differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-web/images/high-level-overview.jpg b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-web/images/high-level-overview.jpg new file mode 100644 index 00000000..8d67ec23 Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-web/images/high-level-overview.jpg differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-web/images/logoIcon.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-web/images/logoIcon.png new file mode 100644 index 00000000..90a834b9 Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-web/images/logoIcon.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-web/images/personIcon.png b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-web/images/personIcon.png new file mode 100644 index 00000000..076e5ebc Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-web/images/personIcon.png differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-web/index.html b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-web/index.html new file mode 100644 index 00000000..199990b1 --- /dev/null +++ b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-web/index.html @@ -0,0 +1,67 @@ + + + + + + Demo: Enterprise chatbot with Oracle Digital Assistant, OCI Data Science, LangChain & Oracle Database 23AI + + + + + + + + + + + + + + + +
+ +
+ Banner +
+
+
+
+
+ Introduction +
+
+
+
+

+ In today's digital landscape, chatbots are evolving to become more intelligent, responsive, and capable of handling complex interactions. In this demo, we showcase a smart chatbot using Retrieval-Augmented Generation (RAG) from both a document repository and from the Enterprise database, powered by Oracle Data Science's AI Quick Actions and Model Deployment, Mistral-7B-Instruct-v0.2, Oracle Database 23AI, LangChain, and Oracle Digital Assistant as the client application. Each of these technologies enables us to build a chatbot that not only understands and responds to user queries with remarkable accuracy but also offers a seamless and engaging conversational experience. +

+

+By leveraging the synergy of Oracle Database 23AI and Oracle Digital Assistant within the RAG pipeline, developers can create a chatbot that excels in both retrieval accuracy and conversational fluidity. This integrated approach not only reduces the time and effort required to build sophisticated chatbots, but also results in a solution that is scalable, efficient, and capable of delivering superior user experiences. +

+

To try the chatbot, click on the chat icon at the bottom right of the screen. +

+
+
+
+
+
+
+ +
+ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-web/scripts/settings.js b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-web/scripts/settings.js new file mode 100644 index 00000000..cb594e61 --- /dev/null +++ b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-web/scripts/settings.js @@ -0,0 +1,178 @@ +'use strict'; + +/** + * Set client auth mode - true to enable client auth, false to disable it. + * + * Disabling authentication is preferred for initial integration of the SDK with the web app. + * + * When client authentication has been disabled, only connections made from unblocked lists (allowed domains) are + * allowed at the server. This use case is recommended when the client application cannot generate a signed JWT (because + * of a static website or no authentication mechanism for the web/mobile app) but requires ODA integration. It can also + * be used when the chat widget is already secured and visible to only authenticated users in the client platforms (web + * application with the protected page). + * + * For other cases, it is recommended that client auth enabled mode is used when using the SDK for production as it adds + * another layer of security when connecting to a DA/skill. + * + * When client authentication has been enabled, client authentication is enforced by signed JWT tokens in addition to + * the unblocked lists. When the SDK needs to establish a connection with the ODA server, it first requests a JWT token + * from the client and then sends it along with the connection request. The ODA server validates the token signature and + * obtains the claim set from the JWT payload to verify the token to establish the connection. + * + * The Web channel in ODA must also be enabled to accept client auth enabled connections. + */ +let isClientAuthEnabled = false; + +/** + * Initializes the SDK and sets a global field with passed name for it the can + * be referred later + * + * @param {string} name Name by which the chat widget should be referred + */ +function initSdk(name) { + // Retry initialization later if the web page hasn't finished loading or the WebSDK is not available yet + if (!document || !document.body || !WebSDK) { + setTimeout(function () { + initSdk(name); + }, 2000); + return; + } + + if (!name) { + name = 'Bots'; // Set default reference name to 'Bots' + } + + let Bots; + + /** + * SDK configuration settings + * + * Other than URI, all fields are optional with two exceptions for auth modes: + * + * In client auth disabled mode, 'channelId' must be passed, 'userId' is optional + * In client auth enabled mode, 'clientAuthEnabled: true' must be passed + */ + const chatWidgetSettings = { + URI: 'oda-6bd20d2d75414fc6893891714bc07f55-da2.data.digitalassistant.oci.oraclecloud.com', // ODA URI, only the hostname part should be passed, without the https:// + clientAuthEnabled: isClientAuthEnabled, // Enables client auth enabled mode of connection if set true, no need to pass if set false + channelId: '05957180-ceed-4dd7-9e6e-8c9b4c9514ae', // Channel ID, available in channel settings in ODA UI, optional if client auth enabled + // openChatOnLoad: true, + userId: '', // User ID, optional field to personalize user experience + // initUserHiddenMessage: 'Hi', + openLinksInNewWindow: false, + disablePastActions: 'none', + enableAttachment: false, + enableAutocomplete: true, // Enables autocomplete suggestions on user input + enableBotAudioResponse: true, // Enables audio utterance of skill responses + enableClearMessage: true, // Enables display of button to clear conversation + enableSpeech: true, // Enables voice recognition + enableTimestamp: false, // Show timestamp with each message + speechLocale: WebSDK.SPEECH_LOCALE.EN_US, + showConnectionStatus: true, // Displays current connection status on the header + speechLocale: WebSDK.SPEECH_LOCALE.EN_US, + i18n: { // Provide translations for the strings used in the widget + en: { // en locale, can be configured for any locale + chatTitle: 'DataScience Oracle23AI ODA Bot' // Set title at chat header + } + }, + timestampMode: 'relative', // Sets the timestamp mode, relative to current time or default (absolute) + theme: WebSDK.THEME.REDWOOD_DARK, // Redwood dark theme. The default is THEME.DEFAULT, while older theme is available as THEME.CLASSIC + icons: { + avatarBot: "./images/botIcon.png", + avatarUser: './images/personIcon.png', + launch:"./images/botButtonIcon.gif", + logo:"./images/logoIcon.png", + }, + height: '85vh', //layout modification property + width: '45vw', //layout modification property + }; + + // Initialize SDK + if (isClientAuthEnabled) { + Bots = new WebSDK(chatWidgetSettings, generateToken); + } else { + Bots = new WebSDK(chatWidgetSettings); + } + + // Connect to skill when the widget is expanded for the first time + let isFirstConnection = true; + + Bots.on(WebSDK.EVENT.WIDGET_OPENED, function () { + if (isFirstConnection) { + Bots.connect(); + + isFirstConnection = false; + } + }); + + function actionHandler(action) { + Bots.sendMessage(action); + } + + // Create global object to refer Bots + window[name] = Bots; +} + +/** + * Function to generate JWT tokens. It returns a Promise to provide tokens. + * The function is passed to SDK which uses it to fetch token whenever it needs + * to establish connections to chat server + * + * @returns {Promise} Promise to provide a signed JWT token + */ +function generateToken() { + return new Promise(function (resolve) { + mockApiCall('https://mockurl').then(function (token) { + resolve(token); + }); + }); +} + +/** + * A function mocking an endpoint call to backend to provide authentication token + * The recommended behaviour is fetching the token from backend server + * + * @returns {Promise} Promise to provide a signed JWT token + */ +function mockApiCall() { + return new Promise(function (resolve) { + setTimeout(function () { + const now = Math.floor(Date.now() / 1000); + const payload = { + iat: now, + exp: now + 3600, + channelId: '', + userId: '' + }; + const SECRET = ''; + + // An unimplemented function generating signed JWT token with given header, payload, and signature + const token = generateJWTToken({ alg: 'HS256', typ: 'JWT' }, payload, SECRET); + resolve(token); + }, Math.floor(Math.random() * 1000) + 1000); + }); +} + +/** + * Unimplemented function to generate signed JWT token. Should be replaced with + * actual method to generate the token on the server. + * + * @param {object} header + * @param {object} payload + * @param {string} signature + */ +function generateJWTToken(header, payload, signature) { + throw new Error('Method not implemented.'); +} + +function connectSkill() { + const URI = document.getElementById('uri').value; + const channelId = document.getElementById('channelId').value; + if (URI && channelId) { + Bots.connect({ + URI, + channelId + }); + Bots.openChat(); + } +} diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-web/scripts/web-sdk.js b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-web/scripts/web-sdk.js new file mode 100644 index 00000000..3cc57a42 --- /dev/null +++ b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-web/scripts/web-sdk.js @@ -0,0 +1,5 @@ +/*! + * Copyright (c) 2024 Oracle and/or its affiliates. + * All rights reserved. Oracle Digital Assistant Client Web SDK, Release: 24.6.0 + */ +!function(t,factory){"object"==typeof exports&&"object"==typeof module?module.exports=factory():"function"==typeof define&&define.amd?define("WebSDK",[],factory):"object"==typeof exports?exports.WebSDK=factory():t.WebSDK=factory();t.WebSDK=factory()}(self,(function(){return function(){"use strict";var t={396:function(t,e,i){i.r(e),i.d(e,{ActionDisplayType:function(){return o},ActionStyle:function(){return s},ActionType:function(){return p},AttachmentType:function(){return a},BaseChatConnection:function(){return vt},ClientActionType:function(){return u},ConnectionEvent:function(){return gt},ConnectionState:function(){return ct},ContextSource:function(){return c},CoreApiError:function(){return ft},CoreError:function(){return bt},CoreEvent:function(){return mt},DisplayType:function(){return n},ExecuteActionType:function(){return h},MessageType:function(){return l},ReadOnlyDisplayType:function(){return r},RecognitionError:function(){return dt},RecognitionLocale:function(){return ht},SenderType:function(){return b},SkillMessageSource:function(){return v},SpeechSynthesisServiceEvent:function(){return pt},StateType:function(){return d},TokenType:function(){return g},buildPostbackMessage:function(){return P},buildUserAttachmentMessage:function(){return E},buildUserMessage:function(){return j},buildUserTextMessage:function(){return L},getCurrentPosition:function(){return Ct},getError:function(){return yt},getRejectPromiseError:function(){return kt},getUtteranceText:function(){return N},isEditFormPayloadWithFields:function(){return S},isEditFormPayloadWithRows:function(){return C},isEventPayload:function(){return _},isFormEntityWithFields:function(){return z},isFormEntityWithRows:function(){return M},isMessage:function(){return x},isMessagePayload:function(){return y},isPing:function(){return A},isPong:function(){return O},isPostbackPayload:function(){return k},isReadOnlyField:function(){return nt},isSuggestionMessage:function(){return $},isSuggestionPayload:function(){return T},isValidLocale:function(){return ut},isValidLocation:function(){return Lt},isValidMessage:function(){return X},isValidProfileMessage:function(){return tt},pingMessage:function(){return m},pongMessage:function(){return f},requestOn:function(){return xt},setRequestHeader:function(){return wt}});const s={Primary:"primary",Danger:"danger",Default:"default"},o={Button:"button",Icon:"icon",Link:"link"},r={Text:"text",Link:"link",Action:"action",Media:"media"},n=Object.assign(Object.assign({},r),{SingleSelect:"singleSelect",MultiSelect:"multiSelect",DatePicker:"datePicker",TimePicker:"timePicker",Toggle:"toggle",TextInput:"textInput",NumberInput:"numberInput"}),a={Image:"image",Video:"video",Audio:"audio",File:"file"},c={ChatWindow:"chatWindow",CompactChat:"compactChat",UIWidget:"UIWidget",Skill:"skill"},h={NAVIGATE:"navigate",QUERY:"query",UPDATE_FIELDS:"updateFields",CUSTOM:"custom"},l={Attachment:"attachment",Card:"card",Location:"location",Postback:"postback",Raw:"raw",Suggest:"suggest",Text:"text",CloseSession:"closeSession",SessionClosed:"sessionClosed",Table:"table",Form:"form",TableForm:"tableForm",Status:"status",EditForm:"editForm",FormSubmission:"formSubmission",InboundEvent:"inboundEvent",OutboundEvent:"outboundEvent",TextStream:"textStream",Command:"command",Error:"error",UpdateApplicationContextCommand:"updateApplicationContextCommand",ExecuteApplicationActionCommand:"executeApplicationActionCommand",GetDebugInfoCommand:"getDebugInfoCommand"},u=Object.assign(Object.assign({},h),{COPY_MESSAGE_TEXT:"copyMessageText"}),p={Call:"call",Client:"client",Location:"location",Popup:"popup",Postback:"postback",Share:"share",SubmitForm:"submitForm",Url:"url",Webview:"webview"},d={Auth:"auth",Ping:"ping",Pong:"pong",Token:"token"},g={JWT:"jwt"},m={state:{type:d.Ping}},f={state:{type:d.Pong}},b={Skill:"bot",User:"user"},v={Agent:"AGENT",Bot:"BOT"};var w=i(476);const x=t=>(0,w.isObject)(t)&&"messagePayload"in t,y=t=>(0,w.isObject)(t)&&"type"in t,k=t=>y(t)&&t.type===l.Postback,_=t=>y(t)&&(t.type===l.InboundEvent||t.type===l.OutboundEvent),z=t=>void 0!==t.fields,M=t=>void 0!==t.formRows,S=t=>void 0!==t.fields,C=t=>void 0!==t.formRows,T=t=>y(t)&&t.type===l.Suggest,$=t=>x(t)&&T(t.messagePayload),I=t=>(0,w.isObject)(t)&&"state"in t,A=t=>I(t)&&t.state.type===d.Ping,O=t=>I(t)&&t.state.type===d.Pong;function E(t,e,i){const s=function(t){const e=t.split("/")[0].toLowerCase();switch(e){case a.Audio:case a.Image:case a.Video:return e;default:return a.File}}(t);return{messagePayload:{type:l.Attachment,attachment:{type:s,url:e,title:i}}}}function L(t,e){const i={messagePayload:{text:t,type:l.Text}};return e&&(i.sdkMetadata?i.sdkMetadata.speechId=e:i.sdkMetadata={speechId:e}),i}function P(t){var e;let i;i="label"in t?t.label:null!==(e=t.text)&&void 0!==e?e:V;return{messagePayload:{text:i,postback:t.postback,type:l.Postback}}}function j(t){return{messagePayload:t}}const F="; ",V="",H=/<[^>]+>/g,D=/&#(\d+);/g,R=/&#[xX]([\da-fA-F]+);/g;function N(t,e){const i=t.messagePayload;let s=V;if(i.voice)return J(function(t){var e;const i=[null===(e=t.voice)||void 0===e?void 0:e.text];switch(t.type){case l.Card:i.push(function(t){if(!(null==t?void 0:t.length))return V;return t.filter((t=>t.voice)).map((t=>{var e;const i=[];return t.voice&&i.push(null===(e=t.voice)||void 0===e?void 0:e.text),i.push(Y(t.actions)),i.filter(Boolean).join(F)})).filter(Boolean).join(F)}(t.cards));break;case l.Form:case l.TableForm:i.push(function(t){if(!(null==t?void 0:t.length))return V;return t.filter(Boolean).map((t=>t.voice&&t.voice.text)).filter(Boolean).join(F)}(t.forms))}return i.push(Y(t.actions)),i.push(Y(t.globalActions)),i.filter(Boolean).join(F)}(t.messagePayload));switch(i.type){case l.Attachment:s=function(t,e){return e[`${t.type}_${t.attachment.type}`]}(i,e);break;case l.Card:s=function(t,e){const i=t.cards;let s=V;if(null==i?void 0:i.length){const t=e.card,o=t?t.indexOf("{0}")>=0?t:`${t} {0}`:V,r=i.length>1;s=i.filter((t=>t.title)).map(((t,e)=>{const i=[r?o.replace("{0}",`${e+1}`):V];return t.voice?i.push(t.voice.text):(i.push(t.title),i.push(t.description)),i.push(U(t.actions)),i.filter(Boolean).join(F)})).filter(Boolean).join(F)}return s}(i,e);break;case l.Location:s=function(t){const e=t.location;return`${e.title?`${e.title}${F}`:V}${e.latitude},${e.longitude}`}(i);break;case l.Text:case l.TextStream:s=i.text;break;case l.Table:s=function(t,e){return B(t.paginationInfo)+t.rows.filter((t=>{var e;return null===(e=null==t?void 0:t.fields)||void 0===e?void 0:e.length})).map(((t,i)=>Z(t,i,e))).filter(Boolean).join(F)}(i,e);break;case l.Form:s=function(t,e){return B(t.paginationInfo)+t.forms.filter((t=>t)).map(((t,i)=>{const s=(t.title?`${t.title}: `:V)+W(t,e);return s?`${(e.itemIterator||V).replace("{0}",`${i+1}`)}: ${s}`:V})).filter(Boolean).join(F)}(i,e);break;case l.TableForm:s=function(t,e){return B(t.paginationInfo)+t.rows.filter((t=>{var e;return null===(e=null==t?void 0:t.fields)||void 0===e?void 0:e.length})).map(((i,s)=>Z(i,s,e)+F+W(t.forms[s],e))).filter(Boolean).join(F)}(i,e);break;case l.EditForm:s=function(t){var e,i;return null!==(i=null!==(e=t.errorMessage)&&void 0!==e?e:t.title)&&void 0!==i?i:V}(i)}return(0,w.pipe)(function(t,e){if(t.type===l.EditForm&&t.errorMessage)return e;const i=[];return i.push(t.headerText),i.push(e),i.push(U(t.actions)),i.push(t.footerText),i.push(U(t.globalActions)),i.filter(Boolean).join(F)}(i,s),J,K,q)}function U(t){return t?t.filter((t=>t.type!==p.SubmitForm)).map((t=>t.voice?t.voice.text:t.label||V)).filter(Boolean).join(F):V}function B(t){if(t&&t.totalCount>t.rangeSize){const e=t.status;return e?e+F:V}return V}function W(t,e){let i=U(t.actions);return i&&(i=F+i),z(t)?G(t.fields,e)+i:t.formRows.filter((t=>null==t?void 0:t.columns.length)).map((t=>t.columns.filter((t=>null==t?void 0:t.fields.length)).map((t=>G(t.fields,e))).filter(Boolean).join(F))).filter(Boolean).join(F)+i}function Z(t,e,i){return`${(i.itemIterator||V).replace("{0}",`${e+1}`)}: ${G(t.fields,i)}`}function G(t,e){return(null==t?void 0:t.length)?t.filter((t=>t)).map((t=>function(t,e){var i;const s=null!==(i=t.label)&&void 0!==i?i:V,o=s?`${s}: `:V;switch(t.displayType){case r.Text:return o+(t.value||V);case r.Link:return o+(e.linkField||V).replace("{0}",s);case r.Action:const i=t.action;return o+(i.voice?i.voice.text:i.label)||V;default:return s}}(t,e))).filter(Boolean).join(F):V}function q(t){if(null==t?void 0:t.length){const e=t.replace((0,w.resetRegex)(D),((t,e)=>String.fromCharCode(e))).replace((0,w.resetRegex)(R),((t,e)=>{const i=Number.parseInt(`0x${e}`,16);return String.fromCharCode(i)}));return(0,w.removeDisplayNoneAndDecode)(e).replace((0,w.resetRegex)(H),V)}return V}function Y(t){return(null==t?void 0:t.length)?t.filter((t=>t.type!==p.SubmitForm)).map((t=>t.voice&&t.voice.text)).filter(Boolean).join(F):V}const J=t=>t.replaceAll(/([-.,?:;!]);/g,"$1"),K=t=>t.replaceAll(/\r|\n|/gim,F);function X(t){const e=!1;if(!x(t))return e;const i=t.messagePayload;return y(i)?i.actions&&!Q(i.actions)||i.globalActions&&!Q(i.globalActions)?e:function(t){switch(t.type){case l.Attachment:return function(t){const e=t.attachment;return!(!(null==e?void 0:e.type)||!e.url)}(t);case l.Card:return function(t){let e=!1;if(t.layout&&t.cards.length){e=!0;for(const e of t.cards){if(!e.title)return!1;if(e.actions&&!Q(e.actions))return!1}}return e}(t);case l.CloseSession:case l.SessionClosed:return!0;case l.Location:return function(t){const e=t.location;return!(!(null==e?void 0:e.latitude)||!e.longitude)}(t);case l.Postback:return function(t){return!!t.postback}(t);case l.Text:return function(t){return!!t.text}(t);case l.TextStream:return function(t){return"string"==typeof t.text&&!!t.streamState}(t);case l.Table:return et(t);case l.Form:return it(t);case l.TableForm:return function(t){return et(t)&&it(t)}(t);case l.EditForm:return function(t){const e=t.fields,i=t.formColumns,s=t.formRows;return(null==e?void 0:e.length)>0&&e.every((t=>function(t){const e=t.displayType,i=t;return e&&Object.values(n).includes(e)&&(function(t){const e=t.id;let i=!1;switch(t.displayType){case n.SingleSelect:case n.MultiSelect:i=function(t){const e=t.layoutStyle,i=t.options;return void 0!==e&&"string"==typeof e&&e.length>0&&void 0!==i&&i.length>0&&i.every((t=>function(t){const e=t.label,i=t.value;return void 0!==e&&"string"==typeof e&&e.length>0&&void 0!==i}(t)))}(t);break;case n.Toggle:i=function(t){const e=t.valueOn,i=t.valueOff;return void 0!==e&&"string"==typeof e&&e.length>0&&void 0!==i&&"string"==typeof i&&i.length>0}(t);break;case n.DatePicker:case n.TimePicker:case n.TextInput:case n.NumberInput:i=!0}return i&&void 0!==e&&e.length>0}(i)||ot(t))}(t)))&&"number"==typeof i&&i>0||(null==s?void 0:s.length)>0}(t);case l.FormSubmission:return function(t){return!!t.submittedFields}(t);case l.InboundEvent:case l.OutboundEvent:return function(t){return!!t.eventType&&!!t.eventVersion&&!!t.eventData}(t);case l.Status:return function(t){return t.type===l.Status&&"status"in t}(t);case l.Command:return function(t){return t.type===l.Command&&"command"in t}(t);case l.UpdateApplicationContextCommand:return function(t){const{context:e,source:i}=t;return void 0!==e&&"string"==typeof e&&at.includes(i)}(t);case l.GetDebugInfoCommand:return function(t){return void 0!==t.infoTypes&&t.infoTypes.length>0}(t)}return!1}(i):e}function Q(t){for(const e of t)if(!e.type||!(e.label&&"string"==typeof e.label||e.imageUrl&&"string"==typeof e.imageUrl))return!1;return!0}function tt(t){return(0,w.isObject)(t)&&(0,w.isObject)(t.profile)}function et(t){const e=t.headings,i=t.rows;return e&&e.length>0&&i&&i.length>0&&e.every((t=>function(t){const e=t.label;return void 0!==e&&e.length>0}(t)))&&i.every((t=>st(t)))}function it(t){const e=t.forms;return e&&e.length>0&&e.every((t=>z(t)&&st(t)||M(t)))}function st(t){const e=t.fields;return e&&e.length>0&&e.every((t=>ot(t)))}function ot(t){return!!t.displayType&&nt(t)}const rt=Object.values(r);function nt(t){return t&&rt.includes(t.displayType)}const at=Object.values(c);const ct={Connecting:0,Open:1,Closing:2,Closed:3},ht={DE_DE:"de-de",EN_AU:"en-au",EN_GB:"en-gb",EN_IN:"en-in",EN_US:"en-us",ES_ES:"es-es",FR_FR:"fr-fr",HI_IN:"hi-in",IT_IT:"it-it",PT_BR:"pt-br"},lt=Object.keys(ht).map((t=>ht[t]));function ut(t){return lt.indexOf(t)>=0}const pt={TTSStart:"tts:start",TTSStop:"tts:stop"},dt={RecognitionNotAvailable:"RecognitionNotAvailable",RecognitionNotReady:"RecognitionNotReady",RecognitionNoAPI:"RecognitionNoAPI",RecognitionProcessingFailure:"RecognitionProcessingFailure",RecognitionTooMuchSpeechTimeout:"RecognitionTooMuchSpeechTimeout",RecognitionNoSpeechTimeout:"RecognitionNoSpeechTimeout",RecognitionMultipleConnection:"RecognitionMultipleConnection"},gt={Open:"open",Close:"close",Error:"error",Message:"message",MessageReceived:"message:received",MessageSent:"message:sent",State:"state"},mt=Object.assign(Object.assign(Object.assign({},pt),gt),h),ft={ConnectionNone:"ConnectionNone",ConnectionExplicitClose:"ConnectionExplicitClose",MessageInvalid:"MessageInvalid",NetworkFailure:"NetworkFailure",NetworkOffline:"NetworkOffline",ProfileInvalid:"ProfileInvalid",TtsNotAvailable:"TtsNotAvailable",TTSNoWebAPI:"TTSNoWebAPI",SuggestionsEmptyRequest:"SuggestionsEmptyRequest",SuggestionsInvalidRequest:"SuggestionsInvalidRequest",SuggestionsTimeout:"SuggestionsTimeout",UploadBadFile:"UploadBadFile",UploadMaxSize:"UploadMaxSize",UploadNetworkFail:"UploadNetworkFail",UploadNotAvailable:"UploadNotAvailable",UploadUnauthorized:"UploadUnauthorized",UploadZeroSize:"UploadZeroSize",LocationNoAPI:"LocationNoAPI",LocationNotAvailable:"LocationNotAvailable",LocationTimeout:"LocationTimeout",LocationInvalid:"LocationInvalid"},bt=Object.assign(Object.assign(Object.assign({},ft),w.AuthError),dt);class vt{constructor(t){this.dispatcher=t,this.state=ct.Closed}getState(){return this.state}isOpen(){return this.state===ct.Open}isClosed(){return this.state===ct.Closed}on(t,e){this.dispatcher.bind(t,e)}off(t,e){this.dispatcher.unbind(t,e)}setState(t){this.state=t,this.dispatcher.trigger(mt.State,t)}}function wt(t,e,i){t.setRequestHeader(e,i)}function xt(t,e,i){t.addEventListener(e,i)}function yt(t){return Error(t)}function kt(t){return Promise.reject(yt(t))}const _t=navigator,zt=null==_t?void 0:_t.geolocation,Mt=1e5,St=t=>Math.round(t*Mt)/Mt;function Ct(){return zt?new Promise(((t,e)=>{zt.getCurrentPosition((e=>{const i=e.coords,s=Object.assign(Object.assign({},i),{latitude:St(i.latitude),longitude:St(i.longitude)});t(s)}),(t=>{let i;switch(t.code){case t.POSITION_UNAVAILABLE:i=bt.LocationNotAvailable;break;case t.TIMEOUT:i=bt.LocationTimeout;break;case t.PERMISSION_DENIED:default:i=bt.LocationNoAPI}e(yt(i))}),{enableHighAccuracy:!0,timeout:5e3})})):kt(bt.LocationNoAPI)}function Tt(t){return"number"==typeof t}function $t(t,e,i){return t>=e&&t<=i}const It=-90,At=90,Ot=-180,Et=180;function Lt(t){const{latitude:e,longitude:i}=t;return Tt(e)&&Tt(i)&&$t(e,It,At)&&$t(i,Ot,Et)}},921:function(t,e,i){i.r(e),i.d(e,{ActionType:function(){return o.ActionType},AttachmentType:function(){return o.AttachmentType},ConnectionState:function(){return o.ConnectionState},CoreError:function(){return o.CoreError},CoreEvent:function(){return o.CoreEvent},CoreTTS:function(){return St},DisplayType:function(){return o.DisplayType},FILE_TYPES:function(){return Mt},MAX_MB:function(){return wt},MessageType:function(){return o.MessageType},RecognitionLocale:function(){return o.RecognitionLocale},SenderType:function(){return o.SenderType},SkillMessageSource:function(){return o.SkillMessageSource},SpeechSynthesisServiceEvent:function(){return o.SpeechSynthesisServiceEvent},WebCore:function(){return Tt},buildPostbackMessage:function(){return o.buildPostbackMessage},buildUserAttachmentMessage:function(){return o.buildUserAttachmentMessage},buildUserMessage:function(){return o.buildUserMessage},buildUserTextMessage:function(){return o.buildUserTextMessage},getCurrentPosition:function(){return o.getCurrentPosition},getError:function(){return o.getError},getRejectPromiseError:function(){return o.getRejectPromiseError},getUtteranceText:function(){return o.getUtteranceText},isEditFormPayloadWithFields:function(){return o.isEditFormPayloadWithFields},isEditFormPayloadWithRows:function(){return o.isEditFormPayloadWithRows},isFormEntityWithFields:function(){return o.isFormEntityWithFields},isFormEntityWithRows:function(){return o.isFormEntityWithRows},isMessagePayload:function(){return o.isMessagePayload},isPostbackPayload:function(){return o.isPostbackPayload},isValidLocale:function(){return o.isValidLocale},isValidLocation:function(){return o.isValidLocation},isValidMessage:function(){return o.isValidMessage},isValidProfileMessage:function(){return o.isValidProfileMessage}});var s=i(476),o=i(396);let r=1,n=1,a=1;const c=window,h=c.addEventListener,l=c.speechSynthesis,u=c.SpeechSynthesisUtterance,p=c.navigator,d=clearTimeout;class g{constructor(){if(this.t=!1,this.i=(0,s.generateEventDispatcher)(),!c||!l||!u)throw Error("TTSNoWebAPI");w().then((t=>{this.l=t})),h("beforeunload",(t=>{l.cancel(),d(this.u),delete t.returnValue})),h("click",(()=>{l&&(l.cancel(),l.resume(),l.speak(new u(" ")))}),{once:!0})}speak(t){if(this.l){const e=new u(t);e.voice=this.l,e.pitch=r,e.rate=n,e.volume=a,l.paused&&l.resume(),this.t||(this.t=!0,this.i.trigger(o.SpeechSynthesisServiceEvent.TTSStart)),l.speak(e),this.l.localService||(d(this.u),y((t=>this.u=t)))}}cancel(){l.speaking&&(l.cancel(),d(this.u))}getVoices(){return m()}setVoice(t){return function(t){const e=t.map((t=>Object.assign({lang:"",name:""},t)));return m().then((t=>{for(const i of e)for(const e of t)if(k(i.lang,e.lang)&&k(i.name,e.name))return e;for(const i of e)for(const e of t)if(k(i.lang,e.lang))return e;for(const i of e)for(const e of t)if(e.lang.indexOf(i.lang)>=0)return e;return w()}))}(t).then((t=>{this.l=t,r=t.pitch||1,n=t.rate||1,a=t.volume||1}))}getVoice(){return this.l}on(t,e){this.i.bind(t,e)}off(t,e){this.i.unbind(t,e)}}function m(){return new Promise((t=>{f(t),l.addEventListener("voiceschanged",(()=>{f(t)}))}))}function f(t){const e=l.getVoices();if(e.length){t(function(t){if(!Array.isArray(t))return t.p;return t}(v(e)))}}const b=["Albert","Bad News","Bahh","Bells","Boing","Bubbles","Cellos","Good News","Jester","Organ","Superstar","Trinoids","Whisper","Wobble","Zarvox"],v=t=>t.filter((t=>b.indexOf(t.name)<0));function w(){return m().then((t=>{let e;const i=t.filter((t=>t.default));if(1===i.length&&(e=i[0]),!e){const i=p&&p.language;i&&(e=t.find((t=>k(t.lang,i))))}if(!e){const i=p&&p.language.substring(0,2);i&&(e=t.find((t=>_(t.lang).indexOf(i)>=0)))}return e||(e=t[0]),e}))}const x=1e4;function y(t){const e=c.setTimeout((()=>{l.speaking&&(l.pause(),l.resume(),y(t))}),x);t(e)}function k(t,e){return _(t)===_(e)}const _=t=>t.toLowerCase(),z={DEFAULT:0,VOICE_RECOGNITION:6},M=window.audioinput;function S(){return M}function C(t){return new Promise(((t,e)=>{const i=S();i.checkMicrophonePermission((s=>{s?t():i.getMicrophonePermission(((i,s)=>{i?t():e(s)}))}))})).then((()=>{const e=S();return e.start(t),e}))}function T(){return new Promise((t=>{const e=S();e.isCapturing()?(e.stop(t),e.disconnect()):t()}))}let $=window.AudioContext;const I=window.navigator;let A=I.mediaDevices;const O=I.webkitGetUserMedia,E=I.mozGetUserMedia,L=!!(A&&A.getUserMedia||O||E);var P=function(t,e,i,s){return new(i||(i=Promise))((function(o,r){function n(t){try{c(s.next(t))}catch(t){r(t)}}function a(t){try{c(s.throw(t))}catch(t){r(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(n,a)}c((s=s.apply(t,e||[])).next())}))};const j=4096,F=48e3;let V,H=!0;class D{static getInstance(){return this.v||(this.v=new D),this.v}constructor(){this.k=[],this._=!1,$=$||window.webkitAudioContext,L&&(void 0===A&&(A={}),void 0===A.getUserMedia&&(A.getUserMedia=t=>{const e=O||E;if(!e){const t=Error("getUserMedia is not implemented in this browser");return t.name="TypeError",Promise.reject(t)}return new Promise(((i,s)=>{e.call(navigator,t,i,s)}))}))}startRecognition(t){var e,i;return this.C=new s.Deferred,t&&(this.T=t.onRecognitionText,this.$=t.onAnalyserReady,this.I=t.onVisualData,this.O=t.onSpeechNetworkChange),(null===(e=this.L)||void 0===e?void 0:e.readyState)===o.ConnectionState.Closing||(null===(i=this.L)||void 0===i?void 0:i.readyState)===o.ConnectionState.Connecting?Promise.reject(new Error(o.RecognitionError.RecognitionMultipleConnection)):(this._?this.C.resolve():this.P?this.j():this.F().then((()=>this.j())),this.C.promise)}stopRecognition(){return this.V=new s.Deferred,this._?this.R():this.V.resolve(),this.V.promise}setConfig(t){return t.recognitionLocale||(t.recognitionLocale=o.RecognitionLocale.EN_US),t.tokenGenerator&&(this.N=s.AuthTokenService.getInstance()),this.U=t,this.F()}setLocale(t){(0,o.isValidLocale)(t)&&this.U&&(this.U.recognitionLocale=t,this.F())}B(t){var e;null===(e=this.O)||void 0===e||e.call(this,t)}F(){return(t=this.U,e=this.N,new Promise(((i,s)=>{t.tokenGenerator?e.get().then((e=>{t.channelId=e.getClaim("channelId"),t.userId=e.getClaim("userId"),U(t,i,s)})).catch((t=>s(t))):U(t,i,s)}))).then((t=>{this.P=t}));var t,e}j(){return new Promise(((t,e)=>{L?function(t,e){navigator.mediaDevices.getUserMedia({audio:!0}).then((e=>{const i=new AudioContext;t({context:i,stream:i.createMediaStreamSource(e)})})).catch((()=>{e(Error(o.RecognitionError.RecognitionNoAPI))}))}(t,e):void 0!==S()?function(t,e){T().then((()=>C({audioSourceType:z.VOICE_RECOGNITION,bufferSize:j,streamToWebAudio:!0}).then((e=>{t({context:S().getAudioContext(),stream:e})})))).catch((()=>{e(Error(o.RecognitionError.RecognitionNoAPI))}))}(t,e):e(Error(o.RecognitionError.RecognitionNoAPI))})).then((t=>{let e;this.k=[],V=new Float32Array(0),this.L=this.W(this.P),function(t,e,i){return P(this,void 0,void 0,(function*(){const s=t.createAnalyser();s.smoothingTimeConstant=.8,s.fftSize=256;const o=`class RecorderProcessor extends AudioWorkletProcessor {\n buffersize = ${j};\n\n // Track the current buffer fill level\n _bytesWritten = 0;\n\n // Create a buffer of fixed size\n _buffer = new Float32Array(this.buffersize);\n\n constructor() {\n super();\n this.initBuffer();\n }\n\n initBuffer() {\n this._bytesWritten = 0;\n }\n\n isBufferEmpty() {\n return this._bytesWritten === 0;\n }\n\n isBufferFull() {\n return this._bytesWritten === this.buffersize;\n }\n\n flush() {\n // trim the buffer if ended prematurely\n this.port.postMessage(\n this._bytesWritten < this.buffersize\n ? this._buffer.slice(0, this._bytesWritten)\n : this._buffer\n );\n this.initBuffer();\n }\n\n process(inputs) {\n this.append(inputs[0][0]);\n return true;\n }\n\n append(channelData) {\n if (this.isBufferFull()) {\n this.flush();\n }\n\n if (!channelData) return;\n\n for (let i = 0; i < channelData.length; i++) {\n this._buffer[this._bytesWritten++] = channelData[i];\n }\n }\n }\n\n registerProcessor('recorder.worklet', RecorderProcessor);`,r=URL.createObjectURL(new Blob([o],{type:"application/javascript"}));yield t.audioWorklet.addModule(r);const n=new AudioWorkletNode(t,"recorder.worklet");return URL.revokeObjectURL(r),e.connect(s),s.connect(n),n.connect(t.destination),n.port.onmessage=i,{analyser:s,processor:n}}))}(t.context,t.stream,this.G.bind(this)).then((i=>{e=i,this.$&&this.$(e.analyser),this.q=t.context,this.Y=t.stream,this.J=e.analyser,this.K=e.processor}))})).catch((t=>{this.C&&this.C.reject(t)}))}W(t){try{const e=new WebSocket(t);return e.onopen=this.X.bind(this),e.onclose=this.tt.bind(this),e.onmessage=this.et.bind(this),e.onerror=this.st.bind(this),e}catch(t){throw Error(o.RecognitionError.RecognitionNotReady)}}X(){this.U.tokenGenerator?this.N.get().then((t=>{this.L.send(`Bearer ${t.token}`),this.B(o.ConnectionState.Open),this.ot()})):(this.B(o.ConnectionState.Open),this.ot())}tt(){this._&&this.R(),this.V&&(this.V.resolve(),this.V=void 0),this.B(o.ConnectionState.Closed)}et(t){try{const e=JSON.parse(t.data);if(!e.event&&e.code)throw t;const i=function(t){let e,i;const s=t.requestId,r=t.nbest;"partialResult"===t.event?(e="partial",i=r[0].utterance):r&&r.length?(e="final",i=r[0].utterance):(e="error",i=t.resultCode?o.RecognitionError.RecognitionTooMuchSpeechTimeout:o.RecognitionError.RecognitionNoSpeechTimeout);return{requestId:s,type:e,text:i,message:t}}(e);"finalResult"===e.event&&this.stopRecognition(),this.T&&this.T(i)}catch(t){this.rt(o.RecognitionError.RecognitionProcessingFailure),this.stopRecognition()}}st(){this.L.readyState===o.ConnectionState.Open&&(this.rt(o.RecognitionError.RecognitionProcessingFailure),this.L.close())}rt(t){this.T&&this.T({requestId:"",text:t,type:"error"})}G(t){var e;this.C&&(this._=!0,this.C.resolve(),this.C=void 0);const i=t.data,s=(null===(e=this.q)||void 0===e?void 0:e.sampleRate)||F;try{const t=function(t,e,i){if(i===e)return t;if(i>e)throw Error();let s=[];if(e===F)s=B;else{if(44100!==e)throw Error();s=W}const o=e/i;let r,n,a;H?(r=Math.floor(t.length%o),n=t.length-r,a=0===r?Array.from(t):t.slice(0,n)):(r=Math.floor((t.length+V.length-s.length)%o),n=t.length+V.length-s.length-r,a=new Float32Array(V.length+n),a.set(V),a.set(t.slice(0,n),V.length));const c=Math.floor(n/o),h=new Int16Array(c),l=-1,u=32767;if(e===F)for(let t=s.length;t=t.length?t[t.length-1]:t[e])*Z(i,s-e)}h[e]=Math.max(Math.min(a,1),l)*u}}V=H?t.slice(n-s.length-V.length):t.slice(n-s.length-(V.length-s.length));return H=!1,h.buffer}(i,s,16e3);this.I&&this.nt(this.J),this.ct(t)}catch(t){this.rt(o.RecognitionError.RecognitionProcessingFailure),this.stopRecognition()}}nt(t){if(t){const e=new Uint8Array(t.frequencyBinCount);t.getByteFrequencyData(e),this.I&&this.I(e)}}ct(t){this.L.readyState!==o.ConnectionState.Open||this.k.length?this.k.push(t):this.L.send(t)}ot(){if(this.L.readyState===o.ConnectionState.Open)for(;this.k.length;){const t=this.k.shift();t&&this.L.send(t)}}R(){var t,e,i;(this._=!1,this.L)&&(this.L.readyState===o.ConnectionState.Open&&(this.L.send("Done"),this.L.close()),this.K&&this.K.disconnect(),this.J&&this.J.disconnect(),S()?T():(i=this.Y)&&i.mediaStream&&i.mediaStream.getAudioTracks().forEach((t=>{t.stop()})),null===(t=this.Y)||void 0===t||t.disconnect(),null===(e=this.q)||void 0===e||e.suspend(),this.K=void 0,this.J=void 0,this.Y=void 0,this.k=[],H=!0,V=new Float32Array(0))}}const R="/voice/stream/recognize",N="generic";function U(t,e,i){t.channelId&&t.userId||i(Error(o.RecognitionError.RecognitionNotReady)),e(function(t){const e=`ws${t.isTLS?"s":""}://`,i=`${R}/${t.recognitionLocale}/${N}`,o={channelId:t.channelId||"",encoding:"audio/raw",userId:t.userId||""};t.tokenGenerator&&(o.jwtInBody="true");return(0,s.buildURL)(e,t.URI,o,i)}(t))}const B=[-25033838264794034e-21,-3645156113737857e-20,-11489993827892933e-21,393243788874656e-19,6998419352067277e-20,37556691270439976e-21,-476966455345305e-19,-.00011379935461751734,-8400957697117619e-20,4208817777607469e-20,.00016391587447478332,.00015508372993570357,-1253765788919669e-20,-.00021258262011091092,-.0002524059896175195,-51874329668708116e-21,.0002479230009768214,.00037351534477673157,.00016157590781788105,-.0002541085239198603,-.000510486865332593,-.0003246104617540939,.00021219136947965464,.0006488877825604561,.0005444416935293036,-.0001016639071691704,-.0007673001147209819,-.0008176720912938691,-972696982411551e-19,.0008376185852528038,.0011319450250252222,.0004008193339799052,-.0008262743020160207,-.0014643282305934196,-.0008183365045047033,.0006964471772153777,.001780467922489105,.0013489288090360295,-.00041122152287042,-.0020347535966250413,-.0019782994815083733,-6247794246099269e-20,.002171643809964705,.0026761621389245617,.00074944268608935,-.00212817775887288,-.003394541347147186,-.0016615884301227524,.001837545335885159,.004067170702246546,.0027936171643976352,-.001233420727213658,-.004610035314537476,-.004119319153202972,.00025459137646049936,.00492286494534436,.005588805700369816,.001150762425755883,-.004891042781491068,-.0071267634777626675,-.003021979039818941,.00438688631315642,.008631467181982988,.005385139236634672,-.003268406079325266,-.009973661255235284,-.008256256502745316,.0013719935383757782,.010993210336541666,.011651337116264694,.0015082475865128093,-.01148872195209017,-.015609515327517686,-.005671504441670989,.011188303272599716,.02024519058502148,.011637590928971467,-.009667754909210324,-.025878090076785515,-.020500381603699786,.006098908137700642,.033428666116203716,.03513487017573178,.001719739622764723,-.046085580848361105,-.06623078150315037,-.023349941728869696,.08292213207159124,.21069217442624302,.2973829711397418,.2973829711397419,.21069217442624305,.08292213207159124,-.023349941728869693,-.06623078150315037,-.046085580848361105,.0017197396227647225,.03513487017573178,.033428666116203716,.006098908137700641,-.020500381603699783,-.025878090076785508,-.009667754909210326,.011637590928971469,.020245190585021472,.011188303272599716,-.00567150444167099,-.015609515327517682,-.01148872195209017,.001508247586512809,.011651337116264699,.010993210336541666,.0013719935383757782,-.008256256502745314,-.009973661255235283,-.0032684060793252657,.00538513923663467,.008631467181982988,.004386886313156419,-.0030219790398189413,-.0071267634777626675,-.0048910427814910715,.0011507624257558842,.005588805700369813,.00492286494534436,.00025459137646049936,-.004119319153202973,-.004610035314537475,-.0012334207272136583,.002793617164397636,.004067170702246546,.0018375453358851592,-.0016615884301227509,-.0033945413471471847,-.0021281777588728797,.0007494426860893505,.0026761621389245612,.0021716438099647056,-6247794246099253e-20,-.001978299481508373,-.0020347535966250404,-.00041122152287042,.0013489288090360292,.0017804679224891048,.0006964471772153777,-.0008183365045047026,-.00146432823059342,-.0008262743020160207,.0004008193339799063,.0011319450250252222,.0008376185852528037,-9726969824115494e-20,-.0008176720912938694,-.0007673001147209783,-.00010166390716916983,.0005444416935293033,.0006488877825604562,.0002121913694796546,-.00032461046175409424,-.000510486865332593,-.00025410852391986036,.0001615759078178811,.0003735153447767315,.00024792300097682137,-5187432966870808e-20,-.0002524059896175194,-.00021258262011091095,-1253765788919669e-20,.0001550837299357036,.0001639158744747833,42088177776074685e-21,-8400957697117623e-20,-.00011379935461751733,-4769664553453051e-20,3755669127044002e-20,699841935206728e-19,393243788874656e-19,-11489993827892933e-21,-3645156113737856e-20,-2503383826479402e-20],W=[-5044267067893139e-21,5738740247594612e-21,1611195555688156e-20,10560179594562795e-21,-1242816862904201e-20,-3084430704328611e-20,-18160396924882423e-21,2303124169528074e-20,5216612702894834e-20,2806026886746509e-20,-389608521587068e-19,-8174245278012476e-20,-4037543061985353e-20,619375276294956e-19,.00012143092661620545,55083199655424166e-21,-9401891583478883e-20,-.00017326981522755043,-7198069055926206e-20,.0001376274218691789,.00023946132645647525,9064030545698025e-20,-.00019557611633250834,-.0003223511502826996,-.00011036322783022617,.0002710935667931249,.00042440564349633953,.00013013140955365376,-.00036784896615780913,-.0005481886438481025,-.00014855826094166272,.0004899798946967381,.000696340560985472,.00016383778624615643,-.0006421263408051642,-.0008715631880363658,-.00017369118859371453,.000829476349448821,.0010766146787146871,.00017530890385814463,-.0010578310750603923,-.001314320458073489,-.0001652844648711556,.0013337004262191077,.0015876076783199174,.000139534308084411,-.0016644454627712116,-.001899573527380014,-9319422024995832e-20,.002058491185395933,.0022536018141979036,20477911370491685e-21,-.0025256449668619525,-.0026535487754524955,8552498376473957e-20,.0030775744811722015,.0031040297261921,-.00023314744969763122,-.003728529808331677,-.003610856230113392,.000432598472497653,.0044964472481822506,.004181705019767344,-.0006966685466235378,-.005404666489478738,-.00482715710731867,.0010418556659416306,.006484667519607787,.00556235368742558,-.0014902159613265254,-.007780573986407925,-.0064097301786953595,.002072517010858728,.009356870546119134,.0074037416266333166,-.00283386009764953,-.011312323822665827,-.008599512596140524,.003844300507349054,.013806774337071994,.01008985372973804,-.005220460312862638,-.01711716324115331,-.01204196749753927,.007174046245357611,.021768247992024713,.01478690833035584,-.010136389804721707,-.02888735624896028,-.019078400739739057,.015146805312378952,.041410446665863104,.027068163980255515,-.025512027260482153,-.07011218378743589,-.04829678433503421,.06041368701604651,.21199607414538668,.3213532652447261,.3213532652447261,.21199607414538668,.060413687016046526,-.04829678433503422,-.07011218378743589,-.025512027260482153,.027068163980255515,.041410446665863104,.015146805312378952,-.019078400739739057,-.02888735624896028,-.010136389804721703,.01478690833035584,.021768247992024713,.007174046245357611,-.01204196749753927,-.01711716324115331,-.005220460312862639,.010089853729738038,.013806774337071994,.0038443005073490553,-.008599512596140524,-.011312323822665827,-.0028338600976495314,.007403741626633317,.009356870546119134,.002072517010858727,-.006409730178695359,-.007780573986407925,-.001490215961326526,.005562353687425577,.006484667519607787,.0010418556659416256,-.004827157107318673,-.005404666489478739,-.0006966685466235378,.004181705019767345,.004496447248182251,.0004325984724976533,-.003610856230113392,-.003728529808331677,-.0002331474496976315,.0031040297261921003,.003077574481172201,8552498376473897e-20,-.002653548775452496,-.002525644966861952,2047791137049164e-20,.002253601814197904,.002058491185395933,-9319422024995909e-20,-.001899573527380014,-.0016644454627712118,.00013953430808441038,.0015876076783199174,.0013337004262191077,-.0001652844648711556,-.0013143204580734896,-.0010578310750603925,.00017530890385814333,.0010766146787146878,.0008294763494488195,-.00017369118859371463,-.00087156318803637,-.0006421263408051633,.00016383778624615698,.0006963405609854716,.0004899798946967381,-.00014855826094166245,-.0005481886438481027,-.00036784896615780924,.00013013140955365368,.00042440564349633964,.00027109356679312505,-.00011036322783022619,-.0003223511502826996,-.00019557611633250842,9064030545698017e-20,.00023946132645647525,.00013762742186917883,-7198069055926207e-20,-.0001732698152275505,-9401891583478886e-20,5508319965542416e-20,.00012143092661620549,6193752762949557e-20,-4037543061985352e-20,-8174245278012477e-20,-38960852158706805e-21,28060268867465078e-21,52166127028948336e-21,2303124169528077e-20,-18160396924882423e-21,-30844307043286126e-21,-12428168629042018e-21,10560179594562806e-21,1611195555688157e-20,5738740247594605e-21,-5044267067893138e-21];function Z(t,e){let i;if(0===e)i=1;else if(Math.abs(e)>=t)i=0;else{const s=Math.PI*e;i=t*Math.sin(s)*Math.sin(s/t)/Math.pow(s,2)}return i}const G="ended",q="suspended";const Y=(t,e)=>new Float32Array([...t,...J(e)]),J=t=>Float32Array.from(new Int16Array(t),(t=>t/32768)),K="speak",X="channelId",Q="userId",tt="https://",et=/<[\w]+/g,it=K;class st{constructor(t){this.ht="",this.lt=[],this.ut=!1,this.t=!1,this.dt=new AbortController,this.i=(0,s.generateEventDispatcher)(),this.U=t=>{this.gt=t,this.ht=`${t.URI}/tts/`,t.tokenGenerator&&(this.N=s.AuthTokenService.getInstance())},this.ft=t=>{let e=t;t.match(et)&&(e=`<${it}>${t}`);const i=Object.assign({text:encodeURIComponent(e),stream:"chunked"},this.l&&{voice:this.l.name});return this.bt(K,i).then((t=>this.vt(t)))},this.bt=(t,e={})=>{const i=this.gt;if(i){if(i.tokenGenerator)return this.N.get().then((i=>(e[X]=i.getClaim(X),e[Q]=i.getClaim(Q),Promise.resolve((0,s.buildURL)(tt,this.ht,e,t)))));e[X]=i.channelId,e[Q]=i.userId}return Promise.resolve((0,s.buildURL)(tt,this.ht,e,t))},this.vt=(t,e=!0)=>new Promise(((i,s)=>{const o=this.gt,r=e?this.dt.signal:void 0;o&&o.tokenGenerator?this.N.get().then((e=>{fetch(t,{signal:r,headers:{Authorization:`Bearer ${e.token}`}}).then(i,s)})):fetch(t,{signal:r}).then(i,s)})),this.wt=t=>{if(t&&t.body){const e=t.body.getReader();this.xt(),this.t||(this.t=!0,this.i.trigger(o.SpeechSynthesisServiceEvent.TTSStart)),this.yt(e)}},this.yt=t=>{t.read().then((({done:e,value:i})=>{if(e)return void this.kt.next();let s=i.buffer;if(this.ut||(this.ut=!0,this._t.config(at(s)),s=nt(s)),void 0!==this.zt){const t=new Uint8Array(s),e=new Uint8Array(t.length+1);e[0]=this.zt,e.set(t,1),s=rt(e),this.zt=void 0}if(s.byteLength%2){const t=new Uint8Array(s),e=new Uint8Array(t.length-1);e.set(t.slice(0,t.length-1)),s=rt(e),this.zt=t[t.length-1]}this._t.play(s),this.yt(t)})).catch((()=>{this.kt.next()}))},this.xt=()=>{this.ut=!1,this.zt=void 0},this.Mt=()=>{this.t&&(this.t=!1,this.i.trigger(o.SpeechSynthesisServiceEvent.TTSStop))},this.U(t),this.kt=ot(this.wt,(()=>{})),this._t=function(t){let e,i,s,o=t,r=[],n=()=>{},a=0,c=!0;const h=()=>{e||(e=new AudioContext),e.state===q&&e.resume()},l=()=>{r.forEach((t=>{t.removeEventListener(G,d),t.stop(),t.disconnect()})),r=[]},u=()=>{(null==e?void 0:e.state)!==q&&(null==e||e.suspend()),s=new Float32Array,c=!0,a=0,r=[]},p=()=>{if(!e||!s.length)return;if(c&&s.length<4096)return void(c=!1);c=!1;const t=s.length,n=new AudioBuffer({sampleRate:o.sampleRate,length:t});for(let e=0;e{a=0,setTimeout((()=>{a||(u(),n())}),250)};return(()=>{const t=document.body,i=["touchend","click"];let s=!0;const o=()=>{s&&(e=new AudioContext,"closed"!==e.state&&e.resume().then((()=>{r()})))},r=()=>{i.forEach((e=>{t.removeEventListener(e,o)})),s=!1};i.forEach((e=>{t.addEventListener(e,o)}))})(),{play:t=>{h(),s=s?Y(s,t):J(t),p()},stop:()=>{e&&(l(),u(),n())},config:t=>{o=Object.assign(Object.assign({},o),t)},onEnd:t=>{n=t}}}({sampleRate:22050,numChannels:1}),this._t.onEnd(this.Mt),this.getVoices().then((t=>{this.l=t.filter((t=>t.default))[0]})),window.addEventListener("beforeunload",(()=>{this.cancel()}))}speak(t){"string"==typeof t&&t.trim().length&&this.kt.push(this.ft(t))}cancel(){this.t&&(this.dt.abort(),this._t.stop(),this.kt.cancel(),this.dt=new AbortController)}getVoices(){let t=this.lt;if(t.length)return Promise.resolve(t);const e=()=>{this.St=void 0};return this.St||(this.St=this.bt("voices").then((t=>this.vt(t,!1))).then((t=>t.json())).then((i=>{const s=i.voices||[];return t=s.map((t=>({name:t.name,lang:ct(t.culture),default:!!t.default}))),setTimeout(e),this.lt=t,t})).catch((()=>(setTimeout(e),t)))),this.St}getVoice(){return this.l}setVoice(t){return t&&Array.isArray(t)&&t.length?this.l&&1===t.length&&!t[0].name&&ct(t[0].lang)===this.l.lang?Promise.resolve():this.getVoices().then((e=>{if(!e.length)return Promise.reject(Error("TTSNoVoices"));return t.find((t=>{let i,s=!1;if(t.name){const s=ct(t.name);i=e.find((t=>s===ct(t.name)))}if(!i&&t.lang){const s=ct(t.lang);let o=e.filter((t=>s===t.lang));o.length||(o=e.filter((t=>s===t.lang.split("-")[0]))),i=o.find((t=>t.default))||o[0]}return i&&(this.l=i,s=!0),s}))?Promise.resolve():Promise.reject(Error("TTSNoMatch"))})):Promise.reject(Error("TTSEmptyParam"))}on(t,e){this.i.bind(t,e)}off(t,e){this.i.unbind(t,e)}}const ot=(t,e)=>{const i=[],s=()=>{i.length&&i[0].then(t).catch(e)};return{push:t=>{t.catch((()=>{const e=i.indexOf(t);e>0&&i.splice(e,1)})),i.push(t),1===i.length&&s()},cancel:()=>{i.length=0},next:()=>{i.shift(),s()}}},rt=t=>t.buffer.slice(t.byteOffset,t.byteLength+t.byteOffset),nt=t=>{const e=new Uint8Array(t),i=new Uint8Array(e.length-44);return i.set(e.slice(44,e.length)),rt(i)},at=t=>{const e=new DataView(t,0,44);return{numChannels:e.getUint16(22,true),sampleRate:e.getUint32(24,true)}},ct=t=>t.toLowerCase();class ht extends o.BaseChatConnection{constructor(t){super(t.dispatcher),this.url=t.url,this.authService=t.authService}open(){return this.isOpen()?Promise.resolve():navigator.onLine?this.Ct():(0,o.getRejectPromiseError)(o.CoreError.NetworkOffline)}close(){return this.isClosed()?Promise.resolve():this.Tt()}send(t){return new Promise(((e,i)=>{if(this.isOpen()){const s=new XMLHttpRequest;s.open("POST",this.url),(0,o.setRequestHeader)(s,"Content-Type","application/json"),s.onload=()=>{s.status>=200&&s.status<300?e(t):i(s.response)},s.onerror=()=>{i((0,o.getError)(o.CoreError.NetworkFailure))},this.$t(s,JSON.stringify(t)).catch(i)}else i((0,o.getError)(o.CoreError.ConnectionNone))}))}updateConnectionUrl(t){this.url=(0,s.getLongPollURL)(t.URI,{channelId:t.channelId,userId:t.userId},t.isTLS)}Ct(){return this.It||(this.It=new s.Deferred,this.setState(o.ConnectionState.Connecting),this.At().then((()=>{this.X(),this.Ot()})).catch((t=>{this.It&&(this.It.reject(t),this.It=null),this.tt()}))),this.It.promise}Tt(){return this.Et||(this.Lt.abort(),this.Et=new s.Deferred,this.setState(o.ConnectionState.Closing),setTimeout((()=>{this.tt()}),100)),this.Et.promise}At(){return new Promise(((t,e)=>{const i=new XMLHttpRequest;i.open("POST",this.url),(0,o.setRequestHeader)(i,"Content-Type","application/json"),i.onload=()=>{i.status>=200&&i.status<300?t():e(i.response)},i.onerror=()=>{e((0,o.getError)(o.CoreError.NetworkFailure))},this.$t(i,JSON.stringify(o.pingMessage)).catch((t=>{e(t)}))}))}Ot(){let t=0;this.isOpen()&&(this.Lt=new XMLHttpRequest,this.Lt.open("GET",this.url),this.Lt.onload=()=>{t=0,this.Lt.status&&200===this.Lt.status&&this.Pt(this.Lt.responseText),this.Ot()},this.Lt.onerror=()=>{5===t?this.close():(t++,this.Ot())},this.$t(this.Lt))}$t(t,e){return this.authService?new Promise(((i,s)=>{var r;null===(r=this.authService)||void 0===r||r.get().then((s=>{(0,o.setRequestHeader)(t,"Authorization",`Bearer ${s.token}`),t.send(e),i()})).catch((t=>{s(t)}))})):(t.send(e),Promise.resolve())}Pt(t){try{JSON.parse(t).forEach((t=>{this.et(JSON.parse(t))}))}catch(t){this.st(t)}}X(){this.It&&(this.It.resolve(),this.It=null),this.Et&&(this.Et.reject(),this.Et=null),this.setState(o.ConnectionState.Open),this.dispatcher.trigger(o.CoreEvent.Open)}tt(){this.Et&&(this.Et.resolve(),this.Et=null),this.It=null,this.setState(o.ConnectionState.Closed),this.dispatcher.trigger(o.CoreEvent.Close)}et(t){ft(t),this.dispatcher.trigger(o.CoreEvent.Message,t),this.dispatcher.trigger(o.CoreEvent.MessageReceived,t);const e=t.messagePayload;if(e.type===o.MessageType.ExecuteApplicationActionCommand){const t=e;this.dispatcher.trigger(t.actionType,t)}}st(t){this.dispatcher.trigger(o.CoreEvent.Error,t)}}const lt=Promise,ut=3e6,pt=window;class dt extends o.BaseChatConnection{constructor(t){super(t.dispatcher),this.jt=!1,this.Ft=!1,this.Vt=!1,this.Ht=0,this.Dt=!1,this.Rt=null,this.url=t.url,this.authService=t.authService,this.Nt=t.retryInterval,this.Ut=t.retryMaxAttempts}open(){return this.isOpen()?lt.resolve():navigator.onLine?this.Ct():(0,o.getRejectPromiseError)(o.CoreError.NetworkOffline)}close(){return this.jt=!0,clearTimeout(this.Bt),this.isClosed()?lt.resolve():this.Tt()}send(t){return new lt(((e,i)=>{if(this.Rt&&this.isOpen()){this.Vt=!0;try{this.Rt.send(JSON.stringify(t)),e(t),(0,o.isPing)(t)||(this.dispatcher.trigger(o.CoreEvent.Message,t),this.dispatcher.trigger(o.CoreEvent.MessageSent,t))}catch(t){i((0,o.getError)(o.CoreError.NetworkFailure))}}else i((0,o.getError)(o.CoreError.ConnectionNone))}))}updateConnectionUrl(t){this.url=(0,s.getWebSocketURL)(t.URI,{channelId:t.channelId,userId:t.userId},t.isTLS,t.channel)}setSuggestionPromise(t){this.Wt=t}Ct(){return this.It||(this.It=new s.Deferred,this.setState(o.ConnectionState.Connecting),this.At()),this.It.promise}Tt(){var t;return this.Et||(null===(t=this.Rt)||void 0===t||t.close(),this.Et=new s.Deferred,this.setState(o.ConnectionState.Closing)),this.Et.promise}At(){try{this.Rt=new WebSocket(this.url),this.Rt.onopen=()=>{this.setState(o.ConnectionState.Open),this.Dt=!1,this.authService?this.Zt():this.X()},this.Rt.onclose=t=>{this.Gt(),this.jt?(this.setState(o.ConnectionState.Closed),this.qt(o.CoreError.ConnectionExplicitClose,t)):this.authService&&!this.Vt&&1006!==t.code?(this.setState(o.ConnectionState.Closed),this.qt(o.CoreError.AuthExpiredToken,t)):this.Dt||this.Yt(t)},this.Rt.onmessage=this.et.bind(this),this.Rt.onerror=()=>{this.Yt(),this.Dt=!0,this.st.bind(this)}}catch(t){this.Yt()}}Yt(t){this.setState(o.ConnectionState.Connecting),this.Ht{this.send(function(t){return{state:{token:t,tokenType:o.TokenType.JWT,type:o.StateType.Auth}}}(t.token)).then((()=>{setTimeout((()=>this.Vt=!0),1e4),this.X()}))})).catch((t=>{var e;null===(e=this.It)||void 0===e||e.reject(t),this.close()}))}X(){var t;this.Gt(),clearTimeout(this.Bt),this.Jt=this.Kt(),this.Xt=(t=this,pt.setTimeout((()=>{gt(t)}),ut)),this.Ht=0,this.jt=!1,this.Vt=!1,this.It&&(this.It.resolve(),this.It=null),this.Et&&(this.Et.reject(),this.Et=null),this.dispatcher.trigger(o.CoreEvent.Open)}tt(t){this.Ht=0,this.jt=!1,this.Vt=!1,this.Et&&(this.Et.resolve(),this.Et=null),this.It=null,this.dispatcher.trigger(o.CoreEvent.Close,t)}et(t){try{const e=JSON.parse(t.data);if((0,o.isPong)(e))this.Ft=!0;else if(e.suggestions&&this.Wt)this.Wt.resolve(e.suggestions);else{ft(e),this.dispatcher.trigger(o.CoreEvent.Message,e),this.dispatcher.trigger(o.CoreEvent.MessageReceived,e);const t=e.messagePayload;if(t.type===o.MessageType.ExecuteApplicationActionCommand){const e=t;this.dispatcher.trigger(e.actionType,e)}}}catch(t){this.st(t)}}st(t){this.dispatcher.trigger(o.CoreEvent.Error,t)}Kt(){return pt.setInterval((()=>{this.send(o.pingMessage).then((()=>{this.Ft=!1,this.Qt=pt.setTimeout((()=>{this.isOpen()&&!this.Ft&>(this)}),1e4)}))}),3e4)}Gt(){clearTimeout(this.Xt),clearInterval(this.Jt),clearTimeout(this.Qt)}}function gt(t){t.close().then((()=>t.open()))}class mt{constructor(t){this.te=t,t.isLongPoll&&(this.te.retryInterval=2e3,this.te.retryMaxAttempts=5),this.i=(0,s.generateEventDispatcher)(),this.ee=new dt({authService:t.authService,url:(0,s.getWebSocketURL)(t.baseURL,t.searchParams,t.isTLS,t.channel),retryInterval:t.retryInterval,retryMaxAttempts:t.retryMaxAttempts,dispatcher:this.i}),this.ie=this.ee}open(){return this.te.isLongPoll?new Promise(((t,e)=>{this.ee.open().then((()=>{this.se(t)})).catch((()=>{this.oe(t,e)}))})):this.ie.open()}close(){return clearTimeout(this.re),this.ie.close()}send(t){return this.ie.send(t)}isOpen(){return this.ie.isOpen()}isClosed(){return this.ie.isClosed()}getState(){return this.ie.getState()}updateConnectionUrl(t){var e;this.ee.updateConnectionUrl(t),this.te=Object.assign(Object.assign({},this.te),{baseURL:t.URI,searchParams:{channelId:t.channelId,userId:t.userId},isTLS:t.isTLS,channel:t.channel}),null===(e=this.ne)||void 0===e||e.updateConnectionUrl(t)}on(t,e){this.i.bind(t,e)}off(t,e){this.i.unbind(t,e)}setSuggestionPromise(t){this.ee.setSuggestionPromise(t)}se(t){var e;this.ie=this.ee,clearTimeout(this.re),(null===(e=this.ne)||void 0===e?void 0:e.isOpen())&&this.ne.close(),t()}oe(t,e){this.ie=this.ae(),this.ie.open().then((()=>{this.re=this.ce(),t()})).catch((t=>{e(t)}))}ae(){return this.ne||(this.ne=new ht({url:(0,s.getLongPollURL)(this.te.baseURL,this.te.searchParams,this.te.isTLS),authService:this.te.authService,dispatcher:this.i})),this.ne}ce(){return window.setTimeout((()=>{this.ie.close().then((()=>{this.open()}))}),3e5)}}const ft=t=>{const e=t.messagePayload;e&&e.type===o.MessageType.TextStream&&(e.streamState=e.streamState.toLowerCase())},bt={isLongPoll:!1,isTLS:!0};class vt{constructor(t){this.he=(t,e,i)=>{let s=!1;return(t&&t!==this.U.URI||e&&e!==this.U.channelId||i&&i!==this.U.userId)&&(s=!0),s},this.le=(t,e,i)=>new Promise(((s,o)=>{t&&"string"==typeof t&&t.length&&(this.U.URI=t),this.N?this.N.get().then((t=>{this.U.channelId=t.getClaim("channelId"),this.U.userId=t.getClaim("userId"),this.L.updateConnectionUrl({URI:this.U.URI,channelId:this.U.channelId,userId:this.U.userId,isTLS:this.U.isTLS,channel:this.U.channel}),s()})).catch((t=>o(t))):("string"==typeof e&&e.length&&(this.U.channelId=e),"string"==typeof i&&i.length&&(this.U.userId=i),this.L.updateConnectionUrl({URI:this.U.URI,channelId:this.U.channelId,userId:this.U.userId,isTLS:this.U.isTLS,channel:this.U.channel}),s())})),this.U=Object.assign(Object.assign({},bt),t),this.U.tokenGenerator&&(this.N=s.AuthTokenService.getInstance()),this.L=new mt({baseURL:this.U.URI,isLongPoll:this.U.isLongPoll,isTLS:this.U.isTLS,channel:this.U.channel,retryInterval:void 0!==this.U.retryInterval&&this.U.retryInterval>=0?1e3*this.U.retryInterval:5e3,retryMaxAttempts:void 0!==this.U.retryMaxAttempts&&this.U.retryMaxAttempts>=0?this.U.retryMaxAttempts:5,searchParams:{channelId:this.U.channelId,userId:this.U.userId},authService:this.N}),window.addEventListener("online",(()=>this.open())),window.addEventListener("offline",(()=>this.close()))}open(t){const{URI:e,userId:i,channelId:s}=t||{};if(this.isOpen()){if(this.he(e,s,i)){const t=e&&this.U.URI!==e;return!this.N||t?this.close().then((()=>this.le(e,s,i).then((()=>this.L.open())))):Promise.resolve()}return Promise.resolve()}return this.le(e,s,i).then((()=>this.L.open()))}close(){return this.L.close()}getState(){return this.L.getState()}isOpen(){return this.L.isOpen()}send(t,e,i){let s;if(s="string"==typeof t?(0,o.buildUserTextMessage)(t,e):(0,o.isPostbackPayload)(t)?(0,o.buildPostbackMessage)(t):(0,o.isMessagePayload)(t)?(0,o.buildUserMessage)(t):t,!(0,o.isValidMessage)(s))return(0,o.getRejectPromiseError)(o.CoreError.MessageInvalid);if(i){const{sdkMetadata:t,threadId:e}=i;t&&(s=this.ue(s,t)),e&&(s.threadId=e)}return s.userId=this.U.userId,this.L.send(s)}updateUser(t,e){let i=t;return(null==e?void 0:e.sdkMetadata)&&(i=this.ue(t,e.sdkMetadata)),this.L.send(i)}sendDeviceToken(t,e){const i={state:{type:"token",deviceToken:t,deviceType:e,"store.undelivered.messages":!1,"notify.undelivered.skill.messages":!1}};return this.L.send(i)}getSuggestions(t){const e=new s.Deferred;this.L.setSuggestionPromise(e);const i={messagePayload:{query:t,threshold:30,type:o.MessageType.Suggest}};return this.L.send(i).catch(null==e?void 0:e.reject),setTimeout((()=>{null==e||e.reject((0,o.getError)(o.CoreError.SuggestionsTimeout))}),1e4),null==e?void 0:e.promise}on(t,e){this.L.on(t,e)}off(t,e){this.L.off(t,e)}ue(t,e){return e&&(t.sdkMetadata=Object.assign(Object.assign({},t.sdkMetadata),e)),t}}const wt=25,xt=1024*wt*1024,yt="channelId",kt="userId";class _t{static getInstance(){return this.v||(this.v=new _t),this.v}setParams(t){this.gt=t,t.tokenGenerator?(this.N=s.AuthTokenService.getInstance(),this.N.get().then((e=>{t[yt]=e.getClaim(yt),t[kt]=e.getClaim(kt),this.pe=zt(t)}))):this.pe=zt(t)}upload(t,e){return new Promise(((i,s)=>{const r=t.size;if(0===r)return void s(Error(o.CoreError.UploadZeroSize));if(r>xt)return void s(Error(o.CoreError.UploadMaxSize));const n=new XMLHttpRequest,a=()=>s(Error(o.CoreError.UploadNetworkFail));(0,o.requestOn)(n,"readystatechange",(()=>{if(4===n.readyState)switch(n.status){case 200:{const t=JSON.parse(n.responseText);i(t);break}case 413:s(Error(o.CoreError.UploadMaxSize));break;case 415:s(Error(o.CoreError.UploadBadFile));break;default:a()}})),(0,o.requestOn)(n,"abort",a),(0,o.requestOn)(n,"error",a),(0,o.requestOn)(n,"timeout",a),this.gt.tokenGenerator?this.N.get().then((i=>this.ge(n,{file:t,options:e,token:i.token}))).catch((t=>s(t))):this.ge(n,{file:t,options:e})}))}ge(t,{file:e,options:i,token:s}){const r=new FormData;r.append("attachment",e,encodeURI(e.name)),t.open("POST",this.pe),(0,o.setRequestHeader)(t,"x-oda-meta-file-size",e.size.toString()),s&&((0,o.setRequestHeader)(t,"Authorization",`Bearer ${s}`),this.gt.enableAttachmentSecurity&&((0,o.setRequestHeader)(t,"x-oda-meta-file-isProtected","True"),(0,o.setRequestHeader)(t,"x-oda-meta-file-authType","ChannelClientAuth"))),t.send(r),i&&i.onInitUpload&&i.onInitUpload(t)}}function zt(t){const e=`http${t.isTLS?"s":""}://`,{URI:i,channelId:o,userId:r}=t;return(0,s.buildURL)(e,i,{channelId:o,userId:r},"/chat/v1/attachments")}const Mt={AUDIO:".aac, .amr, .m4a, .mp3, .mp4a, .mpga, .oga, .ogg, .wav, audio/*",FILE:".7z, .csv, .doc, .docx, .eml, .ics, .key, .log, .msg, .neon, .numbers, .odt, .pages, .pdf, .pps, .ppsx, .ppt, .pptx, .rtf, .txt, .vcf, .xls, .xlsx, .xml, .yml, .yaml, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document",IMAGE:".gif, .jfif, .jpeg, .jpg, .png, .svg, .tif, .tiff, .webp, image/*",VIDEO:".3g2, .3gp, .avi, .m4v, .mov, .mp4, .mpeg, .mpg, .ogv, .qt, .webm, .wmv, video/*",ALL:""};Mt.ALL=`${Mt.AUDIO},${Mt.FILE},${Mt.IMAGE},${Mt.VIDEO}`;const St={oracle:"oracle",platform:"platform"},Ct=St.oracle;class Tt{constructor(t){this.U=t,this.me=null,this.fe=new Map,this.U.URI=(0,s.stripHTTP)(t.URI),this.be(t),this.ve=new vt(t),this.ve.on(o.CoreEvent.Open,(()=>{var t,e;const i=this.U;null===(t=this.we)||void 0===t||t.setParams(i),null===(e=this.xe)||void 0===e||e.setConfig(i)}))}connect(t){return t&&(t.URI&&(t.URI=(0,s.stripHTTP)(t.URI)),this.U=Object.assign(Object.assign({},this.U),t)),this.ve.open(t)}disconnect(){const t=this.ve.close();return t.then(this.ye.bind(this)),t}getState(){return this.ve.getState()}isConnected(){return this.ve.isOpen()}sendMessage(t,e){if(!t)return(0,o.getRejectPromiseError)(o.CoreError.MessageInvalid);let i="",s="";if("string"==typeof t)s=t;else if((0,o.isMessagePayload)(t)){s=t.text}return this.me&&this.me.text===s&&(i=this.me.requestId),this.me=null,this.ve.send(t,i,Object.assign(Object.assign({},e),{threadId:(null==e?void 0:e.threadId)||this.ke}))}updateChatContext(t,e,i,s){return this.sendMessage({messagePayload:Object.assign({type:o.MessageType.UpdateApplicationContextCommand,source:o.ContextSource.ChatWindow,context:t},e)},{sdkMetadata:s,threadId:i})}updateUser(t,e){return(0,o.isValidProfileMessage)(t)?this.ve.updateUser(t,Object.assign(Object.assign({},e),{threadId:this.ke})):(0,o.getRejectPromiseError)(o.CoreError.ProfileInvalid)}sendDeviceToken(t,e){return this.ve.sendDeviceToken(t,e)}setCurrentThreadId(t){this.ke=t}uploadAttachment(t,e){return this.isConnected()?this.we?this.we.upload(t,e).then((t=>(0,o.buildUserAttachmentMessage)(t.type,t.url,t.fileName))):(0,o.getRejectPromiseError)(o.CoreError.UploadNotAvailable):(0,o.getRejectPromiseError)(o.CoreError.ConnectionNone)}sendAttachment(t,e){return this.uploadAttachment(t,e).then((t=>this.ve.send(t,"",{sdkMetadata:null==e?void 0:e.sdkMetadata})))}sendLocation(t){return this.isConnected()?t?(0,o.isValidLocation)(t)?this.ve.send({messagePayload:{type:o.MessageType.Location,location:t}}):(0,o.getRejectPromiseError)(o.CoreError.LocationInvalid):(0,o.getCurrentPosition)().then((t=>this.ve.send({messagePayload:{type:o.MessageType.Location,location:{latitude:t.latitude,longitude:t.longitude}}}))):(0,o.getRejectPromiseError)(o.CoreError.ConnectionNone)}sendUserTypingStatus(t,e){return this.sendMessage((0,o.buildUserMessage)({partyType:"user",source:"sdk",status:t,type:o.MessageType.Status,text:e}))}getSuggestions(t){return t?"string"!=typeof t?(0,o.getRejectPromiseError)(o.CoreError.SuggestionsInvalidRequest):this.ve.getSuggestions(t):(0,o.getRejectPromiseError)(o.CoreError.SuggestionsEmptyRequest)}destroy(){this.disconnect();for(const t in this)this[t]&&delete this[t]}setTTSService(t){this._e="string"==typeof t?this.ze(t):t}getTTSService(){return this._e}getTTSVoices(){return this._e?this._e.getVoices():(0,o.getRejectPromiseError)(o.CoreError.TtsNotAvailable)}setTTSVoice(t){return this._e?this._e.setVoice(t):(0,o.getRejectPromiseError)(o.CoreError.TtsNotAvailable)}getTTSVoice(){if(this._e)return this._e.getVoice();throw(0,o.getError)(o.CoreError.TtsNotAvailable)}speakTTS(t,e){if(this._e){let i;if("string"==typeof t)i=t;else{if(!(0,o.isValidMessage)(t))return;i=(0,o.getUtteranceText)(t,e)}this._e.speak(i)}}cancelTTS(){this._e&&this._e.cancel()}startRecognition(t){return this.xe?this.isConnected()?this.xe.startRecognition(Object.assign(Object.assign({},t),{onRecognitionText:e=>{"final"===e.type&&(this.me=e),t.onRecognitionText(e)}})):(0,o.getRejectPromiseError)(o.CoreError.ConnectionNone):(0,o.getRejectPromiseError)(o.CoreError.RecognitionNotAvailable)}stopRecognition(){return this.xe?this.xe.stopRecognition():(0,o.getRejectPromiseError)(o.CoreError.RecognitionNotAvailable)}setRecognitionLocale(t){if(t&&"string"==typeof t&&this.xe){const e=t.toLowerCase();this.xe.setLocale(e)}}on(t,e){var i;switch(t){case o.SpeechSynthesisServiceEvent.TTSStart:case o.SpeechSynthesisServiceEvent.TTSStop:null===(i=this._e)||void 0===i||i.on(t,e);break;default:this.ve.on(t,e)}}off(t,e){var i;switch(t){case o.SpeechSynthesisServiceEvent.TTSStart:case o.SpeechSynthesisServiceEvent.TTSStop:null===(i=this._e)||void 0===i||i.off(t,e);break;default:this.ve.off(t,e)}}getAuthToken(){var t;return null===(t=this.N)||void 0===t?void 0:t.get()}ye(){}be(t){t.URI=t.URI.replace(/^https?:\/\//gi,(t=>(console.warn(`Please remove "${t}" from URI.`),""))),this.Me(t),this.Se(t),this.Ce(t),this.xe=D.getInstance()}Me(t){t.enableAttachment&&(this.we=_t.getInstance())}Se(t){t.tokenGenerator&&(this.N=s.AuthTokenService.getInstance(),this.N.setFetch(t.tokenGenerator))}Ce(t){if(t.isTTS){let e;const i=t.TTSService;e=i?"string"==typeof i?this.ze(i):i:this.ze(Ct),this._e=e}}ze(t){const e=this.fe.get(t);if(e)return e;let i;try{t===St.oracle?i=new st(this.U):t===St.platform&&(i=new g),this.fe.set(t,i)}catch(t){console.log(t)}return i}}Tt.TTS=St},356:function(t,e,i){i.r(e),i.d(e,{ChatEvent:function(){return o},ContextualWidgetComponent:function(){return Es},DOMUtil:function(){return ai},Logger:function(){return $t},MESSAGE_SIDE:function(){return Ot},MessageComponent:function(){return Et},MessageComponentFactory:function(){return $e},SDK_VERSION:function(){return Ft},ShareCategory:function(){return Oe},StorageType:function(){return Ie},WidgetComponent:function(){return Cs},WidgetTheme:function(){return Ae},addDefaultSettings:function(){return ti},configureColorCustomization:function(){return Ye},configureLocale:function(){return We},debounce:function(){return Ze},getFieldInputValues:function(){return Je},isAnyVoiceAvailable:function(){return Pe},mergeTranslationStrings:function(){return Qe},syncTTSLocaleIfUnavailable:function(){return Ne}});var s=i(396);const o=Object.assign(Object.assign(Object.assign({},s.SpeechSynthesisServiceEvent),{CHAT_LANG:"chatlanguagechange",CLICK_AUDIO_RESPONSE_TOGGLE:"click:audiotoggle",CLICK_ERASE:"click:erase",CLICK_VOICE_TOGGLE:"click:voicetoggle",DESTROY:"destroy",CHAT_END:"chatend",MESSAGE:"message",MESSAGE_RECEIVED:"message:received",MESSAGE_SENT:"message:sent",NETWORK:"networkstatuschange",READY:"ready",TYPING:"typing",UNREAD:"unreadCount",WIDGET_CLOSED:"widget:closed",WIDGET_OPENED:"widget:opened",WIDGET_SHOW:"widget:show",WIDGET_HIDE:"widget:hide"}),s.ExecuteActionType),r=()=>{var t;return(null===(t=navigator.languages)||void 0===t?void 0:t.map((t=>t.toLowerCase())))||[]},n=t=>{let e;try{e=window[t];const i="__storage_test__";return e.setItem(i,i),e.removeItem(i),!0}catch(t){return t instanceof DOMException&&(22===t.code||1014===t.code||"QuotaExceededError"===t.name||"NS_ERROR_DOM_QUOTA_REACHED"===t.name)&&e&&0!==e.length}};var a=i(476);const c=q(''),h=q(''),l=q(''),u=q(''),p=q(''),d=q(''),g=q(''),m=q(''),f=q(''),b=q(''),v=q(''),w=q(''),x=q(''),y=q(''),k=q(''),_=q(''),z='',M=q(''),S=q(''),C=q(''),T=q(''),$=q(''),I=q(''),A=q(''),O=q(''),E=q(''),L=q(''),P=q(''),j=q(''),F=q(''),V=q(''),H=q(''),D=q(''),R=q(''),N=q('',"20"),U=q('',"20"),B=q('',"20"),W=q('',"16"),Z=q('',"16"),G=q('');function q(t,e){return`${t}`}function Y(t){return t.filter((t=>{const e=t.getActionType();return e===s.ActionType.Postback||e===s.ActionType.Location||e===s.ActionType.SubmitForm}))}var J=function(t,e,i,s){return new(i||(i=Promise))((function(o,r){function n(t){try{c(s.next(t))}catch(t){r(t)}}function a(t){try{c(s.throw(t))}catch(t){r(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(n,a)}c((s=s.apply(t,e||[])).next())}))};const K=/\b(?:(?:https?|ftp):\/\/|(www\.))[-a-z0-9+&@#/%?=~_|!:,.;]*[-a-z0-9+&@#/%=~_|]/gimu,X=(t,e,i)=>{const s=Q(t),o=st(s).replace((0,a.resetRegex)(K),at(i,e)),r=ot(o);return vt(r,e)},Q=t=>{let e;try{e=(0,a.parseDOM)(t)}catch(e){return t}return tt(e),et(e),e.innerHTML},tt=t=>(t.querySelectorAll("a").forEach((t=>{t.outerHTML=it(t.outerHTML)})),t),et=t=>{t.querySelectorAll("*").forEach((t=>{if("A"!==t.tagName){const e=t.attributes;for(let t=0;tt.replace(/(https?|www)/gim,nt),st=t=>t.replace(/<|>| |&/gim,nt),ot=t=>{let e=t;return rt.forEach(((t,i)=>{e=e.replace(new RegExp(i,"g"),t)})),rt.clear(),e},rt=new Map,nt=t=>{const e=performance.now().toString(36).replace(".","_")+Math.random().toString(36).substring(2);return rt.set(e,t),e},at=(t,e)=>(i,s)=>{if(t){const t=ct(i,e);if(t)return t}return`${i}`},ct=(t,e)=>{let i,s;try{const e=t.toLowerCase().startsWith("https")?new URL(t):new URL(`https://${t}`);i=e.hostname.toLowerCase()}catch(t){return s}return ft.some((o=>{const r=i.includes(o.name);if(r){const i=wt();"videohub"!==o.name&&ht(o.url,t,e,i),s=o.getEmbed(o.getId(t),i,e)}return r})),s},ht=(t,e,i,s)=>J(void 0,void 0,void 0,(function*(){const o=`${t}?url=${e}`;try{const t=yield fetch(o);if(!t.ok)return;const e=yield t.json();if(e&&e.html){const t=e.html.replace("xt(`src="https://www.youtube.com/embed/${t}" allow="accelerometer; encrypted-media; gyroscope; picture-in-picture"`,e,i,"youtube"),getId:t=>bt(t,lt)},{name:"videohub",url:"",getEmbed:(t,e,i)=>{const s="flashvars";return xt(`src="https://cdnapisec.kaltura.com/p/2171811/sp/217181100/embedIframeJs/uiconf_id/35965902/partner_id/2171811?iframeembed=true&playerId=kaltura_player&entry_id=${t}&${s}[streamerType]=auto&${s}[localizationCode]=en&${s}[sideBarContainer.plugin]=true&${s}[sideBarContainer.position]=left&${s}[sideBarContainer.clickToClose]=true&${s}[chapters.plugin]=true&${s}[chapters.layout]=vertical&${s}[chapters.thumbnailRotator]=false&${s}[streamSelector.plugin]=true&${s}[EmbedPlayer.SpinnerTarget]=videoHolder&${s}[dualScreen.plugin]=true&${s}[hotspots.plugin]=1&${s}[Kaltura.addCrossoriginToIframe]=true&&wid=1_yz4xoltb" ${mt}`,e,i,"ovh")},getId:t=>bt(t,ut)},{name:"vimeo",url:"https://vimeo.com/api/oembed.json",getEmbed:(t,e,i)=>xt(`src="https://player.vimeo.com/video/${t}" allow="fullscreen; picture-in-picture"`,e,i,"vimeo"),getId:t=>bt(t,pt)},{name:"dai",url:"https://www.dailymotion.com/services/oembed",getEmbed:(t,e,i)=>xt(`src="https://geo.dailymotion.com/player.html?video=${t}" allow="fullscreen; picture-in-picture; web-share"`,e,i,"dailymotion"),getId:t=>bt(t,dt)}],bt=(t,e)=>{let i;return t.replace((0,a.resetRegex)(e),((t,e)=>(e&&e.length&&(i=e),t))),i},vt=(t,e)=>{const i=(0,a.parseDOM)(t);if(!i)return t;const s=i.querySelectorAll("video"),o=`${e}-video-wrapper`;return s.forEach((t=>{t.classList.add(o)})),i.innerHTML},wt=()=>`${Date.now()}-${Math.floor(1e3*Math.random())}`,xt=(t,e,i,s)=>`
`;class yt{constructor(t,e){var i,o;this.util=t,this.Te=!1,this.$e=e.type,this.Ie=e.label,this.Ae=e.imageUrl,this.Oe=e.style,this.Ee=e.tooltip,this.Le=e.displayType,this.Pe=null===(i=e.channelExtensions)||void 0===i?void 0:i.activeImageUrl,this.je=null===(o=e.channelExtensions)||void 0===o?void 0:o.c2kText,this.$e!==s.ActionType.SubmitForm||this.Oe||(this.Oe=s.ActionStyle.Primary)}render(){const t=this.util,e=t.createButton(["action-postback",this.Oe===s.ActionStyle.Primary?"primary":this.Oe===s.ActionStyle.Danger?"danger":""]);if(this.Le===s.ActionDisplayType.Icon&&t.addCSSClass(e,s.ActionDisplayType.Icon),e.onclick=this.handleOnClick.bind(this),this.Ae&&e.appendChild(t.createImage(this.Ae,["action-image"],this.Ie||"")),this.Ie){const i=X(this.Ie,t.cssPrefix),o=t.createTextDiv();if(this.Le===s.ActionDisplayType.Link){const s=t.createAnchor("",i);s.onclick=t=>t.preventDefault(),o.appendChild(s),t.addCSSClass(e,"display-link")}else this.je?(o.innerHTML=String.fromCharCode(parseInt(this.Ie)+10111),t.addCSSClass(e,"c2k-action"),e.addEventListener("mouseover",(()=>{o.innerHTML=String.fromCharCode(parseInt(this.Ie)+10121);for(const e of Array.from(document.getElementsByClassName(this.je)))t.addCSSClass(e,"highlight")})),e.addEventListener("mouseleave",(()=>{o.innerHTML=String.fromCharCode(parseInt(this.Ie)+10111);for(const e of Array.from(document.getElementsByClassName(this.je)))t.removeCSSClass(e,"highlight")}))):o.innerHTML=i;e.appendChild(o)}if(this.Te&&t.addCSSClass(e,"disabled"),this.Ee){const i=t.createDiv(["action-wrapper"]),s=t.createDiv(),o=t.createTextDiv(["tooltip","none"]);return o.innerText=this.Ee,o.setAttribute("role","tooltip"),s.appendChild(o),i.appendChild(e),i.appendChild(s),i}return this.Fe=e,e}handleOnClick(t){if(this.onActionClick&&!this.Te){const t={getPayload:this.getEventPayload.bind(this),label:this.Ie,imageUrl:this.Pe||this.Ae,type:this.$e};this.Pe&&this.Fe.lastElementChild.replaceWith(this.util.createImage(this.Pe,["action-image"],this.Ie||"")),this.onActionClick(t)}this.$e!==s.ActionType.Postback&&this.$e!==s.ActionType.Location&&this.$e!==s.ActionType.Share||(t.preventDefault(),t.stopPropagation())}disable(){this.Te=!0,this.Fe&&(this.util.addCSSClass(this.Fe,"disabled"),this.Fe.disabled=!0)}enable(){this.Te=!1,this.Fe&&(this.util.removeCSSClass(this.Fe,"disabled"),this.Fe.disabled=!1)}getActionType(){return this.$e}}class kt extends yt{constructor(t,e){super(t,e),this.Ve=e.phoneNumber}render(){const t=this.util,e=super.render();"button"===e.tagName.toLowerCase()?t.addCSSClass(e,"action-call"):t.addCSSClass(e.firstElementChild,"action-call");const i=t.createAnchor(`tel:${this.Ve}`,"");return this.onActionClick=()=>{i.click()},e}getEventPayload(){return Promise.resolve(this.Ve)}}class _t extends yt{render(){const t=this.util,e=super.render();return"button"===e.tagName.toLowerCase()?t.addCSSClass(e,"action-location"):t.addCSSClass(e.firstElementChild,"action-location"),e}getEventPayload(){return(0,s.getCurrentPosition)()}}class zt extends yt{constructor(t,e,i,s){super(t,e),this.He=i,this.De=s,this.Re=e.popupContent}render(){const t=this.util,e=super.render();"button"===e.tagName.toLowerCase()?t.addCSSClass(e,"action-popup"):t.addCSSClass(e.firstElementChild,"action-popup");const i=function(t,e,i,o){const r=t.createDiv(["wrapper","popup-content-wrapper","none"]),n=t.createDiv(["popup-dialog"]),a=$e.fromMessage(i,t,{messagePayload:e});return a.onActionClick=e=>{(e.type!==s.ActionType.SubmitForm||a.validateForm())&&(t.addCSSClass(r,"none"),o(e))},n.appendChild(a.render()),r.appendChild(n),r.onclick=e=>{n.contains(e.target)||t.addCSSClass(r,"none")},r}(t,this.Re,this.He,this.De);return document.body.appendChild(i),this.onActionClick=()=>{t.removeCSSClass(i,"none")},e}getEventPayload(){return Promise.resolve(this.Re)}}class Mt extends yt{constructor(t,e){super(t,e),this.Ne=e.postback}getEventPayload(){return Promise.resolve(this.Ne)}}class St extends yt{constructor(t,e,i){super(t,e),this.Ue=i}render(){const t=this.util,e=super.render();return"button"===e.tagName.toLowerCase()?t.addCSSClass(e,"action-share"):t.addCSSClass(e.firstElementChild,"action-share"),e}getEventPayload(){return Promise.resolve(this.Ue)}}class Ct extends yt{constructor(t,e){super(t,e),this.Ne=e.postback}getEventPayload(){return Promise.resolve(this.Ne)}}class Tt extends yt{constructor(t,e,i=!1,s){super(t,e),this.Be=i,this.We=s,this.P=e.url}render(){const t=this.util,e=super.render();if("button"===e.tagName.toLowerCase()?t.addCSSClass(e,"action-url"):t.addCSSClass(e.firstElementChild,"action-url"),this.P){const i=t.createAnchor(this.P,"",[],this.Be,this.We);e.onclick=()=>{i.click()}}return e}getEventPayload(){return Promise.resolve(this.P)}}class $t{constructor(t){this.Ze=t}debug(...t){this.Ge($t.LOG_LEVEL.DEBUG,t)}error(...t){this.Ge($t.LOG_LEVEL.ERROR,t)}info(...t){this.Ge($t.LOG_LEVEL.INFO,t)}warn(...t){this.Ge($t.LOG_LEVEL.WARN,t)}Ge(t,e){if($t.logLevel>=t){let i;switch(e.unshift(`[${$t.appName}.${$t.appVersion}.${this.Ze}]`),t){case $t.LOG_LEVEL.ERROR:i=console.error;break;case $t.LOG_LEVEL.WARN:i=console.warn;break;case $t.LOG_LEVEL.INFO:i=console.info;break;case $t.LOG_LEVEL.DEBUG:i=console.debug}i.apply(console,e)}}}$t.LOG_LEVEL={NONE:0,ERROR:1,WARN:2,INFO:3,DEBUG:4},$t.logLevel=$t.LOG_LEVEL.NONE;class It extends yt{constructor(t,e,i){super(t,e),this.qe=e,this.Ue=i}render(){const t=this.util,e=super.render();return"button"===e.tagName.toLowerCase()?t.addCSSClass(e,"action-client"):t.addCSSClass(e.firstElementChild,"action-client"),e}getEventPayload(){return this.qe.actionType===s.ClientActionType.COPY_MESSAGE_TEXT?Promise.resolve(this.Ue):Promise.resolve(this.qe)}}class At{static fromActionPayload(t,e,i,o,r){switch(t.type){case s.ActionType.Postback:return new Mt(e,t);case s.ActionType.Url:return new Tt(e,t,i.openLinksInNewWindow,i.linkHandler);case s.ActionType.Webview:return new Tt(e,t,i.openLinksInNewWindow,r.webviewLinkHandler);case s.ActionType.Location:return new _t(e,t);case s.ActionType.Call:return new kt(e,t);case s.ActionType.Share:return new St(e,t,o);case s.ActionType.SubmitForm:return new Ct(e,t);case s.ActionType.Popup:return new zt(e,t,i,r.onMessageActionClicked);case s.ActionType.Client:return new It(e,t,o);default:return At.logger.error(`Payload contains wrong action type:${t.type}`),null}}}At.logger=new $t("ActionComponentFactory");const Ot={LEFT:"left",RIGHT:"right"};class Et{constructor(t,e,i,o,r,n){this.settings=t,this.util=e,this.payload=i,this.side=o,this.source=r,this.options=n,this.actions=[],this.globalActions=[],this.Ye=[],this.locale=t.locale,this.translations=t.i18n[this.locale],this.shareText=function(t){let e="";switch(t.type){case s.MessageType.Card:return t.cards.forEach((t=>{var i;e+=(t.title?`${t.title} - `:"")+(t.description?`${t.description} - `:"")+(null!==(i=t.url)&&void 0!==i?i:"")+"\n"})),e;case s.MessageType.Text:return t.text;case s.MessageType.Attachment:return t.attachment.url;case s.MessageType.Location:const i=t.location;return`${i.title?`${i.title} - `:""}${i.latitude}, ${i.longitude}`;case s.MessageType.Table:t.rows.forEach((t=>{t.fields.forEach((t=>{e+=t.value?`${t.value} - `:""}))}));break;case s.MessageType.Form:t.forms.forEach((t=>{const i=qe(t);e+=i?`${i} - `:""}));break;case s.MessageType.EditForm:const o=t;e=o.title?`${o.title} - `:"",(0,s.isEditFormPayloadWithFields)(o)?o.fields.forEach((t=>{(0,s.isReadOnlyField)(t)?e+=t.value?`${t.value} - `:"":e+=t.label?`${t.label} - `:""})):o.formRows.forEach((t=>{t.columns.forEach((t=>{t.fields.forEach((t=>{(0,s.isReadOnlyField)(t)?e+=t.value?`${t.value} - `:"":e+=t.label?`${t.label} - `:""}))}))}));break;case s.MessageType.TableForm:const r=t;r.rows.forEach(((t,i)=>{t.fields.forEach((t=>{e+=t.value?`${t.value} - `:""})),e+=qe(r.forms[i])}))}return ei(e)}(i),n&&n.locale&&(this.locale=n.locale,this.translations=Object.assign(Object.assign({},this.translations),this.settings.i18n[n.locale])),i.actions&&(this.actions=this.buildActions(i.actions,this.shareText)),i.globalActions&&(this.globalActions=this.buildActions(i.globalActions,this.shareText)),this.headerText=i.headerText,this.footerText=i.footerText,i.footerForm&&(this.footerFormComponent=je(e,i.footerForm,t,n)),this.Ye=Y(this.actions).concat(Y(this.globalActions))}handleOnActionClick(t){if(this.onActionClick){const e=t;e.messageComponent=this,this.onActionClick(e)}}hasActions(){return this.actions.length>0||this.globalActions.length>0}focusFirstAction(){var t;null===(t=this.firstActionButton)||void 0===t||t.focus()}disableActions(){this.actions.forEach((t=>{t.disable()})),this.globalActions.forEach((t=>{t.disable()})),this.footerFormComponent&&this.footerFormComponent.disableActions()}disablePostbacks(){this.Ye.forEach((t=>{t.disable()})),this.footerFormComponent&&this.footerFormComponent.disablePostbacks()}enableActions(){this.actions.forEach((t=>{t.enable()})),this.globalActions.forEach((t=>{t.enable()})),this.footerFormComponent&&this.footerFormComponent.enableActions()}enablePostbacks(){this.Ye.forEach((t=>{t.enable()})),this.footerFormComponent&&this.footerFormComponent.enablePostbacks()}render(t){const e=this,i=e.util,s=e.actions,o=e.globalActions,r=this.payload.embeddedActions,n="embeddedAction";this.element&&(this.element.innerHTML="");const a=this.element?this.element:i.createDiv(["message"]);a.lang=e.locale;const c=i.createDiv(["message-wrapper"]);a.appendChild(c);const h=e.getContent(t);if(e.headerText&&c.appendChild(e.getHeader()),c.appendChild(h),s&&s.length){const t=e.getActions();(this.settings.displayActionsAsPills?c:h).appendChild(t),e.firstActionButton||(e.firstActionButton=t.firstElementChild),this.actionsWrapper=t}if(e.footerText&&c.appendChild(e.getFooter()),this.footerFormComponent){const t=i.createDiv(["footer-form"]);t.appendChild(this.footerFormComponent.render()),c.appendChild(t)}if(o&&o.length){const t=e.getGlobalActions();a.appendChild(t),e.firstActionButton||(e.firstActionButton=t.firstElementChild)}return this.element=a,a.querySelectorAll(`span.${n}`).forEach((t=>{const e=t,s=r.find((e=>e.id===t.id));if(s){i.addCSSClass(t,n,`display-${s.displayType}`);const o=At.fromActionPayload(s,i,this.settings,this.shareText,this.options);o&&(o.onActionClick=this.handleOnActionClick.bind(this),o.render(),e.onclick=t=>o.handleOnClick(t))}})),a}getHeader(){return Lt(this.headerText,"message-header",this.util,this.settings.embeddedVideo)}getContent(t){const e=this.util.createDiv(["message-bubble"]);return e.style.padding=this.settings.messagePadding||e.style.padding,t&&e.appendChild(t),e}getActions(){const t=this.settings,e=t.displayActionsAsPills?["message-global-actions"]:["message-actions"];return"horizontal"!==t.actionsLayout&&e.push("col"),Pt(this.actions,e,this.util)}getFooter(){return Lt(this.footerText,"message-footer",this.util,this.settings.embeddedVideo)}getGlobalActions(){const t=["message-global-actions"];return this.settings.icons.avatarBot&&t.push("has-message-icon"),"horizontal"!==this.settings.globalActionsLayout&&t.push("col"),Pt(this.globalActions,t,this.util)}buildActions(t,e){const i=this.settings;return function(t,e,i,s,o,r){const n=[];return t.forEach((t=>{const a=At.fromActionPayload(t,e,i,s,o);a&&(a.onActionClick=r,n.push(a))})),n}(t,this.util,i,e,this.options,this.handleOnActionClick.bind(this))}}function Lt(t,e,i,s){const o=i.createDiv(["message-bubble",e]),r=i.createTextDiv();return r.innerHTML=X(t,i.cssPrefix,s),o.appendChild(r),o}function Pt(t,e,i){const s=i.createTextDiv(e);return t.forEach((t=>{s.appendChild(t.render())})),s}class jt{}jt.GEOLOCATION_REQUEST_DENIED=1,jt.CHAT_SCROLL_DELAY=300,jt.WEBSOCKET_READY_STATE=["CONNECTING","OPEN","CLOSING","CLOSED"],jt.WEBSOCKET_CLOSE_EVENT={CODE:{ABNORMAL_CLOSURE:1006}},jt.ATTACHMENT_HEADER={AUTHORIZATION:"Authorization",FILE_AUTH_TYPE:"x-oda-meta-file-authType",FILE_IS_PROTECTED:"x-oda-meta-file-isProtected",FILE_SIZE:"x-oda-meta-file-size"},jt.MAX_SUGGESTIONS_COUNT=5,jt.MIN_SUGGESTIONS_COUNT=1,jt.SUGGESTIONS_COUNT_THRESHOLD=30,jt.TIME={MIN_FIFTY:3e6};const Ft="24.06",Vt=1024,Ht=26214400,Dt=1e3;class Rt{static capitalize(t){return t.charAt(0).toUpperCase()+t.slice(1)}constructor(t,e,i,s,o){this.settings=t,this.util=e,this.side=s,this.Je=o,this.P=i.url,this.$e=i.type;const r=i.url.split("/");this.Ke=i.title||decodeURI(r[r.length-1]),this.Xe=i.filename}Qe(t,e){const i=this.util,s=this.settings,o=i.createElement("a",[],!0),r=i.createIconButton({css:["attachment-control-icon","attachment-button","flex"],icon:s.icons.download||b,iconCss:["attachment-download-icon"],title:s.i18n[s.locale].download});return o.setAttribute("href",t),o.setAttribute("download",e||""),o.setAttribute("target","_blank"),o.appendChild(r),o}createAttachment(t,e){const i=this.util,o=this.settings,r=i.createDiv(["attachment"]),n=i.createDiv(["attachment-placeholder","flex"]),a=i.createDiv(["attachment-icon"]),c=i.createImageIcon({icon:t});a.appendChild(c);const h=this.Ke,l=i.createDiv(["attachment-footer","flex",this.Je&&"with-actions"]),u=i.createLabel(["attachment-title"]),p=i.createDiv(["attachment-controls","flex"]);if(u.innerText=h,u.setAttribute("title",h),l.appendChild(u),this.$e===s.AttachmentType.Image){const t=i.createIconButton({css:["attachment-control-icon","attachment-button","flex"],icon:o.icons.expandImage||H,iconCss:["attachment-expand-icon"],title:o.i18n[o.locale].imageViewerOpen});t.onclick=()=>{this.createImagePreview(this.P,h)},p.appendChild(t)}if(this.side===Ot.LEFT&&p.appendChild(this.Qe(this.P,this.Xe)),e)switch(n.appendChild(e),e.onerror=()=>{e.remove(),n.appendChild(a)},this.$e){case s.AttachmentType.Image:e.onload=()=>{e.clientHeight>211&&(n.style.alignItems="flex-start"),l.appendChild(p)},e.onclick=()=>{this.createImagePreview(this.P,this.Ke)};break;case s.AttachmentType.Audio:case s.AttachmentType.Video:e.onloadeddata=()=>{l.appendChild(p)}}else n.appendChild(a),l.appendChild(p);return r.appendChild(n),null==r||r.appendChild(l),r}createImagePreview(t,e){const i=this.util,s="image-preview",o=this.settings,r=i.createDiv([`${s}-wrapper`]),n=i.createImage(t,[s]),a=i.createLabel([`${s}-title`]);a.innerText=e;const c=document.querySelector(`.${this.settings.name}-wrapper`),h=o.icons.close||m,l=i.createIconButton({css:[`${s}-close`],icon:h,iconCss:[`${s}-close-icon`],title:o.i18n[o.locale].imageViewerClose});l.onclick=()=>{r.remove()},l.onkeydown=t=>{"Tab"===t.code&&(r.focus(),t.preventDefault())};const u=i.createDiv([`${s}-header`]);u.appendChild(a),u.appendChild(l),r.appendChild(u),r.appendChild(n),r.setAttribute("tabindex","-1"),r.onkeydown=t=>{"Escape"===t.code&&r.remove()},c.appendChild(r),r.focus()}}class Nt extends Rt{render(){const t=this.util,e=this.settings,i=e.icons.fileAudio||h,s=t.createMedia("video",this.P,["attachment-audio"]);s.controls=!0,s.preload="metadata",Ot.RIGHT===this.side&&s.setAttribute("controlsList","nodownload");const o=``,r=e.i18n[e.locale].attachmentAudioFallback.replace("{0}",o).replace("{/0}","");return s.innerHTML=r,e.linkHandler?De(s,e.linkHandler):e.openLinksInNewWindow&&Re(s),this.createAttachment(i,s)}}class Ut extends Rt{render(){const t=this.settings.icons.fileGeneric||x;return this.createAttachment(t)}}class Bt extends Rt{render(){const t=this.util,e=this.settings.icons.fileImage||y,i=t.createImage(this.P,["attachment-image"],this.Ke);return this.createAttachment(e,i)}}class Wt extends Rt{render(){const t=this.util,e=this.settings,i=this.P,s=e.icons.fileVideo||F,o=ct(i,t.cssPrefix);if(o){const e=t.createElement("span");return e.innerHTML=o,e}const r=t.createMedia("video",this.P,["attachment-video"]);r.controls=!0,r.preload="metadata",Ot.RIGHT===this.side&&r.setAttribute("controlsList","nodownload");const n=``,a=e.i18n[e.locale].attachmentVideoFallback.replace("{0}",n).replace("{/0}","");return r.innerHTML=a,this.settings.linkHandler?De(r,e.linkHandler):this.settings.openLinksInNewWindow&&Re(r),this.createAttachment(s,r)}}class Zt extends Et{static fromPayload(t,e,i,o,r,n=!1){if(r&&r.authToken&&r.uri&&i.url.indexOf(r.uri)>=0&&!this.ti.test(i.url)){const t=null==r?void 0:r.authToken;(null==t?void 0:t.length)&&(i.url=`${i.url}?token=${t}`)}switch(i.type){case s.AttachmentType.Image:return new Bt(t,e,i,o,n);case s.AttachmentType.Video:return new Wt(t,e,i,o,n);case s.AttachmentType.Audio:return new Nt(t,e,i,o,n);case s.AttachmentType.File:return new Ut(t,e,i,o,n);default:throw Error("Payload contains wrong attachment type")}}constructor(t,e,i,s,o,r){super(t,e,i,s,o,r),this.ei=Zt.fromPayload(t,e,i.attachment,s,r,this.hasActions())}getContent(){return super.getContent(this.ei.render())}}Zt.ti=/token=[a-z\.\d]+/i;class Gt{constructor(t,e,i,s,o){var r;if(this.He=t,this.ii=e,this.te=o,this.si=[],this.Ye=[],this.Ke=i.title,this.oi=i.description,this.Ae=i.imageUrl,this.P=i.url,i.actions){for(const s of i.actions){const i=(this.Ke?`${this.Ke} - `:"")+(this.oi?`${this.oi} - `:"")+(null!==(r=this.P)&&void 0!==r?r:""),n=At.fromActionPayload(s,e,t,i,o);n&&(n.onActionClick=this.handleOnActionClick.bind(this),this.si.push(n))}this.Ye=Y(this.si)}}handleOnActionClick(t){this.onActionClick&&this.onActionClick(t)}render(){const t=this.ii,e=this.He,i=e.embeddedVideo,s=e.locale,o=this.P,r=t.createDiv(["card"]),n=o?t.createAnchor(o,"",["card-component"],e.openLinksInNewWindow,e.linkHandler):t.createDiv(["card-content"]);if(this.P&&(n.innerText=""),this.Ae){const i=e.i18n;let o=i[s].cardImagePlaceholder;if(this.te&&this.te.locale){const t=i[this.te.locale];o=t?t.cardImagePlaceholder:o}n.appendChild(t.createImage(this.Ae,["card-image"],o))}const a=t.createTextDiv(["card-title"]);if(a.innerHTML=X(this.Ke,t.cssPrefix,i),n.appendChild(a),this.oi){const e=t.createTextDiv(["card-description"]);e.innerHTML=X(this.oi,t.cssPrefix,i),n.appendChild(e)}if(r.appendChild(n),e.linkHandler?De(n,e.linkHandler):e.openLinksInNewWindow&&Re(n),this.si.length>0){const i=t.createDiv("horizontal"!==e.cardActionsLayout?["card-actions","col"]:["card-actions"]);let s=!0;for(const t of this.si){const e=t.render();s&&(this.ri=e,s=!1),i.appendChild(e)}r.appendChild(i)}return r}hasActions(){return this.si.length>0}disableActions(){this.si.forEach((t=>t.disable()))}disablePostbacks(){this.Ye.forEach((t=>t.disable()))}enableActions(){this.si.forEach((t=>t.enable()))}enablePostbacks(){this.Ye.forEach((t=>t.enable()))}getFirstActionButton(){return this.ri}}class qt extends Et{constructor(t,e,i,s,o,r){super(t,e,i,s,o,r),this.ni=[],this.ai=i.layout,this.ci=i.cards.length;let n=0;i.cards.forEach((t=>{n++,this.ni.push(new Gt(this.settings,e,t,n,r))})),this.globalActions=this.actions.concat(this.globalActions),this.actions=[],this.li=!1}hasActions(){return this.ni[0].hasActions()||this.actions.length>0||this.globalActions.length>0}disableActions(){super.disableActions(),this.ni.forEach((t=>{t.disableActions()}))}disablePostbacks(){super.disablePostbacks(),this.ni.forEach((t=>{t.disablePostbacks()}))}enableActions(){super.enableActions(),this.ni.forEach((t=>{t.enableActions()}))}enablePostbacks(){super.enablePostbacks(),this.ni.forEach((t=>{t.enablePostbacks()}))}render(){const t=this.util,e=this.settings.name,i=[`card-message-${this.ai}`],s=super.render();if(s.querySelector(`.${e}-icon-wrapper`)){i.push("has-message-icon");const o=s.querySelector(`.${e}-content-wrapper`);t.addCSSClass(o,"with-icon")}return t.addCSSClass(s,...i),s}setCardsScrollDirection(){this.li="rtl"===getComputedStyle(this.ui).direction}getContent(){const t=this.util,e=this.ci,i=t.createDiv(["card-message-content"]),s=t.createDiv(["card-message-cards"]);let o=!0;if(this.ni.forEach((t=>{t.onActionClick=this.handleOnActionClick.bind(this);const e=t.render();o&&t.hasActions()&&(this.firstActionButton=t.getFirstActionButton(),o=!1),s.appendChild(e)})),i.appendChild(s),"horizontal"===this.ai&&e>1){let t;i.appendChild(this.pi()),this.di=0,s.addEventListener("scroll",(()=>{window.clearTimeout(t),t=window.setTimeout((()=>{let t=0;for(let i=0;i{this.mi()}),500))}this.fi=i,this.ui=s;const r=this.settings.name;return new IntersectionObserver((t=>{t.forEach((t=>{t.isIntersecting&&this.mi()}))}),{root:document.querySelector(`.${r}-conversation`)}).observe(s),i}pi(){if(!this.bi){const t=this.util,e=this.translations.cardNavNext;this.bi=t.createDiv(["next-wrapper"]);const i=t.createIconButton({css:["round","next"],icon:p,iconCss:[],title:e});i.onclick=this.vi.bind(this),this.bi.appendChild(i)}return this.bi}wi(){if(!this.xi){const t=this.util,e=this.translations.cardNavPrevious;this.xi=t.createDiv(["prev-wrapper"]);const i=t.createIconButton({css:["round","previous"],icon:d,iconCss:[],title:e});i.onclick=this.yi.bind(this),this.xi.appendChild(i)}return this.xi}vi(){this.di0&&(this.di--,this.gi())}gi(){var t,e,i,s;const o=this.ui.children[this.di];o&&(this.ui.scrollLeft=o.offsetLeft-56,0===this.di?null===(t=this.xi)||void 0===t||t.remove():(null===(e=this.xi)||void 0===e?void 0:e.parentElement)||this.fi.prepend(this.wi()),this.di===this.ci-1?null===(i=this.bi)||void 0===i||i.remove():(null===(s=this.bi)||void 0===s?void 0:s.parentElement)||this.fi.appendChild(this.pi()))}mi(){this.ui.scrollWidth===this.ui.offsetWidth?(this.bi&&(this.bi.hidden=!0),this.xi&&(this.xi.hidden=!0)):(this.bi&&(this.bi.hidden=!1),this.xi&&(this.xi.hidden=!1))}}class Yt extends Et{constructor(t,e,i,s,o,r){super(t,e,i,s,o,r);const n=i.location;this.Ke=n.title,this.P=n.url,this.ki=n.longitude,this._i=n.latitude}render(){const t=this.util,e=t.createDiv(["message"]);e.lang=this.locale;const i=t.createDiv(["message-wrapper"]);e.appendChild(i);const s=t.createDiv(["attachment"]),o=t.createDiv(["attachment-placeholder","flex"]),r=t.createDiv(["attachment-icon"]),n=t.createImageIcon({icon:this.settings.icons.shareMenuLocation||O}),a=t.createDiv(["attachment-footer","flex"]),c=t.createLabel(["attachment-title"]);if(c.innerText=this.Ke?this.Ke:`${this._i.toFixed(4)}, ${this.ki.toFixed(4)}`,a.appendChild(c),r.appendChild(n),o.appendChild(r),!this.actions.length){const e=t.createDiv(["attachment-controls"]),i=t.createIconButton({css:["attachment-control-icon","attachment-button","flex"],icon:this.settings.icons.externalLink||w,iconCss:[],title:this.translations.openMap}),s=t.createAnchor(this.P||`https://www.google.com/maps/@${this._i},${this.ki},12z`,"",[],this.settings.openLinksInNewWindow,this.settings.linkHandler);i.onclick=()=>{s.click()},e.appendChild(i),a.appendChild(e)}return s.appendChild(o),s.appendChild(a),i.appendChild(this.getContent(s)),e}}class Jt extends Et{constructor(t,e,i,s,o,r){super(t,e,i,s,o,r),this.qe=JSON.stringify(i.payload)}getContent(){const t=this.util.createTextSpan();return t.innerText=this.qe,super.getContent(t)}}class Kt extends Et{constructor(t,e,i,s,o,r){super(t,e,i,s,o,r),this.zi=i.text}getContent(){const t=this.settings,e=this.util,i=this.zi,o=e.createTextDiv(["message-text"]);return this.side===Ot.RIGHT?(0,s.isPostbackPayload)(this.payload)&&Xt(i)?(e.addCSSClass(o,"message-user-postback"),o.innerHTML=i):o.textContent=Qt(i):(o.innerHTML=X(i,e.cssPrefix,t.embeddedVideo),t.linkHandler?De(o,t.linkHandler):t.openLinksInNewWindow&&Re(o)),super.getContent(o)}}const Xt=t=>!!t&&/^t.replace(/&#x([0-9a-f]+);/gi,((t,e)=>String.fromCharCode(parseInt(e,16)))),te="start",ee="end";class ie extends Et{constructor(t,e,i,s,o,r){var n;super(t,e,i,s,o,r),this.Mi="",this.Si=!0,this.Ci=i.streamState,this.zi=i.text,this.Mi=i.text,this.Si=null!==(n=r.isFresh)&&void 0!==n?n:this.Si;let a="";this.Ti=se((i=>{a+=i;const s=a.length%20?a:X(a,e.cssPrefix,t.embeddedVideo),o=Ve(s);this.textElement&&(this.textElement instanceof HTMLInputElement||this.textElement instanceof HTMLTextAreaElement?(this.textElement.focus(),this.textElement.value=o,this.textElement instanceof HTMLTextAreaElement&&(this.textElement.scrollTop=this.textElement.scrollHeight)):this.textElement.innerHTML=o)}),(()=>{var t;this.Ci===ee&&(this.isCoPilot?this.showDone():(this.zi=null===(t=this.textElement)||void 0===t?void 0:t.innerHTML,this.render()))}),t.typingDelay||1)}update(t){const e=t.streamState;switch(this.Ci=e,e){case te:this.renderClean(t),this.isCoPilot&&this.Ti.push(t.text.split(""));break;case"running":this.Ti.push(t.text.split("")),this.Mi=t.text;break;case ee:if(this.Si){const e=this.Mi;if(this.Mi="",e.length){const i=t.text.lastIndexOf(e);if(i>=0){const s=t.text.substring(i+e.length);this.Ti.push(s.split("")),this.isCoPilot||this.setAddOnComponents(t);break}}}this.renderClean(t)}}getContent(){var t;const e=this.settings,i=this.util,s=i.createTextDiv();return s.setAttribute("aria-hidden","true"),!this.Si||this.Ci!==te&&this.textElement?(s.innerHTML=X(this.zi,i.cssPrefix,e.embeddedVideo),this.Ci===ee&&s.removeAttribute("aria-hidden"),e.linkHandler?De(s,e.linkHandler):e.openLinksInNewWindow&&Re(s)):(this.textElement=s,this.Ti.push(null===(t=this.zi)||void 0===t?void 0:t.split(""))),super.getContent(s)}renderClean(t){this.Ti.clear(),this.zi=t.text,this.isCoPilot||(this.setAddOnComponents(t),this.render())}setAddOnComponents(t){this.headerText=t.headerText,t.actions&&(this.actions=this.buildActions(t.actions)),this.footerText=t.footerText,t.footerForm&&(this.footerFormComponent=je(this.util,t.footerForm,this.settings,this.options)),t.globalActions&&(this.globalActions=this.buildActions(t.globalActions)),this.Ye=Y(this.actions).concat(Y(this.globalActions))}}const se=(t,e,i)=>{const s=[];let o=!0;const r=()=>{if(!s.length)return o=!0,void setTimeout((()=>e()));setTimeout((()=>{s.length&&(t(s.shift()),r())}),i)};return{push:t=>{s.push(...t),o&&(o=!1,r())},clear:()=>{s.length=0}}};class oe extends Kt{constructor(t,e,i,s,o,r){super(t,e,i,s,o,r),this.$i=0,this.Ii=i.actions,this.ratingId=Date.now()}focusFirstAction(){this.Ai[0].focus()}disableActions(){this.Oi(!0),super.disableActions()}disablePostbacks(){this.Oi(!0),super.disablePostbacks()}enableActions(){this.Oi(!1),super.enableActions()}enablePostbacks(){this.Oi(!1),super.enablePostbacks()}highlightRating(t){if(!this.actions||!this.Ai)return;const e=this.util,i="active",s="string"==typeof t?this.Ei(t):t;for(let t=1;t<=this.Ai.length;t++){const o=this.Ai[t-1];if(!o)break;s&&t<=s||0===s&&t<=this.$i?e.addCSSClass(o,i):e.removeCSSClass(o,i)}}getActions(){const t=this.util,e=this.settings,i=e.i18n[e.locale].ratingStar,s=t.createDiv(["rating-wrapper"]);this.Ai=this.Ii.map((o=>{const r=t.createElement("input",["star-input","rating-hidden"]);r.id=`rating-${o.label}-${this.ratingId}`,r.type="radio",r.name=`rating-${this.ratingId}`,r.value=o.label;const n=t.createLabel(["star-label"]);n.htmlFor=`rating-${o.label}-${this.ratingId}`,n.setAttribute("data-rating",o.label);const a=t.createTextSpan(["rating-hidden"]),c=i.replace("{0}",`${o.label}`);a.innerText=c;const h=e.icons&&e.icons.rating||C,l=t.createImageIcon({icon:h,iconCss:["rating-star-icon"]});return n.appendChild(a),n.appendChild(l),r.onfocus=()=>{r.disabled||(this.$i=this.Li(r))},r.onkeydown=t=>{"Enter"===t.key&&this.Pi(o)},n.onclick=()=>{r.disabled||(this.$i=this.Li(n),this.Pi(o))},n.onmouseover=()=>{r.disabled||this.Li(n)},n.onmouseleave=()=>{r.disabled||this.Li(null)},s.appendChild(r),s.appendChild(n),r})),this.$i&&this.Li(null);const o=t.createDiv(["rating-root"]);return o.appendChild(s),o}Oi(t){this.Ai&&this.Ai.forEach((e=>{e.disabled=t}))}Pi(t){const e={getPayload:()=>Promise.resolve(t.postback),label:t.label,type:t.type};this.handleOnActionClick(e)}Li(t){let e=0;if(t){const i="value"in t?t.value:null==t?void 0:t.getAttribute("data-rating");e=i?parseInt(i,10):0}return this.highlightRating(e),e}Ei(t){let e=0;if(t.match(/^\d+$/)){const i=parseInt(t,10);i>0&&i<=this.actions.length&&(e=i)}return e}}class re extends Et{constructor(t,e,i,s,o,r){super(t,e,i,s,o,r),this.si=[],this.cssPrefix=t.name,this.te=r,this.qe=i}disableActions(){super.disableActions(),this.si.forEach((t=>{t.disable()}))}disablePostbacks(){super.disablePostbacks(),Y(this.si).forEach((t=>{t.disable()}))}enableActions(){super.enableActions(),this.si.forEach((t=>{t.enable()}))}enablePostbacks(){super.enablePostbacks(),Y(this.si).forEach((t=>{t.enable()}))}render(){return super.render()}getHeader(){const t=this.util,e=super.getHeader();return t.addCSSClass(e,"message-header-yellow"),e}getContent(t){const e=this.util,i="message-bubble",o=this.qe.type,r=e.createDiv([i]);o===s.MessageType.Table||o===s.MessageType.TableForm?e.addCSSClass(r,`${i}-tabular-message`):e.addCSSClass(r,`${i}-form-message`,o===s.MessageType.EditForm?"edit-form-message":""),t&&r.appendChild(t);const n=this.getPageStatus();return n&&r.appendChild(n),r}getPageStatus(){const t=this.util;let e;const i=this.qe.paginationInfo;return i&&i.totalCount>i.rangeSize&&(e=t.createTextDiv(["results-page-status"]),e.innerText=i.status),e}}class ne{constructor(t,e,i,o,r,n){this.He=t,this.ii=e,this.ji=i,this.Fi=n,this.isTableField=!1,this.isColumnField=!1,i.displayType===s.DisplayType.Action&&(this.action=At.fromActionPayload(i.action,e,t,o,r))}render(){var t;const e=this.ii,i=this.ji,o="form-message",r=this.He,{alignment:n,label:c,labelFontSize:h,labelFontWeight:l,marginTop:u,onHoverPopupContent:p}=i,d=e.createTextDiv([`${o}-value`]),g=null===(t=i.value)||void 0===t?void 0:t.toString();switch(i.displayType){case s.DisplayType.Link:const t=e.createDiv(),{imageUrl:o,linkLabel:h}=i,l=e.createElement("a",h?[]:["ellipsis"],!0);if(l.href=g,o){const t=e.createImage(o,["video-wrapper"],g);t.alt=h||"",l.appendChild(t),c&&e.addCSSClass(d,"with-top-margin")}else l.innerHTML=h||(0,a.stripHTTP)(g)||"";l.setAttribute("target","_blank"),t.appendChild(l),r.linkHandler?De(t,r.linkHandler):r.openLinksInNewWindow&&Re(t),d.appendChild(l);break;case s.DisplayType.Text:const{fontSize:u,fontWeight:p,truncateAt:m}=i;g&&m?(d.innerHTML=`${g.slice(0,m)}...`,d.title=g):d.innerHTML=g||"",ae(d,u,p,e);break;case s.DisplayType.Media:const f=i.mediaType,b=c&&g;switch(f){case"image":const t=e.createImage(g,["video-wrapper"],g);b&&e.addCSSClass(d,"with-top-margin"),d.appendChild(t);break;case"video":ct(g,e.cssPrefix)?(d.innerHTML=X(g,e.cssPrefix,r.embeddedVideo),r.embeddedVideo&&b&&e.addCSSClass(d,"with-top-margin")):d.appendChild(le(f,g,d,b,e));break;case"audio":d.appendChild(le(f,g,d,b,e))}break;case s.DisplayType.Action:e.addCSSClass(d,"flex"),d.style.justifyContent=n,c&&e.addCSSClass(d,"with-top-margin"),this.action.onActionClick=this.onActionClick,d.appendChild(this.action.render())}if(this.isTableField)return he(d,p,r,e),d;const m=`${o}-field`,f=[m,`${m}-col-${this.Fi}`],b=e.createDiv(f),v=e.createDiv([`${o}-key`]);return v.innerHTML=c||"",n&&(v.style.textAlign=n,d.style.textAlign=n),ae(v,h,l,e),b.appendChild(v),b.appendChild(d),he(b,p,r,e),this.isColumnField?ce(b,u,e):b}disableActions(){this.action.disable()}disablePostbacks(){Y([this.action]).forEach((t=>{t.disable()}))}enableActions(){this.action.enable()}enablePostbacks(){Y([this.action]).forEach((t=>{t.enable()}))}}function ae(t,e,i,s){switch(e){case"large":s.addCSSClass(t,"font-size-lg");break;case"small":s.addCSSClass(t,"font-size-sm");break;default:s.addCSSClass(t,"font-size-md")}switch(i){case"bold":s.addCSSClass(t,"font-weight-bold");break;case"light":s.addCSSClass(t,"font-weight-light");break;default:s.addCSSClass(t,"font-weight-md")}}function ce(t,e,i){return"large"===e?i.addCSSClass(t,"margin-top-lg"):"none"!==e&&i.addCSSClass(t,"margin-top-md"),t}function he(t,e,i,s){if(e){const o=$e.fromMessage(i,s,{messagePayload:e});if(o){const e=s.createDiv(),i=s.createDiv(["popupContent"]);i.appendChild(o.render()),i.setAttribute("role","tooltip"),e.appendChild(i),t.style.cursor="pointer",t.appendChild(e)}}}const le=(t,e,i,s,o)=>{const r=o.createMedia(t,e,["video-wrapper"]);return r.controls=!0,r.preload="metadata",s&&o.addCSSClass(i,"with-top-margin"),r};class ue extends re{getContent(){const t=this.util,e=this.settings,i=this.qe,s="form-message",o=t.createDiv([s]);i.formColumns>2&&(i.formColumns=2);const r=i.forms;return r.forEach(((n,a)=>{if(n.title){const e=t.createTextDiv([`${s}-header`]);e.innerText=n.title,o.appendChild(e)}const[c,h]=pe(t,n,i.formColumns,e,this.handleOnActionClick.bind(this),this.te);this.si=this.si.concat(h);const l=a+1;l===r.length||r[l].title||t.addCSSClass(c,"with-border"),o.appendChild(c)})),super.getContent(o)}}function pe(t,e,i,o,r,n){var a;const c="form-message",h=`${c}-actions-col`,l=null===(a=e.channelExtensions)||void 0===a?void 0:a.c2kReferences,u=t.createDiv([`${c}-item`,l?"c2k-reference":""]),p=qe(e,!0),d=function(t,e,i,s,o,r){var n;const a=[];if((null===(n=t.actions)||void 0===n?void 0:n.length)>0)for(const n of t.actions){const t=At.fromActionPayload(n,e,i,o,r);t&&(t.onActionClick=s,a.push(t))}return a}(e,t,o,r,p,n);let g;if(d.length&&(g=function(t,e,i,s){const o=e.createDiv("horizontal"!==i.formActionsLayout?["form-actions","col",s]:["form-actions"]);for(const e of t){const t=e.render();o.appendChild(t)}return o}(d,t,o,h)),(0,s.isFormEntityWithRows)(e)?e.formRows.forEach(((e,i)=>{const a=de(e,d,t,o,p,r,n),c=e.columns.length;if(e.columns.forEach((e=>{const i=me(e,t);e.fields.forEach((a=>{if((0,s.isReadOnlyField)(a)){const s=new ne(o,t,a,p,n);s.isColumnField=!0,s.onActionClick=r,s.action&&d.push(s.action),fe(e.width,a.displayType,i,c),i.appendChild(s.render())}})),a.appendChild(i)})),l&&0!==i){const e=t.createTextSpan(["delimiter"]);e.innerHTML="•",a.firstElementChild.firstElementChild.lastElementChild.prepend(e)}u.appendChild(a)})):e.fields.forEach((e=>{const s=new ne(o,t,e,p,n,i);s.onActionClick=r,s.action&&d.push(s.action),u.appendChild(s.render())})),g&&u.appendChild(g),e.selectAction){ge(At.fromActionPayload(e.selectAction,t,o,p,n),d,r,u,e.selectAction.label)}return[u,d]}function de(t,e,i,s,o,r,n){const a=i.createDiv(["form-row",t.separator?"separator":""]);if(t.selectAction){ge(At.fromActionPayload(t.selectAction,i,s,o,n),e,r,a,t.selectAction.label)}return a}function ge(t,e,i,s,o){t&&(e.push(t),t.onActionClick=i,s.onclick=e=>t.handleOnClick(e),s.title=o||"",s.style.cursor="pointer")}function me(t,e){const{width:i,verticalAlignment:s}=t,o=e.createDiv(["form-row-column",i||""]);return"center"===s?e.addCSSClass(o,"align-center"):"bottom"===s?e.addCSSClass(o,"align-end"):e.addCSSClass(o,"align-start"),o}function fe(t,e,i,o){"stretch"===t||e!==s.DisplayType.Media||i.style.maxWidth||(i.style.maxWidth=`calc((100% - ${16*(o-1)}px)/${o})`)}const be="aria-expanded";class ve extends re{constructor(){super(...arguments),this.Vi=0,this.Hi=0,this.Di=[],this.Ri=new $t("EditFormMessageComponent"),this.Ni={}}disableActions(){super.disableActions(),we(this.Ui,this.Di,this.util)}disablePostbacks(){super.disablePostbacks(),we(this.Ui,this.Di,this.util)}enableActions(){super.enableActions(),we(this.Ui,this.Di,this.util,!1)}enablePostbacks(){super.enablePostbacks(),we(this.Ui,this.Di,this.util,!1)}getContent(){const t=this.qe,e=this.settings,i=this.util,o="form-message",r=`${o}-item`,n=i.createDiv([o]),a=i.createDiv([r]);if(t.title){const e=i.createTextDiv([`${o}-header`]);e.innerText=t.title,n.appendChild(e)}return(0,s.isEditFormPayloadWithFields)(t)?(t.formColumns>2&&(t.formColumns=2),t.fields.filter((t=>t)).forEach((e=>{a.appendChild(this.Bi(e,o,!1,t.formColumns))}))):t.formRows.forEach((t=>{const s=de(t,this.si,i,e,this.shareText,this.handleOnActionClick.bind(this),this.options),r=t.columns.length;t.columns.forEach((t=>{const e=me(t,i);t.fields.filter((t=>t)).forEach((i=>{e.appendChild(this.Bi(i,o,!0)),fe(t.width,i.displayType,e,r)})),s.appendChild(e)})),a.appendChild(s)})),this.actions.concat(this.si).some((t=>t.getActionType()===s.ActionType.SubmitForm))||this.Ri.error("Payload does not contain submit-form action"),this.Wi(a,t.errorMessage||(this.Hi&&this.Vi>1?this.translations.editFormErrorMessage:""),!0),n.appendChild(a),this.Zi=a,super.getContent(n)}validateForm(){var t;let e=!0;return null===(t=this.Ui)||void 0===t||t.remove(),this.Di.forEach((t=>{e=this.Gi(t)&&e})),!e&&this.Vi>1&&this.Wi(this.Zi,this.translations.editFormErrorMessage,!0),e}getSubmittedFields(){return this.Di.filter((t=>{const e=t.tagName.toLowerCase();return"textarea"===e&&(this.Ni[t.id]=t.value),"input"===e})).forEach((t=>{const e=t;switch(e.type){case"checkbox":this.Ni[e.id]=e.checked?e.getAttribute("valueOn"):e.getAttribute("valueOff");break;case"number":this.Ni[e.id]=e.valueAsNumber;break;default:this.Ni[e.id]=e.value}})),this.Ni}Bi(t,e,i,o){const r=this.shareText,n=this.util;if(this.Vi++,(0,s.isReadOnlyField)(t)){const e=new ne(this.settings,n,t,r,this.options,o);return e.isColumnField=i,e.onActionClick=this.handleOnActionClick.bind(this),e.action&&this.si.push(e.action),e.render()}return i?ce(this.qi(t,o,e,n),t.marginTop,n):this.qi(t,o,e,n)}qi(t,e,i,o){var r,n,c,h;const u=`${i}-field`,p=[u,`${u}-col-${e}`,`edit-${u}`],d=o.createDiv(p),g=o.createDiv([`${i}-key`,"with-margin"]),{labelFontSize:f,labelFontWeight:b,id:v,displayType:w,placeholder:x,required:y,clientErrorMessage:k,serverErrorMessage:_,autoSubmit:z}=t;let M,S,C;switch(g.innerHTML=t.label||"",ae(g,f,b,o),d.appendChild(g),w){case s.DisplayType.SingleSelect:const e=t;if(S=e.defaultValue,C=e.layoutStyle,S&&(this.Ni[v]=S),C&&"list"!==C)if("radioGroup"===C){const t=o.createElement("form",[`${i}-value`,"form-container","col"]);o.setAttributes(t,{id:v,ariaLabel:w,errorMsg:k}),t.onclick=t=>t.stopPropagation(),e.options.forEach((e=>{const i=o.createInputElement({type:"radio",name:v,value:e.label,required:y,checked:e.value===S},["radio-input"]);i.onchange=()=>{i.checked&&(this.Ni[v]=e.value),this.Yi(v,z,t)};const s=o.createLabel();s.innerText=e.label,s.prepend(i),t.appendChild(s)})),this.Di.push(t),d.appendChild(t),this.Wi(t,_)}else this.Ri.error(`Payload contains wrong layout style:${C} for single select field`);else{const t=o.createDiv(["select-wrapper",`${i}-value`]),s=o.createInputElement({type:"text",placeholder:x,required:y,id:v,autocomplete:"off"},[`${i}-value`]),n=o.createDiv(),c=o.createDiv(["listbox","popup","none"]),h=o.createElement("ul",["single-select-list"]),u=h.getElementsByTagName("li"),p=o.createIconButton({css:["select-icon"],icon:l,iconCss:[],title:""}),g=e=>{"true"!==t.getAttribute(be)||n.contains(e.target)||(b||(s.value=""),f(!1))},m=()=>{"false"===t.getAttribute(be)&&(t.setAttribute(be,"true"),o.removeCSSClass(c,"none"),setTimeout((()=>document.addEventListener("click",g))),s.focus())},f=(e=!0)=>{"true"===t.getAttribute(be)&&(b&&(s.value=b.textContent||b.innerText),t.setAttribute(be,"false"),o.addCSSClass(c,"none"),document.removeEventListener("click",g),this.Ji("",u,M),e&&s.focus())};let b,M=[];o.setAttributes(t,{errorMsg:k}),t.setAttribute(be,"false"),t.setAttribute("aria-label",w),t.onclick=t=>{t.stopPropagation(),m()},t.oninput=()=>{this.Ji(s.value,u,M)?m():f()},t.onkeydown=t=>{var e;const i=t.key;i===a.KeyCode.Down||i===a.KeyCode.Up?!b||b.classList.contains(`${this.cssPrefix}-none`)?null===(e=M[0])||void 0===e||e.focus():null==b||b.focus():i!==a.KeyCode.Esc&&i!==a.KeyCode.Tab||f()},s.onfocus=()=>o.addCSSClass(t,"focused"),s.onblur=()=>o.removeCSSClass(t,"focused"),p.onclick=e=>{e.stopPropagation(),"true"===t.getAttribute(be)?f():m()},null===(r=e.options)||void 0===r||r.forEach((e=>{const i=o.createListItem(e.label,e.label,e.label,"","",(()=>{o.addCSSClass(i,"selected"),b&&o.removeCSSClass(b,"selected"),b=i,f(),this.Ni[v]=e.value,this.Yi(v,z,t)}),!1,!1);i.onkeydown=t=>this.Ki(t,i,h,s,M),e.value===S&&(o.addCSSClass(i,"selected"),b=i,s.value=e.label),h.appendChild(i)})),M=Array.from(u),n.onclick=t=>t.stopPropagation(),t.appendChild(s),t.appendChild(p),c.appendChild(h),n.appendChild(c),d.appendChild(t),d.appendChild(n),this.Di.push(t),this.Wi(s,_)}break;case s.DisplayType.MultiSelect:const u=t;if(S=u.defaultValue,C=u.layoutStyle,this.Ni[v]=S||[],C&&"list"!==C)if("checkboxes"===C){const t=o.createElement("form",[`${i}-value`,"form-container","col"]);o.setAttributes(t,{id:v,ariaLabel:w,errorMsg:k,ariaRequired:y?"true":""}),t.onclick=t=>t.stopPropagation(),u.options.forEach((e=>{const i=o.createInputElement({type:"checkbox",name:v,value:e.label,checked:null==S?void 0:S.includes(e.value),required:y},["radio-input"]),s=o.createLabel();s.innerText=e.label,s.prepend(i),i.onchange=()=>{if(i.checked)this.Ni[v].push(e.value);else{const t=this.Ni[v];t.splice(t.indexOf(e.value),1)}this.Yi(v,z,t)},t.appendChild(s)})),this.Di.push(t),d.appendChild(t),this.Wi(t,_)}else this.Ri.error(`Payload contains wrong layout style:${C} for multi select field`);else{const t=o.createDiv([`${i}-value`,"text-field-container"]),e=o.createElement("ul",["selected-options"]),s=o.createDiv(),r=o.createDiv(["listbox","popup","none"]),n=[],c=o.createDiv(["filter-message-box"]),h=o.createDiv(["filter-message-text","none"]),l=o.createInputElement({type:"text"},[`${i}-value`,"listbox-search","none"]),p=o.createElement("ul",["multi-select-list"]),g=p.getElementsByTagName("li"),f=o.createDiv(["search-icon-wrapper","none"]),b=o.createImageIcon({icon:T,iconCss:["search-icon"]});h.textContent=this.translations.noResultText,c.appendChild(h),l.oninput=()=>this.Ji(l.value,g,n)?o.addCSSClass(h,"none"):o.removeCSSClass(h,"none"),l.onkeydown=e=>{var i;const s=e.key;s===a.KeyCode.Down?(this.Ji(l.value,g,n),null===(i=n[0])||void 0===i||i.focus()):s!==a.KeyCode.Esc&&s!==a.KeyCode.Tab||t.click()},x&&e.setAttribute("data-placeholder",x),t.setAttribute(be,"false");const w=e=>{"true"!==t.getAttribute(be)||s.contains(e.target)||M()},M=()=>{t.setAttribute(be,"false"),o.addCSSClass(r,"none"),document.removeEventListener("click",w),l.value="",this.Ji(l.value,g,n),o.addCSSClass(l,"none"),o.addCSSClass(f,"none"),o.addCSSClass(h,"none")};t.onclick=e=>{if(e.stopPropagation(),"true"===t.getAttribute(be))M(),t.focus();else{t.setAttribute(be,"true"),o.removeCSSClass(r,"none");const e=p.firstElementChild;e?e.focus():o.removeCSSClass(h,"none"),setTimeout((()=>document.addEventListener("click",w)))}},t.onkeydown=e=>{const i=e.code;e.ctrlKey||e.altKey||e.metaKey||e.shiftKey||i===a.KeyCode.Esc||i===a.KeyCode.Tab||(t.click(),o.removeCSSClass(l,"none"),o.removeCSSClass(f,"none"),l.focus())},t.setAttribute("aria-required",y?"true":"false"),t.tabIndex=0,k&&t.setAttribute("data-error",k),u.options.forEach((i=>{const s=s=>{const r=o.createDiv(["multi-select-option"]);r.innerText=i.label;const n=o.createImageIcon({icon:m,iconCss:["opt-close"]});n.onclick=()=>{e.removeChild(r),p.appendChild(s);const o=this.Ni[v];o.splice(o.indexOf(i.value),1),this.Yi(v,z,t)},r.appendChild(n),r.onclick=e=>{e.stopPropagation(),"true"===t.getAttribute(be)&&t.click()},e.appendChild(r)},r=o.createListItem(i.label,i.label,i.label,"","",(()=>{t.click(),p.removeChild(r),this.Ni[v].push(i.value),s(r),this.Yi(v,z,t)}),!1,!1);r.onkeydown=e=>this.Ki(e,r,p,t,n),(null==S?void 0:S.includes(i.value))?s(r):p.appendChild(r)})),s.onclick=t=>t.stopPropagation(),t.appendChild(e),this.Di.push(t),d.appendChild(t),f.appendChild(b),r.appendChild(c),r.appendChild(l),r.appendChild(f),r.appendChild(p),s.appendChild(r),d.appendChild(s),this.Wi(t,_)}break;case s.DisplayType.Toggle:const p=t,g=o.createLabel([`${i}-value`,"toggle"]);g.tabIndex=0,g.onclick=t=>t.stopPropagation(),M=o.createInputElement({id:v,placeholder:x,required:y,type:"checkbox",checked:p.defaultValue===p.valueOn,errorMsg:k,valueOn:p.valueOn,valueOff:p.valueOff});const f=p.labelOn||p.valueOn,b=p.labelOff||p.valueOff;M.setAttribute("aria-label",M.checked?f:b),M.oninput=()=>{M.setAttribute("aria-label",M.checked?f:b),this.Yi(v,z,M)},g.appendChild(M),g.appendChild(o.createDiv(["round-slider"])),d.appendChild(g),this.Wi(M.parentElement,_);break;case s.DisplayType.DatePicker:const $=t;M=o.createInputElement({type:"date",id:v,title:x,required:y,defaultValue:$.defaultValue,min:$.minDate,max:$.maxDate,errorMsg:k},[`${i}-value`]);break;case s.DisplayType.TimePicker:const I=t;M=o.createInputElement({type:"time",id:v,title:x,required:y,defaultValue:I.defaultValue,min:I.minTime,max:I.maxTime,errorMsg:k},[`${i}-value`]);break;case s.DisplayType.TextInput:const A=t;if(A.multiLine){const t=o.createElement("textarea",[`${i}-value`],!0);o.setAttributes(t,{id:v,required:y,minLength:A.minLength,maxLength:A.maxLength,defaultValue:A.defaultValue,placeholder:A.placeholder,errorMsg:k}),t.rows=3,t.onchange=()=>this.Yi(v,z,t),t.onclick=t=>t.stopPropagation(),d.appendChild(t),this.Di.push(t),this.Wi(t,_)}else M=o.createInputElement({type:A.inputStyle||"text",id:v,placeholder:x,required:y,defaultValue:A.defaultValue,errorMsg:k,minLength:A.minLength,maxLength:A.maxLength,pattern:A.validationRegularExpression},[`${i}-value`]);break;case s.DisplayType.NumberInput:const O=t;M=o.createInputElement({type:"number",id:v,placeholder:x,required:y,defaultValue:null===(n=O.defaultValue)||void 0===n?void 0:n.toString(),min:null===(c=O.minValue)||void 0===c?void 0:c.toString(),max:null===(h=O.maxValue)||void 0===h?void 0:h.toString(),errorMsg:k},[`${i}-value`]);break;default:this.Ri.error(`Payload contains wrong display type:${w} for editable field`)}return M&&("checkbox"!==M.type&&(d.appendChild(M),this.Wi(M,_),M.onchange=()=>this.Yi(v,z,M),M.onclick=t=>t.stopPropagation()),this.Di.push(M)),d}Gi(t,e=!1){const i=t.dataset.error,o=()=>{e||("SPAN"===(null==n?void 0:n.tagName)&&(this.util.removeCSSClass(t.parentElement,"error"),n.remove(),this.Hi--),a||this.Wi(t,r||this.translations.editFieldErrorMessage))};let r,n=t.nextElementSibling,a=!0;switch(t.tagName.toLowerCase()){case"form":const e=t,c=e.getAttribute("aria-label");if(c===s.DisplayType.MultiSelect&&"true"===e.ariaRequired){e.querySelectorAll("input[type='checkbox']:checked").length||(a=!1,r=i||e.querySelector("input").validationMessage)}else c!==s.DisplayType.SingleSelect||e.checkValidity()||(a=!1,r=i||e.querySelector("input").validationMessage);break;case"input":const h=t;"checkbox"===h.type?n=n.parentElement.nextElementSibling:h.checkValidity()||(r=i||h.validationMessage,a=!1);break;case"textarea":const l=t;l.checkValidity()||(r=i||l.validationMessage,a=!1);break;case"div":const u=t;n=n.nextElementSibling,u.getAttribute("aria-label")===s.DisplayType.SingleSelect?setTimeout((()=>{const t=u.firstElementChild;return t.checkValidity()||(a=!1,r=i||t.validationMessage),o(),a})):"true"===u.getAttribute("aria-required")&&(r=i,a=!!u.firstElementChild.firstElementChild)}return o(),a}Ji(t,e,i){const s=this.util;i.length=0;for(let o=0;o)|(<\/b>)/g,"")):(n.innerHTML=t?a.replace(new RegExp(`${t}`,"gi"),"$&"):a.replace(/()|(<\/b>)/g,""),s.removeCSSClass(r,"none"),i.push(r))}return i.length>0}Ki(t,e,i,s,o){var r,n,c,h;const l=this.cssPrefix,u=o.indexOf(e),p=o.length;let d=!1;if(!(t.ctrlKey||t.altKey||t.metaKey)){if(t.shiftKey&&t.code===a.KeyCode.Tab)s.click();else switch(t.code){case a.KeyCode.Return:case a.KeyCode.Space:e.click(),d=!0;break;case a.KeyCode.Esc:case a.KeyCode.Tab:s.click(),t.code===a.KeyCode.Esc&&(s.focus(),d=!0);break;case a.KeyCode.Up:const g=e.previousElementSibling||i.lastElementChild;g.classList.contains(`${l}-none`)?null===(r=o[(u+p-1)%p])||void 0===r||r.focus():g.focus(),d=!0;break;case a.KeyCode.Down:const m=e.nextElementSibling||i.firstElementChild;m.classList.contains(`${l}-none`)?null===(n=o[(u+1)%p])||void 0===n||n.focus():m.focus(),d=!0;break;case a.KeyCode.Home:case a.KeyCode.PageUp:const f=i.firstElementChild;f.classList.contains(`${l}-none`)?null===(c=o[0])||void 0===c||c.focus():f.focus(),d=!0;break;case a.KeyCode.End:case a.KeyCode.PageDown:const b=i.lastElementChild;b.classList.contains(`${l}-none`)?null===(h=o[p-1])||void 0===h||h.focus():b.focus(),d=!0;break;default:if(s instanceof HTMLInputElement)s.focus();else{const t=i.previousElementSibling,e=t.previousElementSibling,s=this.util;s.removeCSSClass(e,"none"),s.removeCSSClass(t,"none"),e.focus()}}d&&(t.stopPropagation(),t.preventDefault())}}Yi(t,e,i){if(this.Gi(i)&&e){const e=JSON.parse(JSON.stringify(this.getSubmittedFields()));this.Di.forEach((t=>{this.Gi(t,!0)||delete e[t.id]})),Object.keys(e).forEach((t=>{const i=e[t];Array.isArray(i)?0===i.length&&delete e[t]:0===i||i||delete e[t]}));const i=this.settings.sdkMetadata?Object.assign({version:Ft},this.settings.sdkMetadata):{version:Ft};this.te.webCore.sendMessage((0,s.buildUserMessage)({submittedFields:e,partialSubmitField:t,type:s.MessageType.FormSubmission}),{sdkMetadata:i}).then((()=>{const t=this.settings.disablePastActions;"all"===t?this.disableActions():"postback"===t&&this.disablePostbacks()})).catch((t=>this.Ri.error("[partialSubmit] Failed to send postback message:",t)))}}Wi(t,e,i=!1){if(e){const s=this.util,o=s.createTextSpan(["field-error",i?"form-error":""]),r=s.createImageIcon({icon:v,iconCss:["form-error-icon"]}),n=s.createTextSpan(["error-text"]);if(n.innerText=e,o.appendChild(r),o.appendChild(n),i)t.appendChild(o),this.Ui=o;else{const e=t.parentElement;s.addCSSClass(e,"error"),e.appendChild(o),this.Hi++}}}}function we(t,e,i,s=!0){t&&(s?i.addCSSClass(t,"disabled"):i.removeCSSClass(t,"disabled")),e.forEach((t=>{switch(t.tagName.toLowerCase()){case"form":const e=t.getElementsByTagName("input");s?i.addCSSClass(t,"disabled"):i.removeCSSClass(t,"disabled");for(let t=0;t{const i=ke(t,[`${s}-heading`],e.width,e.alignment);i.innerText=e.label,n.appendChild(i)})),r.appendChild(n),e.rows.forEach((e=>{const o=t.createElement("tr",[`${s}-row`]);if(e.selectAction){ge(At.fromActionPayload(e.selectAction,t,this.settings,this.shareText,this.options),this.si,this.handleOnActionClick.bind(this),o,e.selectAction.label)}e.fields.forEach(((e,r)=>{const n=ke(t,[`${s}-item`],i[r].width,e.alignment),a=new ne(this.settings,t,e,this.shareText,this.options);a.isTableField=!0,a.onActionClick=this.handleOnActionClick.bind(this),a.action&&this.si.push(a.action),n.appendChild(a.render()),o.appendChild(n)})),r.appendChild(o)})),super.getContent(o)}}function ke(t,e,i,s){const o=t.createElement("td",e,!0);return o.style.textAlign=s,o.style.width=`${i}%`,o}function _e(t){let e;if(t.every((t=>!t.width||t.width>=0&&t.width<=xe))){let i=0,s=0;if(t.forEach((t=>{t.width?s+=t.width:i++})),i)if(s(t.width||(t.width=o),t)))}else e=ze(t);else if(s===xe)e=t;else{const i=xe/s;e=t.map((t=>(t.width=t.width*i,t)))}}else e=ze(t);return e}function ze(t){const e=xe/t.length;return t.map((t=>(t.width=e,t)))}class Me extends re{getContent(){const t=this.util,e=this.qe,i=_e(e.headings.concat({alignment:"center",label:""})),s="table-message",o=t.createDiv([`${s}-wrapper`]),r=t.createElement("table",[s,"tableform-message"]);o.appendChild(r);const n=t.createElement("tr",[`${s}-headings`]);i.forEach((e=>{const i=ke(t,[`${s}-heading`],e.width,e.alignment);i.innerText=e.label,n.appendChild(i)})),r.appendChild(n);return n.lastElementChild.style.width="32px",e.rows.forEach(((o,n)=>{const a=t.createElement("tr",[`${s}-row`]);o.fields.forEach(((e,o)=>{const r=ke(t,[`${s}-item`],i[o].width,e.alignment),n=new ne(this.settings,t,e,this.shareText,this.options);n.isTableField=!0,n.onActionClick=this.handleOnActionClick.bind(this),n.action&&this.si.push(n.action),r.appendChild(n.render()),a.appendChild(r)})),e.formColumns>2&&(e.formColumns=2);const c=e.forms[n],h=ke(t,[`${s}-item`,"button-cell"]),l=t.createIconButton({css:[`${s}-item`,`${s}-item-form-toggle`],icon:u,iconCss:[],title:c.title||""});h.appendChild(l),a.appendChild(h);const p="none",d="rotate-180",[g,m]=pe(t,c,e.formColumns,this.settings,this.handleOnActionClick.bind(this),this.te);this.si=this.si.concat(m),t.addCSSClass(g,p);let f=!1;a.onclick=()=>{f?(t.addCSSClass(g,p),t.removeCSSClass(l,d)):(t.removeCSSClass(g,p),t.addCSSClass(l,d)),f=!f},r.appendChild(a),r.appendChild(g)})),super.getContent(o)}}function Se(t){return!!t.source}function Ce(t){if(t.msgId)return t.msgId;const e=JSON.stringify(t.messagePayload);return`${Te(e)}`}const Te=t=>{let e=0,i=0;const s=Math.pow(9,9);for(;e>>9};class $e{static fromMessage(t,e,i,o){let r,n;Se(i)?(r=Ot.LEFT,n=i.source||s.SkillMessageSource.Bot):r=Ot.RIGHT;const a=i.messagePayload;switch(a.type){case s.MessageType.Postback:case s.MessageType.Text:return a.channelExtensions&&"stars"===a.channelExtensions.displayType?new oe(t,e,a,r,n,o):new Kt(t,e,a,r,n,o);case s.MessageType.TextStream:return new ie(t,e,a,r,n,o);case s.MessageType.Attachment:return new Zt(t,e,a,r,n,o);case s.MessageType.Card:return new qt(t,e,a,r,n,o);case s.MessageType.Location:return new Yt(t,e,a,r,n,o);case s.MessageType.Table:return new ye(t,e,a,r,n,o);case s.MessageType.Form:return new ue(t,e,a,r,n,o);case s.MessageType.TableForm:return new Me(t,e,a,r,n,o);case s.MessageType.EditForm:return new ve(t,e,a,r,n,o);case s.MessageType.Raw:return new Jt(t,e,a,r,n,o);default:throw Error(`Wrong message payload type:${a.type}`)}}}const Ie={SESSION:"sessionStorage",LOCAL:"localStorage",CUSTOM:"custom"},Ae={CLASSIC:"classic",DEFAULT:"default",REDWOOD_DARK:"redwood-dark"},Oe={AUDIO:"audio",FILE:"file",LOCATION:"location",VISUAL:"visual"},Ee="Please try sharing it again, or else type it in.",Le={badgePosition:{right:"-5px",top:"-5px"},clientAuthEnabled:!1,conversationBeginPosition:"bottom",disablePastActions:"all",displayActionsAsPills:!1,searchBarMode:!1,sidepanel:!1,embedded:!1,embeddedVideo:!0,enableAgentSneakPreview:!1,enableAttachment:!0,enableAttachmentSecurity:!1,enableHeaderActionCollapse:!0,enableAutocomplete:!1,enableAutocompleteClientCache:!1,enableBotAudioResponse:!1,enableDefaultClientResponse:!1,enableClearMessage:!1,enableEndConversation:!0,enableHeadless:!1,enableLocalConversationHistory:!1,enableLongPolling:!1,enableResizableWidget:!1,enableSendTypingStatus:!1,enableSecureConnection:!0,enableSpeech:!1,enableSpeechAutoSend:!0,enableTabsSync:!0,enableTimestamp:!0,enableVoiceOnlyMode:!1,focusOnNewMessage:"input",height:"620px",i18n:{en:{agent:"Agent",agentMessage:"{0} says",attachment_audio:"Audio attachment",attachment_file:"File attachment",attachment_image:"Image attachment",attachment_video:"Video attachment",attachmentAudioFallback:"Your browser does not support embedded audio. However you can {0}download it{/0}.",attachmentVideoFallback:"Your browser does not support embedded video. However you can {0}download it{/0}.",audioResponseOff:"Turn audio response on",audioResponseOn:"Turn audio response off",avatarAgent:"Agent icon",avatarBot:"Bot icon",avatarUser:"User icon",card:"Card {0}",cardImagePlaceholder:"Card image",cardNavNext:"Next card",cardNavPrevious:"Previous card",chatTitle:"Chat",clear:"Clear conversation",close:"Close widget",closing:"Closing",connected:"Connected",connecting:"Connecting",connectionFailureMessage:"Sorry, the assistant is unavailable right now. If the issue persists, contact your help desk.",connectionRetryLabel:"Try Again",copyFailureMessage:"Sorry, copying is not available on this device.",copySuccessMessage:"Successfully copied the response text to the clipboard.",defaultGreetingMessage:"Hey, Nice to meet you! Allow me a moment to get back to you.",defaultWaitMessage:"I'm still working on your request. Thank you for your patience!",defaultSorryMessage:"I'm sorry. I can't get you the right content. Please try again.",disconnected:"Disconnected",download:"Download",editFieldErrorMessage:"Field input is invalid",editFormErrorMessage:"Some of the fields need your attention",endConversation:"End Conversation",endConversationConfirmMessage:"Are you sure you want to end the conversation?",endConversationDescription:"This will also clear your conversation history.",errorSpeechInvalidUrl:"ODA URL for connection is not set. Please pass 'URI' parameter during SDK initialization.",errorSpeechMultipleConnection:"Another voice recognition is ongoing. Can't start a new one.",errorSpeechTooMuchTimeout:"The voice message is too long to recognize and generate text.",errorSpeechUnavailable:"To allow voice messaging, update your browser settings to enable access to your microphone.",errorSpeechUnsupportedLocale:"The locale set for voice recognition is not supported. Please use a valid locale in 'speechLocale' setting.",inputPlaceholder:"Type a message",imageViewerClose:"Close image viewer",imageViewerOpen:"Open image viewer",itemIterator:"Item {0}",language_ar:"Arabic",language_de:"German",language_detect:"Detect Language",language_en:"English",language_es:"Spanish",language_fr:"French",language_hi:"Hindi",language_it:"Italian",language_nl:"Dutch",language_pt:"Portuguese",languageSelectDropdown:"Select chat language",linkField:"Click on the highlighted text to open Link for {0}",noResultText:"No more results",noSpeechTimeout:"The voice could not be detected to perform recognition.",noText:"No",openMap:"Open Map",previousChats:"End of previous conversation",ratingStar:"Rate {0} star",recognitionTextPlaceholder:"Speak your message",relTimeDay:"{0}d ago",relTimeHr:"{0}hr ago",relTimeMin:"{0}min ago",relTimeMoment:"A few seconds ago",relTimeMon:"{0}mth ago",relTimeNow:"Now",relTimeYr:"{0}yr ago",requestLocation:"Requesting location",requestLocationDeniedPermission:"To allow sharing your location, update your browser settings to enable access to your location. You can also type in the location instead.",requestLocationDeniedTimeout:`It is taking too long to get your location. ${Ee}`,requestLocationDeniedUnavailable:`Your current location is unavailable. ${Ee}`,retryMessage:"Try again",send:"Send message",shareAudio:"Share Audio",shareFailureMessage:"Sorry, sharing is not available on this device.",shareFile:"Share File",shareLocation:"Share Location",shareVisual:"Share Image/Video",skillMessage:"Skill says",showOptions:"Show Options",speak:"Speak a message",typingIndicator:"Waiting for response",upload:"Share popup",uploadFailed:"Upload Failed.",uploadFileNetworkFailure:"Upload not completed due to network failure.",uploadFileSizeLimitExceeded:"File size should not be more than {0}MB.",uploadFileSizeZeroByte:"Files of size zero bytes can't be uploaded.",uploadUnauthorized:"Upload request is unauthorized.",uploadUnsupportedFileType:"Unsupported file type.",userMessage:"I say",utteranceGeneric:"Message from skill.",webViewAccessibilityTitle:"In-widget WebView to display links",webViewClose:"Done",webViewErrorInfoDismiss:"Dismiss",webViewErrorInfoText:"Don't see the page? {0}Click here{/0} to open it in a browser.",yesText:"Yes"},ar:{language_ar:"اَلْعَرَبِيَّةُ"},de:{language_de:"Deutsch"},es:{language_es:"Español"},fr:{language_fr:"Français"},hi:{language_hi:"हिन्दी"},it:{language_it:"Italiano"},nl:{language_nl:"Nederlands"},pt:{language_pt:"Português"}},initBotAudioMuted:!0,initMessageOptions:{sendAt:"expand"},disableInlineCSS:!1,isDebugMode:!1,locale:"en",messageCacheSizeLimit:2e3,name:"oda-chat",openChatOnLoad:!1,openLinksInNewWindow:!1,readMark:"✓",reconnectInterval:5,reconnectMaxAttempts:5,shareMenuItems:[Oe.AUDIO,Oe.FILE,Oe.LOCATION,Oe.VISUAL],showConnectionStatus:!1,showPrevConvStatus:!0,showTypingIndicator:!0,speechLocale:s.RecognitionLocale.EN_US,theme:Ae.DEFAULT,timestampMode:"default",defaultGreetingTimeout:5,defaultWaitMessageInterval:5,typingIndicatorTimeout:30,typingStatusInterval:3,typingDelay:0,upgradeToWebSocketInterval:300,webViewConfig:{},width:"375px",actionsLayout:"vertical",globalActionsLayout:"vertical",cardActionsLayout:"vertical",formActionsLayout:"vertical",wcfsEnableEndConversationButtonToClose:!1};function Pe(t,e){if(!e)return Promise.resolve(!1);if(Array.isArray(e)||(e=[e]),!e.length)return Promise.resolve(!1);const i=e.map((t=>{var e;return null===(e=t.lang)||void 0===e?void 0:e.toLowerCase()}));return t.getVoices().then((t=>{let e=!1;const s=t.map((t=>t.lang.toLowerCase()));for(const t of i)if(s.indexOf(t)>=0){e=!0;break}return e}))}function je(t,e,i,o){const r=$e.fromMessage(i,t,{messagePayload:{type:s.MessageType.Form,forms:[e]}},o);return r.onActionClick=o.onMessageActionClicked,r}const Fe=//g,Ve=t=>t.replace(Fe,"\n");const He=[{match:/<([a-z])/gi,replace:(t,e)=>`<${e}`},{match:/<\/([a-z])/gi,replace:(t,e)=>`</${e}`}];function De(t,e){for(let i=0;i(window.open(i.href,"","height=450px,width=800px,menubar,toolbar,personalbar,status,resizable,noopener,noreferrer"),t.preventDefault(),t.stopPropagation(),!1)),i.hasChildNodes()&&Re(i)}}const Ne=(()=>{let t=!1;return(e={hasRecognition:!1,hasSynthesis:!1,isReset:!1,recognitionLocale:"",synthesisLocales:[]})=>{var i;e.isReset&&(t=!1);let s=e.synthesisLocales;return Array.isArray(s)||(s=[]),e.hasRecognition&&e.hasSynthesis&&(null===(i=e.recognitionLocale)||void 0===i?void 0:i.length)&&(!t&&e.synthesisLocales.length||(t=!0,s=[{lang:e.recognitionLocale}])),s}})();function Ue(t,e){const i=t.toLowerCase();for(const t in e)if(i===t.toLowerCase())return!0;return!1}function Be(t,e){const i=t.toLowerCase().split("-")[0];for(const t in e)if(i===t.toLowerCase())return!0;return!1}function We(t,e){let i=[t.toLowerCase()],s="en";i=i.concat(r()),i.indexOf(s)<0&&i.push(s);for(const t of i){if(Ue(t,e)){s=t;break}if(Be(t,e)){s=t.split("-")[0];break}}return s}function Ze(t,e){let i;return function(){const s=this,o=arguments;clearTimeout(i),i=setTimeout((function(){i=null,t.apply(s,o)}),e)}}function Ge(t,e){let i=!1;return function(){const s=this;i||(t.apply(s,arguments),i=!0,setTimeout((()=>{i=!1}),e))}}function qe(t,e=!1){let i=t.title?`${t.title} - `:"";return(0,s.isFormEntityWithFields)(t)?t.fields.forEach((t=>{i+=t.value?`${t.value} - `:""})):t.formRows.forEach((t=>{t.columns.forEach((t=>{t.fields.forEach((t=>{(0,s.isReadOnlyField)(t)&&(i+=t.value?`${t.value} - `:"")}))}))})),e?ei(i):i}function Ye(t,e){if(t){const i=["headerBackground","visualizer","ratingStarFill"],s=["botText","userText"],o=Object.assign({},t);i.forEach((e=>{o[e]=t[e]||t.branding})),s.forEach((e=>{o[e]=t[e]||t.text})),Object.keys(o).forEach((t=>{const i=o[t];if(i)if("shareMenuText"===t)e.updateCSSVar("--color-popup-button-text",i);else{const s=`--color-${t.replace(/([A-Z&])/g,"-$1").toLowerCase()}`;e.updateCSSVar(s,i)}}))}}function Je(t){const e={};return t&&Object.keys(t).forEach((i=>{var s;e[i]=null===(s=document.getElementById(t[i]))||void 0===s?void 0:s.value})),e}const Ke={avatarAgent:"agentAvatar",avatarBot:"botIcon",avatarUser:"personIcon",fileAudio:"audioIcon",fileImage:"imageIcon",fileGeneric:"fileIcon",fileVideo:"videoIcon",clearHistory:"clearMessageIcon",close:void 0,collapse:"closeIcon",download:"downloadIcon",error:"errorIcon",expandImage:"expandImageIcon",keyboard:"keyboardIcon",logo:"logoIcon",launch:"botButtonIcon",mic:"micIcon",rating:void 0,send:"sendIcon",shareMenu:"attachmentIcon",shareMenuAudio:void 0,shareMenuFile:void 0,shareMenuLocation:void 0,shareMenuVisual:void 0,ttsOff:"audioResponseOffIcon",ttsOn:"audioResponseOnIcon",typingIndicator:"chatBubbleIcon"};function Xe(t){const e={},i=Object.keys(t);for(const s of i)e[s.toLowerCase()]=t[s];return e}function Qe(t,e){t=Xe(t),e=Xe(e);const i=new Set;Object.keys(t).forEach((t=>{i.add(t)})),Object.keys(e).forEach((t=>{i.add(t)}));const s={};return i.forEach((i=>{s[i]=Object.assign(Object.assign(Object.assign({},t.en),t[i]),e[i])})),s}function ti(t){const e=Object.assign(Object.assign({},Le),t);if(t.i18n&&Object.keys(t.i18n).length&&(e.i18n=Qe(Le.i18n,t.i18n)),e.colors=Object.assign(Object.assign({},Le.colors),t.colors),e.userId=t.userId||`user${Math.floor(1e4+9e4*Math.random())}${Date.now()%1e5}`,e.icons=function(t){const e=t.icons||{};for(const i in Ke){const s=i,o=Ke[s];o in t&&(e[s]=t[o])}return e}(e),e.locale=We(e.locale,e.i18n),t.typingStatusInterval&&t.typingStatusIntervalt.classList.add(`${this.Xi}-${e}`))):t.setAttribute("class",e.reduce(((t,e)=>`${t} ${this.Xi}-${e}`),""))}createAnchor(t,e,i=[],s=!1,o){const r=this.createElement("a",i,ni);r.rel="noreferrer noopener";let n=!1;return r.href=t,r.innerText=e,o&&(o.onclick&&(r.onclick=o.onclick.bind(r),n=!0),o.target&&(r.target=o.target,n=!0)),n||(s?r.addEventListener("click",(e=>(window.open(t,"","height=450px,width=800px,menubar,toolbar,personalbar,status,resizable,noopener,noreferrer"),e.preventDefault(),e.stopPropagation(),!1))):r.target="_blank"),r}createButton(t=[]){const e="button",i=this.createElement(e,[...t,"flex"],ni);return i.type=e,i}createDiv(t=[]){return this.createElement("div",t)}createElement(t,e=[],i=!1){const s=document.createElement(t);return this.os(s,e),i&&(s.dir="auto"),s}createElementFromString(t,e=[]){const i=this.createDiv();i.innerHTML=t.trim();const s=i.firstElementChild;return e&&this.os(i.firstElementChild,e),s}createIconButton({css:t,icon:e,title:i,iconCss:s}){const o=this.createButton(["icon",...t]);o.innerHTML="",o.title=i;const r=this.createImageIcon({icon:e,iconCss:s});return o.appendChild(r),o}createImage(t,e=[],i=""){const s=this.createElement("img",e);return t&&(s.src=t),s.alt=i,s.setAttribute("draggable","false"),s}createImageIcon({icon:t,iconCss:e}){if((t=>{const e=t.match(/0})(t)){const i=this.createElementFromString(t,e);return i.setAttribute("role","presentation"),i.setAttribute("focusable","false"),i}return this.createImage(t,e)}createInputElement(t,e=[]){const i=this.createElement("input",e,!0);return this.setAttributes(i,t),i}createLabel(t=[]){return this.createElement("label",t,ni)}createTextDiv(t=[]){return this.createElement("div",t,ni)}createTextSpan(t=[]){return this.createElement("span",t,ni)}setAttributes(t,e){const i=["valueOn","valueOff"];Object.keys(e).forEach((s=>{const o=e[s];o&&("errorMsg"===s?t.setAttribute("data-error",o):i.includes(s)?t.setAttribute(s,o):t[s]=o)}))}createListItem(t,e,i,s,o,r,n=!1,a=!0){const c=this.createElement("li",[o,n&&"with-sub-menu"],!0);if(c.id=t,c.tabIndex=-1,c.setAttribute("role","menuitem"),i&&c.setAttribute("data-value",i),s){const t=this.createImageIcon({icon:s,iconCss:["icon",`${o}-icon`]});c.appendChild(t)}const h=this.createTextSpan(["text",`${o}-text`,a?"ellipsis":""]);return h.innerText=e,c.appendChild(h),r&&ci(c,"click",r),c}createMedia(t,e,i=[]){const s=this.createElement(t,i,!0);return e&&(s.src=e),s.autoplay=!1,s}getMenu(t){const e=this.createElement("ul",["popup",...t.menuClassList]);e.id=t.menuId,e.tabIndex=-1,e.setAttribute("role","menu"),e.setAttribute("aria-labelledby",t.buttonId);const i=t.menuItems;if(i.forEach((t=>e.appendChild(t))),t.defaultValue){const i=e.querySelector(`[data-value="${t.defaultValue}"]`);this.addCSSClass(i,"active")}return ci(e,"click",(()=>this.rs(e,t.menuButton))),ci(e,"keydown",(s=>{let o=!1;if(!(s.ctrlKey||s.altKey||s.metaKey)){if(s.shiftKey&&s.code===a.KeyCode.Tab)this.rs(t.menuButton,e);else switch(s.code){case a.KeyCode.Return:case a.KeyCode.Space:s.target.click(),o=!0;break;case a.KeyCode.Esc:case a.KeyCode.Tab:this.rs(t.menuButton,e),s.code===a.KeyCode.Esc&&(t.menuButton.focus(),o=!0);break;case a.KeyCode.Up:this.ns(e),o=!0;break;case a.KeyCode.Down:this.cs(e),o=!0;break;case a.KeyCode.Home:case a.KeyCode.PageUp:this.hs(e,i),o=!0;break;case a.KeyCode.End:case a.KeyCode.PageDown:this.ls(e,i),o=!0}o&&(s.stopPropagation(),s.preventDefault())}})),e}getMenuButton(t){const e=t.button,i=t.menu,s=i.querySelectorAll("li"),o=e.classList.contains(`${this.Xi}-with-sub-menu`),r=t.widget;return e.setAttribute("role","button"),e.setAttribute("aria-haspopup","true"),e.setAttribute(si,"false"),e.setAttribute("aria-controls",t.menuId),ci(e,"click",(()=>{const i=document.getElementById(t.menuId);"true"===e.getAttribute(si)?this.rs(e,i):this.us(e,i,r,o)})),ci(e,"keydown",(t=>{let n=!1;switch(t.code){case a.KeyCode.Return:case a.KeyCode.Down:case a.KeyCode.Space:this.us(e,i,r,o),this.hs(i,s),n=!0;break;case a.KeyCode.Up:this.us(e,i,r,o),this.ls(i,s),n=!0}n&&(t.stopPropagation(),t.preventDefault())})),e}getMessage(t,e=!1){const i="message",s=this.createDiv([i]),o=this.createDiv([`${i}-wrapper`]),r=this.createDiv([`${i}-bubble`,e&&"error"]);return r.appendChild(t),o.appendChild(r),s.appendChild(o),s}wrapMessageBlock(t,e,i=Ot.LEFT){const s="message",o=this.createDiv([`${s}-block`,"flex",i]),r=this.createDiv([`${s}s-wrapper`]),n=this.createDiv([`${s}-list`,"flex","col"]);if(e){const t=this.createImageIcon({icon:e,iconCss:["message-icon"]}),i=this.createDiv(["icon-wrapper"]);i.appendChild(t),o.appendChild(i)}return n.appendChild(t),r.appendChild(n),o.appendChild(r),o}getMessageBlock(t,e,i,s=!1){return this.wrapMessageBlock(this.getMessage(e,s),i,t)}removeCSSClass(t,...e){var i,s;if(t.classList)e.forEach((e=>t.classList.remove(`${this.Xi}-${e}`)));else{const e="class",o=null!==(s=null===(i=t.getAttribute(e))||void 0===i?void 0:i.split(" "))&&void 0!==s?s:[];if(o.length){const i=o.filter((t=>o.indexOf(`${this.Xi}-${t}`)<0)).join(" ");t.setAttribute(e,i)}}}setChatWidgetWrapper(t){this.ps=t;for(const[t,e]of Object.entries(this.Qi))this.updateCSSVar(t,e)}updateCSSVar(t,e){this.Qi[t]=e,this.ps&&this.ps.style.setProperty(t,e)}os(t,e=[]){return e&&this.addCSSClass(t,...e),t}rs(t,e){t.getAttribute(si)&&(this.removeCSSClass(e,ri),t.setAttribute(si,"false"))}hs(t,e){this.ds(e[0],t)}ls(t,e){this.ds(e[e.length-1],t)}ns(t){const e=t.getAttribute(oi),i=t.querySelector(`#${e}`);this.ds(i.previousSibling||t.lastChild,t)}cs(t){const e=t.getAttribute(oi),i=t.querySelector(`#${e}`);this.ds(i.nextSibling||t.firstChild,t)}ds(t,e){t.focus(),e.setAttribute(oi,t.id)}us(t,e,i,s=!1){if("false"===t.getAttribute(si)){this.addCSSClass(e,ri),t.setAttribute(si,"true");const o=i.getBoundingClientRect(),r=t.getBoundingClientRect(),n="rtl"===window.getComputedStyle(e).direction;if(s){const s=48;e.style.top=`${t.offsetTop+t.offsetHeight+60}px`,n?e.style.left=`${s}px`:e.style.right=`${s}px`,e.style.maxWidth=i.offsetWidth-s+"px"}else{let t=o.right-r.right;n?(t=r.left-o.left,e.style.left=`${t}px`):e.style.right=`${t}px`,e.style.maxWidth=i.offsetWidth-t+"px"}setTimeout((()=>{const i=document.querySelectorAll(`.${this.Xi}-with-sub-menu`);document.addEventListener("click",(s=>{let o=!1;i.forEach((t=>{t.contains(s.target)&&(o=!0)})),o?this.ts.push({menu:e,menuButton:t}):(this.ts.length&&(this.ts.forEach((t=>{this.rs(t.menuButton,t.menu)})),this.ts=[]),this.rs(t,e))}),{once:!0})}))}}}function ci(t,e,i,s){t.addEventListener(e,i,s)}function hi(t,e,i,s){t.removeEventListener(e,i,s)}class li{remove(){this.element.remove()}appendToElement(t){t.appendChild(this.element)}prependToElement(t){const e=t.firstChild;e?t.insertBefore(this.element,e):t.appendChild(this.element)}appendContentChildElement(t){this.gs().appendChild(t)}appendContentChild(t){this.gs().appendChild(t.element)}gs(){return this.element}}const ui="aria",pi=`${ui}-expanded`,di=`${ui}-selected`,gi=`${ui}-activedescendant`,mi="autocomplete-active";class fi{constructor(t,e,i){this.fs=t,this.ii=i,this.bs=-1,this.vs=this.ws(e),ii(t,{"aria-autocomplete":"list","aria-controls":e,[pi]:"false",autocomplete:"off",role:"combobox"})}display(t,e){this.xs(),this.te=t.map(((i,s)=>{const o=this.ys(s,t.length);return this.ks(o,i,e),o.onclick=()=>{this.fs.value=i,this.hide()},this.vs.appendChild(o),o})),this.fs.setAttribute(pi,"true")}hide(){this.fs.setAttribute(pi,"false"),this.fs.removeAttribute(gi),this.xs()}isOpen(){return"true"===this.fs.getAttribute(pi)}handleKeyboardEvent(t){let e=!1;if(t.ctrlKey)return e;const i=this.te.length;switch(t.code){case a.KeyCode.Return:case a.KeyCode.Space:case a.KeyCode.Tab:this._s&&vi(this.fs,this._s.textContent),this.hide();break;case a.KeyCode.Down:this.bs=(this.bs+1)%i,e=!0;break;case a.KeyCode.Up:this.bs=this.bs<0?i-1:(this.bs-1+i)%i,e=!0;break;case a.KeyCode.Esc:this.hide(),this.fs.focus()}return e&&(t.stopPropagation(),t.preventDefault(),this.zs(this.te[this.bs])),e}getListbox(){return this.vs}ws(t){const e=this.ii.createElement("ul",["autocomplete-items"]);return e.id=t,ii(e,{"aria-labelledby":`${this.fs.id}-label`,"aria-live":"polite",role:"listbox"}),ci(e,"keydown",(t=>{this.fs.dispatchEvent(new KeyboardEvent(t.type,t))})),e}ys(t,e){const i=this.ii.createElement("li",["autocomplete-item"]);return i.id=`${this.vs.id}item-${t+1}`,i.tabIndex=-1,ii(i,{"aria-posinset":(t+1).toString(),"aria-setsize":e.toString(),[di]:"false",role:"option"}),i}ks(t,e,i){const s=e.toLowerCase().indexOf(i),o=this.ii.createTextSpan();if(o.setAttribute("aria-hidden","true"),s>=0){const t=bi(e.substring(0,s)),r=this.ii.createElement("strong",[],!0);r.textContent=e.substring(s,s+i.length);const n=bi(e.substring(s+i.length));o.append(t,r,n)}else o.textContent=e;t.append(o),t.setAttribute("aria-label",e)}zs(t){const e=this._s;e&&(this.ii.removeCSSClass(e,mi),e.setAttribute(di,"false")),t&&(t.scrollIntoView(!1),t.setAttribute(di,"true"),this.ii.addCSSClass(t,mi),this._s=t,this.fs.setAttribute(gi,t.id))}xs(){const t=this.vs;for(;t.firstChild;)t.removeChild(t.lastChild);this.te=[],this._s=null,this.bs=-1}}const bi=t=>document.createTextNode(t),vi=(t,e)=>{t.value=e,t.setSelectionRange(e.length,e.length)},wi={ARROW_DOWN:"ArrowDown",ARROW_UP:"ArrowUp",ENTER:"Enter"},xi="keyboard",yi="voice",ki={AUDIO:".aac, .amr, .m4a, .mp3, .mp4a, .mpga, .oga, .ogg, .wav, audio/*",FILE:".7z, .csv, .doc, .docx, .eml, .ics, .key, .log, .msg, .neon, .numbers, .odt, .pages, .pdf, .pps, .ppsx, .ppt, .pptx, .rtf, .txt, .vcf, .xls, .xlsx, .xml, .yml, .yaml, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document",IMAGE:".gif, .jfif, .jpeg, .jpg, .png, .svg, .tif, .tiff, .webp, image/*",VIDEO:".3g2, .3gp, .avi, .m4v, .mov, .mp4, .mpeg, .mpg, .ogv, .qt, .webm, .wmv, video/*",ALL:""};ki.ALL=`${ki.AUDIO},${ki.FILE},${ki.IMAGE},${ki.VIDEO}`;const _i=window.setTimeout;class zi extends li{constructor(t,e,i,s,r,n,c,h,l,u,p){super(),this.ii=t,this.Ms=e,this.Ss=i,this.He=s,this.Cs=r,this.Ts=n,this.$s=c,this.Is=h,this.As=l,this.Os=u,this.Es=p,this.mode=void 0,this.Ls=Ht,this.Ps=[],this.js=!1,this.Fs=!1,this.Vs=!1,this.Hs=!0,this.Ds=Ge((t=>{this.As.trigger(o.TYPING,t)}),1e3),this.Rs=Ge((t=>{this.Is("RESPONDING",this.He.enableAgentSneakPreview?t:"...")}),this.He.typingStatusInterval*Dt),this.Xi=s.name,this.Ns=s.i18n,this.Us=s.icons,this.Bs=this.Ns[s.locale],this.Hs=!(0,a.isMobile)(),this.Ws=`${this.Xi}-share-button`}render(){if(this.element=this.Zs(),this.He.enableSpeech){const t=this.Gs();this.element.appendChild(t)}const t=this.qs();this.element.appendChild(t),this.setInputMode(xi),this.disable(),window.addEventListener("resize",Ze((()=>{this.Ys()}),100))}setInputMode(t){t!==this.mode&&(this.He.enableSpeech?(this.mode=t,this.mode===xi?this.Js():this.Ks()):(this.mode=xi,this.Js()))}setUserInputText(t){this.Xs&&(this.Xs.value=t,this.Xs.setSelectionRange(t.length,t.length),this.focusTextArea(),this.Qs())}getUserInputText(){return this.Xs.value}setUserInputPlaceholder(t){this.Xs&&(this.mode===xi?this.eo(t):this.io=t)}setRecognitionRequested(t){this.Vs=t}setVoiceRecording(t){this.He.enableSpeech&&(t&&this.Vs?this.setInputMode(yi):t||this.setInputMode(xi))}updateVisualizer(t,e){this.mode===yi&&(0,a.drawVisualizer)(t,this.so,e)}focusTextArea(){this.Hs&&this.Xs.focus(),this.Xs.scrollTop=this.Xs.scrollHeight}disable(t=!0){const e=this.ii,i="disabled";this.He.enableAttachment&&(this.oo.disabled=t),t?(e.addCSSClass(this.Xs,i),this.He.enableAutocomplete&&(this.ro(),this.no())):e.removeCSSClass(this.Xs,i),this.He.enableSpeech&&(this.setInputMode(xi),this.disableVoiceModeButton(t,{src:"network"})),this.ao=t,this.Qs()}isDisabled(){return this.ao}disableVoiceModeButton(t,{src:e}){if(this.He.enableSpeech){switch(e){case"lang":this.js=t;break;case"network":this.Fs=t}this.He.multiLangChat&&(this.js||this.Fs)?this.co.disabled=!0:this.co.disabled=this.Fs}}displaySuggestions(t){if(this.ho=t,this.lo=t.length>0,!this.lo||!this.Xs.value)return void this.no();const e=this.Xs.value.trim().toLowerCase();this.uo.display(t.slice(0,Math.min(t.length,jt.MAX_SUGGESTIONS_COUNT)),e)}getSuggestions(){return this.ho}getSuggestionsValid(){return this.lo}getSuggestionsList(){var t;return null===(t=this.uo)||void 0===t?void 0:t.getListbox()}setLocale(t){this.Bs=t,this.oo&&(Si(this.oo,t.upload),this.po.querySelectorAll("li").forEach((t=>{const e=t.dataset.value,i=this.Bs[`share${e.charAt(0).toUpperCase()+e.substring(1).toLowerCase()}`]||this.Bs[e]||t;t.querySelector("span").innerText=i}))),this.setUserInputPlaceholder(t.inputPlaceholder),this.do&&Si(this.do,t.send),this.co&&Si(this.co,t.speak),this.mo&&Si(this.mo,t.inputPlaceholder)}Zs(){return this.ii.createDiv(["footer"])}Js(){var t;const e=this.ii;e.removeCSSClass(this.element,"mode-voice"),e.addCSSClass(this.element,"mode-keyboard"),this.eo(this.io),this.Xs.disabled=!1,this.Qs(),this.He.enableAutocomplete&&(null===(t=this.Xs.value)||void 0===t?void 0:t.trim().length)>=3&&this.fo()}Ks(){const t=this.ii;t.removeCSSClass(this.element,"mode-keyboard"),t.addCSSClass(this.element,"mode-voice"),this.io=this.Xs.placeholder,this.eo(this.Bs.recognitionTextPlaceholder),this.Xs.disabled=!0,this.Qs(),this.no()}qs(){var t;const e=this.ii,i=e.createDiv(["footer-mode-keyboard","flex"]),s=null===(t=this.He.icons)||void 0===t?void 0:t.footerLogo;s&&i.appendChild(e.createImageIcon({icon:s,iconCss:["footer-logo"]})),this.bo(i);const o=e.createDiv(["footer-actions","flex"]),r=this.vo();if(this.do=r,this.Es("send",r),o.appendChild(r),this.He.enableSpeech&&(this.co=this.wo(),o.appendChild(this.co),this.mo=this.xo(),o.appendChild(this.mo)),this.He.enableAttachment){const t=this.yo();o.appendChild(t)}return i.appendChild(o),i}yo(){const t=this.ii,e=t.createDiv(),i=Mi(this.ii,{css:["button-upload","flex"],customIcon:this.Us.shareMenu,defaultIcon:c,title:this.Bs.upload});i.id=this.Ws;const s=t.createElement("input",["none"]);s.type="file",s.tabIndex=-1,s.setAttribute("aria-hidden","true"),this.ko=s,this.po=this._o(i);const o=t.getMenuButton({button:i,menuId:this.po.id,menu:this.po,widget:this.He.searchBarMode?this.Os.element:this.Os.chatWidgetDiv});return ci(o,"click",(()=>{this.no()})),this.oo=o,this.Es("shareMenu",o),document.addEventListener("deviceready",(()=>{const t=globalThis?globalThis.device:window?window.device:void 0;"Android"===(null==t?void 0:t.platform)&&this.ko.removeAttribute("accept")}),!1),ci(s,"click",(()=>s.value=null)),ci(s,"change",(t=>{const e=t.target;e.files&&e.files.length&&this.zo(e.files[0])})),e.appendChild(this.oo),e.appendChild(this.po),e.appendChild(s),e}_o(t){return this.ii.getMenu({menuId:`${this.He.name}-share-menu`,menuClassList:["share-popup-list"],buttonId:this.Ws,menuItems:this.Mo(),menuButton:t})}Mo(){const t=this.ii,e=this.Us,i=this.Bs,s=this.ko,o=`${this.Xi}-share-`;let r=this.He.shareMenuItems;const n=[],a=[Oe.AUDIO,Oe.FILE,Oe.LOCATION,Oe.VISUAL],c=new Set;if((null==r?void 0:r.length)&&!r.every((t=>"string"==typeof t&&a.indexOf(t.toLowerCase())<0))||(r=a),r.forEach((t=>{"string"==typeof t&&c.add(t.toLowerCase())})),c.has(Oe.VISUAL)){const r=`${o}visual`,a=e.shareMenuVisual||E,c=t.createListItem(r,i.shareVisual,"visual",a,"share-popup-item",(()=>{s.accept=`${ki.IMAGE},${ki.VIDEO}`,s.click()}));n.push(c),this.Es("shareMenuVisual",c)}if(c.has(Oe.AUDIO)){const r=`${o}audio`,a=e.shareMenuAudio||I,c=t.createListItem(r,i.shareAudio,"audio",a,"share-popup-item",(()=>{s.accept=ki.AUDIO,s.click()}));n.push(c),this.Es("shareMenuAudio",c)}if(c.has(Oe.FILE)){const r=`${o}file`,a=e.shareMenuFile||A,c=t.createListItem(r,i.shareFile,"file",a,"share-popup-item",(()=>{s.accept=ki.FILE,s.click()}));n.push(c),this.Es("shareMenuFile",c)}if(c.has(Oe.LOCATION)){const s=`${o}location`,r=e.shareMenuLocation||O,a=t.createListItem(s,i.shareLocation,"location",r,"share-popup-item",(()=>this.$s()));n.push(a),this.Es("shareMenuLocation",a)}const h=e.shareMenuFile||A;return this.He.shareMenuItems.filter((t=>"string"!=typeof t&&"string"==typeof t.type)).forEach((e=>{const o=e.type.toLowerCase(),r=`share_${o.indexOf("*")>=0?"all":o.replace(/ /g,"_")}`,a=`${this.Xi}-${r}`,c=i[r]||this.Ns.en[r];let l=e.label;c?l=c:this.Ns.en[r]=l;const u=e.icon||h,p=e.maxSize&&e.maxSize>=1?Math.min(e.maxSize*Vt,Ht):Ht;let d="";"wcfs_*"!==o&&(d=o.indexOf("*")>=0&&"wcfs_*"!==o?ki.ALL:o.split(" ").map((t=>`.${t} `)).join(",")),n.push(t.createListItem(a,l,r,u,"share-popup-item",(()=>{this.Ls=p,s.accept=d,s.click()})))})),n}bo(t){const e=this.ii;this.Xs=this.So();const i=e.createLabel(["hidden"]);i.id=`${this.Xs.id}-label`,i.htmlFor=this.Xs.id,this.Co=i,this.eo(this.io),t.append(i,this.Xs),this.He.enableAutocomplete&&(this.uo=new fi(this.Xs,`${this.Xi}-suggestions-list`,this.ii),t.append(this.uo.getListbox()))}So(){const t=["user-input"];this.He.enableSpeech&&t.push("user-input-inline-send");const e=this.ii.createElement("textarea",t,!0);return e.setAttribute("enterkeyhint","send"),e.id=`${this.Xi}-user-text-input`,this.io=this.Bs.inputPlaceholder,e.rows=1,e.onkeydown=this.To.bind(this),e.onkeyup=this.$o.bind(this),e.oninput=()=>{const t=e.value;this.Os.speechFinalResult=this.Os.speechFinalResult||{speechId:"",text:""},this.Os.speechFinalResult.text=t,this.Ys()},ci(e,"paste",(()=>{this.ao||_i(this.Qs.bind(this))})),this.Io(e),this.Es("input",e),e}eo(t){this.Xs.placeholder=t,this.Co.innerText=t}Io(t){const e=Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype,"value");Object.defineProperty(t,"value",{set:i=>{e.set.call(t,i),this.Qs(),this.Ys()},get:e.get})}vo(){const t=Mi(this.ii,{css:["button-send"],customIcon:this.Us.send,defaultIcon:$,title:this.Bs.send});return t.disabled=!0,t.onclick=()=>{var t;this.Ao()||(this.Oo=void 0,this.Xs.value=null===(t=this.Xs)||void 0===t?void 0:t.value.trim(),this.He.enableAutocomplete&&(this.ro(),this.no()),this.Eo())},t}wo(){const t=Mi(this.ii,{css:["button-switch-voice"],customIcon:this.Us.mic,defaultIcon:S,title:this.Bs.speak});return t.onclick=()=>{this.Ts(!0),this.Vs=!0},this.Es("mic",t),t}Gs(){const t=this.ii,e=t.createDiv(["footer-mode-voice","flex"]),i=t.createDiv(["footer-visualizer-wrapper"]);return this.so=t.createElement("canvas"),this.so.width=244,this.so.height=32,i.appendChild(this.so),e.appendChild(i),e}xo(){const t=Mi(this.ii,{css:["button-switch-kbd"],customIcon:this.Us.keyboard,defaultIcon:k,title:this.Bs.inputPlaceholder});return t.onclick=()=>{this.Vs=!1,this.Ts(!1)},this.Es("keyboard",t),t}Qs(){var t,e;const i=this.do;if(!i||!i.nodeType)return;const s=this.ii,o="none",r=(null===(e=null===(t=this.Xs)||void 0===t?void 0:t.value)||void 0===e?void 0:e.trim().length)>0;this.mode===xi&&(this.He.alwaysShowSendButton||r)?s.removeCSSClass(i,o):s.addCSSClass(i,o),i.disabled=this.ao||!r}Ao(){return!this.Xs||0===this.Xs.value.trim().length}To(t){var e;this.isDisabled()||this.He.enableAutocomplete&&this.uo.isOpen()&&this.uo.handleKeyboardEvent(t)||t.key===a.KeyCode.Return&&!t.shiftKey&&(null===(e=this.Xs.value)||void 0===e?void 0:e.trim().length)>0&&(t.preventDefault(),this.do.click())}$o(t){var e;if(this.Qs(),this.isDisabled())return this.ro(),void this.no();if(t.isComposing)return;const i=null===(e=this.Xs.value)||void 0===e?void 0:e.trim();this.Ds(!0),this.He.enableSendTypingStatus&&(i?this.Rs(i):this.Is("LISTENING")),clearTimeout(this.Lo),this.Lo=_i((()=>{this.Ds(!1),this.He.enableSendTypingStatus&&this.Is("LISTENING")}),this.He.typingStatusInterval*Dt),this.He.enableAutocomplete&&(t.code===a.KeyCode.Backspace&&(this.Oo=void 0,this.ro(),this.no(),clearTimeout(this.Po)),this.jo().indexOf(t.code)<0&&(i.length>=3?this.Oo!==i&&(this.Oo=i,clearTimeout(this.Po),this.fo()):(this.Oo=void 0,this.no(),clearTimeout(this.Po))))}Ys(){if(!this.He.searchBarMode){this.Xs.style.height=null;const t=.6*this.Os.chatWidgetDiv.clientHeight,e=this.Xs.scrollHeight;this.Xs.style.height=`${e{}))}no(){this.uo&&this.uo.isOpen()&&this.uo.hide()}fo(){this.Po=_i((()=>{this.Fo()}),300)}ro(){this.ho=null,this.lo=!1}jo(){if(!this.Ps.length)for(const t of Object.keys(wi))this.Ps.push(wi[t]);return this.Ps}}function Mi(t,{css:e,customIcon:i,defaultIcon:s,title:o}){const r=i||s;return t.createIconButton({css:["footer-button","flex"].concat(e),icon:r,iconCss:[],title:o})}function Si(t,e){t.title=e}const Ci="end-conversation",Ti="collapse",$i="clear",Ii="tts",Ai="none";class Oi extends li{constructor(t,e,i,s,o,r,n,a,c){super(),this.He=t,this.ii=e,this.tt=i,this.Vo=s,this.Ho=o,this.Ro=r,this.No=n,this.Es=a,this.Os=c,this.Ri=new $t("ChatHeaderComponent"),this.Uo=[],this.Bo=[],this.Xi=t.name,this.Ns=this.He.i18n}render(){this.element=this.Zs(),this.He.showConnectionStatus&&(this.Wo=t=>this.Zo(t),this.Ro.on(s.CoreEvent.State,this.Wo)),this.disable()}addLanguageSelect(t){const e=!(!this.Bo||!this.Bo.length);this.Go=t.render(e),this.Es("language",this.Go),this.Go&&(e?this.qo.appendChild(this.Go):this.Yo.prepend(this.Go))}closeWidgetPopup(){this.tt()}clearHistory(){this.Vo()}showTTSButton(t){const e=this.Jo(Ii);e&&(e.style.display=t?"flex":Ai)}disableTTSButton(t){const e=this.Jo(Ii);if(e){const i=this.ii;if("LI"===e.tagName){const s="disable";t?(i.addCSSClass(e,s),e.ariaDisabled="true"):(i.removeCSSClass(e,s),e.ariaDisabled="false")}else e.disabled=t}}setLocale(t){var e;const i=this.ii,s=this.Go;this.Ko=t;const o=t.chatTitle;o&&(this.Ke.innerText=o);const r=t.chatSubtitle;r?(this.Xo.innerText=r,i.removeCSSClass(this.Xo,Ai),i.addCSSClass(this.Qo,Ai)):this.He.showConnectionStatus?(this.Zo(this.tr),i.removeCSSClass(this.Qo,Ai),i.addCSSClass(this.Xo,Ai)):(i.addCSSClass(this.Xo,Ai),i.addCSSClass(this.Qo,Ai)),this.er&&Ei(this.er,t.showOptions),null===(e=this.Uo)||void 0===e||e.forEach((e=>{Ei(e.element,t[e.title])})),s&&Ei(s.querySelector("button")||s,t.languageSelectDropdown)}disable(t=!0){if(this.He.enableEndConversation&&!this.He.wcfsEnableEndConversationButtonToClose)for(const e of this.Uo)e.name===Ci&&(e.element.disabled=t)}addAction(t){this.Uo.push(t)}remove(){this.Ro.off(s.CoreEvent.State,this.Wo)}Zs(){var t;const e=this.ii,i=this.He,s=i.icons,o=e.createDiv(["header","flex"]),r=e.createDiv(["header-info-wrapper"]),n=e.createDiv(["header-actions","flex"]),a=i.locale,c=this.Ns[a],h=c.chatTitle,l=c.chatSubtitle;if(!("logo"in s)||s.logo){const t=e.createImageIcon({icon:s.logo||M,iconCss:["logo"]});o.appendChild(t)}if(h){const t=e.createTextDiv(["title"]);t.id=`${i.name}-title`,t.innerText=h,r.appendChild(t),this.Ke=t}this.Xo=e.createTextDiv(["subtitle",Ai]),r.appendChild(this.Xo),this.Qo=e.createTextDiv(["connection-status",Ai]),r.appendChild(this.Qo),l?(this.Xo.innerText=l,e.removeCSSClass(this.Xo,Ai)):i.showConnectionStatus&&(this.Zo(this.Ro.getState()),e.removeCSSClass(this.Qo,Ai)),o.appendChild(r);const u=e.createDiv(["header-gap"]);if(o.appendChild(u),i.customHeaderElementId){const t=document.getElementById(i.customHeaderElementId);if(t){const i=e.createDiv(["header-custom-element"]);i.appendChild(t),o.appendChild(i)}else this.Ri.error(`Could not find element with ID '${i.customHeaderElementId}'. No custom element added to the chat header.`)}if(this.Yo=n,i.enableEndConversation){const t=s.close||m;this.Uo.push({name:Ci,title:"endConversation",icon:t,clickHandler:this.No.bind(this),order:10})}if(!i.embedded){const t=s.collapse||f;this.Uo.push({name:Ti,title:"close",icon:t,clickHandler:this.closeWidgetPopup.bind(this),order:20})}if(i.enableBotAudioResponse&&(this.ir=!i.initBotAudioMuted,this.Uo.push({name:Ii,title:this.ir?"audioResponseOn":"audioResponseOff",icon:this.ir?s.ttsOn||j:s.ttsOff||P,clickHandler:()=>{this.ir=!this.ir,this.sr(),this.Ho(this.ir)},order:30})),i.enableClearMessage){const t=s.clearHistory||g;this.Uo.push({name:$i,title:"clear",icon:t,clickHandler:this.clearHistory.bind(this),order:40})}return this.Uo.sort(((t,e)=>t.order>e.order?1:-1)),null===(t=this.Uo)||void 0===t||t.forEach(((t,i)=>{const s=this.He.multiLangChat?this.Uo.length+1:this.Uo.length;if(!this.He.enableHeaderActionCollapse||i<2&&!(s>2&&1===i)){const i=e.createIconButton({css:["header-button"],icon:t.icon,iconCss:[],title:c[t.title]});i.onclick=t.clickHandler,this.rr(t,i),t.element=i,this.Yo.prepend(i)}else this.Bo.push(t)})),this.Bo&&this.Bo.length&&this.nr(this.Bo),o.appendChild(n),o}rr(t,e){switch(e.id=`${this.Xi}-${t.name}`,t.name){case Ci:this.Es("close",e);break;case Ti:case Ii:this.Es(t.name,e);break;case $i:this.Es("clearHistory",e)}}nr(t){const e=this.ii,i=this.Ko||this.Ns[this.He.locale],s=`${this.He.name}-action-menu`,o=`${s}-button`,r=t.map((t=>{const s=e.createListItem(`action-menu-option-${t.name}`,i[t.title],t.name,t.icon,"action-item",t.clickHandler);return this.rr(t,s),t.element=s,s})),n=e.createIconButton({css:["header-button","button-show-options"],icon:'{this.remove()}),1e3*this.He.typingIndicatorTimeout)))}remove(){this.isVisible()&&(this.ur.remove(),this.dr=!1)}isVisible(){return this.dr}render(){const t=this.ii,e=this.He,i=t.createDiv(["typing-cue-wrapper"]),s=e.icons.avatarBot;if(e.icons.typingIndicator){const s=e.icons.typingIndicator,o=t.createImageIcon({icon:s});o.style.height=e.chatBubbleIconHeight||o.style.height,o.style.width=e.chatBubbleIconWidth||o.style.width,i.appendChild(o)}else{const e=t.createDiv(["typing-cue"]);i.appendChild(e)}return i.setAttribute("aria-live","polite"),this.fi=i,this.updateTypingCueLocale(e.i18n[e.locale].typingIndicator),e.searchBarMode?t.getMessage(i):t.getMessageBlock(this.lr,i,s)}updateTypingCueLocale(t){this.fi.setAttribute("aria-label",t)}resetTypingCueIcon(){this.ur.remove(),this.ur=this.render()}updateTypingCueIcon(t){t.style.marginTop="0px",this.ur.firstChild.replaceWith(t)}setAutoTimeout(t){this.gr=t}}const Hi=["no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"],Di=["allow-downloads-without-user-activation","allow-downloads","allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-popups-to-escape-sandbox","allow-presentation","allow-same-origin","allow-scripts","allow-storage-access-by-user-activation","allow-top-navigation","allow-top-navigation-by-user-activation"],Ri="none",Ni="webview-container",Ui=`${Ni}-open`,Bi=`${Ni}-close`;class Wi{constructor(t,e,i){this.ii=e,this.He=i,this.br=.8,this.vr={closeButtonIcon:m,closeButtonType:"icon",errorInfoBar:!0,referrerPolicy:"no-referrer-when-downgrade",sandbox:[],size:"tall"},this.wr=!1,this.yr=!1,this.setProps(t||{}),this.Xi=i.name}setProps(t){Array.isArray(t.sandbox)&&t.sandbox.length&&(t.sandbox=t.sandbox.map((t=>t.toLowerCase())).filter((t=>Di.indexOf(t)>=0)));const e=Object.assign(Object.assign({},this.vr),t);var i;e.closeButtonIcon||(e.closeButtonIcon=this.vr.closeButtonIcon),e.closeButtonType||(e.closeButtonType="icon"),e.size||(e.size="tall"),i=e.referrerPolicy,Hi.indexOf(null==i?void 0:i.toLowerCase())>=0||(e.referrerPolicy="no-referrer-when-downgrade"),"full"===e.size&&(this.br=1),this.vr=e,this.wr=!1,this.yr=!1}open(t){if(this.kr){const e=this.ii,i=100;this.kr.style.height=i*this.br+"%",e.removeCSSClass(this.kr,Bi,Ri),e.addCSSClass(this.kr,Ui),this.kr.insertBefore(this._r,this.zr),this.zr.onload=()=>{this._r.remove(),e.removeCSSClass(this.zr,Ri)},this.vr.title||(this.Ke.textContent=t),this.vr.errorInfoBar&&setTimeout((()=>{this.wr&&!this.yr&&(this.Mr=this.Sr(),t&&(this.Cr.href=t),e.removeCSSClass(this.Mr,Ri),this.kr.appendChild(this.Mr),this.yr=!0)}),1e3),this.wr=!0}}close(){const t=this.ii;this.wr=!1,t.removeCSSClass(this.kr,Ui),t.addCSSClass(this.kr,Bi),this.Tr(),this.zr.setAttribute("src",""),setTimeout((()=>{t.addCSSClass(this.kr,Ri),t.removeCSSClass(this.zr,Ri)}),400)}render(){const t=this.ii,e=this.vr;return this.kr=t.createDiv(["webview-container"]),this.$r=t.createDiv(["header","webview-header","flex"]),this.Ke=t.createTextDiv(["title","webview-title","ellipsis"]),this.Ir=t.createIconButton({css:["header-button","webview-button-close"],icon:e.closeButtonIcon,iconCss:[],title:e.closeButtonLabel}),this.Ir.id=`${this.Xi}-webview-button-close`,this._r=this.Ar(),this.zr=t.createElement("iframe",["webview"]),this.zr.name=`${this.He.name}-webview`,this.zr.title=e.accessibilityTitle,e.title&&(this.Ke.textContent=e.title),"label"===e.closeButtonType?(this.Ir.classList.add(`${this.Xi}-label-only`),this.Ir.appendChild(document.createTextNode(e.closeButtonLabel))):"iconWithLabel"===e.closeButtonType&&(this.Ir.classList.add(`${this.Xi}-with-label`),this.Ir.appendChild(document.createTextNode(e.closeButtonLabel))),this.zr.setAttribute("referrerpolicy",e.referrerPolicy),this.vr.sandbox.length&&this.vr.sandbox.forEach((t=>{this.zr.sandbox.add(t)})),t.addCSSClass(this.kr,Ri),this.Ir.onclick=()=>{this.close()},this.$r.appendChild(this.Ke),this.$r.appendChild(this.Ir),this.kr.appendChild(this.$r),this.kr.appendChild(this.zr),this.kr}Ar(){return new Pi(this.ii).render()}Sr(){const t=this.ii,e=t.createDiv(["webview-error","flex"]);this.Or=t.createDiv(["webview-error-text"]),e.appendChild(this.Or),this.Er(this.vr.errorInfoText);const i=t.createIconButton({css:["webview-error-button-close"],icon:this.vr.closeButtonIcon,iconCss:[],title:this.vr.errorInfoDismissLabel});return i.onclick=this.Tr.bind(this),e.appendChild(i),e}Er(t){var e;const i=this.ii,s=(o=t,He.forEach((t=>{o=o.replace((0,a.resetRegex)(t.match),t.replace)})),o);var o;let r;const n=/\{0\}(.*)\{\/0\}/g,c=null===(e=n.exec(s))||void 0===e?void 0:e[1];if(c){const t=i.createAnchor("",c,["webview-alt-link"]);r=s.replace((0,a.resetRegex)(n),t.outerHTML)}else r=i.createAnchor("",s,["webview-alt-link"]).outerHTML;this.Or.innerHTML=r,this.Cr=this.Or.querySelector("a")}Tr(){const t=this.ii;this.yr&&(t.addCSSClass(this.Mr,Ri),setTimeout((()=>{this.kr.removeChild(this.Mr),this.yr=!1}),600))}}const Zi=window.setTimeout,Gi=window.setInterval,qi=36e5,Yi=864e5,Ji="relTimeNow",Ki="relTimeMoment";class Xi{constructor(t,e){this.ii=e,this.Ns=t.i18n[t.locale];const i=t.icons,s=t.name,o="-has-message-icon";this.Xi=s,this.Lr=`${s}-left ${i.avatarBot?`${s}${o}`:""}`,this.Pr=`${s}-right ${i.avatarUser?`${s}${o}`:""}`}render(){const t=this.ii;let e=this.ur;return e?(e.setAttribute("aria-live","off"),e.setAttribute("aria-hidden","true")):e=t.createTextDiv(),e.className=`${this.Xi}-relative-timestamp ${this.jr}`,this.ur=e,e}setLocale(t){if(this.Ns=t,this.Fr)switch(this.Fr){case Ji:case Ki:this.Vr(t[this.Fr]);break;default:this.Vr(t[this.Fr].replace("{0}",`${this.Hr}`))}}setRelativeTime(t){const e=(new Date).getTime()-t.getTime(),i=Math.floor(e/1e3),s=Math.floor(i/60),o=Math.floor(s/60),r=Math.floor(o/24),n=Math.floor(r/30),a=Math.floor(n/12);a>0?this.Dr(a):n>0?this.Rr(n):r>0?this.Nr(r):o>0?this.Ur(o):s>0?this.Br(s):this.Wr(i)}refresh(t){this.jr=t===s.SenderType.Skill?this.Lr:this.Pr,this.ur.className=`${this.Xi}-relative-timestamp ${this.jr}`,this.Zr()}remove(){var t;(null===(t=this.ur)||void 0===t?void 0:t.parentElement)&&this.ur.remove()}Zr(){this.Gr(Ji,1e4,this.Wr.bind(this))}Wr(t=10){t*=1e3,this.Gr(Ki,6e4-t,this.Br.bind(this))}Br(t=1){this.qr("relTimeMin",6e4,60,this.Ur.bind(this),t)}Ur(t=1){this.qr("relTimeHr",qi,24,this.Nr.bind(this),t)}Nr(t=1){this.qr("relTimeDay",Yi,30,this.Rr.bind(this),t)}Rr(t=1){this.qr("relTimeMon",2592e6,12,this.Dr.bind(this),t)}Dr(t=1){this.qr("relTimeYr",31536e6,60,(()=>{}),t)}Gr(t,e,i){this.Yr(),this.Vr(this.Ns[t]),this.Fr=t,this.Jr=Zi((()=>{i()}),e)}qr(t,e,i,s,o=1){this.Yr(),this.Vr(this.Ns[t].replace("{0}",`${o}`)),this.Fr=t,this.Hr=o,this.Jr=Gi((()=>{o++,this.Hr=o,o>i?(clearInterval(this.Jr),s()):this.Vr(this.Ns[t].replace("{0}",`${o}`))}),e)}Vr(t){this.ur||this.render(),this.ur.innerText=t}Yr(){clearTimeout(this.Jr),clearInterval(this.Jr)}}class Qi{constructor(t,e,i){let o,r;if(this.U=e,this.Os=i,this.Ri=new $t("MultiLangChatComponent"),this.Kr=!0,this.Xr=!0,this.Qr=!1,this.tn={},this.sn={},this.rn=[],this.Ro=e.webCore,this.He=e.settings,this.nn=this.He.i18n[this.He.locale],this.Xi=e.settings.name,t&&(this.an=Object.assign(Object.assign({},t),{supportedLangs:t.supportedLangs?[...t.supportedLangs]:[]}),o=this.an.supportedLangs,r=this.an.primary,"string"==typeof r&&(this.an.primary=r.toLowerCase())),o&&o.length)if(o.forEach((t=>{t.lang=t.lang.toLowerCase()})),o.length>1?(o.unshift({lang:"und",label:this.nn.language_detect}),this.an.primary||(this.an.primary=null)):this.an.primary=o[0].lang,this.rn=o.map((t=>t.lang)),this.He.enableBotAudioResponse){const t=e.synthesisVoices;if(t&&t.length){const e={};o.filter((t=>t.lang&&"und"!==t.lang)).forEach((i=>{const s=t.filter((t=>t.lang.indexOf(i.lang)>=0));s.push({lang:i.lang}),e[i.lang]=s})),this.sn=e}else new Set(this.rn.filter((t=>"und"!==t))).forEach((t=>{this.sn[t]=[{lang:t,name:t}]}))}else this.cn=()=>{};if(this.He.enableSpeech){const t={};Object.values(s.RecognitionLocale).forEach((e=>{t[e.substring(0,2)]=e,t[e]=e})),es(s.RecognitionLocale.EN_GB,t),es(s.RecognitionLocale.EN_AU,t),es(s.RecognitionLocale.EN_IN,t),this.tn=t}else this.hn=()=>{}}render(t){const e=this.U.util,i=this.Xi,s="language-selection",o=`${i}-${s}-button`,r=`${i}-${s}-menu`,n=this.an;let a;if(this.Qr=t,!(n&&n.supportedLangs&&n.supportedLangs.length>=2))return null;if(!this.kr){const i=this.He.icons.language||_,c=e.createIconButton({css:["header-button","button-lang"],icon:i,iconCss:[],title:this.nn.languageSelectDropdown}),h=e.createListItem("action-menu-option-lang",this.nn.languageSelectDropdown,"lang",i,"action-item",null,!0),l=n.supportedLangs.map((t=>{var i;const{lang:o,label:r}=t,a="und"===o&&n.primary?n.primary:o,c=`language_${"und"===o?"detect":o}`,h=(null===(i=this.He.i18n[a])||void 0===i?void 0:i[c])||r||o;return e.createListItem(`${s}-option-${o}`,h,o,"",`${s}-option`,(t=>{let e=t.target;"LI"!==e.tagName&&(e=e.parentElement);const i=e.dataset.value;this.ln(i)}))})),u=e.getMenu({menuId:r,menuClassList:[`${s}-menu`],menuItems:l,buttonId:o,menuButton:t?h:c});if(t){a=e.getMenuButton({button:h,menuId:r,menu:u,widget:this.Os.chatWidgetDiv});const t=e.createDiv(["arrow-icon"]),i=e.createImageIcon({icon:''});t.appendChild(i),a.appendChild(t),this.U.chatWidget.chatWidgetDiv.appendChild(u)}else{a=e.createDiv();const t=e.getMenuButton({button:c,menuId:r,menu:u,widget:this.Os.chatWidgetDiv});a.appendChild(t),a.appendChild(u),c.id=o}this.disableComponent(!1)}return this.kr=a,a}setLocale(t){this.kr&&this.an.supportedLangs.forEach((e=>{const{lang:i,label:s}=e,o=`language_${"und"===i?"detect":i}`,r=document.getElementById(`language-selection-option-${i}`);if(!r)return;const n=t[o]||s||i;r.title=n}))}setTag(t,e=!0){let i="";null!==t&&(i=t.toLowerCase()),this.rn.length&&(i=this.rn.indexOf(i)>=0?i:null),this.ln(i,e)}disableComponent(t){if(this.kr){const e=this.U.util,i=this.kr;if(this.Qr){const s="disable";t?e.addCSSClass(i,s):e.removeCSSClass(i,s)}else i.querySelector("button").disabled=t}}ln(t,e=!0){let i=t;this.nn=this.He.i18n[i],this.un!==i&&(this.un=i,this.U.eventDispatcher.trigger(o.CHAT_LANG,i)),this.kr&&this.pn(i),"und"===i&&(i=null),e&&(this.dn(i),this.U.storageService.setItem(ts(this.He),i)),this.cn(i),this.hn(i),this.U.chatWidget.onLanguageUpdate(i,e)}dn(t){if(this.Ro.isConnected()){const e={profile:{languageTag:t}};t||(e.profile.locale=t);const i=this.He.sdkMetadata?Object.assign({version:Ft},this.He.sdkMetadata):{version:Ft};this.Ro.updateUser(e,{sdkMetadata:i}).catch((t=>this.Ri.warn("[updateProfile] Failed to update user profile:",t)))}}cn(t){const e=this.U.chatWidget;if(t){if(this.Kr||(e.enableSpeechSynthesisService(!0),this.Kr=!0),this.He.enableBotAudioResponse){const e=this.sn[t];this.Ro.setTTSVoice(e).catch((t=>{this.Ri.info(`Failed to set TTS voice for '${e[0].lang}'. ${t}`),this.cn(null)}))}}else this.Kr=!1,this.He.enableBotAudioResponse&&this.Ro.cancelTTS(),e.enableSpeechSynthesisService(!1)}hn(t){const e=this.U,i=this.tn[t],s=e.chatWidget;i?(this.Xr||(s.setVoiceRecognitionService(!0),this.Xr=!0),this.Ro.setRecognitionLocale(i)):(this.Xr=!1,this.Ro.stopRecognition(),this.Ro.setRecognitionLocale(null),s.setVoiceRecognitionService(!1))}pn(t){const e=this.U.util,i=t||"und",s=document.getElementById(`${this.Xi}-language-selection-menu`),o="active";if(s){const t=s.querySelector(`li.${this.Xi}-${o}`);t&&e.removeCSSClass(t,o);const r=s.querySelector(`[data-value="${i}"]`);r&&e.addCSSClass(r,o)}}initLanguage(){const{primary:t}=this.an||{},e=this.U.storageService.getItem(ts(this.He));let i=t;e&&(i="null"===e?null:e),void 0!==i&&this.setTag(i)}}function ts(t){return`${t.name}-${t.channelId}-${t.userId}`}function es(t,e){navigator.language.toLowerCase()===t&&(e[t.substring(0,2)]=t)}class is{constructor(t){this.getItem=t=>(!this.gn[t]&&this.mn&&(this.gn[t]=this.fn.getItem(t)),this.gn[t]),this.setItem=(t,e)=>{this.mn?(this.fn.setItem(t,e),delete this.gn[t]):this.gn[t]=e},this.removeItem=t=>{this.mn&&this.fn.removeItem(t),delete this.gn[t]},this.gn={},n(t)?(this.mn=!0,this.fn=window[t]):this.mn=!1}}const ss="keydown";class os{constructor(t){var e;this.bn=new Map,this.vn=!0,this.wn=t=>{if(rs(t)&&this.xn(t.code)){const t=document.querySelector(this.yn);if(t){const e=t.value.length;setTimeout((()=>{t.value.length>e&&(t.value=t.value.slice(0,e))}))}}};const i=null!==(e=t.name)&&void 0!==e?e:"oda-chat";this.yn=`.${i}-user-input`}add(t,e,i=!0){this.vn&&(this.kn(),this.vn=!1);const s=t.toUpperCase(),o=isNaN(s)?`Key${s}`:`Digit${s}`;this.bn.set(o,{check:i,elem:e}),e.setAttribute("aria-keyshortcuts",`Alt+${s}`)}setWidget(t){this.Os=t}remove(){document.removeEventListener(ss,this.wn)}kn(){document.addEventListener(ss,this.wn)}xn(t){let e=!1;const i=this.bn.get(t),s=i&&i.elem;return s&&ns(i.check?this.Os:s)&&!s.disabled&&(s.focus(),s.click(),e=!0),e}}const rs=t=>t.altKey&&!t.ctrlKey&&!t.metaKey&&!t.shiftKey&&!t.repeat,ns=t=>null!==t.offsetParent,as="resize",cs=[`nw-${as}`,`se-${as}`,`nwse-${as}`,`w-${as}`,`e-${as}`],hs=[`ne-${as}`,`sw-${as}`,`nesw-${as}`,`e-${as}`,`w-${as}`];class ls{constructor(t,e,i){this.ur=t,this._n=e,this.zn=i,this.Mn=200,this.Sn=375,this.Cn=!1,this.Tn=!1}makeWidgetResizable(){const t=this.ur,e=this.zn,i=e.createDiv(["resizable",`top-${as}`]);i.addEventListener("mousedown",this.$n()),t.appendChild(i);const s=e.createDiv(["resizable",`left-${as}`]);s.addEventListener("mousedown",this.In()),t.appendChild(s);const o=e.createDiv(["resizable",`right-${as}`]);o.addEventListener("mousedown",this.In(!1)),t.appendChild(o);const r=e.createDiv(["resizable",`left-${as}`,"corner"]);r.addEventListener("mousedown",this.In(!0,!0)),r.addEventListener("mousedown",this.$n(!0)),t.appendChild(r);const n=e.createDiv(["resizable",`right-${as}`,"corner"]);n.addEventListener("mousedown",this.In(!1,!0)),n.addEventListener("mousedown",this.$n(!0)),t.appendChild(n)}In(t=!0,e=!1){const i=this.ur,s=t?cs:hs;let o;const r=r=>{const n=parseInt(getComputedStyle(i).maxWidth),a=i.offsetWidth;let c=o-r.x;t||(c=-c);const h=a+c;if(a=n?e?this.Tn?s[1]:s[2]:s[4]:e?s[2]:`col-${as}`,h>=this.Sn&&h<=n){const t=`${h}px`;i.style.width=t,this._n(t)}r.preventDefault()},n=()=>{document.removeEventListener("mouseup",n,!1),document.removeEventListener("mousemove",r,!1),document.body.style.removeProperty("cursor")};return t=>{t.preventDefault(),o=t.x,document.addEventListener("mouseup",n,!1),document.addEventListener("mousemove",r,!1)}}$n(t=!1){const e=this.ur;let i;const s=s=>{const o=i-s.y,r=parseInt(getComputedStyle(e).maxHeight),n=e.offsetHeight,a=n+o;n=r?(this.Tn=!0,t||(document.body.style.cursor=`s-${as}`)):(this.Cn=!1,this.Tn=!1,t||(document.body.style.cursor=`row-${as}`)),a>=this.Mn&&a<=r&&(e.style.height=`${a}px`),s.preventDefault()},o=()=>{document.removeEventListener("mouseup",o,!1),document.removeEventListener("mousemove",s,!1),document.body.style.removeProperty("cursor")};return t=>{t.preventDefault(),i=t.y,document.addEventListener("mouseup",o,!1),document.addEventListener("mousemove",s,!1)}}}class us{constructor(t){this.vr=t,this.An=!1,this.On=t=>{bs(t)||t.code===a.KeyCode.Esc&&(this.close(),t.stopPropagation())},this.En=t=>{bs(t)||t.code===a.KeyCode.Tab&&(t.target!==this.Ln||t.shiftKey?t.target===this.Pn&&t.shiftKey&&(t.preventDefault(),this.Ln.focus()):(t.preventDefault(),this.Pn.focus()))}}open(){if(this.An)return;const{parent:t,autoDismiss:e}=this.vr;if(this.jn=document.activeElement,this.An=!0,t.append(this.render()),this.Fn(),this.Vn(),e){setTimeout((()=>{this.close()}),1e4)}}close(){if(!this.An)return;const{domUtil:t,fallbackFocus:e}=this.vr,i="dialog-out";t.addCSSClass(this.Hn,i),setTimeout((()=>{this.Dn(),t.removeCSSClass(this.Hn,i),this.Rn.remove(),this.jn&&this.jn.offsetParent?this.jn.focus():e(),this.An=!1}),200)}render(){const{title:t,description:e,domUtil:i,icon:s,actions:o,showDismiss:r,dismissLabel:n}=this.vr,a="dialog",c=i.createDiv.bind(i),h=i.cssPrefix,l=c([`${a}-wrapper`]),u=c([`${a}-backdrop`]),p=c([`${a}-icon-content-wrapper`,"flex"]),d=c([`${a}-content`]),g=c([a]);if(s){const t=i.createImageIcon({icon:s}),e=c([`${a}-icon`]);fs(e,t),fs(p,e)}const f=`${a}-title`,b=i.createElement("h2",[f],!0);if(b.id=`${h}-${f}`,b.textContent=t,fs(d,b),e){const t=`${a}-description`,s=i.createTextDiv([t]);s.id=`${h}-${t}`,s.textContent=e,fs(d,s),g.setAttribute("aria-describedby",s.id)}if(fs(p,d),fs(g,p),r){const t=`${a}-close-button`,e=i.createIconButton({css:[t],icon:m,title:n,iconCss:[`${t}-icon`]});ci(e,ms,this.close.bind(this)),fs(g,e)}if(o&&o.length){const t=c(["action-wrapper","flex"]);o.forEach((e=>{const s=["popup-action"];e.type===ps&&s.push(ps);const o=i.createButton(s);o.innerHTML=e.label,ci(o,ms,(t=>{e.handler(t)})),t.appendChild(o)})),fs(g,t)}return fs(l,u,g),ii(g,{role:"alertDialog","aria-modal":"true","aria-labelledby":b.id}),this.Hn=g,this.Rn=l,this.Nn(g),l}Nn(t){const e=t.querySelectorAll("[tabIndex]:not([tabIndex^='-']), button");this.Pn=e[0],this.Ln=e[e.length-1]}Fn(){this.Pn.focus()}Vn(){const t=this.Hn;ci(t,ds,this.En),ci(t,gs,this.On)}Dn(){const t=this.Hn;hi(t,ds,this.En,!0),hi(t,gs,this.On,!0)}}const ps="filled",ds="keydown",gs="keyup",ms="click",fs=(t,...e)=>{t.append(...e)},bs=t=>t.ctrlKey||t.metaKey||t.altKey,vs="none";class ws extends li{constructor(t,e,i,s,o,r){super(),this.He=t,this.ii=e,this.Ro=i,this.Un=s,this.Ct=o,this.As=r,this.Ri=new $t("SearchBarWidgetComponent");const{getSuggestions:n,sendMessage:a,uploadFile:c,Ts:h,Bn:l,Is:u,Es:p}=this.Un;this.Wn=new zi(this.ii,a.bind(s),c.bind(s),this.He,n.bind(s),h.bind(s),l.bind(s),u.bind(s),this.As,s,p.bind(s)),this.He.showTypingIndicator&&(this.Zn=new Vi(Ot.LEFT,this.He,this.ii))}get footer(){return this.Wn}get typingIndicator(){return this.Zn}render(){return this.Gn()}appendMessageToConversation(t){const e=this.qn;e.textContent="",e.appendChild(t),this.ii.removeCSSClass(e,vs)}renderMessage(t,e){const i=this.qn,s=this.ii;if(i){Se(t)||(i.textContent="");const o=this.Yn(t,e,i);o&&(Se(t)||s.addCSSClass(o,"user-message"),i.appendChild(o))}}showMessage(t,e){const i=this.ii.getMessage(e.render());i.id=t,this.qn.appendChild(i)}Gn(){const t=this.He,e=document.getElementById(t.targetElement);let i;if(e){const t=this.ii,s=t.createDiv(["search-bar-widget-wrapper","wrapper"]),o=t.createDiv(["search-bar-widget"]),r=t.createDiv(["search-bar-widget-content"]);i=t.createDiv(["search-bar-popup",vs]),this.element=e,this.Un.element=e,this.Wn.render();const n=this.Wn.element.querySelector("textarea"),a=this.Wn.getSuggestionsList(),c=e=>{const o=e.target;o.isConnected&&!s.contains(o)&&("true"===n.getAttribute("aria-expanded")?t.addCSSClass(a,vs):t.addCSSClass(i,vs),document.removeEventListener("click",c))},h=()=>{(null==a?void 0:a.hasChildNodes())?t.removeCSSClass(a,vs):i.hasChildNodes()&&t.removeCSSClass(i,vs),document.addEventListener("click",c)};this.Ro.isConnected()||this.Ct(),t.setChatWidgetWrapper(s),r.appendChild(i),o.appendChild(r),s.appendChild(this.Wn.element),s.appendChild(o),e.appendChild(s),this.qn=i,n.addEventListener("input",(()=>{n.value&&(null==a?void 0:a.hasChildNodes())?t.addCSSClass(i,vs):t.removeCSSClass(i,vs)})),document.addEventListener("click",c),this.Wn.element.addEventListener("click",(()=>document.addEventListener("click",c))),n.addEventListener("focus",h),n.addEventListener("click",h),null==a||a.addEventListener("click",(()=>{setTimeout((()=>{a.childElementCount&&document.removeEventListener("click",c)}))}))}else this.Ri.error(`Cannot fetch search bar using the passed target element: ${t.targetElement}`);return i}Yn(t,e,i){const s=this.He.delegate;if(s&&s.render){const e=this.ii.createDiv(["message"]);e.id=t.msgId,e.lang=this.He.locale,i.appendChild(e);if(s.render(t))return null;e.remove()}return e.render()}}const xs=window.BroadcastChannel,ys="collapsed",ks="expanded",_s="none",zs=window.setTimeout,Ms=[s.MessageType.Suggest,s.MessageType.SessionClosed,s.MessageType.CloseSession,s.MessageType.Status],Ss=[s.MessageType.Text,s.MessageType.Attachment,s.MessageType.Location,s.MessageType.FormSubmission];class Cs extends li{constructor(t,e,i){var r,n,c;super(),this.skillMessages=[],this.contextWidgetMap={},this.Jn=[],this.Ri=new $t("ChatComponent"),this.Kn=[],this.Xn=0,this.Qn=[],this.ta=!0,this.ea=!0,this.ia=!1,this.sa=!1,this.oa=!1,this.ra=!0,this.na=!1,this.aa=[],this.ca=1e4,this.ha=new Map,this.la=t=>{this.Ri.warn("[sendMessage] Failed to send message",t)},this.Ro=t,this.He=e,this.Ct=i&&(0,a.isFunction)(i.connect)?i.connect:()=>{this.Ro.connect().catch((t=>this.Ri.error("Failed to connect to backend:",t)))},this.ua=i&&(0,a.isFunction)(i.openChat)?i.openChat:()=>{},this.pa=i&&(0,a.isFunction)(i.closeChat)?i.closeChat:()=>{},this.As=(null==i?void 0:i.eventDispatcher)||(0,a.generateEventDispatcher)(),this.da=i&&(0,a.isFunction)(i.handleSessionEnd)?i.handleSessionEnd:()=>{},this.ga=i&&(0,a.isFunction)(i.receivedMessage)?i.receivedMessage:t=>{this.As.trigger(o.MESSAGE_RECEIVED,t),this.As.trigger(o.MESSAGE,t)},this.ma=i&&(0,a.isFunction)(i.sentMessage)?i.sentMessage:t=>{this.As.trigger(o.MESSAGE_SENT,t),this.As.trigger(o.MESSAGE,t)},this.fa=i&&(0,a.isFunction)(i.onConnectionStatusChange)?i.onConnectionStatusChange:()=>{},this.ba=i&&(0,a.isFunction)(i.getUnreadMessagesCount)?i.getUnreadMessagesCount:()=>this.getUnreadMsgsCount(),this.ii=(null==i?void 0:i.util)||new ai(this.He),this.Xi=this.He.name,this.va=this.He.locale,this.wa=this.He.i18n[this.He.locale],this.isOpen=!1,this.sa="init"===(null===(r=this.He.initMessageOptions)||void 0===r?void 0:r.sendAt)||this.He.openChatOnLoad||this.He.embedded,this.ia=this.He.enableHeadless,this.xa=!this.He.embedded&&!this.He.sidepanel&&this.He.enableResizableWidget,this.ya=this.He.enableDefaultClientResponse,this.ka=this.He.enableLocalConversationHistory&&this.He.storageType!==Ie.CUSTOM,this.configureStorage(),this._a=!1;const h=this.za.getItem(this.Ma);h&&(this.He.icons.avatarUser=h),this.He.enableTabsSync||(this.Sa=()=>{}),this.He.threadId&&(this.ke=this.He.threadId,this.Ro.setCurrentThreadId(this.He.threadId)),this.Ca=()=>this.Ta(),this.Wo=t=>this.$a(t),this.Ia=t=>{const e=t,{endOfTurn:i,messagePayload:o,threadId:r}=e,n=Boolean(null==r?void 0:r.startsWith(`${s.ContextSource.UIWidget}:`));let a;if(n&&(a=this.contextWidgetMap[r]),o){if(o.type===s.MessageType.ExecuteApplicationActionCommand){const t=o;return n?a.showFullSizeWidget():this.Aa(Boolean(i)),void this.As.trigger(t.actionType,t)}if(n)a.onMessageReceived(e);else{const t=o.type===s.MessageType.Command&&"noReply"===o.command;r!==this.ke?this.Oa(r).then((()=>{t||this.Ea(e)})):t||this.Ea(e)}}else console.warn("Message Payload Not available")},this.Ro.on(s.CoreEvent.Open,this.Ca),this.Ro.on(s.CoreEvent.State,this.Wo),this.Ro.on(s.CoreEvent.MessageReceived,this.Ia),this.He.enableVoiceOnlyMode&&(this.La=()=>this.Ts(!0,this.He.enableVoiceOnlyMode),this.Ro.on(s.CoreEvent.TTSStop,this.La)),this.He.enableBotAudioResponse&&(this.ea=this.He.initBotAudioMuted),this.He.searchBarMode?(this.Pa=new ws(this.He,this.ii,this.Ro,this,this.Ct,this.As),this.Wn=this.Pa.footer,this.Zn=this.Pa.typingIndicator,this.ja=()=>{},this.updateNotificationBadge=()=>{},this.Fa=()=>{},this.Va=()=>{}):(this.$r=new Oi(this.He,this.ii,null===(n=this.pa)||void 0===n?void 0:n.bind(this),this.clearConversationHistory.bind(this),this.onToggleNarration.bind(this),this.Ro,this.Ha.bind(this),this.Es.bind(this),this),this.Wn=new zi(this.ii,this.sendMessage.bind(this),this.uploadFile.bind(this),this.He,this.getSuggestions.bind(this),this.Ts.bind(this),this.Bn.bind(this),this.Is.bind(this),this.As,this,this.Es.bind(this)),this.He.showTypingIndicator&&(this.Zn=new Vi(Ot.LEFT,this.He,this.ii)),!this.He.enableTimestamp||"relative"!==this.He.timestampMode&&"default"!==this.He.timestampMode?(this.Va=()=>{},this.Fa=()=>{}):this.Da=new Xi(this.He,this.ii)),"action"!==(null===(c=this.He.focusOnNewMessage)||void 0===c?void 0:c.toLowerCase())&&(this.Ra=()=>{});const l=this.za.getItem(this.Na);l&&(this.Ua=JSON.parse(l),this.Ba()),this.Ro.isConnected()&&this.Ta()}render(){const t=this.He,e=this.ii;var i,s;"undefined"!=typeof window&&(this.Wa(),i=t.position,(s=e).updateCSSVar("--position-top",i.top||"unset"),s.updateCSSVar("--position-left",i.left||"unset"),s.updateCSSVar("--position-right",i.right||"unset"),s.updateCSSVar("--position-bottom",i.bottom||"unset"),i.bottom&&s.updateCSSVar("--widget-max-height",`calc(100vh - 60px - ${i.bottom})`),t.font&&e.updateCSSVar("font",t.font),t.fontFamily&&e.updateCSSVar("font-family",t.fontFamily),t.fontSize&&e.updateCSSVar("font-size",t.fontSize)),t.searchBarMode?this.qn=this.Pa.render():(this.element=this.Zs(),this.Za(),t.multiLangChat&&this.Ga()),this.qa(t),this.Ya(),this.$a(this.Ro.getState())}embedInElement(t){const e=document.getElementById(t);if(!e)throw new Error("Can not embed chat widget.");this.ii.addCSSClass(e,"wrapper",this.He.theme,"embedded"),this.appendToElement(e)}showChat(){if(!this.isOpen){const t=this.ii;t.removeCSSClass(this.element,ys),t.addCSSClass(this.element,ks),t.removeCSSClass(this.chatWidgetDiv,_s),this.He.embedded||zs((()=>{t.addCSSClass(this.Ja,_s)}),250),this.isOpen=!0,this.sa=!0,this.updateNotificationBadge(0),this.ja(),this.Wn.focusTextArea(),this.Ta()}}onClose(){if(this.isOpen){const t=this.ii;this.Ka(),t.removeCSSClass(this.element,ks),t.addCSSClass(this.element,ys),this.He.embedded||(t.removeCSSClass(this.Ja,_s),zs((()=>{t.addCSSClass(this.chatWidgetDiv,_s),this.Ja.focus()}),250),this.updateNotificationBadge(this.ba())),this.isOpen=!1}}sendExitEvent(){const t={messagePayload:{type:s.MessageType.CloseSession},userId:this.He.userId};if(this.He.delegate&&this.He.delegate.beforeEndConversation&&(0,a.isFunction)(this.He.delegate.beforeEndConversation))try{this.He.delegate.beforeEndConversation(t).then((t=>{t&&this.sendMessage(t,{hidden:!0,delegate:!1}).catch(this.la)}))}catch(t){this.Ri.error(t)}else this.sendMessage(t,{hidden:!0,delegate:!1}).catch(this.la);this.ia=!1}updateNotificationBadge(t){var e;this.Xn=t,t>0?this.Xa&&(this.Xa.innerText=`${t}`,this.Ja.appendChild(this.Xa)):(null===(e=this.Xa)||void 0===e?void 0:e.parentElement)&&this.Xa.remove()}onToggleNarration(t){this.Qa(t),this.As.trigger(o.CLICK_AUDIO_RESPONSE_TOGGLE,t)}remove(){var t;super.remove(),null===(t=this.$r)||void 0===t||t.remove(),this.Ro.off(s.CoreEvent.Open,this.Ca),this.Ro.off(s.CoreEvent.State,this.Wo),this.Ro.off(s.CoreEvent.MessageReceived,this.Ia),this.La&&this.Ro.off(s.CoreEvent.TTSStop,this.La),this.He.embedded&&window.removeEventListener("resize",this.tc);const e=this.ec;e&&e.remove()}clearConversationHistory(t=!1){t?this.ic(t):(this.clearMessages(this.He.userId),this.ic(),this.sc({type:"actionClearHistory"})),this.oc=null,this.aa=[],this.skillMessages=[],this.Aa(),this.updateNotificationBadge(0)}clearMessages(t,e){const i=this.He;if(i.storageType===Ie.CUSTOM){const t=i.conversationHistoryProvider;(0,a.isFunction)(null==t?void 0:t.deleteMessages)?t.deleteMessages({threadId:i.threadId}):this.Ri.warn("Can not clear conversation history. Pass conversationHistoryProvider object with deleteMessages function when custom storage is enabled.")}else{const s=`${i.name}-${t}-messages`;(e?window[e]:this.za).getItem(s)&&this.za.removeItem(s)}}clearAllMessage(){const t=null===window||void 0===window?void 0:window.localStorage,e=(null==t?void 0:t.length)||0;if(e){const i=/oda-chat-.*-messages/g;for(let s=0;swindow.innerWidth&&(t.style.right="10px"),i=1024?(i.addCSSClass(e,"large-size"),i.removeCSSClass(e,"medium-size")):s>=900?(i.addCSSClass(e,"medium-size"),i.removeCSSClass(e,"large-size")):(i.removeCSSClass(e,"medium-size"),i.removeCSSClass(e,"large-size"))}}setHeight(t){const e=this.chatWidgetDiv;e&&!this.He.sidepanel&&(e.style.height=t,this.He.height=t)}setWidth(t){const e=this.He.sidepanel?this.chatWidgetWrapper:this.chatWidgetDiv;e&&(e.style.width=t,this.He.width=t,this.updateFullScreenWidth(t))}setSize(t,e){this.setHeight(e),this.setWidth(t)}setMessagePadding(t){this.ac("message-bubble",{padding:t}),this.He.messagePadding=t}setChatBubbleIconHeight(t){this.ac("typing-cue-wrapper",{height:t}),this.He.height=t}setChatBubbleIconWidth(t){this.ac("typing-cue-wrapper",{width:t}),this.He.width=t}setChatBubbleIconSize(t,e){this.ac("typing-cue-wrapper",{height:e,width:t}),this.He.width=t,this.He.height=e}onMessageActionClicked(t){const e=this.ii,i=this.wa;switch(this.Ts(!1),t.type){case s.ActionType.Postback:this.cc(this.Qn),this.ja(),t.getPayload().then((i=>{const{label:o,imageUrl:r}=t;this.sendMessage((0,s.buildUserMessage)({postback:i,text:r?e.createImage(r,[],o||"").outerHTML:o,type:s.MessageType.Postback})).catch((()=>{this.hc(this.Qn)}))}));break;case s.ActionType.Location:this.Bn();break;case s.ActionType.Share:navigator.share?t.getPayload().then((e=>navigator.share({text:e,title:t.label}))):this.lc(i.shareFailureMessage,V);break;case s.ActionType.SubmitForm:const o=t.messageComponent;if(!o.validateForm())break;const r=o.getSubmittedFields();if(this.ka){const t=this.getMessages();for(let e=t.length-1;e>=0;e--){const i=t[e];if(i.msgId===o.msgId&&i.messagePayload.type===s.MessageType.EditForm){const t=i.messagePayload;(0,s.isEditFormPayloadWithFields)(t)?t.fields.forEach((t=>{(0,s.isReadOnlyField)(t)||(t.defaultValue=r[t.id])})):t.formRows.forEach((t=>{t.columns.forEach((t=>{t.fields.forEach((t=>{(0,s.isReadOnlyField)(t)||(t.defaultValue=r[t.id])}))}))}));break}}this.za.setItem(this.uc,JSON.stringify(t))}this.ja(),t.getPayload().then((t=>{const e={postback:t,submittedFields:r,type:s.MessageType.FormSubmission};t||delete e.postback,this.sendMessage((0,s.buildUserMessage)(e),{hidden:!0}).catch(this.la)}));break;case s.ActionType.Call:t.getPayload().then((t=>{e.createAnchor(`tel:${t}`,"").click()}));break;case s.ActionType.Client:t.getPayload().then((t=>{"string"==typeof t?navigator.clipboard?navigator.clipboard.writeText(t).then((()=>{this.lc(i.copySuccessMessage,L)})):this.lc(i.copyFailureMessage,V):this.As.trigger(t.actionType,t)}));break;default:t.getPayload().then((i=>{e.createAnchor(i,"",[],this.He.openLinksInNewWindow,t.type===s.ActionType.Url?this.He.linkHandler:this.dc).click()}))}}applyDelegates(t){var e;let i;i="string"==typeof t?(0,s.buildUserTextMessage)(t,null===(e=this.speechFinalResult)||void 0===e?void 0:e.speechId):(0,s.isPostbackPayload)(t)?(0,s.buildPostbackMessage)(t):(0,s.isMessagePayload)(t)?(0,s.buildUserMessage)(t):t;const o=i.messagePayload.type,r=this.He.delegate,n=r.beforePostbackSend,c=r.beforeSend;return o===s.MessageType.Postback&&(0,a.isFunction)(n)?i=this.gc(i,n):Ss.includes(o)&&(0,a.isFunction)(c)&&(i=this.gc(i,c)),i}sendMessage(t,e){if(this.mc)return $s();this.Aa(),!this.He.enableSpeechAutoSend&&this.speechFinalResult&&"string"==typeof t&&t.toLowerCase().indexOf(this.speechFinalResult.text.toLowerCase())>=0&&(t=(0,s.buildUserTextMessage)(t,this.speechFinalResult.speechId)),this.Wn.focusTextArea(),this.Ka(),void 0===(e=e||{}).delegate&&(e.delegate=!0),e.delegate&&this.He.delegate&&(t=this.applyDelegates(t));const i=this.He.sdkMetadata?Object.assign({version:Ft},this.He.sdkMetadata):{version:Ft};return t&&this.Ro.sendMessage(t,{sdkMetadata:i}).then((i=>{this.Ri.debug("onMessageSent",t),(0,s.isEventPayload)(i.messagePayload)||(this.ma&&this.ma(i),this.fc(),this.na=!1,this.ya&&this.bc(),this.speechFinalResult=null,(null==e?void 0:e.hidden)?this.oc=s.SenderType.User:this.vc(i),this.getAgentDetails()||this.showTypingIndicator())}))}uploadFile(t,e){if(this.mc)return $s();const i=this.wa;this.Ka(),this.fc();const o=new Promise(((o,r)=>{var n,a;if(this.He.enableHeadless){const e=this.He.sdkMetadata?Object.assign({version:Ft},this.He.sdkMetadata):{version:Ft};this.Ro.uploadAttachment(t,{sdkMetadata:e}).then((t=>this.Ro.sendMessage(this.He.delegate?this.applyDelegates(t):t,{sdkMetadata:e}))).then(o).catch(r)}else{this.ja();const c=`${null===(n=t.name)||void 0===n?void 0:n.replace(/[\s:'"\\/[\]~,.;^`()@#%*+=$&!{}?<>|]/g,"")}${Math.floor(1e4+9e4*Math.random())}${Date.now()%1e5}`,h=this.ii.createDiv();if(h.id=c,this.Kn.push({divId:c,fileName:t.name}),this.Va(new Date),this.wc(h),this.xc=this.customFileMaxSize?this.customFileMaxSize:e?e.maxSize:Ht,t.size>this.xc){this.ja();const e=this.xc/1048576;let o=e.toString();"number"==typeof(a=e)&&isFinite(a)&&Math.floor(a)===a||(o=e.toFixed(3));const n=`${t.name} - ${i.uploadFailed}`,h=i.uploadFileSizeLimitExceeded.replace("{0}",o);this.yc(n,h,c),this.Fa(s.SenderType.User),r(new Error(h))}else if(0===t.size){this.ja();const e=`${t.name} - ${i.uploadFailed}`,o=i.uploadFileSizeZeroByte;this.yc(e,o,c),this.Fa(s.SenderType.User),r(new Error(o))}else{const e=new ji(t.name,Ot.RIGHT,this.He,this.ii),i=this.He.sdkMetadata?Object.assign({version:Ft},this.He.sdkMetadata):{version:Ft};this.Fa(s.SenderType.User),h.appendChild(e.render()),this.ja(),this.Ro.uploadAttachment(t,{sdkMetadata:i}).then((t=>this.Ro.sendMessage(this.He.delegate?this.applyDelegates(t):t,{sdkMetadata:i}))).then((e=>{e.messagePayload.attachment.title=t.name,h.remove(),this.Kn=this.Kn.filter((t=>t.divId!==c)),this.ra=!1,this.ma&&this.ma(e),this.vc(e),o(e)})).catch((e=>{this.kc(t.name,e.message,c),r(e)}))}}}));return o.catch((t=>{this.Ri.error(t)})),o}refreshTTS(){this.$r.showTTSButton(!!this.He.ttsService)}getSuggestions(t){if(this.mc)return $s();if(!this.He.enableAutocompleteClientCache||this.He.enableAutocompleteClientCache&&!this.Wn.getSuggestionsValid())return this.Ro.getSuggestions(t).then((t=>(this.Wn.displaySuggestions(t),t))).catch((t=>(this.Ri.debug("[getSuggestions] Failed to receive suggestions, reset list:",t),[])));const e=this._c(this.Wn.getSuggestions(),t);return null!==this.Wn&&this.Wn.displaySuggestions(e),Promise.resolve(e)}getUnreadMsgsCount(){return this.Xn}getMessages(){const t=this.za.getItem(this.uc);let e=[];if(t)try{e=JSON.parse(t).map((t=>Object.assign({},t)))}catch(t){this.Ri.error("Failed to parse saved chat.")}return e}getAgentDetails(){return this.Ua}setAgentDetails(t){this.Ua=Object.assign(Object.assign({},this.Ua),t),this.Ba(),this.za.setItem(this.Na,JSON.stringify(this.Ua))}setUserAvatar(t){this.He.icons.avatarUser=t,this.za.setItem(this.Ma,t);document.querySelectorAll(`.${this.Xi}-right .${this.Xi}-message-icon`).forEach((e=>{e.parentElement.replaceWith(this.zc(t,this.wa.avatarUser))}))}Mc(t){const e=Object.assign({date:Date.now()},t);if(this.Jn.push(e),this.He.storageType===Ie.CUSTOM){const t=this.He.conversationHistoryProvider;(0,a.isFunction)(null==t?void 0:t.saveMessage)?t.saveMessage(e):this.Ri.warn("Can not save conversation history. Pass conversationHistoryProvider object with saveMessage function when custom storage is enabled.")}else if(this.ka){const t=this.getMessages();t.length>=this.He.messageCacheSizeLimit&&t.splice(0,t.length-(this.He.messageCacheSizeLimit-1)),t.push(e),this.za.setItem(this.uc,JSON.stringify(t))}}configureStorage(){const t=this.He;this.ka&&(t.userId?t.storageType!==Ie.LOCAL&&t.storageType!==Ie.SESSION&&(t.storageType=Ie.LOCAL):t.storageType=Ie.SESSION),this.uc=`${t.name}-${t.userId}-messages`,this.Na=`${t.name}-${t.userId}-agent-details`,this.Ma=`${t.name}-${t.userId}-user-avatar`,this.za=new is(t.storageType)}setVoiceRecognitionService(t){this.Wn.disableVoiceModeButton(!t,{src:"lang"})}enableSpeechSynthesisService(t){this.$r.disableTTSButton(!t)}onShareLocation(){this.Bn()}setPrimaryChatLanguage(t){this.Sc.setTag(t)}onLanguageUpdate(t,e=!0){const i=this.He.i18n,s=Object.assign(Object.assign(Object.assign({},i.en),i[this.He.locale]),i[t]);e&&this.sc({type:"actionLanguage",tag:t}),this.va=t,this.Ja.title=s.chatButtonTitle||s.chatTitle,this.$r.setLocale(s),this.Wn.setLocale(s),this.He.showTypingIndicator&&this.Zn.updateTypingCueLocale(s.typingIndicator);document.querySelectorAll(`.${this.Xi}-message-icon`).forEach((t=>{const e=t.parentElement.parentElement.className.indexOf(`${this.Xi}-left`)<0?s.avatarUser:s.avatarBot;"img"===t.localName?t.alt=e:t.setAttribute("aria-label",e)})),this.refreshWebView({accessibilityTitle:s.webViewAccessibilityTitle,closeButtonLabel:s.webViewClose,errorInfoDismissLabel:s.webViewErrorInfoDismiss,errorInfoText:s.webViewErrorInfoText}),this.Sc&&this.Sc.setLocale(s),this.Cc&&(this.Cc.textContent=(0,a.formatDate)(this.Tc,{pattern:this.He.timestampFormat,locale:t})),this.Da&&this.Da.setLocale(s),this.$c&&(this.$c.innerText=s.previousChats),this.wa=s}showTypingIndicator(){const t=document.getElementById(`${this.Xi}-connection-error`);t&&t.remove(),this.He.showTypingIndicator&&(this.He.searchBarMode?this.Zn.append(this.qn):(this.Zn.append(this.Ic),this.ja()))}hideTypingIndicator(){this.He.showTypingIndicator&&this.Zn.remove()}showConnectionError(){const t={messagePayload:{type:s.MessageType.Text,text:(0,a.safeHTML)(this.wa.connectionFailureMessage),globalActions:[{type:s.ActionType.Postback,label:this.wa.connectionRetryLabel}]},source:s.SkillMessageSource.Bot},e=$e.fromMessage(this.He,this.ii,t);e.onActionClick=()=>{this.Ct()},this.showMessage(`${this.Xi}-connection-error`,e)}showMessage(t,e){var i;if(this.He.searchBarMode)this.Pa.showMessage(t,e);else{const i=this.ii.wrapMessageBlock(e.render(),this.He.icons.avatarBot,Ot.LEFT);i.id=t,this.Ic.appendChild(i)}(null===(i=this.Zn)||void 0===i?void 0:i.isVisible())&&this.hideTypingIndicator(),this.ja()}showWidget(){this.Ac(!0)}hideWidget(){this.Ac(!1)}Ac(t){const e=this.He;if(e.embedded||e.enableHeadless)return;const i=this.chatWidgetWrapper,s=`${this.ii.cssPrefix}-none`;i&&i.classList.contains(s)===t&&(i.classList.toggle(s),this.As.trigger(t?o.WIDGET_SHOW:o.WIDGET_HIDE))}Oc(t){if(this.ra=!1,!this.na){const e={source:s.SkillMessageSource.Bot,messagePayload:{type:s.MessageType.Text,text:t},userId:this.He.userId,msgId:`${Date.now()}`};this.Mc(e),this.Ec(t),this.Lc([e])}}bc(){const t=this.wa;this.Pc=zs((()=>{this.ra&&this.Oc(t.defaultGreetingMessage),this.jc=window.setInterval((()=>{this.Oc(t.defaultWaitMessage)}),this.He.defaultWaitMessageInterval*Dt),this.Fc=zs((()=>{window.clearInterval(this.jc)}),(this.He.typingIndicatorTimeout-1)*Dt),this.Pc=zs((()=>{this.hideTypingIndicator(),this.Oc(t.defaultSorryMessage)}),this.He.typingIndicatorTimeout*Dt)}),this.He.defaultGreetingTimeout*Dt)}$a(t){var e,i;if(Number.isInteger(t)&&t!==s.ConnectionState.Open){this.Vc(),this.Wn.isDisabled()||(this.Wn.disable(),null===(e=this.$r)||void 0===e||e.disable(),this.Ri.debug("WebSocket not open, send message button disabled")),this.Hc(),t===s.ConnectionState.Connecting?this.showTypingIndicator():this.hideTypingIndicator();for(const t of this.Kn)this.kc(t.fileName,s.CoreError.UploadNetworkFail,t.divId);this.Sc&&this.Sc.disableComponent(!0)}else this.Dc=void 0,this.hideTypingIndicator(),this.Sa(),this.Wn.isDisabled()&&(this.Wn.disable(!1),null===(i=this.$r)||void 0===i||i.disable(!1),this.Ri.debug("Connection established, send message button enabled")),this.Rc();this.fa(t)}Ga(){const t=this.He;this.Sc=new Qi(t.multiLangChat,{webCore:this.Ro,chatWidget:this,eventDispatcher:this.As,settings:t,synthesisVoices:t.ttsVoice,storageService:new is(t.storageType),util:this.ii},this),this.$r.addLanguageSelect(this.Sc)}Bn(){const t=this.wa;if(navigator&&navigator.geolocation){const e=new ji(t.requestLocation,Ot.RIGHT,this.He,this.ii);this.wc(e.render()),this.ja(),(0,s.getCurrentPosition)().then((t=>{const i=(0,s.buildUserMessage)({location:{latitude:t.latitude,longitude:t.longitude,title:void 0},type:s.MessageType.Location});e.remove(),this.sendMessage(i).catch(this.la)}),(i=>{let s;switch(i.code){case i.PERMISSION_DENIED:s=t.requestLocationDeniedPermission;break;case i.POSITION_UNAVAILABLE:s=t.requestLocationDeniedUnavailable;break;case i.TIMEOUT:s=t.requestLocationDeniedTimeout;break;default:s=t.requestLocationDeniedPermission}this.lc(s,V),e.remove()}))}else this.lc(t.requestLocationDeniedUnavailable,V)}_c(t,e){const i=[];for(const s of t)s.search(new RegExp(e,"i"))>=0&&i.push(s);return i}kc(t,e,i){const o=this.wa,r=`${t} - ${o.uploadFailed}`;let n="";switch(e){case s.CoreError.UploadMaxSize:n=o.uploadFileSizeLimitExceeded.replace("{0}",this.xc.toString());break;case s.CoreError.UploadZeroSize:n=o.uploadFileSizeZeroByte;break;case s.CoreError.UploadBadFile:n=o.uploadUnsupportedFileType;break;case s.CoreError.UploadNetworkFail:n=o.uploadFileNetworkFailure;break;case s.CoreError.UploadUnauthorized:n=o.uploadUnauthorized}this.yc(r,n,i)}gc(t,e){var i;const o=JSON.parse(JSON.stringify(t));let r,n=JSON.parse(JSON.stringify(t));t.messagePayload.type===s.MessageType.Text&&(null===(i=t.sdkMetadata)||void 0===i?void 0:i.speechId)&&(r=(t.messagePayload.text||"").toLowerCase());try{n=e(o)}catch(t){this.Ri.error(t)}if(n&&n.messagePayload||(n=null),n&&!(0,s.isValidMessage)(n)&&(this.Ri.error("The generated delegate message is invalid. Sending original message instead."),n=t),r&&n)if(n.messagePayload)if(n.messagePayload.type===s.MessageType.Text){const t=n.messagePayload.text;(null==t?void 0:t.toLowerCase().indexOf(r))<0&&delete n.sdkMetadata}else delete n.sdkMetadata;else delete n.sdkMetadata;return n}yc(t,e,i){const s=document.getElementById(i);if(s){s.firstElementChild&&s.removeChild(s.firstElementChild),this.Kn=this.Kn.filter((t=>t.divId!==i));const o=new Fi(t,e,Ot.RIGHT,this.He,this.ii,!0),r=this.He.icons.error||v;s.appendChild(o.render(r))}}Nc(t,e){const i=this.ii;let s,o,r=!1,n=!1,a=0,c=0,h=0,l=0,u=0,p=0;const d=t=>{let e,i;const s=t.target.classList;for(let o=0;o{let g,m;if(r){"touchmove"===d.type?(g=d.touches[0].clientX,m=d.touches[0].clientY):(g=d.clientX,m=d.clientY);const r=g-u,f=m-p;s=g-a,o=m-c,h=s,l=o,(r>=5||f>=5||r<=-5||f<=-5)&&(i.addCSSClass(t,"drag"),e.style.transform=`translate3d(${s}px, ${o}px, 0)`,e.onclick=null,n=!0)}},m=()=>{if(n){zs((()=>{var t;e.onclick=null===(t=this.ua)||void 0===t?void 0:t.bind(this)}),10),e.focus(),n=!1}r=!1},f=i.createDiv(["button-drag-handle"]);e.appendChild(f),e.addEventListener("touchstart",d),document.addEventListener("touchmove",g),e.addEventListener("touchend",m),e.addEventListener("mousedown",d),document.addEventListener("mousemove",g),e.addEventListener("mouseup",m)}addHeaderAction(t){this.$r.addAction(t)}updateHeaderAction(t){this.$r.hr(t)}on(t,e){switch(t){case s.SpeechSynthesisServiceEvent.TTSStart:case s.SpeechSynthesisServiceEvent.TTSStop:this.Ro.on(t,e);break;default:this.As.bind(t,e)}}off(t,e){switch(t){case s.SpeechSynthesisServiceEvent.TTSStart:case s.SpeechSynthesisServiceEvent.TTSStop:this.Ro.off(t,e);break;default:this.As.unbind(t,e)}}Zs(){var t,e,i,s,o,r;const n=this.He,a=this.ii,c=this.wa,h=a.createDiv(n.embedded?[]:["wrapper",n.theme,n.enableHeadless?"none":""]);this.chatWidgetDiv=a.createDiv(["widget","flex","col"]),this.chatWidgetDiv.setAttribute("role","region"),this.chatWidgetDiv.setAttribute("aria-labelledby",`${this.Xi}-title`),this.ii.setChatWidgetWrapper(h),this.$r.render(),this.chatWidgetDiv.appendChild(this.$r.element),n.embedTopStickyId&&this.Uc(n.embedTopStickyId,this.chatWidgetDiv,["embed-sticky-top"]),this.Bc=new Li(a),this.Wc=a.createDiv(["conversation-pane",n.icons.avatarBot?"bot-icon":"",n.icons.avatarUser?"user-icon":""]),"bottom"===n.conversationBeginPosition&&(this.Wc.style.marginTop="auto"),n.embedTopScrollId&&this.Uc(n.embedTopScrollId,this.Wc,["embed-scroll-top"]),this.Ic=a.createDiv(["conversation-container"]),this.Ic.setAttribute("role","log"),this.Ic.setAttribute("aria-live","polite"),this.Ic.setAttribute("aria-atomic","false"),this.Wc.appendChild(this.Ic),this.Bc.element.appendChild(this.Wc),n.embedBottomScrollId&&this.Uc(n.embedBottomScrollId,this.Bc.element,["embed-scroll-bottom"]),this.chatWidgetDiv.appendChild(this.Bc.element),n.embedBottomStickyId&&this.Uc(n.embedBottomStickyId,this.chatWidgetDiv,["embed-sticky-bottom"]),this.Wn.render(),this.chatWidgetDiv.appendChild(this.Wn.element),(e=n.webViewConfig).accessibilityTitle||(e.accessibilityTitle=c.webViewAccessibilityTitle),(i=n.webViewConfig).closeButtonLabel||(i.closeButtonLabel=c.webViewClose),(s=n.webViewConfig).errorInfoDismissLabel||(s.errorInfoDismissLabel=c.webViewErrorInfoDismiss),(o=n.webViewConfig).errorInfoText||(o.errorInfoText=c.webViewErrorInfoText),(r=n.webViewConfig).closeButtonIcon||(r.closeButtonIcon=n.icons.close),this.rc=new Wi(n.webViewConfig,a,n),this.nc=this.rc.render(),this.chatWidgetDiv.appendChild(this.nc);const l=this.rc,u=`${this.Xi}-webview`;if(this.dc={target:u,onclick:function(){l.open(this.href)}},n.linkHandler&&n.linkHandler.target===u&&(n.linkHandler=this.dc),h.appendChild(this.chatWidgetDiv),n.embedded)this.isOpen=!0,a.addCSSClass(h,"open");else{const e=n.icons.launch||(n.colors&&n.colors.branding?z.replace("#025e7e",n.colors.branding):z),i="button",s=a.createIconButton({css:[i],icon:e,iconCss:[`${i}-icon`],title:c.chatButtonTitle||c.chatTitle});s.classList.remove(`${this.Xi}-icon`),this.Ja=s,this.Ja.onclick=null===(t=this.ua)||void 0===t?void 0:t.bind(this),this.Xa=a.createTextDiv(["notification-badge"]),h.appendChild(s),this.ha.set("launch",s),n.enableDraggableButton&&this.Nc(h,s),n.openChatOnLoad||a.addCSSClass(h,ys),a.addCSSClass(this.chatWidgetDiv,_s)}if(this.chatWidgetWrapper=h,n.sidepanel){const t=t=>{const e=window.screen.width-t.x;if(a.addCSSClass(this.chatWidgetWrapper,"drag"),document.body.style.cursor=e<=375?"w-resize":e>=800?"e-resize":"col-resize",e>=375&&e<=800){const t=`${e}px`;this.chatWidgetWrapper.style.width=t,this.updateFullScreenWidth(t)}t.preventDefault()};h.addEventListener("mousedown",(e=>{e.offsetX<4&&document.addEventListener("mousemove",t,!1)}),!1),document.addEventListener("mouseup",(()=>{document.removeEventListener("mousemove",t,!1),a.removeCSSClass(this.chatWidgetWrapper,"drag"),this.chatWidgetWrapper.style.removeProperty("cursor"),document.body.style.removeProperty("cursor")}),!1)}else if(this.xa){new ls(this.chatWidgetDiv,this.updateFullScreenWidth.bind(this),a).makeWidgetResizable()}return this.chatWidgetWrapper}Wa(){const t=this.He;if(!t.disableInlineCSS){let t=!1;const e=document.head.children,i=document.createElement("style");i.appendChild(document.createTextNode('@keyframes scale-in-center{0%{opacity:1;transform:scale(0)}100%{opacity:1;transform:scale(1)}}@keyframes scale-out-center{0%{display:flex;opacity:1;transform:scale(1)}100%{display:none;opacity:1;transform:scale(0)}}@keyframes scale-in-br{0%{opacity:1;transform:scale(0);transform-origin:100% 100%}100%{opacity:1;transform:scale(1);transform-origin:100% 100%}}@keyframes scale-in-bl{0%{opacity:1;transform:scale(0);transform-origin:0 100%}100%{opacity:1;transform:scale(1);transform-origin:0 100%}}@keyframes scale-in-tl{0%{opacity:1;transform:scale(0);transform-origin:0 0}100%{opacity:1;transform:scale(1);transform-origin:0 0}}@keyframes scale-in-tr{0%{opacity:1;transform:scale(0);transform-origin:100% 0}100%{opacity:1;transform:scale(1);transform-origin:100% 0}}@keyframes scale-out-br{0%{opacity:1;transform:scale(1);transform-origin:100% 100%}99%{opacity:1;transform:scale(0.01);transform-origin:100% 100%}100%{display:none;opacity:1;transform:scale(0);transform-origin:100% 100%}}@keyframes scale-out-bl{0%{opacity:1;transform:scale(1);transform-origin:0 100%}99%{opacity:1;transform:scale(0.01);transform-origin:0 100%}100%{display:none;opacity:1;transform:scale(0);transform-origin:0 100%}}@keyframes popup-suggestion{0%{box-shadow:0 0 0 0 rgba(0,0,0,0),0 0 0 0 rgba(0,0,0,0);transform:scaleY(0.4);transform-origin:0 100%}100%{box-shadow:0 -12px 15px -12px rgba(0,0,0,.35);transform:scaleY(1);transform-origin:0 100%}}@keyframes spin{from{transform:rotate(0)}to{transform:rotate(360deg)}}@keyframes dialog-in{0%{transform:translateY(-20px);opacity:0}100%{transform:translateY(0);opacity:1}}@keyframes dialog-out{0%{transform:translateY(0);opacity:1}100%{transform:translateY(-20px);opacity:0}}@keyframes typing-cue{0%{opacity:1}30%{opacity:.1}50%{opacity:1}100%{opacity:.1}}@keyframes oda-chat-webview-slide-out-bottom{0%{transform:translateY(0);opacity:1}95%{opacity:1}100%{transform:translateY(100%);opacity:0}}@keyframes oda-chat-webview-slide-in-bottom{0%{transform:translateY(100%);opacity:0}1%{opacity:1}100%{transform:translateY(0%);opacity:1}}.flex{display:flex;justify-content:space-between;align-items:center}.col{flex-direction:column}.none{display:none !important}.wrapper{--color-branding: #c0533f;--color-launch-icon-background: #c0533f;--color-text: #161513;--color-text-light: #161513;--color-header-background: #F1EFED;--color-header-button-fill: #161513;--color-header-text: #161513;--color-header-button-background-hover: rgba(22, 21, 19, 0.04);--color-header-button-fill-hover: #161513;--color-conversation-background: #F5F4F2;--color-timestamp: rgba(22, 21, 19, 0.65);--color-typing-indicator: #161513;--color-agent-initials: #FFFFFF;--color-agent-avatar-background: #A890B6;--color-agent-name: rgba(22, 21, 19, 0.65);--color-bot-message-background: #FFFFFF;--color-bot-text: #161513;--color-user-message-background: #E4E1DD;--color-user-text: #161513;--color-error-message-background: #FFF8F7;--color-error-border: #DC5C5E;--color-error-title: #D63B25;--color-error-text: #161513;--color-card-background: #FFFFFF;--color-card-nav-button: #FFF;--color-card-nav-button-focus: #FBF9F8;--color-card-nav-button-hover: #FBF9F8;--color-actions-background: #fff;--color-actions-background-focus: rgba(22, 21, 19, 0.04);--color-actions-background-hover: rgba(22, 21, 19, 0.04);--color-actions-border: rgba(22, 21, 19, 0.5);--color-actions-text: #161513;--color-actions-text-focus: #161513;--color-actions-text-hover: #161513;--color-global-actions-background: transparent;--color-global-actions-background-focus: rgba(22, 21, 19, 0.04);--color-global-actions-background-hover: rgba(22, 21, 19, 0.04);--color-global-actions-border: rgba(22, 21, 19, 0.5);--color-global-actions-text: #161513;--color-global-actions-text-focus: #161513;--color-global-actions-text-hover: #161513;--color-primary-actions-background: rgb(49, 45, 42);--color-primary-actions-background-focus: rgb(49, 45, 42) linear-gradient(rgb(58, 54, 50), rgb(58, 54, 50));--color-primary-actions-background-hover: rgb(49, 45, 42) linear-gradient(rgb(58, 54, 50), rgb(58, 54, 50));--color-primary-actions-border: transparent;--color-primary-actions-text: #fff;--color-primary-actions-text-focus: #fff;--color-primary-actions-text-hover: #fff;--color-danger-actions-background: rgb(214, 59, 37);--color-danger-actions-background-focus: rgb(214, 59, 37) linear-gradient(rgb(195, 53, 34), rgb(195, 53, 34));--color-danger-actions-background-hover: rgb(214, 59, 37) linear-gradient(rgb(195, 53, 34), rgb(195, 53, 34));--color-danger-actions-border: transparent;--color-danger-actions-text: #fff;--color-danger-actions-text-focus: #fff;--color-danger-actions-text-hover: #fff;--color-links: #c0533f;--color-user-links: #c0533f;--color-rating-star: #ececec;--color-rating-star-fill: #f0cc71;--color-horizontal-rule-background: #cbc5bf;--color-attachment-placeholder: #e3e1dc;--color-attachment-footer: #fff;--color-attachment-text: #161513;--color-footer-background: #fff;--color-footer-button-fill: #161513;--color-footer-button-background-hover: rgba(22, 21, 19, 0.04);--color-footer-button-fill-hover: #161513;--color-input-background: #fff;--color-input-border: #fff;--color-input-text: #161513;--color-recognition-view-text: #fff;--color-visualizer: #161513;--color-visualizer-container-background: #fff;--color-notification-badge-background: #312d2a;--color-notification-badge-text: #fff;--color-popup-background: #fff;--color-popup-text: #161513;--color-popup-button-background: #fff;--color-popup-button-text: #161513;--color-popup-horizontal-rule: #cbc5bf;--color-popup-item-background-hover: rgba(22, 21, 19, 0.04);--color-table-header-background: #f1efec;--color-table-header-text: #161513;--color-table-background: #fff;--color-table-text: #161513;--color-table-separator: rgba(22, 21, 19, 0.1);--color-table-row-background-hover: rgba(22, 21, 19, 0.04);--color-table-actions-background: transparent;--color-table-actions-background-focus: rgba(22, 21, 19, 0.04);--color-table-actions-background-hover: rgba(22, 21, 19, 0.04);--color-table-actions-border: rgba(22, 21, 19, 0.5);--color-table-actions-text: #161513;--color-table-actions-text-focus: #161513;--color-table-actions-text-hover: #161513;--color-form-header-background: #f1efec;--color-form-header-text: #161513;--color-form-background: #fff;--color-form-text: #161513;--color-form-input-background: #fff;--color-form-input-border: rgba(22, 21, 19, 0.5);--color-form-input-border-focus: rgb(14, 114, 151);--color-form-input-text: #161513;--color-form-label: rgba(22, 21, 19, 0.65);--color-form-error: rgba(179,49,31);--color-form-error-text: rgba(22, 21, 19, 0.65);--color-form-actions-background: transparent;--color-form-actions-background-focus: rgba(22, 21, 19, 0.04);--color-form-actions-background-hover: rgba(22, 21, 19, 0.04);--color-form-actions-border: rgba(22, 21, 19, 0.5);--color-form-actions-text: #161513;--color-form-actions-text-focus: #161513;--color-form-actions-text-hover: #161513;--color-primary-form-actions-background: rgb(49, 45, 42);--color-primary-form-actions-background-focus: rgb(49, 45, 42) linear-gradient(rgb(58, 54, 50), rgb(58, 54, 50));--color-primary-form-actions-background-hover: rgb(49, 45, 42) linear-gradient(rgb(58, 54, 50), rgb(58, 54, 50));--color-primary-form-actions-border: transparent;--color-primary-form-actions-text: #fff;--color-primary-form-actions-text-focus: #fff;--color-primary-form-actions-text-hover: #fff;--color-danger-form-actions-background: rgb(214, 59, 37);--color-danger-form-actions-background-focus: rgb(214, 59, 37) linear-gradient(rgb(195, 53, 34), rgb(195, 53, 34));--color-danger-form-actions-background-hover: rgb(214, 59, 37) linear-gradient(rgb(195, 53, 34), rgb(195, 53, 34));--color-danger-form-actions-border: transparent;--color-danger-form-actions-text: #fff;--color-danger-form-actions-text-focus: #fff;--color-danger-form-actions-text-hover: #fff;--width-full-screen: 375px;--widget-max-height: calc(100vh - 60px);--position-top: 0;--position-left: 0;--position-right: 20px;--position-bottom: 20px;--font-family: "Oracle Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", sans-serif;position:fixed;box-sizing:border-box;text-transform:none;z-index:10000;color:var(--color-text);font-size:16px;font-family:var(--font-family);-webkit-font-smoothing:antialiased}.wrapper.classic{--color-branding: #025e7e;--color-launch-icon-background: #025e7e;--color-text: #161513;--color-text-light: #3a3631;--color-header-background: #025e7e;--color-header-button-fill: #fff;--color-header-button-fill-hover: #fff;--color-header-text: #fff;--color-conversation-background: #fff;--color-timestamp: #5b5652;--color-typing-indicator: #227e9e;--color-bot-message-background: #e5f1ff;--color-user-message-background: #ececec;--color-card-background: #e5f1ff;--color-card-nav-button: #4190ac;--color-card-nav-button-focus: #5fa2ba;--color-card-nav-button-hover: #0e7295;--color-actions-background: transparent;--color-actions-background-focus: rgba(14, 114, 149, 0.04);--color-actions-background-hover: rgba(14, 114, 149, 0.04);--color-actions-border: rgb(14, 114, 149);--color-actions-text: rgb(14, 114, 149);--color-actions-text-focus: rgb(14, 114, 149);--color-actions-text-hover: rgb(14, 114, 149);--color-global-actions-background: #fff;--color-global-actions-background-focus: rgba(14, 114, 149, 0.04);--color-global-actions-background-hover: rgba(14, 114, 149, 0.04);--color-global-actions-border: rgb(14, 114, 149);--color-global-actions-text: rgb(14, 114, 149);--color-global-actions-text-focus: rgb(14, 114, 149);--color-global-actions-text-hover: rgb(14, 114, 149);--color-primary-actions-background: rgb(14, 114, 149);--color-primary-actions-background-focus: rgba(14, 114, 149, 0.95);--color-primary-actions-background-hover: rgba(14, 114, 149, 0.95);--color-links: #0e7295;--color-user-links: #0e7295;--color-agent-name: #5b5652;--color-attachment-footer: #e5f1ff;--color-footer-background: #fff;--color-footer-button-fill: #161513;--color-footer-button-fill-hover: #025e7e;--color-visualizer: #025e7e;--color-primary-form-actions-background: rgb(14, 114, 149);--color-primary-form-actions-background-focus: rgba(14, 114, 149, 0.95);--color-primary-form-actions-background-hover: rgba(14, 114, 149, 0.95);--color-notification-badge-background: #9a0007;--color-notification-badge-text: #fff;--color-popup-button-text: #025e7e}.wrapper.redwood-dark{--color-branding: #c0533f;--color-launch-icon-background: #c0533f;--color-text: #161513;--color-text-light: #fcfbfa;--color-header-background: #201e1c;--color-header-button-fill: #fff;--color-header-button-fill-hover: #fff;--color-header-button-background-hover: rgba(255, 255, 255, 0.04);--color-header-text: #fff;--color-conversation-background: #3a3631;--color-timestamp: #fcfbfa;--color-typing-indicator: #fff;--color-bot-message-background: #655f5c;--color-bot-text: #fff;--color-user-message-background: #fff;--color-user-text: #161513;--color-card-background: #655f5c;--color-card-nav-button: #d5b364;--color-card-nav-button-focus: #f7e0a1;--color-card-nav-button-hover: #b39554;--color-actions-background: #655f5c;--color-actions-background-focus: rgba(22, 21, 19, 0.5);--color-actions-background-hover: rgba(22, 21, 19, 0.3);--color-actions-border: #fff;--color-actions-text: #fff;--color-actions-text-focus: #fff;--color-actions-text-hover: #fff;--color-global-actions-background: #3a3631;--color-global-actions-background-focus: rgba(22, 21, 19, 0.3);--color-global-actions-background-hover: rgba(22, 21, 19, 0.3);--color-global-actions-border: #fff;--color-global-actions-text: #fff;--color-global-actions-text-focus: #fff;--color-global-actions-text-hover: #fff;--color-primary-actions-background: #fff;--color-primary-actions-background-focus: #fff linear-gradient(rgb(251, 249, 248), rgb(251, 249, 248));--color-primary-actions-background-hover: #fff linear-gradient(rgb(251, 249, 248), rgb(251, 249, 248));--color-primary-actions-text: #161513;--color-primary-actions-text-focus: #161513;--color-primary-actions-text-hover: #161513;--color-danger-actions-background-focus: rgb(214, 59, 37) linear-gradient(rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.08));--color-danger-actions-background-hover: rgb(214, 59, 37) linear-gradient(rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.08));--color-links: #f7e0a1;--color-user-links: #c0533f;--color-agent-name: #fcfbfa;--color-footer-background: #fff;--color-footer-button-fill: #161513;--color-input-background: #fff;--color-input-text: #161513;--color-recognition-view-text: #fff;--color-visualizer-container-background: #fff;--color-notification-badge-background: #312d2a;--color-notification-badge-text: #fff;--color-popup-button-text: #201e1c}.wrapper:not(.embedded):not(.contextual-widget):not(.search-bar-widget-wrapper){bottom:var(--position-bottom);left:var(--position-left);top:var(--position-top);right:var(--position-right)}.wrapper *{box-sizing:border-box}.wrapper b{font-weight:700}.wrapper button{position:relative;max-width:100%;padding:9px 16px;margin:0 0 8px;min-height:36px;line-height:16px;font-size:13.75px;font-weight:600;font-family:inherit;border-radius:4px;border-width:thin;border-style:solid;cursor:pointer;overflow:hidden;word-break:break-word;flex-shrink:0}.wrapper button:disabled{opacity:.5;cursor:not-allowed}.wrapper button.icon{width:36px;height:36px;padding:8px;margin:0;margin-inline-start:4px;border:none;border-radius:4px;color:var(--color-text);background-color:rgba(0,0,0,0);justify-content:center}.wrapper button.icon.with-label{width:auto;max-width:200px}.wrapper button.icon.with-label svg,.wrapper button.icon.with-label img{margin-right:4px}.wrapper button.icon.label-only{width:auto;max-width:200px}.wrapper button.icon.label-only svg,.wrapper button.icon.label-only img{display:none}.wrapper button svg,.wrapper button img{width:20px;height:20px;flex-shrink:0}.wrapper .button{position:absolute;right:0;bottom:0;height:48px;width:48px;max-width:unset;padding:0;margin:0;border:none;background-position:center center;background-repeat:no-repeat;cursor:pointer;justify-content:center;align-items:center;z-index:10000;color:var(--color-text);background-color:var(--color-launch-icon-background);border-radius:0;overflow:visible}.wrapper .button svg,.wrapper .button img{height:unset;width:unset;max-width:100%;max-height:100%}.wrapper .button:not(:disabled):hover,.wrapper .button:not(:disabled):focus,.wrapper .button:not(:disabled):active{background-color:var(--color-launch-icon-background)}@media screen and (min-width: 769px){.wrapper .button{height:64px;width:64px}}.wrapper .dialog-wrapper{position:absolute;top:0;left:0;right:0;width:100%;height:100%}.wrapper .dialog-wrapper .dialog-backdrop{position:absolute;background:rgba(0,0,0,.2);height:100%;width:100%;z-index:5}.wrapper .dialog-wrapper .dialog{box-shadow:rgba(0,0,0,.16) 0px 4px 8px 0px;border-radius:6px;display:flex;position:absolute;max-width:450px;min-height:48px;max-height:60%;top:30%;left:0;right:0;padding:8px 16px;margin:8px auto;width:calc(100% - 16px);z-index:5;animation:dialog-in .2s cubic-bezier(0.22, 0.45, 0.42, 0.92) both;background-color:var(--color-popup-background);flex-direction:column;align-items:flex-start;overflow-y:auto}.wrapper .dialog-wrapper .dialog.dialog-out{animation:dialog-out .2s cubic-bezier(0.5, 0.07, 0.68, 0.48) both}.wrapper .dialog-wrapper .dialog .dialog-icon-content-wrapper{margin:16px 0;align-items:flex-start}.wrapper .dialog-wrapper .dialog .dialog-icon-content-wrapper .dialog-icon{margin:4px 16px 0 0}[dir=rtl] .wrapper .dialog-wrapper .dialog .dialog-icon-content-wrapper .dialog-icon{margin:4px 0 0 16px}.wrapper .dialog-wrapper .dialog .dialog-icon-content-wrapper .dialog-title{margin:0 28px 0 0;font-family:var(--font-family);font-size:18px;font-weight:bold;color:var(--color-popup-text)}[dir=rtl] .wrapper .dialog-wrapper .dialog .dialog-icon-content-wrapper .dialog-title{margin:0 0 0 28px}.wrapper .dialog-wrapper .dialog .dialog-icon-content-wrapper .dialog-description{color:var(--color-popup-text);opacity:.6;font-size:13px;margin:8px 28px 0 0}[dir=rtl] .wrapper .dialog-wrapper .dialog .dialog-icon-content-wrapper .dialog-description{margin:8px 0 0 28px}.wrapper .dialog-wrapper .dialog .dialog-icon-content-wrapper .dialog-label{color:var(--color-popup-text);font-size:large}.wrapper .dialog-wrapper .dialog .dialog-icon-content-wrapper .dialog-input{font-size:medium;min-height:36px;width:100%;margin:0 0 10px 0;padding:10px;color:var(--color-form-input-text);background-color:var(--color-form-actions-background);border:1px solid var(--color-form-input-border);border-radius:4px}.wrapper .dialog-wrapper .dialog .dialog-close-button{position:absolute;border:none;right:16px}[dir=rtl] .wrapper .dialog-wrapper .dialog .dialog-close-button{right:unset;left:16px}.wrapper .dialog-wrapper .dialog .action-wrapper{width:100%;margin:16px 0 6px}.wrapper .dialog-wrapper .dialog .action-wrapper .popup-action{background-color:var(--color-popup-button-background);border-color:var(--color-popup-button-text);color:var(--color-popup-button-text);border-style:solid;margin:0;height:34px;justify-content:center;width:49%}.wrapper .dialog-wrapper .dialog .action-wrapper .popup-action:hover{background-color:var(--color-footer-button-background-hover)}.wrapper .dialog-wrapper .dialog .action-wrapper .popup-action:last-child{margin:0}.wrapper .dialog-wrapper .dialog .action-wrapper .popup-action.filled{background-color:var(--color-popup-button-text);color:var(--color-popup-button-background)}.wrapper .dialog-wrapper .dialog .action-wrapper .popup-action.filled:hover{opacity:.9}.wrapper .header{height:56px;padding:0 8px;background-color:var(--color-header-background);color:var(--color-header-text)}.wrapper .header .logo{flex:0 0 auto;max-width:100px;height:36px;max-height:36px;overflow:hidden;padding:0}.wrapper .header .header-info-wrapper{flex-direction:column;flex-wrap:nowrap;width:100%;min-width:0;padding:0;margin:0 8px}.wrapper .header .header-info-wrapper .title{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:1.125em;font-weight:700}.wrapper .header .header-info-wrapper .subtitle{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.wrapper .header .header-info-wrapper .connection-status{font-weight:bold;font-size:10px;justify-content:center;padding:0;margin:0;text-transform:uppercase;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.wrapper .header .header-gap{flex:auto}.wrapper .header-actions{flex:1 0 auto;justify-content:flex-end;flex-direction:inherit}.wrapper .header-button svg>path{fill:var(--color-header-button-fill)}.wrapper .header-button:not(:disabled):hover,.wrapper .header-button:not(:disabled):focus{background-color:var(--color-header-button-background-hover)}.wrapper .header-button:not(:disabled):hover svg>path,.wrapper .header-button:not(:disabled):focus svg>path{fill:var(--color-header-button-fill-hover)}.wrapper .conversation{display:flex;flex:1;-webkit-box-orient:vertical;-webkit-box-direction:normal;flex-direction:column;overflow-x:hidden;overflow-y:auto;scroll-behavior:smooth;width:100%;padding:16px}.wrapper .conversation .conversation-pane .message-date,.wrapper .conversation .conversation-pane .relative-timestamp{font-size:12px;margin:8px 0 8px;color:var(--color-timestamp);text-align:start}.wrapper .conversation .conversation-pane .message-date.right,.wrapper .conversation .conversation-pane .relative-timestamp.right{text-align:end}.wrapper .conversation .conversation-pane.bot-icon .message.card-message-horizontal{margin-inline-start:-56px}.wrapper .conversation .conversation-pane.bot-icon .message.card-message-horizontal .message-header,.wrapper .conversation .conversation-pane.bot-icon .message.card-message-horizontal .message-footer,.wrapper .conversation .conversation-pane.bot-icon .message.card-message-horizontal .message-global-actions{margin-inline-start:56px}.wrapper .conversation .conversation-pane.bot-icon .message.card-message-horizontal .card-message-content .card-message-cards{padding-inline-start:56px}.wrapper .conversation .conversation-pane.bot-icon .relative-timestamp.left{margin-inline-start:40px}.wrapper .conversation .conversation-pane.user-icon .relative-timestamp.right{margin-inline-end:40px}.wrapper .conversation .conversation-pane.bot-icon .message-block .messages-wrapper,.wrapper .conversation .conversation-pane.user-icon .message-block .messages-wrapper{max-width:calc(.9*(100% - 40px))}.wrapper .conversation .conversation-pane.bot-icon .message-block .messages-wrapper .message.card-message-horizontal .message-header,.wrapper .conversation .conversation-pane.bot-icon .message-block .messages-wrapper .message.card-message-horizontal .message-footer,.wrapper .conversation .conversation-pane.bot-icon .message-block .messages-wrapper .message.card-message-horizontal .message-global-actions,.wrapper .conversation .conversation-pane.user-icon .message-block .messages-wrapper .message.card-message-horizontal .message-header,.wrapper .conversation .conversation-pane.user-icon .message-block .messages-wrapper .message.card-message-horizontal .message-footer,.wrapper .conversation .conversation-pane.user-icon .message-block .messages-wrapper .message.card-message-horizontal .message-global-actions{max-width:calc(.9*(100% - 72px))}.wrapper .conversation .conversation-pane.user-icon.bot-icon .message-block .messages-wrapper{max-width:calc(.9*(100% - 80px))}.wrapper .conversation .conversation-pane.user-icon.bot-icon .message-block .messages-wrapper .message.card-message-horizontal .message-header,.wrapper .conversation .conversation-pane.user-icon.bot-icon .message-block .messages-wrapper .message.card-message-horizontal .message-footer,.wrapper .conversation .conversation-pane.user-icon.bot-icon .message-block .messages-wrapper .message.card-message-horizontal .message-global-actions{max-width:calc(.9*(100% - 112px))}.wrapper .timestamp-header{text-align:center;font-size:12px;font-weight:700;color:var(--color-timestamp);margin:16px 0}.wrapper .hr{margin:24px 0;font-size:12px;color:var(--color-horizontal-rule-background)}.wrapper .hr:before{content:"";background-color:var(--color-horizontal-rule-background);height:1px;flex-grow:1;margin-inline-end:10px}.wrapper .hr:after{content:"";background-color:var(--color-horizontal-rule-background);height:1px;flex-grow:1;margin-inline-start:10px}.wrapper .card-actions,.wrapper .form-actions,.wrapper .message-actions,.wrapper .message-global-actions{margin-top:6px;display:flex;align-items:flex-start;justify-content:flex-start;flex-wrap:wrap}.wrapper .card-actions .action-postback.display-link:first-child,.wrapper .form-actions .action-postback.display-link:first-child,.wrapper .message-actions .action-postback.display-link:first-child,.wrapper .message-global-actions .action-postback.display-link:first-child{padding-left:0}.wrapper .card-actions.form-message-actions-col,.wrapper .form-actions.form-message-actions-col,.wrapper .message-actions.form-message-actions-col,.wrapper .message-global-actions.form-message-actions-col{flex-basis:100%;max-width:100%}.wrapper .card-actions:not(.col) .action-postback,.wrapper .form-actions:not(.col) .action-postback,.wrapper .message-actions:not(.col) .action-postback,.wrapper .message-global-actions:not(.col) .action-postback{margin-inline-end:8px}.wrapper .card-actions:not(.col) .action-postback:last-child,.wrapper .form-actions:not(.col) .action-postback:last-child,.wrapper .message-actions:not(.col) .action-postback:last-child,.wrapper .message-global-actions:not(.col) .action-postback:last-child{margin-inline-end:0}.wrapper .action-postback{background:var(--color-actions-background);border-color:var(--color-actions-border);color:var(--color-actions-text);display:flex;flex-direction:row;gap:10px;text-align:start}.wrapper .action-postback:not(:disabled):hover{color:var(--color-actions-text-hover);background-color:var(--color-actions-background-hover)}.wrapper .action-postback:not(:disabled):hover svg>path{fill:var(--color-actions-text-hover)}.wrapper .action-postback:not(:disabled):focus,.wrapper .action-postback:not(:disabled):active{background-color:var(--color-actions-background-focus);color:var(--color-actions-text-focus)}.wrapper .action-postback:not(:disabled):focus svg>path,.wrapper .action-postback:not(:disabled):active svg>path{fill:var(--color-actions-text-focus)}.wrapper .action-postback.primary{background:var(--color-primary-actions-background);color:var(--color-primary-actions-text);border:var(--color-primary-actions-border)}.wrapper .action-postback.primary:not(:disabled):hover{background:var(--color-primary-actions-background-hover);color:var(--color-primary-actions-text-hover)}.wrapper .action-postback.primary:not(:disabled):hover svg>path{fill:var(--color-primary-actions-text-hover)}.wrapper .action-postback.primary:not(:disabled):focus,.wrapper .action-postback.primary:not(:disabled):active{background:var(--color-primary-actions-background-focus);color:var(--color-primary-actions-text-focus)}.wrapper .action-postback.primary:not(:disabled):focus svg>path,.wrapper .action-postback.primary:not(:disabled):active svg>path{fill:var(--color-primary-actions-text-focus)}.wrapper .action-postback.danger{background:var(--color-danger-actions-background);color:var(--color-danger-actions-text);border:var(--color-danger-actions-border)}.wrapper .action-postback.danger:not(:disabled):hover{background:var(--color-danger-actions-background-hover);color:var(--color-danger-actions-text-hover)}.wrapper .action-postback.danger:not(:disabled):hover svg>path{fill:var(--color-danger-actions-text-hover)}.wrapper .action-postback.danger:not(:disabled):focus,.wrapper .action-postback.danger:not(:disabled):active{background:var(--color-danger-actions-background-focus);color:var(--color-danger-actions-text-focus)}.wrapper .action-postback.danger:not(:disabled):focus svg>path,.wrapper .action-postback.danger:not(:disabled):active svg>path{fill:var(--color-danger-actions-text-focus)}.wrapper .action-postback.display-link{outline:1px solid rgba(0,0,0,0);border:none;min-height:unset;background:rgba(0,0,0,0) !important}.wrapper .action-postback.display-link:hover{text-decoration:underline}.wrapper .action-postback.c2k-action{border-radius:0;color:#227e9e !important;border:none;padding:0;min-height:unset;font-size:16px;background:rgba(0,0,0,0) !important;margin-bottom:0}.wrapper .message-global-actions{margin-top:8px}.wrapper .message-global-actions.stars{display:block}.wrapper .message-global-actions button{background:var(--color-global-actions-background);color:var(--color-global-actions-text);border-color:var(--color-global-actions-border)}.wrapper .message-global-actions button:not(:disabled):hover{background-color:var(--color-global-actions-background-hover);color:var(--color-global-actions-text-hover)}.wrapper .message-global-actions button:not(:disabled):hover svg>path{fill:var(--color-global-actions-text-hover)}.wrapper .message-global-actions button:not(:disabled):focus,.wrapper .message-global-actions button:not(:disabled):active{background-color:var(--color-global-actions-background-focus);color:var(--color-global-actions-text-focus)}.wrapper .message-global-actions button:not(:disabled):focus svg>path,.wrapper .message-global-actions button:not(:disabled):active svg>path{fill:var(--color-global-actions-text-focus)}.wrapper .message-bubble{position:relative;display:flex;flex-direction:column;align-items:flex-start;margin:0;padding:6px 16px;color:var(--color-bot-text);background:var(--color-bot-message-background);min-height:32px;line-height:20px;overflow-wrap:break-word;max-width:100%;border-radius:2px 10px 10px 2px;margin-top:2px}.wrapper .message-bubble>*{width:100%}.wrapper .message-bubble.before-card{border-radius:2px 10px 10px 10px}.wrapper .message-bubble .video-wrapper{max-width:100%}.wrapper .message-bubble.error{background-color:var(--color-error-message-background);color:var(--color-error-text);border:1px dashed var(--color-error-border)}.wrapper .message-bubble.error .message-icon path{fill:var(--color-error-title)}.wrapper .message-bubble.error .message-title{color:var(--color-error-title)}.wrapper .message-bubble span.highlight{background-color:rgba(143,191,208,.4)}.wrapper .message-bubble .message-with-icon{display:flex;align-items:flex-start;justify-content:space-between}.wrapper .message-bubble .message-with-icon .message-icon{width:24px;height:24px;align-items:center;margin-inline-end:16px}.wrapper .message-bubble .message-with-icon .message-text{word-break:break-word}.wrapper .message-bubble.message-header{margin-bottom:2px}.wrapper .message-bubble.message-footer{margin-top:2px}.wrapper .message-bubble .message-user-postback>img{max-height:32px;max-width:32px}.wrapper .messages-wrapper{max-width:90%;align-items:flex-start}.wrapper .messages-wrapper .agent-name{position:relative;bottom:3px;max-width:111.1111111111%;height:16px;font-size:12px;line-height:16px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--color-agent-name)}.wrapper .messages-wrapper .screen-reader-only{height:1px;left:-20000px;overflow:hidden;position:absolute;top:auto;width:1px}.wrapper .messages-wrapper .message-list{width:100%;align-items:flex-start}.wrapper .message{width:100%;white-space:pre-wrap}.wrapper .message .embeddedAction{padding:2px 6px;border-radius:4px;cursor:pointer;display:inline-block;font-size:12px;font-weight:600;height:20px;line-height:16px;border:1px solid rgba(122,115,110,.2509803922)}.wrapper .message .embeddedAction.display-link{color:var(--color-links);padding:2px 0;outline:1px solid rgba(0,0,0,0);border:none}.wrapper .message .embeddedAction.display-link:hover{text-decoration:underline}.wrapper .message .embeddedAction.display-icon{padding:0;outline:1px solid rgba(0,0,0,0);border:none}.wrapper .message .action-wrapper{display:flex;flex-direction:column;position:relative}.wrapper .message .action-wrapper button:not(:disabled):hover+div>.tooltip{display:block;position:absolute;background-color:var(--color-bot-message-background);max-width:296px;border-radius:2px;box-shadow:0px 1px 4px 0px rgba(0,0,0,.1215686275);padding:8px;z-index:3;font-size:13px;font-weight:400;inset-inline-start:-16px;line-height:20px;margin-top:-4px;overflow-wrap:break-word}.wrapper .message a{color:var(--color-links)}.wrapper .message button.anchor-btn{padding:0}.wrapper .message button.anchor-btn a{display:block;text-decoration:inherit;color:inherit;padding:10px 20px}.wrapper .message button:last-child{margin-bottom:0}.wrapper .message .message-wrapper{display:flex;align-items:flex-start;flex-direction:column;width:100%;max-width:100%}.wrapper .message:first-child .message-bubble:not(.message-footer){margin-top:0}.wrapper .message:first-child .card-message-content:first-child .card-message-cards{margin-top:0}.wrapper .message:last-child .message-bubble:last-child{border-radius:2px 10px 10px 10px}.wrapper .message:last-child .message-bubble:last-child.edit-form-message .form-message-header{border-radius:1px 9px 0 0}.wrapper .message:last-child .message-bubble:last-child.edit-form-message .form-message-item{border-radius:1px 9px 9px 9px}.wrapper .message:last-child .card-message-content:last-child .card-message-cards{margin-bottom:-8px}.wrapper .message.card-message-horizontal{margin-inline-start:-16px;width:100vw}.wrapper .message.card-message-horizontal .message-header,.wrapper .message.card-message-horizontal .message-footer,.wrapper .message.card-message-horizontal .message-global-actions{margin-inline-start:16px;max-width:calc(.9*(100% - 32px))}.wrapper .message.card-message-horizontal .message-header{border-radius:2px 10px 10px 10px}.wrapper .message.card-message-horizontal .card-message-cards{flex-direction:row;overflow-x:auto;padding:0 56px 0 16px}.wrapper .message.card-message-horizontal .card{border:1px solid rgba(22,21,19,.12);box-shadow:0px 1px 4px 0px rgba(0,0,0,.12);margin-inline-end:8px}.wrapper .message.card-message-horizontal .next-wrapper,.wrapper .message.card-message-horizontal .prev-wrapper{position:absolute;height:100%;top:0;width:52px;z-index:1}.wrapper .message.card-message-horizontal .next-wrapper{inset-inline-end:0;background:linear-gradient(90deg, rgba(255, 255, 255, 0), var(--color-conversation-background) 60%)}.wrapper .message.card-message-horizontal .prev-wrapper{inset-inline-start:0;background:linear-gradient(90deg, var(--color-conversation-background) 40%, rgba(255, 255, 255, 0))}[dir=rtl] .wrapper .message.card-message-horizontal .next-wrapper{background:linear-gradient(90deg, var(--color-conversation-background) 40%, rgba(255, 255, 255, 0))}[dir=rtl] .wrapper .message.card-message-horizontal .prev-wrapper{background:linear-gradient(90deg, rgba(255, 255, 255, 0), var(--color-conversation-background) 60%)}[dir=rtl] .wrapper .message.card-message-horizontal .next,[dir=rtl] .wrapper .message.card-message-horizontal .previous{transform:rotate(180deg)}.wrapper .message.card-message-horizontal .next,.wrapper .message.card-message-horizontal .previous{position:absolute;z-index:10;width:36px;height:36px;left:8px;padding:0;overflow:hidden;background-color:var(--color-card-nav-button);border:none;box-shadow:0px 2px 4px rgba(0,0,0,.1);top:calc(50% - 18px);justify-content:center}.wrapper .message.card-message-horizontal .next:hover,.wrapper .message.card-message-horizontal .previous:hover{background-color:var(--color-card-nav-button-hover)}.wrapper .message.card-message-horizontal .next:focus,.wrapper .message.card-message-horizontal .next:active,.wrapper .message.card-message-horizontal .previous:focus,.wrapper .message.card-message-horizontal .previous:active{background-color:var(--color-card-nav-button-focus)}.wrapper .message-block{justify-content:flex-start;align-items:flex-start;margin-bottom:8px}.wrapper .message-block.right{flex-direction:row-reverse}.wrapper .message-block.right .icon-wrapper{margin:unset;margin-inline-start:8px}.wrapper .message-block.right .messages-wrapper{align-items:flex-end}.wrapper .message-block.right .messages-wrapper .message a{color:var(--color-user-links)}.wrapper .message-block.right .messages-wrapper .message .message-wrapper{align-items:flex-end}.wrapper .message-block.right .messages-wrapper .message .message-bubble{border-radius:10px 2px 2px 10px}.wrapper .message-block.right .messages-wrapper .message .message-bubble:not(.error){color:var(--color-user-text);background:var(--color-user-message-background)}.wrapper .message-block.right .messages-wrapper .message:last-child .message-bubble:last-child{border-radius:10px 2px 10px 10px}.wrapper .message-block.right .message-date{text-align:right}.wrapper .icon-wrapper{margin-inline-end:8px;width:32px;min-width:32px;height:32px;border-radius:4px;overflow:hidden;z-index:1}.wrapper .icon-wrapper.agent-avatar{background:var(--color-agent-avatar-background);margin-top:16px}.wrapper .icon-wrapper .message-icon{height:32px;max-height:32px;max-width:32px;width:32px;color:var(--color-timestamp);overflow:hidden;text-overflow:ellipsis}.wrapper .icon-wrapper .agent-icon{position:relative;width:20px;height:20px;left:6px;top:6px;font-weight:700;font-size:16px;line-height:20px;text-align:center;color:var(--color-agent-initials)}.wrapper .attachment{width:100%}.wrapper .attachment .attachment-placeholder{background-color:var(--color-attachment-placeholder);max-width:calc(100% + 32px);min-width:228px;min-height:88px;max-height:230px;margin:-6px -16px 0;justify-content:center;overflow:hidden}.wrapper .attachment .attachment-placeholder>*{max-width:100%}.wrapper .attachment .attachment-placeholder .attachment-icon{height:48px;width:48px}.wrapper .attachment .attachment-placeholder .attachment-icon svg{height:48px;width:48px}.wrapper .attachment .attachment-placeholder .attachment-icon img{width:100%}.wrapper .attachment .attachment-placeholder .attachment-audio{height:50px;width:100%}.wrapper .attachment .attachment-placeholder .attachment-audio::-webkit-media-controls-enclosure{background-color:rgba(0,0,0,0)}.wrapper .attachment .attachment-footer{background-color:var(--color-attachment-footer);color:var(--color-attachment-text);margin:0 -16px -6px;height:50px;padding:16px}.wrapper .attachment .attachment-footer.with-actions{border-bottom:thin solid rgba(22,21,19,.1);margin-bottom:6px}.wrapper .attachment .attachment-footer .attachment-title{flex-grow:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.wrapper .card{width:252px;border-radius:6px;padding:16px;margin-block-end:8px;justify-content:flex-start;flex-shrink:0;color:var(--color-bot-text);background:var(--color-card-background);overflow:hidden}.wrapper .card .card-image{display:block;width:calc(100% + 32px);margin:-16px -16px 10px;min-height:88px;background-color:var(--color-attachment-placeholder)}.wrapper .card .card-title{line-height:20px;margin:0 0 4px;font-weight:700;word-break:break-word}.wrapper .card .card-description{margin-bottom:16px;color:var(--color-text-light)}.wrapper .card-message-content{width:100%;position:relative}.wrapper .card-message-content .card-message-cards{width:100%;align-items:stretch;display:flex;scroll-behavior:smooth;overflow-x:visible;flex-direction:column;margin:8px 0 0;scrollbar-width:none}.wrapper .card-message-content .card-message-cards::-webkit-scrollbar{display:none}.wrapper .message-bubble-tabular-message,.wrapper .message-bubble-form-message{width:111%;max-width:unset;border-radius:0 8px 8px 8px;padding:0;background-color:var(--color-table-background);color:var(--color-table-text);border:1px solid var(--color-table-header-background)}.wrapper .message-bubble-tabular-message .popupContent,.wrapper .message-bubble-form-message .popupContent{max-width:280px;position:absolute;height:auto;border-radius:8px;z-index:3;box-shadow:0px 4px 4px 0px rgba(0,0,0,.1019607843);border:1px solid rgba(22,21,19,.1215686275);background:var(--color-bot-message-background);display:none;inset-inline-start:-4px}.wrapper .message-bubble-tabular-message .results-page-status,.wrapper .message-bubble-form-message .results-page-status{align-items:center;background-color:var(--color-table-background);color:var(--color-table-text);display:flex;flex-direction:row;font-size:13.75px;justify-content:flex-end;line-height:16px;padding:12px 16px;border-top:1px solid var(--color-table-separator)}.wrapper .message-bubble-tabular-message~.message-footer,.wrapper .message-bubble-form-message~.message-footer{margin-top:8px}.wrapper .message-bubble-tabular-message .message-actions .action-postback,.wrapper .message-bubble-tabular-message .table-message-item .action-postback{background:var(--color-table-actions-background);color:var(--color-table-actions-text);border-color:var(--color-table-actions-border)}.wrapper .message-bubble-tabular-message .message-actions .action-postback:not(:disabled):hover,.wrapper .message-bubble-tabular-message .table-message-item .action-postback:not(:disabled):hover{color:var(--color-table-actions-text-hover);background:var(--color-table-actions-background-hover)}.wrapper .message-bubble-tabular-message .message-actions .action-postback:not(:disabled):hover svg>path,.wrapper .message-bubble-tabular-message .table-message-item .action-postback:not(:disabled):hover svg>path{fill:var(--color-table-actions-text-hover)}.wrapper .message-bubble-tabular-message .message-actions .action-postback:not(:disabled):focus,.wrapper .message-bubble-tabular-message .message-actions .action-postback:not(:disabled):active,.wrapper .message-bubble-tabular-message .table-message-item .action-postback:not(:disabled):focus,.wrapper .message-bubble-tabular-message .table-message-item .action-postback:not(:disabled):active{background:var(--color-table-actions-background-focus);color:var(--color-table-actions-text-focus)}.wrapper .message-bubble-tabular-message .message-actions .action-postback:not(:disabled):focus svg>path,.wrapper .message-bubble-tabular-message .message-actions .action-postback:not(:disabled):active svg>path,.wrapper .message-bubble-tabular-message .table-message-item .action-postback:not(:disabled):focus svg>path,.wrapper .message-bubble-tabular-message .table-message-item .action-postback:not(:disabled):active svg>path{fill:var(--color-table-actions-text-focus)}.wrapper .message-bubble-tabular-message .message-actions,.wrapper .message-bubble-form-message .message-actions{border-top:1px solid var(--color-table-separator);padding:12px 16px;margin-top:auto}.wrapper .message-bubble-tabular-message .message-actions .action-postback.primary,.wrapper .message-bubble-tabular-message .table-message-item .action-postback.primary,.wrapper .message-bubble-tabular-message .form-actions .action-postback.primary,.wrapper .message-bubble-tabular-message .form-message-value .action-postback.primary,.wrapper .message-bubble-form-message .message-actions .action-postback.primary,.wrapper .message-bubble-form-message .table-message-item .action-postback.primary,.wrapper .message-bubble-form-message .form-actions .action-postback.primary,.wrapper .message-bubble-form-message .form-message-value .action-postback.primary{background:var(--color-primary-form-actions-background);color:var(--color-primary-form-actions-text);border:var(--color-primary-form-actions-border)}.wrapper .message-bubble-tabular-message .message-actions .action-postback.primary:not(:disabled):hover,.wrapper .message-bubble-tabular-message .table-message-item .action-postback.primary:not(:disabled):hover,.wrapper .message-bubble-tabular-message .form-actions .action-postback.primary:not(:disabled):hover,.wrapper .message-bubble-tabular-message .form-message-value .action-postback.primary:not(:disabled):hover,.wrapper .message-bubble-form-message .message-actions .action-postback.primary:not(:disabled):hover,.wrapper .message-bubble-form-message .table-message-item .action-postback.primary:not(:disabled):hover,.wrapper .message-bubble-form-message .form-actions .action-postback.primary:not(:disabled):hover,.wrapper .message-bubble-form-message .form-message-value .action-postback.primary:not(:disabled):hover{background:var(--color-primary-form-actions-background-hover);color:var(--color-primary-form-actions-text-hover)}.wrapper .message-bubble-tabular-message .message-actions .action-postback.primary:not(:disabled):hover svg>path,.wrapper .message-bubble-tabular-message .table-message-item .action-postback.primary:not(:disabled):hover svg>path,.wrapper .message-bubble-tabular-message .form-actions .action-postback.primary:not(:disabled):hover svg>path,.wrapper .message-bubble-tabular-message .form-message-value .action-postback.primary:not(:disabled):hover svg>path,.wrapper .message-bubble-form-message .message-actions .action-postback.primary:not(:disabled):hover svg>path,.wrapper .message-bubble-form-message .table-message-item .action-postback.primary:not(:disabled):hover svg>path,.wrapper .message-bubble-form-message .form-actions .action-postback.primary:not(:disabled):hover svg>path,.wrapper .message-bubble-form-message .form-message-value .action-postback.primary:not(:disabled):hover svg>path{fill:var(--color-primary-form-actions-text-hover)}.wrapper .message-bubble-tabular-message .message-actions .action-postback.primary:not(:disabled):focus,.wrapper .message-bubble-tabular-message .message-actions .action-postback.primary:not(:disabled):active,.wrapper .message-bubble-tabular-message .table-message-item .action-postback.primary:not(:disabled):focus,.wrapper .message-bubble-tabular-message .table-message-item .action-postback.primary:not(:disabled):active,.wrapper .message-bubble-tabular-message .form-actions .action-postback.primary:not(:disabled):focus,.wrapper .message-bubble-tabular-message .form-actions .action-postback.primary:not(:disabled):active,.wrapper .message-bubble-tabular-message .form-message-value .action-postback.primary:not(:disabled):focus,.wrapper .message-bubble-tabular-message .form-message-value .action-postback.primary:not(:disabled):active,.wrapper .message-bubble-form-message .message-actions .action-postback.primary:not(:disabled):focus,.wrapper .message-bubble-form-message .message-actions .action-postback.primary:not(:disabled):active,.wrapper .message-bubble-form-message .table-message-item .action-postback.primary:not(:disabled):focus,.wrapper .message-bubble-form-message .table-message-item .action-postback.primary:not(:disabled):active,.wrapper .message-bubble-form-message .form-actions .action-postback.primary:not(:disabled):focus,.wrapper .message-bubble-form-message .form-actions .action-postback.primary:not(:disabled):active,.wrapper .message-bubble-form-message .form-message-value .action-postback.primary:not(:disabled):focus,.wrapper .message-bubble-form-message .form-message-value .action-postback.primary:not(:disabled):active{background:var(--color-primary-form-actions-background-focus);color:var(--color-primary-form-actions-text-focus)}.wrapper .message-bubble-tabular-message .message-actions .action-postback.primary:not(:disabled):focus svg>path,.wrapper .message-bubble-tabular-message .message-actions .action-postback.primary:not(:disabled):active svg>path,.wrapper .message-bubble-tabular-message .table-message-item .action-postback.primary:not(:disabled):focus svg>path,.wrapper .message-bubble-tabular-message .table-message-item .action-postback.primary:not(:disabled):active svg>path,.wrapper .message-bubble-tabular-message .form-actions .action-postback.primary:not(:disabled):focus svg>path,.wrapper .message-bubble-tabular-message .form-actions .action-postback.primary:not(:disabled):active svg>path,.wrapper .message-bubble-tabular-message .form-message-value .action-postback.primary:not(:disabled):focus svg>path,.wrapper .message-bubble-tabular-message .form-message-value .action-postback.primary:not(:disabled):active svg>path,.wrapper .message-bubble-form-message .message-actions .action-postback.primary:not(:disabled):focus svg>path,.wrapper .message-bubble-form-message .message-actions .action-postback.primary:not(:disabled):active svg>path,.wrapper .message-bubble-form-message .table-message-item .action-postback.primary:not(:disabled):focus svg>path,.wrapper .message-bubble-form-message .table-message-item .action-postback.primary:not(:disabled):active svg>path,.wrapper .message-bubble-form-message .form-actions .action-postback.primary:not(:disabled):focus svg>path,.wrapper .message-bubble-form-message .form-actions .action-postback.primary:not(:disabled):active svg>path,.wrapper .message-bubble-form-message .form-message-value .action-postback.primary:not(:disabled):focus svg>path,.wrapper .message-bubble-form-message .form-message-value .action-postback.primary:not(:disabled):active svg>path{fill:var(--color-primary-form-actions-text-focus)}.wrapper .message-bubble-tabular-message .message-actions .action-postback.danger,.wrapper .message-bubble-tabular-message .table-message-item .action-postback.danger,.wrapper .message-bubble-tabular-message .form-actions .action-postback.danger,.wrapper .message-bubble-tabular-message .form-message-value .action-postback.danger,.wrapper .message-bubble-form-message .message-actions .action-postback.danger,.wrapper .message-bubble-form-message .table-message-item .action-postback.danger,.wrapper .message-bubble-form-message .form-actions .action-postback.danger,.wrapper .message-bubble-form-message .form-message-value .action-postback.danger{background:var(--color-danger-form-actions-background);color:var(--color-danger-form-actions-text);border:var(--color-danger-form-actions-border)}.wrapper .message-bubble-tabular-message .message-actions .action-postback.danger:not(:disabled):hover,.wrapper .message-bubble-tabular-message .table-message-item .action-postback.danger:not(:disabled):hover,.wrapper .message-bubble-tabular-message .form-actions .action-postback.danger:not(:disabled):hover,.wrapper .message-bubble-tabular-message .form-message-value .action-postback.danger:not(:disabled):hover,.wrapper .message-bubble-form-message .message-actions .action-postback.danger:not(:disabled):hover,.wrapper .message-bubble-form-message .table-message-item .action-postback.danger:not(:disabled):hover,.wrapper .message-bubble-form-message .form-actions .action-postback.danger:not(:disabled):hover,.wrapper .message-bubble-form-message .form-message-value .action-postback.danger:not(:disabled):hover{background:var(--color-danger-form-actions-background-hover);color:var(--color-danger-form-actions-text-hover)}.wrapper .message-bubble-tabular-message .message-actions .action-postback.danger:not(:disabled):hover svg>path,.wrapper .message-bubble-tabular-message .table-message-item .action-postback.danger:not(:disabled):hover svg>path,.wrapper .message-bubble-tabular-message .form-actions .action-postback.danger:not(:disabled):hover svg>path,.wrapper .message-bubble-tabular-message .form-message-value .action-postback.danger:not(:disabled):hover svg>path,.wrapper .message-bubble-form-message .message-actions .action-postback.danger:not(:disabled):hover svg>path,.wrapper .message-bubble-form-message .table-message-item .action-postback.danger:not(:disabled):hover svg>path,.wrapper .message-bubble-form-message .form-actions .action-postback.danger:not(:disabled):hover svg>path,.wrapper .message-bubble-form-message .form-message-value .action-postback.danger:not(:disabled):hover svg>path{fill:var(--color-danger-form-actions-text-hover)}.wrapper .message-bubble-tabular-message .message-actions .action-postback.danger:not(:disabled):focus,.wrapper .message-bubble-tabular-message .message-actions .action-postback.danger:not(:disabled):active,.wrapper .message-bubble-tabular-message .table-message-item .action-postback.danger:not(:disabled):focus,.wrapper .message-bubble-tabular-message .table-message-item .action-postback.danger:not(:disabled):active,.wrapper .message-bubble-tabular-message .form-actions .action-postback.danger:not(:disabled):focus,.wrapper .message-bubble-tabular-message .form-actions .action-postback.danger:not(:disabled):active,.wrapper .message-bubble-tabular-message .form-message-value .action-postback.danger:not(:disabled):focus,.wrapper .message-bubble-tabular-message .form-message-value .action-postback.danger:not(:disabled):active,.wrapper .message-bubble-form-message .message-actions .action-postback.danger:not(:disabled):focus,.wrapper .message-bubble-form-message .message-actions .action-postback.danger:not(:disabled):active,.wrapper .message-bubble-form-message .table-message-item .action-postback.danger:not(:disabled):focus,.wrapper .message-bubble-form-message .table-message-item .action-postback.danger:not(:disabled):active,.wrapper .message-bubble-form-message .form-actions .action-postback.danger:not(:disabled):focus,.wrapper .message-bubble-form-message .form-actions .action-postback.danger:not(:disabled):active,.wrapper .message-bubble-form-message .form-message-value .action-postback.danger:not(:disabled):focus,.wrapper .message-bubble-form-message .form-message-value .action-postback.danger:not(:disabled):active{background:var(--color-danger-form-actions-background-focus);color:var(--color-danger-form-actions-text-focus)}.wrapper .message-bubble-tabular-message .message-actions .action-postback.danger:not(:disabled):focus svg>path,.wrapper .message-bubble-tabular-message .message-actions .action-postback.danger:not(:disabled):active svg>path,.wrapper .message-bubble-tabular-message .table-message-item .action-postback.danger:not(:disabled):focus svg>path,.wrapper .message-bubble-tabular-message .table-message-item .action-postback.danger:not(:disabled):active svg>path,.wrapper .message-bubble-tabular-message .form-actions .action-postback.danger:not(:disabled):focus svg>path,.wrapper .message-bubble-tabular-message .form-actions .action-postback.danger:not(:disabled):active svg>path,.wrapper .message-bubble-tabular-message .form-message-value .action-postback.danger:not(:disabled):focus svg>path,.wrapper .message-bubble-tabular-message .form-message-value .action-postback.danger:not(:disabled):active svg>path,.wrapper .message-bubble-form-message .message-actions .action-postback.danger:not(:disabled):focus svg>path,.wrapper .message-bubble-form-message .message-actions .action-postback.danger:not(:disabled):active svg>path,.wrapper .message-bubble-form-message .table-message-item .action-postback.danger:not(:disabled):focus svg>path,.wrapper .message-bubble-form-message .table-message-item .action-postback.danger:not(:disabled):active svg>path,.wrapper .message-bubble-form-message .form-actions .action-postback.danger:not(:disabled):focus svg>path,.wrapper .message-bubble-form-message .form-actions .action-postback.danger:not(:disabled):active svg>path,.wrapper .message-bubble-form-message .form-message-value .action-postback.danger:not(:disabled):focus svg>path,.wrapper .message-bubble-form-message .form-message-value .action-postback.danger:not(:disabled):active svg>path{fill:var(--color-danger-form-actions-text-focus)}.wrapper .message-bubble-form-message{background-color:var(--color-form-background);color:var(--color-form-text)}.wrapper .message-bubble-form-message.edit-form-message{overflow:visible}.wrapper .message-bubble-form-message.edit-form-message .message-actions{border-top:none;padding-top:0}.wrapper .message-bubble-form-message.edit-form-message .form-message-header{border-radius:0 7px 0 0}.wrapper .message-bubble-form-message.edit-form-message .form-message-item{border-radius:0 7px 7px 7px}.wrapper .message-bubble-form-message .results-page-status{background-color:var(--color-form-background);color:var(--color-form-text)}.wrapper .message-bubble-form-message .message-actions .action-postback{background:var(--color-form-actions-background);color:var(--color-form-actions-text);border-color:var(--color-form-actions-border)}.wrapper .message-bubble-form-message .message-actions .action-postback:not(:disabled):hover{color:var(--color-form-actions-text-hover);background:var(--color-form-actions-background-hover)}.wrapper .message-bubble-form-message .message-actions .action-postback:not(:disabled):hover svg>path{fill:var(--color-form-actions-text-hover)}.wrapper .message-bubble-form-message .message-actions .action-postback:not(:disabled):focus,.wrapper .message-bubble-form-message .message-actions .action-postback:not(:disabled):active{background:var(--color-form-actions-background-focus);color:var(--color-form-actions-text-focus)}.wrapper .message-bubble-form-message .message-actions .action-postback:not(:disabled):focus svg>path,.wrapper .message-bubble-form-message .message-actions .action-postback:not(:disabled):active svg>path{fill:var(--color-form-actions-text-focus)}.wrapper .form-message-field,.wrapper .table-message-heading,.wrapper .table-message-item{overflow-wrap:break-word;word-break:break-word}.wrapper .form-message-field:hover .popupContent,.wrapper .table-message-heading:hover .popupContent,.wrapper .table-message-item:hover .popupContent{display:flex}.wrapper .table-message-wrapper{overflow:auto}.wrapper .table-message-wrapper .table-message{min-width:100%;max-width:200%;border-collapse:collapse}.wrapper .table-message-wrapper .table-message .table-message-headings{align-items:center;color:var(--color-table-header-text);background-color:var(--color-table-header-background);display:flex}.wrapper .table-message-wrapper .table-message .table-message-headings .table-message-heading{font-size:12px;font-weight:600;line-height:16px;padding:16px;min-width:120px}.wrapper .table-message-wrapper .table-message .table-message-row{border-top:1px solid var(--color-table-separator);display:flex;align-items:center}.wrapper .table-message-wrapper .table-message .table-message-row .table-message-item{color:var(--color-table-text);font-size:16px;line-height:20px;min-width:120px;padding:10px 16px}.wrapper .form-message-header{align-items:center;background-color:var(--color-form-header-background);color:var(--color-form-header-text);display:flex;font-weight:700;line-height:20px;padding:16px;text-align:start}.wrapper .form-message-item{color:var(--color-form-text);background-color:var(--color-form-background);display:flex;flex-flow:row wrap;justify-content:space-between;padding:16px}.wrapper .form-message-item .form-row{display:flex;flex-basis:100%;flex-wrap:nowrap;width:100%}.wrapper .form-message-item .form-row.separator{border-top:1px solid var(--color-table-separator);margin-top:8px}.wrapper .form-message-item .form-row .form-row-column{display:flex;flex-flow:column wrap;flex:0 1 auto;min-width:0}.wrapper .form-message-item .form-row .form-row-column.stretch{flex-grow:1}.wrapper .form-message-item .form-row .form-row-column.align-center{justify-content:center}.wrapper .form-message-item .form-row .form-row-column.align-start{justify-content:flex-start}.wrapper .form-message-item .form-row .form-row-column.align-end{justify-content:flex-end}.wrapper .form-message-item .form-row .form-row-column:not(:last-child){margin-inline-end:16px}.wrapper .form-message-item .form-row .form-row-column .form-message-field.margin-top-lg{margin-top:28px}.wrapper .form-message-item .form-row .form-row-column .form-message-field.margin-top-md{margin-top:16px}.wrapper .form-message-item .form-row .form-row-column .edit-form-message-field .listbox{min-width:100%;inset-inline-start:0;max-width:unset}.wrapper .form-message-item.c2k-reference{justify-content:flex-start}.wrapper .form-message-item.c2k-reference .form-row{margin-inline-end:8px;flex-basis:auto;width:auto;line-height:16px;color:rgba(22,21,19,.6509803922)}.wrapper .form-message-item.c2k-reference .form-row .form-row-column:not(:last-child){margin-inline-end:6px}.wrapper .form-message-item.c2k-reference .form-row span.delimiter{margin-inline-end:8px}.wrapper .form-message-item.with-border{border-bottom:1px solid var(--color-table-separator)}.wrapper .form-message-item .form-message-key{color:var(--color-form-label);line-height:16px}.wrapper .form-message-item .form-message-key.with-margin{cursor:auto;margin-bottom:8px}.wrapper .form-message-item .form-message-key.font-size-lg{font-size:14px;line-height:18px}.wrapper .form-message-item .form-message-key.font-size-md{font-size:12px;line-height:15.5px}.wrapper .form-message-item .form-message-key.font-size-sm{font-size:10px;line-height:13px}.wrapper .form-message-item .form-message-key.font-weight-bold{font-weight:700}.wrapper .form-message-item .form-message-key.font-weight-md{font-weight:600}.wrapper .form-message-item .form-message-key.font-weight-light{font-weight:400}.wrapper .form-message-item>.form-message-field{margin-bottom:16px}.wrapper .form-message-item .form-message-field .form-message-value.font-size-lg{font-size:18px;line-height:23.5px}.wrapper .form-message-item .form-message-field .form-message-value.font-size-md{font-size:16px;line-height:21px}.wrapper .form-message-item .form-message-field .form-message-value.font-size-sm{font-size:13.8px;line-height:18px}.wrapper .form-message-item .form-message-field .form-message-value.font-weight-bold{font-weight:600}.wrapper .form-message-item .form-message-field .form-message-value.font-weight-md{font-weight:400}.wrapper .form-message-item .form-message-field .form-message-value.font-weight-light{font-weight:300}.wrapper .form-message-item .form-message-field .form-message-value.with-top-margin{margin-top:2px}.wrapper .form-message-item .form-message-field.form-message-field-col-1{flex-basis:100%;max-width:100%}.wrapper .form-message-item .form-message-field.form-message-field-col-2{flex-basis:calc(50% - 12px);max-width:calc(50% - 12px);height:100%}.wrapper .form-message-item .form-message-field.form-message-field-col-2:nth-child(even) .popupContent{inset-inline-start:calc(50% - 7px)}.wrapper .form-message-item .form-message-field.form-message-field-col-2.edit-form-message-field:nth-child(even) .listbox{inset-inline:auto 16px}.wrapper .form-message-item .form-message-field.form-message-field-col-2.edit-form-message-field .listbox{min-width:calc(50% - 28px)}.wrapper .form-message-item .form-message-field.edit-form-message-field{display:flex;flex-direction:column;overflow:visible;width:100%}.wrapper .form-message-item .form-message-field.edit-form-message-field.disabled{cursor:not-allowed}.wrapper .form-message-item .form-message-field.edit-form-message-field input.form-message-value,.wrapper .form-message-item .form-message-field.edit-form-message-field textarea.form-message-value,.wrapper .form-message-item .form-message-field.edit-form-message-field .select-wrapper.form-message-value{border-radius:4px;background-color:var(--color-form-input-background);color:var(--color-form-input-text);border:1px solid var(--color-form-input-border);font-size:16px}.wrapper .form-message-item .form-message-field.edit-form-message-field input.form-message-value:focus,.wrapper .form-message-item .form-message-field.edit-form-message-field textarea.form-message-value:focus,.wrapper .form-message-item .form-message-field.edit-form-message-field .select-wrapper.form-message-value:focus{border-color:var(--color-form-input-border-focus);box-shadow:0 0 0 1px var(--color-form-input-border-focus) inset;outline:1px solid rgba(0,0,0,0)}.wrapper .form-message-item .form-message-field.edit-form-message-field input:disabled,.wrapper .form-message-item .form-message-field.edit-form-message-field textarea:disabled,.wrapper .form-message-item .form-message-field.edit-form-message-field .select-wrapper:disabled{opacity:.5;cursor:not-allowed}.wrapper .form-message-item .form-message-field.edit-form-message-field input:disabled~.field-error,.wrapper .form-message-item .form-message-field.edit-form-message-field textarea:disabled~.field-error,.wrapper .form-message-item .form-message-field.edit-form-message-field .select-wrapper:disabled~.field-error{display:none}.wrapper .form-message-item .form-message-field.edit-form-message-field.error>input:not(:disabled,.disabled),.wrapper .form-message-item .form-message-field.edit-form-message-field.error>textarea:not(:disabled,.disabled),.wrapper .form-message-item .form-message-field.edit-form-message-field.error>.select-wrapper:not(:disabled,.disabled),.wrapper .form-message-item .form-message-field.edit-form-message-field.error>.text-field-container:not(:disabled,.disabled){border-color:var(--color-form-error)}.wrapper .form-message-item .form-message-field.edit-form-message-field input.form-message-value{height:42px;padding:0 12px}.wrapper .form-message-item .form-message-field.edit-form-message-field input.form-message-value[type=date]::-webkit-calendar-picker-indicator,.wrapper .form-message-item .form-message-field.edit-form-message-field input.form-message-value[type=time]::-webkit-calendar-picker-indicator,.wrapper .form-message-item .form-message-field.edit-form-message-field input.form-message-value[type=number]::-webkit-inner-spin-button{cursor:pointer;width:20px;height:20px;margin-inline-end:-8px}.wrapper .form-message-item .form-message-field.edit-form-message-field .select-wrapper{align-items:center;display:flex;height:44px}.wrapper .form-message-item .form-message-field.edit-form-message-field .select-wrapper.focused{border-color:var(--color-form-input-border-focus);box-shadow:0 0 0 1px var(--color-form-input-border-focus) inset;outline:1px solid rgba(0,0,0,0)}.wrapper .form-message-item .form-message-field.edit-form-message-field .select-wrapper.disabled{opacity:.5;pointer-events:none}.wrapper .form-message-item .form-message-field.edit-form-message-field .select-wrapper.disabled~.field-error{display:none}.wrapper .form-message-item .form-message-field.edit-form-message-field .select-wrapper input{width:calc(100% - 36px);border:none;box-shadow:none !important;outline:1px solid rgba(0,0,0,0);height:40px;margin-inline-start:1px}.wrapper .form-message-item .form-message-field.edit-form-message-field .select-wrapper .select-icon{margin-inline-start:0;color:var(--color-form-input-text)}.wrapper .form-message-item .form-message-field.edit-form-message-field textarea.form-message-value{overflow:auto;padding:11px 12px;resize:none}.wrapper .form-message-item .form-message-field.edit-form-message-field .form-container{display:flex;max-width:max-content}.wrapper .form-message-item .form-message-field.edit-form-message-field .form-container.disabled{cursor:not-allowed;opacity:.5}.wrapper .form-message-item .form-message-field.edit-form-message-field .form-container.disabled+.field-error{display:none}.wrapper .form-message-item .form-message-field.edit-form-message-field .form-container label{display:flex;min-height:36px;align-items:center;padding:7.5px 0;border-bottom:1px solid rgba(0,0,0,0)}.wrapper .form-message-item .form-message-field.edit-form-message-field .form-container .radio-input{margin-inline-end:8px}.wrapper .form-message-item .form-message-field.edit-form-message-field .text-field-container{background-color:var(--color-form-input-background);border-radius:4px;border:1px solid var(--color-form-input-border);display:flex;min-height:44px;flex-direction:row;cursor:text}.wrapper .form-message-item .form-message-field.edit-form-message-field .text-field-container.disabled{opacity:.5;pointer-events:none}.wrapper .form-message-item .form-message-field.edit-form-message-field .text-field-container.disabled~.field-error{display:none}.wrapper .form-message-item .form-message-field.edit-form-message-field .text-field-container:focus{border-color:var(--color-form-input-border-focus);box-shadow:0 0 0 1px var(--color-form-input-border-focus) inset;outline:1px solid rgba(0,0,0,0)}.wrapper .form-message-item .form-message-field.edit-form-message-field .text-field-container .selected-options{padding:0 12px 5px}.wrapper .form-message-item .form-message-field.edit-form-message-field .text-field-container .selected-options:empty{padding-top:5px}.wrapper .form-message-item .form-message-field.edit-form-message-field .text-field-container .selected-options:empty:before{content:attr(data-placeholder)}.wrapper .form-message-item .form-message-field.edit-form-message-field .text-field-container .selected-options .multi-select-option{float:left;line-height:16px;display:flex;align-items:center;cursor:default;border-radius:4px;border:1px solid var(--color-form-input-border);color:var(--color-form-input-text);background-clip:padding-box;font-size:12px;margin-inline-end:6px;margin-top:5px;padding-inline:6px 4px}.wrapper .form-message-item .form-message-field.edit-form-message-field .text-field-container .selected-options .multi-select-option .opt-close{cursor:pointer;height:16px;width:16px}.wrapper .form-message-item .form-message-field.edit-form-message-field .listbox{border:1px solid var(--color-table-separator);border-radius:4px;display:flex;flex-direction:column;margin-top:3px;inset-inline-start:16px;max-width:calc(100% - 32px);min-width:calc(100% - 32px);z-index:3}.wrapper .form-message-item .form-message-field.edit-form-message-field .listbox .filter-message-box{display:flex;flex-direction:column;padding:0 12px}.wrapper .form-message-item .form-message-field.edit-form-message-field .listbox .filter-message-box .filter-message-text{color:var(--color-form-label);font-size:13.75px;height:42px;padding:12px 0;border-bottom:1px solid var(--color-table-separator)}.wrapper .form-message-item .form-message-field.edit-form-message-field .listbox .listbox-search{flex-shrink:0;margin:12px;padding-inline-end:36px}.wrapper .form-message-item .form-message-field.edit-form-message-field .listbox .search-icon-wrapper{position:relative;height:0}.wrapper .form-message-item .form-message-field.edit-form-message-field .listbox .search-icon-wrapper .search-icon{position:absolute;inset-inline-end:21px;bottom:23px}.wrapper .form-message-item .form-message-field.edit-form-message-field .listbox .multi-select-list,.wrapper .form-message-item .form-message-field.edit-form-message-field .listbox .single-select-list{animation:none;display:block;max-height:400px;margin:1px 0 2px 0;overflow-y:auto;padding:8px 0;z-index:3}.wrapper .form-message-item .form-message-field.edit-form-message-field .listbox .multi-select-list li,.wrapper .form-message-item .form-message-field.edit-form-message-field .listbox .single-select-list li{height:auto;margin:0;padding:12px}.wrapper .form-message-item .form-message-field.edit-form-message-field .listbox .multi-select-list li:not(.none).selected,.wrapper .form-message-item .form-message-field.edit-form-message-field .listbox .single-select-list li:not(.none).selected{border-top:1px solid #227e9e;background-color:#e4f1f7}.wrapper .form-message-item .form-message-field.edit-form-message-field .listbox .multi-select-list li:not(.none).selected:last-child,.wrapper .form-message-item .form-message-field.edit-form-message-field .listbox .single-select-list li:not(.none).selected:last-child{box-shadow:inset 0 -1px 0 0 #227e9e}.wrapper .form-message-item .form-message-field.edit-form-message-field .listbox .multi-select-list li:not(.none).selected+li,.wrapper .form-message-item .form-message-field.edit-form-message-field .listbox .single-select-list li:not(.none).selected+li{border-top:1px solid #227e9e}.wrapper .form-message-item .form-message-field.edit-form-message-field .toggle{position:relative;width:36px;height:20px}.wrapper .form-message-item .form-message-field.edit-form-message-field .toggle.disabled+.field-error{display:none}.wrapper .form-message-item .form-message-field.edit-form-message-field .toggle input{display:none}.wrapper .form-message-item .form-message-field.edit-form-message-field .toggle input:disabled+.round-slider{cursor:not-allowed;opacity:.5}.wrapper .form-message-item .form-message-field.edit-form-message-field .toggle input:checked+.round-slider{background-color:#227e9e;border-color:#227e9e}.wrapper .form-message-item .form-message-field.edit-form-message-field .toggle input:checked+.round-slider:before{inset-inline:auto 1px;transition:height .3s cubic-bezier(0, 0, 0.2, 1),width .3s cubic-bezier(0, 0, 0.2, 1),right .3s cubic-bezier(0, 0, 0.2, 1)}.wrapper .form-message-item .form-message-field.edit-form-message-field .toggle .round-slider{position:absolute;cursor:pointer;background-color:#8b8580;transition:background-color .2s linear .1s,opacity .2s linear .1s,border-color .2s linear .1s;border:1px solid rgba(0,0,0,0);border-radius:4px;height:20px;width:36px}.wrapper .form-message-item .form-message-field.edit-form-message-field .toggle .round-slider:before{border-radius:4px;width:16px;height:16px;inset-inline:1px auto;position:absolute;content:"";bottom:1px;background-color:var(--color-form-background);transition:height .3s cubic-bezier(0, 0, 0.2, 1),width .3s cubic-bezier(0, 0, 0.2, 1),left .3s cubic-bezier(0, 0, 0.2, 1)}.wrapper .form-message-item span.field-error{display:flex;margin-top:2px;line-height:16px}.wrapper .form-message-item span.field-error .error-text{color:var(--color-form-error-text);font-size:12px;margin-inline-start:4px}.wrapper .form-message-item span.field-error svg.form-error-icon{position:relative;height:16px;width:16px;fill:var(--color-form-error);flex-shrink:0}.wrapper .form-message-item span.field-error.form-error{padding:8px;background:var(--color-error-message-background);border-radius:4px;margin:10px 0;border:thin dashed var(--color-error-border);width:100%}.wrapper .form-message-item span.field-error.form-error.disabled{display:none}.wrapper .form-message-item span.field-error.form-error svg.form-error-icon{top:0}.wrapper .form-message-item span.field-error.form-error .error-text{font-weight:600;color:var(--color-error-title);margin-inline-start:8px;font-size:14px}.wrapper .form-message-item .form-actions .action-postback,.wrapper .form-message-item .form-message-value .action-postback{background:var(--color-form-actions-background);color:var(--color-form-actions-text);border-color:var(--color-form-actions-border)}.wrapper .form-message-item .form-actions .action-postback:not(:disabled):hover,.wrapper .form-message-item .form-message-value .action-postback:not(:disabled):hover{color:var(--color-form-actions-text-hover);background:var(--color-form-actions-background-hover)}.wrapper .form-message-item .form-actions .action-postback:not(:disabled):hover svg>path,.wrapper .form-message-item .form-message-value .action-postback:not(:disabled):hover svg>path{fill:var(--color-form-actions-text-hover)}.wrapper .form-message-item .form-actions .action-postback:not(:disabled):focus,.wrapper .form-message-item .form-actions .action-postback:not(:disabled):active,.wrapper .form-message-item .form-message-value .action-postback:not(:disabled):focus,.wrapper .form-message-item .form-message-value .action-postback:not(:disabled):active{background:var(--color-form-actions-background-focus);color:var(--color-form-actions-text-focus)}.wrapper .form-message-item .form-actions .action-postback:not(:disabled):focus svg>path,.wrapper .form-message-item .form-actions .action-postback:not(:disabled):active svg>path,.wrapper .form-message-item .form-message-value .action-postback:not(:disabled):focus svg>path,.wrapper .form-message-item .form-message-value .action-postback:not(:disabled):active svg>path{fill:var(--color-form-actions-text-focus)}.wrapper .tableform-message .table-message-row{cursor:pointer}.wrapper .tableform-message .table-message-row:hover{background-color:var(--color-table-row-background-hover)}.wrapper .tableform-message .table-message-row button:hover,.wrapper .tableform-message .table-message-row button:active,.wrapper .tableform-message .table-message-row button:focus{background-color:unset}.wrapper .tableform-message .table-message-headings .table-message-heading:last-child,.wrapper .tableform-message .table-message-row .table-message-item:last-child{min-width:unset;padding:0}.wrapper .tableform-message .table-message-headings .table-message-heading:last-child button,.wrapper .tableform-message .table-message-row .table-message-item:last-child button{margin:0 2px;transition:transform .25s ease-in-out}.wrapper .tableform-message .table-message-headings .table-message-heading:last-child button.rotate-180,.wrapper .tableform-message .table-message-row .table-message-item:last-child button.rotate-180{transform:rotate3d(0, 0, 1, 180deg)}.wrapper .tableform-message .form-message-item{margin:0;padding:16px;transition:all .25s ease-in-out;border-bottom:none}.wrapper .tableform-message .form-message-item:last-child{border-top:1px solid var(--color-table-bottom)}.wrapper .footer-form{width:100%}.wrapper .footer-form .message-bubble-form-message{background:rgba(0,0,0,0);border:none;width:100%}.wrapper .footer-form .message-bubble-form-message .form-message-item{background:rgba(0,0,0,0);padding:0}.wrapper .footer{max-width:100%;padding:0;background-color:var(--color-footer-background);z-index:3;box-shadow:0px -1px 4px 0px rgba(0,0,0,.1019607843);border-top:1px solid rgba(22,21,19,.1)}.wrapper .footer .footer-mode-keyboard{min-height:44px;margin:5px;background-color:var(--color-input-background);color:var(--color-input-text);border:1px solid var(--color-input-border);border-radius:6px}.wrapper .footer .footer-mode-voice{height:60px;padding:14px 0;background:var(--color-visualizer-container-background);justify-content:center}.wrapper .footer .footer-mode-voice .footer-visualizer-wrapper{max-width:296px;height:32px}.wrapper .footer .footer-logo{flex:0 0 auto;max-width:100px;max-height:36px;overflow:hidden;padding:0}.wrapper .footer.mode-keyboard .button-switch-kbd{display:none}.wrapper .footer.mode-keyboard .footer-mode-voice{display:none}.wrapper .footer.mode-voice .button-switch-voice{display:none}.wrapper .user-input{flex-grow:1;min-height:44px;padding:10px;margin:0;font-size:1em;font-family:inherit;line-height:24px;outline:1px solid rgba(0,0,0,0);resize:none;border:none;border-radius:6px;background-color:rgba(0,0,0,0);color:var(--color-input-text)}.wrapper .user-input:focus,.wrapper .user-input:focus-visible{outline:1px solid rgba(22,21,19,0)}.wrapper .footer-actions{padding-inline-end:4px}.wrapper .footer-button.button-send{background-color:var(--color-footer-button-fill);border-radius:50%}.wrapper .footer-button.button-send svg>path{fill:var(--color-input-background)}.wrapper .footer-button.button-send:not(:disabled):hover{background-color:var(--color-footer-button-fill-hover)}.wrapper .footer-button.button-send:not(:disabled):hover svg>path{fill:var(--color-input-background)}.wrapper .footer-button svg>path{fill:var(--color-footer-button-fill)}.wrapper .footer-button:not(:disabled):hover,.wrapper .footer-button:not(:disabled):focus{background-color:var(--color-footer-button-background-hover)}.wrapper .footer-button:not(:disabled):hover svg>path,.wrapper .footer-button:not(:disabled):focus svg>path{fill:var(--color-footer-button-fill-hover)}.wrapper .autocomplete-items{position:absolute;bottom:56px;width:100%;max-height:calc(100% - 56px);overflow-y:auto;background-color:var(--color-input-background);box-shadow:0px -1px 4px 0px rgba(0,0,0,.1019607843);margin:0 -5px}.wrapper .autocomplete-items .autocomplete-item{min-height:40px;padding:8px 16px;cursor:pointer}.wrapper .autocomplete-items .autocomplete-item:hover,.wrapper .autocomplete-items .autocomplete-item.autocomplete-active{background-color:var(--color-card-nav-button-hover)}.wrapper .autocomplete-items .autocomplete-item:first-of-type{margin-top:8px}.wrapper .autocomplete-items .autocomplete-item:last-of-type{margin-bottom:8px}.wrapper .autocomplete-items .autocomplete-item strong{font-weight:700}.wrapper.embedded .open{width:100%;height:100%}.wrapper.embedded .open .widget{border-radius:0;width:100%;min-width:100%;max-width:100%;height:100%;position:inherit;box-shadow:none;max-height:unset}.wrapper.popup-content-wrapper{background:rgba(22,21,19,.4);width:100vw;height:100vh;position:fixed;z-index:10000;top:0 !important;left:0 !important;display:flex;align-items:center;justify-content:center}.wrapper.popup-content-wrapper .popup-dialog{overflow:hidden;width:600px;border-radius:6px;box-shadow:0px 6px 12px 0px rgba(0,0,0,.2)}.wrapper.popup-content-wrapper .popup-dialog .message-bubble{width:auto;padding:32px;margin-top:0;border-radius:6px;overflow:auto;max-height:calc(100vh - 16px)}.wrapper.popup-content-wrapper .popup-dialog .message-bubble.message-bubble-form-message{padding:0}.wrapper.popup-content-wrapper .popup-dialog .message-bubble.message-bubble-form-message .form-message-header{padding:32px 32px 12px}.wrapper.popup-content-wrapper .popup-dialog .message-bubble.message-bubble-form-message .form-message-item{padding:0 32px 32px}.wrapper .full-screen-modal{position:fixed;top:0;left:0;width:100%;height:100vh;z-index:1000000;background-color:rgba(0,0,0,.8)}.wrapper .modal-header{background:linear-gradient(180deg, rgba(0, 0, 0, 0.5), transparent);color:#fff;display:flex;justify-content:space-between;position:relative;padding:10px 20px;z-index:1000001}.wrapper .modal-header .close-btn{border:none;background:rgba(0,0,0,0);cursor:pointer}.wrapper .full-screen-image{position:absolute;max-width:100vw;max-height:100vh;margin:auto;top:0;bottom:0;left:0;right:0}.wrapper .typing-cue-wrapper{width:32px;margin:auto;display:flex}.wrapper .typing-cue-wrapper .typing-cue{position:relative;left:0;right:0;margin:auto;width:8px;height:8px;border-radius:50%;background-color:var(--color-typing-indicator);animation:typing-cue 1550ms infinite linear alternate;animation-delay:250ms;opacity:.1}.wrapper .typing-cue-wrapper .typing-cue::before,.wrapper .typing-cue-wrapper .typing-cue::after{content:"";display:inline-block;position:absolute;width:8px;height:8px;border-radius:50%;background-color:var(--color-typing-indicator);animation:typing-cue 1550ms infinite linear alternate;opacity:.1}.wrapper .typing-cue-wrapper .typing-cue::before{left:-12px;animation-delay:0s}.wrapper .typing-cue-wrapper .typing-cue::after{left:12px;animation-delay:500ms}.wrapper .hidden{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.wrapper .rating-root{display:flex}.wrapper [dir=rtl] .rating-root{flex-direction:row-reverse}.wrapper .rating-wrapper{display:flex;margin-top:8px}.wrapper [dir=rtl] .rating-wrapper{flex-direction:row-reverse}.wrapper .rating-hidden{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.wrapper .star-label{background-color:rgba(0,0,0,0);border:0;cursor:pointer;padding:0}.wrapper .star-label>svg>path{fill:var(--color-rating-star)}.wrapper .star-input.active+label>svg>path{fill:var(--color-rating-star-fill)}.wrapper .star-input:disabled+.star-label{cursor:not-allowed;filter:brightness(0.8)}.wrapper .rating-star-icon{height:32px;width:32px}.wrapper.expanded .widget{animation:scale-in-br .25s cubic-bezier(0.25, 0.46, 0.45, 0.94) .2s both}.wrapper.expanded .widget.sidepanel{animation:unset}.wrapper.expanded .widget .resizable{width:4px;height:100%;top:0;left:0;background-color:rgba(0,0,0,0);position:absolute;z-index:10000;cursor:col-resize}.wrapper.expanded .widget .resizable.right-resize{right:0;left:unset}.wrapper.expanded .widget .resizable.top-resize{width:100%;height:4px;cursor:row-resize}.wrapper.expanded .widget .resizable.corner{height:8px;width:8px;cursor:nwse-resize}.wrapper.expanded .widget .resizable.corner.right-resize{cursor:nesw-resize}.wrapper.expanded:not(.pos-left) .right-resize{display:none}.wrapper.expanded:not(.drag) .button{animation:scale-out-center .25s cubic-bezier(0.55, 0.085, 0.68, 0.53) forwards}.wrapper.collapsed .widget{animation:scale-out-br .25s cubic-bezier(0.55, 0.085, 0.68, 0.53) forwards}.wrapper.collapsed .widget.sidepanel{animation:unset}.wrapper.collapsed .notification-badge{background-color:var(--color-notification-badge-background);color:var(--color-notification-badge-text);right:-5px;top:-5px;align-items:center;border-radius:24px;display:flex;font-size:14px;height:24px;justify-content:center;position:absolute;text-align:center;width:32px}.wrapper.collapsed:not(.drag) .button{animation:scale-in-center .25s cubic-bezier(0.25, 0.46, 0.45, 0.94) .2s both}.wrapper.pos-left .widget{right:unset;left:calc(var(--position-left)*-1);max-width:100vw}.wrapper.pos-left.expanded .widget{animation:scale-in-bl .25s cubic-bezier(0.25, 0.46, 0.45, 0.94) .2s both}.wrapper.pos-left.expanded .widget .left-resize{display:none}.wrapper.pos-left.collapsed .widget{animation:scale-out-bl .25s cubic-bezier(0.55, 0.085, 0.68, 0.53) forwards}.wrapper .ellipsis{display:inline-block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%}.wrapper .popup{position:absolute;background-color:var(--color-popup-background);color:var(--color-popup-text);min-width:140px;max-height:calc(100% - 128px);display:none;padding:4px 0;border-radius:6px;box-shadow:rgba(0,0,0,.16) 0px 4px 8px 0px;overflow-y:auto;z-index:5}.wrapper .popup li{display:flex;align-items:center;height:48px;margin:4px 0;cursor:pointer;overflow:hidden;color:var(--color-popup-button-text)}.wrapper .popup li svg>path{fill:var(--color-popup-text)}.wrapper .popup li#action-menu-option-lang{border-top:1px solid var(--color-popup-horizontal-rule)}.wrapper .popup li.disable{pointer-events:none;cursor:not-allowed;opacity:.5}.wrapper .popup li:hover,.wrapper .popup li:focus,.wrapper .popup li.active{background-color:var(--color-popup-item-background-hover)}.wrapper .popup li .icon{margin-inline-start:16px;height:20px;width:20px}.wrapper .popup li .text{padding:0 16px 0 16px}.wrapper .popup.expand{display:block;-webkit-animation:scale-in-br .25s cubic-bezier(0.25, 0.46, 0.45, 0.94) .2s both;animation:scale-in-br .25s cubic-bezier(0.25, 0.46, 0.45, 0.94) .2s both}.wrapper .popup.action-menu,.wrapper .popup.language-selection-menu{top:50px;bottom:unset}.wrapper .popup.action-menu.expand,.wrapper .popup.language-selection-menu.expand{display:block;-webkit-animation:scale-in-tr .25s cubic-bezier(0.25, 0.46, 0.45, 0.94) .2s both;animation:scale-in-tr .25s cubic-bezier(0.25, 0.46, 0.45, 0.94) .2s both}.wrapper .popup.language-selection-menu{max-height:calc(100% - 280px)}.wrapper .popup.share-popup-list{bottom:50px;left:unset}.wrapper .spinner{height:48px;width:48px}.wrapper .spinner svg{animation-duration:750ms;-webkit-animation:spin 1s linear infinite;animation:spin 1s linear infinite}.wrapper .spinner svg circle{fill:rgba(0,0,0,0);stroke:var(--color-user-text);stroke-width:2px;stroke-dasharray:128px;stroke-dashoffset:82px}.wrapper .webview-container{position:absolute;width:100%;height:80%;bottom:0;box-shadow:0px -4px 32px rgba(0,0,0,.1);z-index:10}.wrapper .webview-container .webview-header svg{fill:var(--color-actions-text)}.wrapper .webview-container .webview-header button{color:var(--color-actions-text)}.wrapper .webview-container .spinner{position:absolute;margin:auto;left:0;right:0;top:40%}.wrapper .webview-container iframe{width:100%;height:100%;background:var(--color-conversation-background);border:none}.wrapper .webview-container .webview-error{position:absolute;bottom:0;background:var(--color-popup-background);width:calc(100% - 32px);margin:10px 16px;padding:6px 16px;border-radius:6px;display:flex;align-items:center;box-shadow:0px -4px 32px rgba(0,0,0,.1)}.wrapper .webview-container .webview-error .webview-error-button-close{border:none}.wrapper .webview-container.webview-container-close{animation:oda-chat-webview-slide-out-bottom .4s cubic-bezier(0.55, 0.085, 0.68, 0.53) both}.wrapper .webview-container.webview-container-open{animation:oda-chat-webview-slide-in-bottom .4s cubic-bezier(0.25, 0.46, 0.45, 0.94) both}.widget{position:absolute;bottom:calc(var(--position-bottom)*-1);border-radius:6px 6px 0 0;box-shadow:0px -4px 32px rgba(0,0,0,.1);right:calc(var(--position-right)*-1);width:100vw;min-width:100vw;max-width:100vw;max-height:var(--widget-max-height);margin:0;overflow:hidden;text-decoration:none;text-transform:none;z-index:10000;align-items:stretch;background:var(--color-conversation-background)}.widget.large-size .conversation .conversation-pane .message-bubble{padding:16px 24px}.widget.large-size .conversation .conversation-pane .message-bubble .attachment .attachment-placeholder{margin:-16px -24px 0;max-width:calc(100% + 48px)}.widget.large-size .conversation .conversation-pane .message-bubble .attachment .attachment-footer{margin:0 -24px -16px}.widget.large-size .conversation .conversation-pane.bot-icon .message-block .messages-wrapper,.widget.large-size .conversation .conversation-pane.user-icon .message-block .messages-wrapper{max-width:780px}.widget.large-size .conversation .conversation-pane.bot-icon .message-block .messages-wrapper .message-header,.widget.large-size .conversation .conversation-pane.bot-icon .message-block .messages-wrapper .message-footer,.widget.large-size .conversation .conversation-pane.user-icon .message-block .messages-wrapper .message-header,.widget.large-size .conversation .conversation-pane.user-icon .message-block .messages-wrapper .message-footer{max-width:780px}.widget.large-size .conversation .conversation-pane.bot-icon.bot-icon .message-block .messages-wrapper,.widget.large-size .conversation .conversation-pane.user-icon.bot-icon .message-block .messages-wrapper{max-width:780px}.widget.large-size .conversation .conversation-pane.bot-icon.bot-icon .message-block .messages-wrapper .message.card-message-horizontal .message-header,.widget.large-size .conversation .conversation-pane.bot-icon.bot-icon .message-block .messages-wrapper .message.card-message-horizontal .message-footer,.widget.large-size .conversation .conversation-pane.user-icon.bot-icon .message-block .messages-wrapper .message.card-message-horizontal .message-header,.widget.large-size .conversation .conversation-pane.user-icon.bot-icon .message-block .messages-wrapper .message.card-message-horizontal .message-footer{max-width:780px}.widget.large-size button:not(.icon){height:44px}.widget.medium-size .conversation .conversation-pane .message-bubble{padding:8px 16px}.widget.medium-size .conversation .conversation-pane .message-bubble .attachment .attachment-placeholder{margin:-8px -16px 0}.widget.medium-size .conversation .conversation-pane .message-bubble .attachment .attachment-footer{margin:0 -16px -8px}.widget.medium-size .conversation .conversation-pane.bot-icon .message-block .messages-wrapper,.widget.medium-size .conversation .conversation-pane.user-icon .message-block .messages-wrapper{max-width:680px}.widget.medium-size .conversation .conversation-pane.bot-icon .message-block .messages-wrapper .message.card-message-horizontal .message-header,.widget.medium-size .conversation .conversation-pane.bot-icon .message-block .messages-wrapper .message.card-message-horizontal .message-footer,.widget.medium-size .conversation .conversation-pane.user-icon .message-block .messages-wrapper .message.card-message-horizontal .message-header,.widget.medium-size .conversation .conversation-pane.user-icon .message-block .messages-wrapper .message.card-message-horizontal .message-footer{max-width:680px}.widget.medium-size .conversation .conversation-pane.bot-icon.bot-icon .message-block .messages-wrapper,.widget.medium-size .conversation .conversation-pane.user-icon.bot-icon .message-block .messages-wrapper{max-width:680px}.widget.medium-size .conversation .conversation-pane.bot-icon.bot-icon .message-block .messages-wrapper .message.card-message-horizontal .message-bubble,.widget.medium-size .conversation .conversation-pane.user-icon.bot-icon .message-block .messages-wrapper .message.card-message-horizontal .message-bubble{padding:16px 24px}.widget.medium-size .conversation .conversation-pane.bot-icon.bot-icon .message-block .messages-wrapper .message.card-message-horizontal .message-header,.widget.medium-size .conversation .conversation-pane.bot-icon.bot-icon .message-block .messages-wrapper .message.card-message-horizontal .message-footer,.widget.medium-size .conversation .conversation-pane.user-icon.bot-icon .message-block .messages-wrapper .message.card-message-horizontal .message-header,.widget.medium-size .conversation .conversation-pane.user-icon.bot-icon .message-block .messages-wrapper .message.card-message-horizontal .message-footer{max-width:680px}.widget.medium-size button:not(.icon){height:44px}.widget .alert-wrapper{position:absolute;top:48px;width:100%}.widget .alert-wrapper .alert-prompt{position:relative;left:0;right:0;width:auto;margin:6px;padding:10px;border-radius:10px;z-index:11}.widget .msg-icon{padding:5px 10px 0 0}.widget .msg{flex-grow:1}.sidepanel-content-wrapper{display:flex;width:100vw}.sidepanel-content-wrapper>*{flex-grow:1}.sidepanel-content-wrapper .wrapper:not(.contextual-widget){position:absolute;bottom:0;right:0;height:100vh;flex-grow:unset;width:0;min-width:0;max-width:0;flex-shrink:0;--width-full-screen: 375px}.sidepanel-content-wrapper .wrapper:not(.contextual-widget).expanded{min-width:100vw;max-width:100vw}.sidepanel-content-wrapper .wrapper:not(.contextual-widget).expanded::after{content:"";background-color:rgba(0,0,0,0);position:absolute;top:0;left:0;width:4px;height:100%;cursor:col-resize;z-index:10000}.sidepanel-content-wrapper .wrapper:not(.contextual-widget).expanded.drag{transition:unset}.sidepanel-content-wrapper .wrapper:not(.contextual-widget).expanded.drag::after{background-color:#ccc}.sidepanel-content-wrapper .widget{position:relative;bottom:0;right:0;left:0;top:0;width:100%;min-width:unset;max-width:unset;height:100%;max-height:100%;box-shadow:none;border-radius:0}.contextual-widget-wrapper{position:relative}.contextual-widget-wrapper .widget-wrapper{position:sticky;height:0;z-index:1;top:8px;max-width:100%}.contextual-widget-wrapper .widget-wrapper .container{position:absolute;right:-44px}.contextual-widget-wrapper .widget-wrapper .container .contextual-widget{position:relative;width:272px;border-radius:6px;background-color:#f5f4f2;box-shadow:0px 6px 12px 0px rgba(0,0,0,.2)}.contextual-widget-wrapper .widget-wrapper .container .contextual-widget.minimum-size{width:36px;box-shadow:0px 1px 4px 0px rgba(0,0,0,.1215686275);border-radius:4px}.contextual-widget-wrapper .widget-wrapper .container .contextual-widget.minimum-size.no-feedback>:first-child{border-bottom:none}.contextual-widget-wrapper .widget-wrapper .container .contextual-widget.minimum-size.no-feedback>:not(:first-child){display:none}.contextual-widget-wrapper .widget-wrapper .container .contextual-widget.minimum-size>:not(:last-child){border-bottom:1px solid rgba(22,21,19,.1215686275)}.contextual-widget-wrapper .widget-wrapper .container .contextual-widget.minimum-size button{background:#f5f4f2;margin-inline-start:0;border-radius:0}.contextual-widget-wrapper .widget-wrapper .container .contextual-widget.full-size{width:416px;display:block}.contextual-widget-wrapper .widget-wrapper .container .contextual-widget.full-size .conversation .message-wrapper{border-bottom:1px solid rgba(22,21,19,.1215686275)}.contextual-widget-wrapper .widget-wrapper .container .contextual-widget.full-size .footer.enabled{display:block}.contextual-widget-wrapper .widget-wrapper .container .contextual-widget:not(.full-size) .message-actions>:only-child,.contextual-widget-wrapper .widget-wrapper .container .contextual-widget:not(.full-size) .message-actions>:nth-child(2){border:none}.contextual-widget-wrapper .widget-wrapper .container .contextual-widget .header{height:44px;background:#f5f4f2;padding:8px 12px 0}.contextual-widget-wrapper .widget-wrapper .container .contextual-widget .header .logo{height:16px;width:16px}.contextual-widget-wrapper .widget-wrapper .container .contextual-widget .header .title{height:16px;font-weight:400;font-size:12px;line-height:16px;color:rgba(22,21,19,.6980392157)}.contextual-widget-wrapper .widget-wrapper .container .contextual-widget .error-message{display:flex;height:76px;border-radius:6px;border:1px solid rgba(22,21,19,.1215686275);margin:0 12px 12px;background:#fef9f2;padding:8px}.contextual-widget-wrapper .widget-wrapper .container .contextual-widget .error-message .error-icon{height:18px;margin:8px;padding-top:2px;width:16px}.contextual-widget-wrapper .widget-wrapper .container .contextual-widget .error-message .error-info{margin:8px 0}.contextual-widget-wrapper .widget-wrapper .container .contextual-widget .error-message .error-info .error-text{color:#8f520a;line-height:20px;font-weight:700}.contextual-widget-wrapper .widget-wrapper .container .contextual-widget .error-message .error-info .reset-button{cursor:pointer;line-height:16px;font-size:13.75px;font-weight:600;margin-top:8px;color:#161513}.contextual-widget-wrapper .widget-wrapper .container .contextual-widget .message-global-actions{margin-top:0px;padding:12px 12px 4px;background:#fff}.contextual-widget-wrapper .widget-wrapper .container .contextual-widget .message-global-actions button.action-postback{height:auto}.contextual-widget-wrapper .widget-wrapper .container .contextual-widget .message-wrapper{padding:0 12px 0}.contextual-widget-wrapper .widget-wrapper .container .contextual-widget .message-wrapper .message-actions{margin-top:0;margin-bottom:4px;padding:0}.contextual-widget-wrapper .widget-wrapper .container .contextual-widget .message-wrapper .message-actions .action-postback{background:rgba(0,0,0,0)}.contextual-widget-wrapper .widget-wrapper .container .contextual-widget .message-bubble{font-size:13.75px;line-height:16px;margin-top:0;margin-bottom:0;background:rgba(0,0,0,0);border-radius:0;min-height:unset;padding:0 !important}.contextual-widget-wrapper .widget-wrapper .container .contextual-widget .message-bubble .message-text{margin-bottom:12px}.contextual-widget-wrapper .widget-wrapper .container .contextual-widget .footer,.contextual-widget-wrapper .widget-wrapper .container .contextual-widget .footer-form{display:none}.contextual-widget-wrapper .widget-wrapper .container .generate-spinner{background-color:#f5f4f2;box-sizing:border-box;width:154px;height:52px;padding:8px 12px;border-radius:6px;box-shadow:0px 6px 12px 0px rgba(0,0,0,.2);position:sticky;top:8px;bottom:8px;z-index:1;display:flex;align-items:center}.contextual-widget-wrapper .widget-wrapper .container .generate-spinner .generate-icon{height:16px;width:16px}.contextual-widget-wrapper .widget-wrapper .container .generate-spinner .generate-icon.spin{-webkit-animation:spin 1s linear infinite;animation:spin 1s linear infinite}.contextual-widget-wrapper .widget-wrapper .container .generate-spinner .generate-text{width:70px;height:16px;font-size:12px;line-height:16px;color:rgba(22,21,19,.6980392157)}.contextual-widget-wrapper .widget-wrapper .container .generate-spinner .close-button{border:rgba(0,0,0,0);cursor:pointer;background:#f5f4f2;width:36px;height:36px;padding:8px}.contextual-widget-wrapper .widget-wrapper .container .generate-spinner>:not(:last-child){margin-inline-end:4px}.contextual-widget-wrapper .widget-wrapper .widget{position:relative;bottom:0;right:0;left:0;top:0;width:100%;height:100%;border-radius:6px}.search-bar-widget-wrapper{position:relative;height:100%;min-height:40px}.search-bar-widget-wrapper .dialog-wrapper{position:relative}.search-bar-widget-wrapper .dialog-wrapper .dialog{position:relative}.search-bar-widget-wrapper .footer{border:none;box-shadow:none;background:rgba(0,0,0,0);height:100%}.search-bar-widget-wrapper .footer.mode-voice+.search-bar-widget .search-bar-popup{display:none}.search-bar-widget-wrapper .footer .footer-mode-keyboard{min-height:unset;margin:0;border:0;background:rgba(0,0,0,0);height:100%;top:0;position:absolute;width:100%}.search-bar-widget-wrapper .footer .footer-mode-voice{position:absolute;left:0;right:0;top:calc(100% + 2px);border:1px solid rgba(22,21,19,.12)}.search-bar-widget-wrapper .footer .user-input{height:100%;min-height:unset;padding:4px;line-height:unset}.search-bar-widget-wrapper .footer .footer-actions{height:100%}.search-bar-widget-wrapper .footer .footer-actions .share-popup-list{max-height:unset;bottom:unset;animation:none}.search-bar-widget-wrapper .autocomplete-items{max-height:unset;top:56px;bottom:unset}.search-bar-widget-wrapper .search-bar-widget{position:absolute;bottom:0;height:0;width:100%}.search-bar-widget-wrapper .search-bar-widget .search-bar-widget-content{position:relative;top:4px;background:#fff;height:0}.search-bar-widget-wrapper .search-bar-widget .search-bar-widget-content .search-bar-popup{position:absolute;min-width:100%;width:100%;max-width:100%;border-radius:6.06px;border:2px solid #000;background:#fff;padding:8px;display:flex;flex-direction:column;box-shadow:0 12px 20px rgba(0,0,0,.2784313725);max-height:400px;overflow:auto;--color-conversation-background: #fff}.search-bar-widget-wrapper .search-bar-widget .search-bar-widget-content .search-bar-popup:empty{display:none !important}.search-bar-widget-wrapper .search-bar-widget .search-bar-widget-content .search-bar-popup .user-message{font-weight:bold}.search-bar-widget-wrapper .search-bar-widget .search-bar-widget-content .search-bar-popup .message{max-width:100%}.search-bar-widget-wrapper .search-bar-widget .search-bar-widget-content .search-bar-popup .message.card-message-horizontal{margin-inline:0;width:100vw}.button-drag-handle{position:absolute;width:100%;height:100%}.image-preview-wrapper{background:rgba(0,0,0,.8);height:100%;position:fixed;top:0;left:0;width:100%;z-index:10000}.image-preview-wrapper .image-preview-header{align-items:center;background:linear-gradient(180deg, rgba(0, 0, 0, 0.5), transparent);color:#fff;display:flex;justify-content:space-between;position:relative;padding:10px 20px;z-index:1000001}.image-preview-wrapper .image-preview-header .image-preview-close{background:rgba(0,0,0,0);border:none;cursor:pointer;height:36px;width:36px}.image-preview-wrapper .image-preview-header .image-preview-close .image-preview-close-icon{fill:#fff;height:100%;width:100%}.image-preview-wrapper .image-preview{bottom:0;left:0;margin:auto;max-height:100vh;max-width:100vw;position:absolute;right:0;top:0}.arrow-icon{margin-inline-end:2px;width:32px;height:32px;display:flex;align-items:center;flex-shrink:0}@media screen and (min-width: 426px){.wrapper.pos-left .widget{left:0}.wrapper:not(.embedded) .widget:not(.sidepanel){max-width:calc(100vw - var(--position-right))}.wrapper:not(.embedded).pos-left .widget:not(.sidepanel){max-width:calc(100vw - var(--position-left))}.wrapper .messages-wrapper .message-list .message.card-message-horizontal{width:var(--width-full-screen)}.widget:not(.sidepanel){width:var(--width-full-screen);min-width:unset;max-height:var(--widget-max-height);bottom:0;right:0}.sidepanel-content-wrapper .wrapper.wrapper:not(.contextual-widget){position:sticky;top:0}.sidepanel-content-wrapper .wrapper.wrapper:not(.contextual-widget).expanded{min-width:375px;max-width:800px}.sidepanel-content-wrapper .wrapper.wrapper:not(.contextual-widget) .widget{border-left:thin solid #ccc}}@media(prefers-reduced-motion){.open{animation:none}.close{animation:none}}[dir=rtl] .wrapper *{direction:rtl}[dir=rtl] .multi-select-option{float:right !important}[dir=rtl] .wrapper{text-align:right}[dir=rtl] .wrapper .widget.open{animation:scale-in-bl .25s cubic-bezier(0.25, 0.46, 0.45, 0.94) .2s both}[dir=rtl] .wrapper .widget.close{animation:scale-out-bl .25s cubic-bezier(0.55, 0.085, 0.68, 0.53) forwards}[dir=rtl] .wrapper .message-bubble{border-radius:10px 2px 2px 10px}[dir=rtl] .wrapper .message-block .message:last-child .message-bubble:last-child{border-radius:10px 2px 10px 10px}[dir=rtl] .wrapper .message-block.right .messages-wrapper .message .message-bubble{border-radius:2px 10px 10px 2px}[dir=rtl] .wrapper .message-block.right .messages-wrapper .message:last-child .message-bubble:last-child{border-radius:2px 10px 10px 10px}[dir=rtl] .wrapper .button{left:0;right:unset}[dir=rtl] .wrapper .popup.expand{-webkit-animation:scale-in-bl .25s cubic-bezier(0.25, 0.46, 0.45, 0.94) .2s both;animation:scale-in-bl .25s cubic-bezier(0.25, 0.46, 0.45, 0.94) .2s both}[dir=rtl] .wrapper .popup.action-menu.expand,[dir=rtl] .wrapper .popup.language-selection-menu.expand{-webkit-animation:scale-in-tl .25s cubic-bezier(0.25, 0.46, 0.45, 0.94) .2s both;animation:scale-in-tl .25s cubic-bezier(0.25, 0.46, 0.45, 0.94) .2s both}'.replace(/(\.)([a-zA-Z_-]+)(?=[^}]+{)/gi,`$1${this.Xi}-$2`)));for(let s=0;s{this.updateFullScreenWidth(`${t.clientWidth}px`)}),500))}catch(t){this.Ri.error("Target Element not specified",t)}else if(e.sidepanel)try{const t=document.getElementById(e.targetElement),s=t.parentNode,o=i.createDiv(["sidepanel-content-wrapper"]);s.replaceChild(o,t),i.addCSSClass(this.chatWidgetDiv,"sidepanel"),o.appendChild(t),o.appendChild(this.chatWidgetWrapper)}catch(t){this.Ri.error("Target Element not specified",t)}else{try{this.appendToElement(document.body)}catch(t){return void this.Ri.error("Initialisation failed as page is not completely loaded. Make sure to initialise the SDK after document.body is available.")}zs((()=>{this.orientWidgetAnimation()}),0),window.addEventListener("resize",Ze((()=>{this.orientWidgetAnimation()}),500));const i=e.width,s=e.height;i&&this.setWidth(i),s&&this.setHeight(s),e.openChatOnLoad&&zs(null===(t=this.ua)||void 0===t?void 0:t.bind(this),0)}}wc(t){var e;this.He.searchBarMode?this.Pa.appendMessageToConversation(t):this.Ic.appendChild(t),(null===(e=this.Zn)||void 0===e?void 0:e.isVisible())&&(this.hideTypingIndicator(),this.showTypingIndicator())}ja(){const t=this.Bc.element;zs((()=>{t&&(t.scrollTop=t.scrollHeight)}),jt.CHAT_SCROLL_DELAY)}Lc(t,e=!0){if(!t||!t.length)return Promise.resolve();const i=this.He.threadId,s=t.filter((t=>!t.threadId||!i||t.threadId===i));return s.length?new Promise((t=>{const i={isFresh:e};this.He.clientAuthEnabled&&this.He.enableAttachmentSecurity?this.Ro.getAuthToken().then((e=>{i.authToken=e.token,this.Zc(s,i),t(),this.ja()})).catch((()=>{this.Zc(s,i),t(),this.ja()})):(this.Zc(s,i),t(),this.ja())})):Promise.resolve()}Gc(t,e){var i,o,r,n;let a;if(Se(t)){let c="";if(t.source===s.SkillMessageSource.Agent){const s=this.He.icons;(null===(i=t.messagePayload.channelExtensions)||void 0===i?void 0:i.agentSession)||(t.messagePayload.channelExtensions?t.messagePayload.channelExtensions.agentSession=this.Ua:t.messagePayload.channelExtensions={agentSession:this.Ua}),!this.Ua.avatarImage&&s.avatarBot&&e.appendChild(this.qc()),c=this.Ua.name}else if(t.source===s.SkillMessageSource.Bot&&(null===(o=t.messagePayload.channelExtensions)||void 0===o?void 0:o.agentSession)){c=(null===(r=t.messagePayload.channelExtensions)||void 0===r?void 0:r.agentSession).name}c&&(a=this.ii.createTextDiv(["agent-name"]),a.title=c,a.innerHTML=c,a.setAttribute("aria-hidden","true"),(null===(n=this.Ua)||void 0===n?void 0:n.nameTextColor)&&(a.style.color=this.Ua.nameTextColor))}return a}qc(){const t=this.Ua||{},e=t.name.split(" ").filter((t=>t));let i=e[0][0];return e.length>1&&(i+=e[e.length-1][0]),this.zc(i.toUpperCase(),t.name,!0)}Ba(){if(this.He.showTypingIndicator){const t=this.Ua||{},e=this.He.icons,i=this.wa;e.avatarBot&&(!t.avatarImage&&t.name?this.Zn.updateTypingCueIcon(this.qc()):this.Zn.updateTypingCueIcon(this.zc(t.avatarImage||e.avatarBot,i.avatarAgent||i.avatarBot)))}}zc(t,e,i=!1){const s=this.ii,o=s.createDiv(["icon-wrapper",i?"agent-avatar":""]),r=this.Ua||{};let n;return i?(n=s.createTextDiv(["agent-icon"]),n.innerText=t,r.avatarTextColor&&(n.style.color=r.avatarTextColor),r.avatarBackgroundColor&&(o.style.background=r.avatarBackgroundColor)):n=s.createImageIcon({icon:t,iconCss:["message-icon"]}),o.appendChild(n),o.setAttribute("aria-label",e),o}Yc(t){const e=t?new Date(t):new Date,i=(0,a.formatDate)(e,{pattern:this.He.timestampFormat,locale:this.va}),s=this.ii.createTextDiv(["message-date"]);return s.setAttribute("aria-live","off"),s.setAttribute("aria-hidden","true"),s.innerText=`${i}`,s}Zc(t,e){const{isFresh:i,authToken:o}=e,r=this.He,n=this.ii,a={locale:this.va,webviewLinkHandler:this.dc,webCore:this.Ro,onMessageActionClicked:this.onMessageActionClicked.bind(this),isFresh:i};(null==o?void 0:o.length)&&(a.authToken=o,a.uri=r.URI),t.forEach((t=>{var e,i,o,c,h;if(t.messagePayload.type===s.MessageType.Error)return;if(Se(t)){const e=Ce(t);if(this.aa.indexOf(e)>=0)return;this.aa.push(e)}const l=$e.fromMessage(r,n,t,a);if(!l)return;if(l instanceof ie){const e=t.messagePayload;switch(e.streamState){case"start":this.Wn.disable(),this.mc=l;break;case"running":if(this.mc)return this.mc.update(e),clearTimeout(this.Jc),void(this.Jc=zs((()=>{this.Wn.disable(!1),this.mc=null}),this.ca));this.Wn.disable(),this.mc=l;break;case"end":if(clearTimeout(this.Jc),this.Wn.disable(!1),this.mc)return this.mc.update(e),void(this.mc=null)}}else this.mc=null,clearTimeout(this.Jc);if(l.onActionClick=this.onMessageActionClicked.bind(this),r.searchBarMode)return void this.Pa.renderMessage(t,l);const u=Se(t)?s.SenderType.Skill:s.SenderType.User,p=this.Kc(t.messagePayload,u),d=p||this.Xc(t,u);let g;if(l.msgId=t.msgId,this.oc=u,this.Dc=Date.now(),this._a=t.messagePayload.globalActions&&0!==t.messagePayload.globalActions.length,this.Qc=(null===(i=null===(e=t.messagePayload.channelExtensions)||void 0===e?void 0:e.agentSession)||void 0===i?void 0:i.name)||"",Se(t)&&(this.th=t.source),d||(g=n.createDiv(["message-block","flex"]),this.eh=g),void 0!==l.ratingId&&(this.ih=l),Se(t))this.ta?this.sh(l):this.skillMessages.push(l),t.source===s.SkillMessageSource.Agent?((null===(o=t.messagePayload.channelExtensions)||void 0===o?void 0:o.agentName)&&this.setAgentDetails({name:t.messagePayload.channelExtensions.agentName,avatarImage:r.icons.avatarAgent,nameTextColor:null,avatarTextColor:null,avatarBackgroundColor:null}),(null===(c=t.messagePayload.channelExtensions)||void 0===c?void 0:c.agentSession)&&this.setAgentDetails(t.messagePayload.channelExtensions.agentSession)):(this.za.removeItem(this.Na),this.Ua=null),this.Ra(l);else if(this.ih){const e=t;if(e.messagePayload.type===s.MessageType.Text||e.messagePayload.type===s.MessageType.Postback){const t=e.messagePayload;this.ih.highlightRating(t.text)}this.ih=null}const m=t.date?new Date(t.date):new Date;this.Va(m),g&&(this.oh(t,g),this.wc(g));const f=this.eh.querySelector('[class*="message-list"]'),b=this.Yn(t,l,f);if(b){if(t.messagePayload.type===s.MessageType.Card){const t=f.querySelectorAll('[class*="message-bubble"]');if(t.length){t[t.length-1].classList.add(`${this.Xi}-before-card`)}}p&&f.lastElementChild?null===(h=f.lastElementChild)||void 0===h||h.replaceWith(b):f.appendChild(b),l instanceof qt&&l.setCardsScrollDirection()}this.Fa(u)}))}Kc(t,e){var i,o;if(e===s.SenderType.Skill&&(null===(i=this.eh)||void 0===i?void 0:i.className.includes(`${this.Xi}-left`))){const e=null===(o=t.channelExtensions)||void 0===o?void 0:o.replaceMessage;return!0===e||e&&"true"===(null==e?void 0:e.toLowerCase())}return!1}Xc(t,e){var i,o;if(!(Date.now()-this.Dc<1e4))return!1;if(Se(t)&&t.source===s.SkillMessageSource.Agent&&(null===(i=t.messagePayload.channelExtensions)||void 0===i?void 0:i.agentSession)){const e=null===(o=t.messagePayload.channelExtensions)||void 0===o?void 0:o.agentSession;return this.Qc===e.name}return!(this.oc!==e||Se(t)&&t.source!==this.th||this._a)}oh(t,e){const i=this.He.icons,o=this.wa,r=this.ii,n=this.Ua||{};let a,c,h;if(Se(t)){if(a=this.Gc(t,e),t.source===s.SkillMessageSource.Agent?(c=i.avatarBot&&(n.avatarImage||!n.name)&&(n.avatarImage||i.avatarAgent||i.avatarBot),h=o.agentMessage.replace("{0}",`${n.name||o.agent}`)):(this.th===s.SkillMessageSource.Agent&&this.He.showTypingIndicator&&this.Zn.resetTypingCueIcon(),c=i.avatarBot,h=o.skillMessage),r.addCSSClass(e,"left"),c){const i=this.zc(c,t.source===s.SkillMessageSource.Agent&&o.avatarAgent||o.avatarBot);i.style.marginTop=a&&"16px",e.appendChild(i)}}else r.addCSSClass(e,"right"),h=o.userMessage,i.avatarUser&&e.appendChild(this.zc(i.avatarUser,o.avatarUser));const l=r.createDiv(["messages-wrapper","flex","col"]);a&&l.appendChild(a);const u=this.ii.createTextSpan(["screen-reader-only"]);u.innerText=h,l.appendChild(u);const p=r.createDiv(["message-list","flex","col"]);if(l.appendChild(p),this.He.enableTimestamp&&"absolute"===this.He.timestampMode){const e=this.Yc(t.date);l.appendChild(e)}e.appendChild(l)}Yn(t,e,i){const s=this.He.delegate;if(s&&s.render){const e=this.ii.createDiv(["message"]);e.id=t.msgId,e.lang=this.He.locale,i.appendChild(e);if(s.render(t))return null;e.remove()}return e.render()}Va(t){(0,a.isSameDay)(this.Tc,t)||(this.Tc=new Date(t),this.wc(this.rh(this.Tc)))}rh(t){const e=this.ii.createTextDiv(["timestamp-header"]);return e.textContent=(0,a.formatDate)(t,{pattern:this.He.timestampFormat,locale:this.va}),this.Cc=e,e}Fa(t){this.nh||(this.nh=this.Da.render()),this.nh.remove(),this.Da.refresh(t),this.wc(this.nh)}Ra(t){t.hasActions()&&zs((()=>{t.focusFirstAction()}),290)}Uc(t,e,i){const s=document.querySelector(`#${t}`);if(s){const t=this.ii.createDiv(i);t.appendChild(s),e.appendChild(t)}else this.Ri.error(`Could not find element with ID '${t}'. No element embedded to the chat conversation pane.`)}Ts(t,e=!1){const i=function(t,e){const i=document.querySelector(`.${e}-wrapper`);return getComputedStyle(i).getPropertyValue(t)}("--color-visualizer",this.He.name),r=this.wa;e||(this.Ka(),this.As.trigger(o.CLICK_VOICE_TOGGLE,t)),this.He.enableSpeech&&(t?(this.ah(),this.He.speechLocale&&!(0,s.isValidLocale)(this.He.speechLocale)?this.lc(r.errorSpeechUnsupportedLocale,V):this.Ro.startRecognition({onRecognitionText:this.lh.bind(this),onVisualData:t=>{this.Wn.updateVisualizer(t,i)}}).then((()=>{e&&this.Wn.setRecognitionRequested(e),this.Wn.setVoiceRecording(!0),this.ja()})).catch((t=>{this.Wn.setVoiceRecording(!1);let e="";switch(t.message){case s.CoreError.RecognitionMultipleConnection:e=r.errorSpeechMultipleConnection;break;case s.CoreError.RecognitionNotReady:e=r.errorSpeechInvalidUrl;break;case s.CoreError.RecognitionProcessingFailure:e=r.errorSpeechTooMuchTimeout;break;default:e=r.errorSpeechUnavailable}this.lc(e,V)}))):(this.Ro.stopRecognition(),this.Wn.setVoiceRecording(!1)))}lh(t){if(t)switch(t.type){case"error":this.Ri.error("Failed to recognize voice",t.text),t.text===s.CoreError.RecognitionTooMuchSpeechTimeout&&this.lc(this.wa.errorSpeechTooMuchTimeout,V),this.Wn.setVoiceRecording(!1);break;case"final":let e=t.text;e.length>0?(this.speechFinalResult&&(e=`${this.speechFinalResult.text} ${e}`),this.Wn.setUserInputText(e),this.He.enableSpeechAutoSend?zs((()=>{const i=(0,s.buildUserTextMessage)(e,t.requestId);this.sendMessage(i).then((()=>{this.Wn.setUserInputText("")})).catch(this.la)}),200):this.speechFinalResult={speechId:t.requestId,text:e},this.Wn.setVoiceRecording(!1)):this.Wn.setUserInputText(this.speechFinalResult.text);break;case"partial":let i=t.text;i.length>0&&(this.speechFinalResult&&(i=`${this.speechFinalResult.text} ${i}`),this.Wn.setUserInputText(i))}}cc(t){switch(this.He.disablePastActions){case"all":t.forEach((t=>{t.disableActions()}));break;case"postback":t.forEach((t=>{t.disablePostbacks()}))}}hc(t){switch(this.He.disablePastActions){case"all":t.forEach((t=>{t.enableActions()}));break;case"postback":t.forEach((t=>{t.enablePostbacks()}))}}uh(){this.cc(this.skillMessages)}sh(t){("none"===this.He.disablePastActions?this.skillMessages:this.Qn).push(t)}fc(){this.cc(this.Qn),this.Qn=[]}Rc(){("none"===this.He.disablePastActions?this.skillMessages:this.Qn).forEach((t=>{t.enablePostbacks()}))}Hc(){("none"===this.He.disablePastActions?this.skillMessages:this.Qn).forEach((t=>{t.disablePostbacks()}))}ic(t=!1){var e;const i=this.He.searchBarMode?this.qn:this.Ic;let s=!1;for((null===(e=this.Zn)||void 0===e?void 0:e.isVisible())&&(s=!0,this.hideTypingIndicator());i.firstChild;)i.removeChild(i.lastChild);s&&this.showTypingIndicator(),this.ra=!0,this.Tc=null,this.Ka(),t?this.oa=!0:this.As.trigger(o.CLICK_ERASE)}Sa(){const{userId:t,channelId:e}=this.He;xs&&(this.Vc(),this.ph=new xs(`${t}-${e}`),this.ph.onmessage=this.dh.bind(this))}Vc(){this.ph&&(this.ph.close(),this.ph=null)}gh(t){if(this.ph){const e={type:"message",message:t};if(Se(t)){const i=Ce(t);if(this.aa.indexOf(i)>=0)return;e.digest=i}this.ph.postMessage(e)}}sc(t){this.ph&&this.ph.postMessage(t)}dh(t){var e;const i=t.data;switch(i.type){case"message":const t=i.message.messagePayload;if(t.type===s.MessageType.Status){const e=t;return void("RESPONDING"===e.status?this.showTypingIndicator():"LISTENING"===e.status&&this.hideTypingIndicator())}if(t.type===s.MessageType.SessionClosed)return void(this.da&&this.da());if(i.digest){if(this.aa.indexOf(i.digest)>=0)return;this.ga&&this.ga(i.message)}else this.ma&&this.ma(i.message),this.fc(),this.showTypingIndicator();this.hideTypingIndicator(),this.Lc([i.message]);break;case"actionClearHistory":this.ic();break;case"actionLanguage":null===(e=this.Sc)||void 0===e||e.setTag(i.tag,!1)}}Ha(){if(this.He.wcfsEnableEndConversationButtonToClose&&this.Ro.getState()===s.ConnectionState.Closed)this.da();else{const t=this.wa;this.ah();const e=new us({title:t.endConversationConfirmMessage||"",description:t.endConversationDescription||"",parent:this.chatWidgetDiv,domUtil:this.ii,actions:[{label:t.noText,handler:this.ah.bind(this)},{label:t.yesText,handler:this.mh.bind(this),type:"filled"}]});e.open(),this.fh=e}}mh(){this.sendExitEvent(),this.ah()}lc(t,e){this.ah();const i=new us({title:t,icon:e,parent:this.He.searchBarMode?this.qn:this.chatWidgetDiv,domUtil:this.ii,fallbackFocus:()=>{this.Wn.focusTextArea()},showDismiss:!0,autoDismiss:!0,dismissLabel:this.wa.webViewErrorInfoDismiss});i.open(),this.fh=i}ah(){this.fh&&(this.fh.close(),this.fh=void 0)}Aa(t=!0){window.clearTimeout(this.Pc),window.clearInterval(this.jc),window.clearTimeout(this.Fc),this.He.showTypingIndicator&&(t?(this.hideTypingIndicator(),this.Zn.setAutoTimeout(!0)):(this.Zn.setAutoTimeout(!1),this.showTypingIndicator()))}Ea(t){const e=this.He.delegate;if(this.Ri.debug("onMessageReceived",t),this.ja(),this.na=!0,this.ra=!1,this.He.enableDefaultClientResponse&&(t.source===s.SkillMessageSource.Agent?this.ya=!1:this.ya||(this.ya=!0)),t){if(e&&e.beforeDisplay&&(0,a.isFunction)(e.beforeDisplay)&&Ts(t)){let i=JSON.parse(JSON.stringify(t));try{i=e.beforeDisplay(i)}catch(t){this.Ri.error(t)}if(!i)return;(0,s.isValidMessage)(i)?t=i:this.Ri.error("The generated delegate message is invalid. Displaying original message instead.")}switch(this.ga&&this.ga(t),this.gh(t),t.messagePayload.type){case s.MessageType.Status:{const e=t.messagePayload;"RESPONDING"===e.status?this.showTypingIndicator():"LISTENING"===e.status&&this.hideTypingIndicator();break}case s.MessageType.SessionClosed:this.da&&this.da();break;case s.MessageType.TextStream:{this.Lc([t]);const e=t.messagePayload;if("end"!==e.streamState)this.Ec(t),this.bh=e.text;else{if(!this.ea){const i=this.bh;if(i.length){const s=e.text.lastIndexOf(i);if(s>=0){const o=e.text.substring(s+i.length);e.text=o,this.Ec(t)}}}this.Mc(t)}this.isOpen||this.updateNotificationBadge(++this.Xn);break}default:this.Lc([t]),this.Ec(t),this.Mc(t),this.isOpen||this.updateNotificationBadge(++this.Xn)}this.Aa(Boolean(t.endOfTurn))}}vc(t){this.Mc(t),this.ja(),t&&(this.gh(t),t.messagePayload&&Ms.indexOf(t.messagePayload.type)<0&&(this.isOpen||this.updateNotificationBadge(++this.Xn),this.Lc([t])))}Qa(t){t||this.Ka(),this.ea=!t}Oa(t){const e=this.Jn.filter((e=>e.threadId===t));return this.ke=t,this.Ro.setCurrentThreadId(t),this.clearConversationHistory(!0),this.wh(e,!1)}xh(t){const e=this.He.threadId;this.Jn=t.slice(),e?this.wh(t.filter((t=>t.threadId===e))):this.wh(t)}Ya(){const t=this.He;if(t.storageType===Ie.CUSTOM){const e=t.conversationHistoryProvider;(0,a.isFunction)(null==e?void 0:e.getMessages)?e.getMessages({threadId:t.threadId}).then((t=>this.xh(t.messages))).catch((t=>this.Ri.error("Failed to fetch conversation history with provider.",t))):this.Ri.warn("Can not load conversation history. Pass conversationHistoryProvider object with getMessages function when custom storage is enabled.")}else t.enableLocalConversationHistory&&this.xh(this.getMessages())}wh(t,e=!0){return t.length?(this.ta=!1,this.Lc(t.slice(),!1).then((()=>{this.ta=!0,e||this.oc!==s.SenderType.Skill?this.uh():this.cc(this.skillMessages.slice(0,this.skillMessages.length-1)),this.He.searchBarMode||!e&&!this.oa||(this.Da&&(this.Da.setRelativeTime(new Date(t[t.length-1].date)),this.nh=this.Da.render(),this.wc(this.nh)),this.He.showPrevConvStatus&&(this.$c=this.ii.createTextDiv(["hr","flex"]),this.$c.innerText=this.wa.previousChats,this.wc(this.$c)),this.oa&&(this.oa=!1))}))):Promise.resolve()}Ta(){var t;if(this.Ro.isConnected()&&this.sa&&(this.Sc&&(this.Sc.disableComponent(!1),this.Sc.initLanguage()),!this.ia)){const e=this.He.initUserProfile;if(e){const t=this.He.sdkMetadata?Object.assign({version:Ft},this.He.sdkMetadata):{version:Ft};this.Ro.updateUser(e,{sdkMetadata:t}).then((()=>{this.ia=!0})).catch((t=>{this.Ri.error("[sendInitMessages] Failed to update user profile:",t)}))}if(this.He.initUserHiddenMessage){const t=this.He.initUserHiddenMessage;this.sendMessage(t,{hidden:!0,delegate:!1}).then((()=>{this.ia=!0})).catch(this.la)}if(null===(t=this.He.deviceToken)||void 0===t?void 0:t.length){const t=(0,a.getDeviceType)();this.Ro.sendDeviceToken(this.He.deviceToken,this.He.deviceType||t).then((()=>{this.ia=!0})).catch((t=>{this.Ri.error("[sendInitMessages] Failed to send device token:",t)}))}}}Ec(t){this.ea||this.Ro.speakTTS(t,this.wa)}Ka(){this.Ro.cancelTTS()}Is(t,e){this.getAgentDetails()&&this.Ro.sendUserTypingStatus(t,e).catch((t=>{this.Ri.error("[sendUserTypingStatusMessage] Failed to send user typing status:",t)}))}qa(t){if(t.hotkeys){const e=new os(t);e.setWidget(this.chatWidgetDiv);const i=t.hotkeys;Object.keys(i).forEach((t=>{const s=this.ha.get(t);s&&e.add(i[t],s,"launch"!==t)})),this.ec=e}}ac(t,e){const i=document.getElementsByClassName(`${this.Xi}-${t}`);for(const t of Array.from(i))for(const[i,s]of Object.entries(e))t.style[i]=s}Es(t,e){this.ha.set(t,e)}}const Ts=t=>{let e=!0;const i=t.messagePayload;if(i){i.type===s.MessageType.TextStream&&(e=!1)}return e},$s=()=>Promise.reject(Error("TextStreamProgress"));var Is=i(168);const As="none",Os="full-size";class Es extends li{constructor(t,e,i,o,r,n,a,c,h){super(),this.He=t,this.zn=e,this.yh=i,this.kh=o,this._h=r,this.zh=n,this.Ro=a,this.Un=c,this.As=h,this.Ri=new $t("ContextualWidgetComponent"),this.Mh=!1,this.Xi=t.name,this.qe={type:s.MessageType.Text,text:"",globalActions:[{type:s.ActionType.Postback,label:"Global1",postback:{}},{type:s.ActionType.Postback,label:"Global2",postback:{}},{type:s.ActionType.Postback,label:"Global3",postback:{}},{type:s.ActionType.Postback,label:"Global4",postback:{}}]},this.threadId=`${s.ContextSource.UIWidget}:${this.kh||""}-${this.yh||""}`,this.Sh=this.He.sdkMetadata?Object.assign({version:Ft},this.He.sdkMetadata):{version:Ft},this.He.icons=Object.assign(Object.assign({},this.He.icons),{logo:W});const{uploadFile:l,getSuggestions:u,Ts:p,Bn:d,Is:g,Es:m}=this.Un;this.Wn=new zi(e,this.sendMessage.bind(this),l.bind(c),Object.assign(Object.assign({},this.He),{enableAttachment:!1}),u.bind(c),p.bind(c),d.bind(c),g.bind(c),this.As,c,m.bind(c)),this.contextualElem=document.getElementById(this.yh),this.Ch=this.contextualElem.querySelector("input, textarea"),this.Th=[{type:s.ActionType.Postback,label:"Show more",postback:{showMore:!0}}],this.$h=!1,this.Ih=!1,this.Ah=!1,this.Oh=!0,this.Eh={webCore:a,onMessageActionClicked:this.De.bind(this)}}render(){const t=this.zn,e=t.createDiv(["widget-wrapper"]);this.element=t.createDiv(["contextual-widget"]),this.element.id=this.threadId;const i=t.createDiv(["container","none"]);this.appendToElement(i),e.appendChild(i),this.Lh=i;const s=this.contextualElem.parentNode,o=t.createDiv(["contextual-widget-wrapper"]);s.replaceChild(o,this.contextualElem),o.appendChild(this.contextualElem),document.body.appendChild(e),this.contextualElem.parentElement.insertBefore(e,this.contextualElem);const r=t.createDiv([]);this.Ph=t.createDiv(["widget","flex","col"]),this.Ph.setAttribute("role","region"),this.Ph.setAttribute("aria-labelledby",`${this.Xi}-title`);const n=t.createDiv(["header","flex"]),a=t.createDiv(["header-info-wrapper"]),c=this.He.i18n[this.He.locale].chatTitle,h=this.He.icons;if(!("logo"in h)||h.logo){const e=t.createImageIcon({icon:h.logo||M,iconCss:["logo"]});n.appendChild(e)}if(c){const e=t.createTextDiv(["title"]);e.id=`${this.Xi}-contextual-title`,e.innerText=c,e.title=c,a.appendChild(e)}n.appendChild(a);const l=t.createIconButton({css:["start-over-button",As],icon:G,iconCss:[],title:"Start Again"});l.onclick=()=>{this.Ch?this.Ch.value="":this.Ri.error("The input element is not found for clearing the filled-in text."),this.Oh=!0,this.Mh=!0,t.addCSSClass(l,As),this.jh()},n.appendChild(l),this.Fh=l;const u=t.createIconButton({css:["close-button"],icon:h.close||m,iconCss:[],title:"close"});u.onclick=this.Vh.bind(this),n.appendChild(u),this.Ph.appendChild(n),this.Hh=t.createDiv(["widget-content"]),this.Ph.appendChild(this.Hh),this.Wn.render(),this.Wn.disable(!1),this.Ph.appendChild(this.Wn.element),t.addCSSClass(r,"open"),r.appendChild(this.Ph),t.addCSSClass(this.element,"wrapper",this.He.theme),this.element.appendChild(r),this.qe.globalActions&&(this.Dh=this.qe.globalActions),this.Rh(!0)}sendMessage(t,e=!0){return this.mc?$s():("string"==typeof t&&(t=(0,s.buildUserTextMessage)(t)),this.Wn.focusTextArea(),t&&this.Ro.sendMessage(t,{sdkMetadata:this.Sh,threadId:this.threadId}).then((()=>{this.Ah=!1,this.zn.removeCSSClass(this.Fh,As),e&&this.Nh()})).catch((t=>this.Ri.error("[sendMessage] Failed to send message:",t))))}onMessageReceived(t){var e,i;const o=this.He,r=this.Ch,n=this.zn;if(this.Ih=!1,this.$h||(n.addCSSClass(this.Wn.element,"enabled"),this.$h=!0),t.messagePayload.llmGenerated){const e=$e.fromMessage(o,n,t,this.Eh);if(!e)return;if(this.Ah=!0,e instanceof ie){const i=t.messagePayload;switch(i.streamState){case"start":return this.Wn.disable(),e.isCoPilot=!0,e.showDone=this.Uh.bind(this),void(this.Bh?this.Bh(i):r?(e.textElement=r,e.update(i),this.mc=e):this.Ri.error("The input element is not found for filling in the generated text."));case"running":return void(this.Bh?this.Bh(i):this.mc.update(i));case"end":this.Wn.disable(!1),this.Bh?(this.Bh(i),this.Uh()):(this.mc.update(i),this.mc=null),this.Oh=!1,i.text="",this.Yn(t)}}else if(this.mc=null,this.Oh=!1,e instanceof Kt){const e=t.messagePayload;this.Bh?this.Bh(e):(r.innerHTML=(0,Is.convertBreakTagsToNewLines)(e.text),e.text="",this.Yn(t)),this.Vh()}}else if(null===(e=t.messagePayload.channelExtensions)||void 0===e?void 0:e.showInDialog){const e=n.createDiv(["wrapper","popup-content-wrapper"]),i=n.createDiv(["popup-dialog"]),s=$e.fromMessage(o,n,t,this.Eh);s.onActionClick=this.De.bind(this),i.appendChild(s.render()),e.appendChild(i);const r=s.actionsWrapper;if(r){const t=r.children;for(let i=0;ie.remove()))}e.onclick=t=>{i.contains(t.target)||e.remove()},document.body.appendChild(e),this.Oh=!1,this.Vh()}else if(this.Oh=!1,t.messagePayload.type===s.MessageType.Error){if(this.Ih=!0,null===(i=this.Hh.firstChild)||void 0===i||i.remove(),!this.Wh){const t=n.createDiv(["error-message"]);t.appendChild(n.createImageIcon({icon:Z,iconCss:["error-icon"]}));const e=n.createDiv(["error-info"]),i=n.createTextDiv(["error-text"]),s=n.createTextDiv(["reset-button"]);s.onclick=()=>{this.Ih=!1,this.Oh=!0,this.jh()},i.innerText="Something went wrong",s.innerText="Start over",e.appendChild(i),e.appendChild(s),t.appendChild(e),this.Wh=t}this.Hh.appendChild(this.Wh),this.jh()}else this.Yn(t),this.showFullSizeWidget()}addText(t){return this.qe.text=t,this}addAction(t,e,i=!1){return this.Th.push({type:s.ActionType.Postback,label:t,postback:{actionId:e,generate:i}}),this}addFieldInputParameter(t,e,i){return this.Th.forEach((s=>{const o=s.postback;o.actionId===t&&(o.fieldInputParameters||(o.fieldInputParameters={}),o.fieldInputParameters[e]=i)})),this}addAdditionalInputParameter(t,e,i){return this.Th.forEach((s=>{const o=s.postback;o.actionId===t&&(o.additionalInputParameters||(o.additionalInputParameters={}),o.additionalInputParameters[e]=i)})),this}createWidget(){const t=this.contextualElem;return this.element||this.render(),this._h&&t.addEventListener("focus",(()=>{this.showWidget()})),this}showWidget(){const t=this.zh;return Object.keys(t).filter((t=>t!==this.threadId)).forEach((e=>{t[e].hideWidget()})),this.zn.removeCSSClass(this.Lh,As),this}collapseWidget(){return this.Vh(),this}hideWidget(){return this.zn.addCSSClass(this.Lh,As),this}startWidgetInteraction(t){return this.Zh(this.Gh(t)),this}onGeneratedText(t){return this.Bh=t,this}Yn(t){var e;const i=$e.fromMessage(Object.assign(Object.assign({},this.He),{actionsLayout:"horizontal",globalActionsLayout:"horizontal"}),this.zn,t,this.Eh);i.onActionClick=this.De.bind(this),null===(e=this.Hh.firstChild)||void 0===e||e.remove(),this.Hh.appendChild(i.render())}Rh(t=!1){this.Oh&&(t?(1===this.Th.length?this.qe.actions=this.Th.slice(0):this.qe.actions=this.Th.slice(0,2).reverse(),this.qe.globalActions=[]):(this.qe.actions=this.Th.slice(1),this.Dh&&(this.qe.globalActions=this.Dh.slice(0))),this.Yn({messagePayload:this.qe}))}Vh(){const t=this.zn;if(!this.qh){const e=t.createDiv(["minimum-size","contextual-widget","wrapper"]),i=t.createIconButton({css:[],icon:B,iconCss:[],title:"open"}),o=t.createIconButton({css:[],icon:U,iconCss:[],title:"like"}),r=t.createIconButton({css:[],icon:N,iconCss:[],title:"dislike"});i.onclick=()=>{this.Oh||this.Ih?this.jh():this.showFullSizeWidget()},o.onclick=()=>{this.sendMessage((0,s.buildPostbackMessage)({postback:{rating:"positive",feedbackType:"llm"},type:s.ActionType.Postback}),!1)},r.onclick=()=>{this.sendMessage((0,s.buildPostbackMessage)({postback:{rating:"negative",feedbackType:"llm"},type:s.ActionType.Postback}),!1)},e.appendChild(i),e.appendChild(o),e.appendChild(r),this.Lh.appendChild(e),this.qh=e}t.removeCSSClass(this.element,Os),t.addCSSClass(this.element,As),this.Yh&&t.addCSSClass(this.Yh,As),this.Jh&&t.addCSSClass(this.Jh,As),t.removeCSSClass(this.qh,As),this.Ah?t.removeCSSClass(this.qh,"no-feedback"):t.addCSSClass(this.qh,"no-feedback")}jh(){const t=this.zn;this.qh&&t.addCSSClass(this.qh,As),this.Yh&&t.addCSSClass(this.Yh,As),this.Jh&&t.addCSSClass(this.Jh,As),t.removeCSSClass(this.element,Os),t.removeCSSClass(this.element,As),this.Rh(!0),this.Ah=!1}showFullSizeWidget(){const t=this.zn;this.qh&&t.addCSSClass(this.qh,As),this.Yh&&t.addCSSClass(this.Yh,As),this.Jh&&t.addCSSClass(this.Jh,As),t.addCSSClass(this.element,As),this.Rh(),t.addCSSClass(this.element,Os)}Nh(){const t=this.zn;if(!this.Yh){const e=t.createDiv(["generate-spinner"]),i=t.createTextDiv(["generate-text"]);i.innerText="Generating...",e.appendChild(t.createImageIcon({icon:R,iconCss:["generate-icon","spin"]}));const s=t.createIconButton({css:["close-button",As],icon:m,iconCss:[],title:"close"});s.onclick=this.Vh.bind(this),e.appendChild(i),e.appendChild(s),this.Lh.appendChild(e),this.Yh=e}this.qh&&t.addCSSClass(this.qh,As),this.Jh&&t.addCSSClass(this.Jh,As),t.removeCSSClass(this.element,Os),t.addCSSClass(this.element,As),t.removeCSSClass(this.Yh,As)}Uh(){const t=this.zn;if(!this.Jh){const e=t.createDiv(["generate-spinner"]),i=t.createTextDiv(["generate-text"]);i.innerText="Done",e.appendChild(t.createImageIcon({icon:D,iconCss:["generate-icon"]})),e.appendChild(i),this.Lh.appendChild(e),this.Jh=e}this.qh&&t.addCSSClass(this.qh,As),t.addCSSClass(this.Yh,As),t.removeCSSClass(this.Jh,As),t.removeCSSClass(this.element,Os),t.addCSSClass(this.element,As),setTimeout(this.Vh.bind(this),3e3)}De(t){switch(t.type){case s.ActionType.Postback:t.getPayload().then((e=>{(null==e?void 0:e.generate)?this.Zh(Object.assign(Object.assign({},(0,Is.getFieldInputValues)(e.fieldInputParameters)),e.additionalInputParameters)):(null==e?void 0:e.showMore)?this.showFullSizeWidget():this.sendMessage((0,s.buildPostbackMessage)({postback:e,text:t.label,type:s.MessageType.Postback}))}));break;case s.ActionType.SubmitForm:const e=t.messageComponent;if(!e.validateForm())break;t.getPayload().then((t=>{const i={postback:t,submittedFields:e.getSubmittedFields(),type:s.MessageType.FormSubmission};t||delete i.postback,this.sendMessage((0,s.buildUserMessage)(i))}))}}Zh(t){this.sendMessage({messagePayload:{type:s.MessageType.UpdateApplicationContextCommand,source:s.ContextSource.UIWidget,context:this.kh,properties:t,reset:this.Mh}})}Gh(t){let e;return this.Th.forEach((i=>{const s=i.postback,{fieldInputParameters:o,additionalInputParameters:r}=s;s.actionId===t&&(e=Object.assign(Object.assign({},(0,Is.getFieldInputValues)(o)),r))})),e}}},476:function(t,e,i){i.r(e),i.d(e,{AuthError:function(){return s},AuthTokenService:function(){return p},Deferred:function(){return Z},JWT:function(){return o},KeyCode:function(){return w},buildURL:function(){return A},deepFreeze:function(){return a},drawVisualizer:function(){return G},formatDate:function(){return y},generateEventDispatcher:function(){return x},getDeviceType:function(){return H},getLongPollURL:function(){return E},getWebSocketURL:function(){return O},isAndroid:function(){return j},isApple:function(){return F},isFunction:function(){return n},isMobile:function(){return V},isObject:function(){return r},isSameDay:function(){return I},parseDOM:function(){return N},pipe:function(){return h},removeDisplayNoneAndDecode:function(){return D},resetRegex:function(){return l},safeHTML:function(){return U},setReadOnly:function(){return c},startTimer:function(){return ct},stringToHTML:function(){return W},stripHTTP:function(){return P}});const s={AuthExpiredToken:"AuthExpiredToken",AuthNoToken:"AuthNoToken",AuthNoChannelId:"AuthNochannelId",AuthNoUserId:"AuthNouserId",AuthNoExp:"AuthNoexp",AuthNoIat:"AuthNoiat",AuthInvalidChannelId:"AuthInvalidchannelId",AuthInvalidUserId:"AuthInvaliduserId",AuthInvalidExp:"AuthInvalidexp",AuthInvalidIat:"AuthInvalidiat",AuthEmptyChannelIdClaim:"AuthInvalidchannelId",AuthEmptyUserIdClaim:"AuthInvaliduserId",AuthNegativeExp:"AuthNegativeexp",AuthNegativeIat:"AuthNegativeiat",AuthExpLessThanIat:"AuthExpLessThanIat"};class o{constructor(t){this.token=t;const e=this.token.split(".");this.header=JSON.parse(atob(e[0])),this.payload=JSON.parse(atob(e[1]))}getClaim(t){return this.payload[t]}}const r=t=>"object"==typeof t&&null!==t,n=t=>t instanceof Function,a=t=>{if(!r(t))return t;for(const e of Object.keys(t)){const i=t[e];r(i)&&a(i)}return Object.freeze(t)},c=t=>{const e={};return Object.keys(t).forEach((i=>{Object.defineProperty(e,i,{get:()=>t[i],enumerable:!0,configurable:!0})})),e},h=(t,...e)=>e.reduce(((t,e)=>e(t)),t),l=t=>(t.lastIndex=0,t),u=Promise;class p{static getInstance(){return this.v||(this.v=new p),this.v}get(){return this.Kh&&f(this.Kh)?u.resolve(this.Kh):new u(((t,e)=>{u.resolve(this.Xh()).then((i=>{this.Kh=new o(i);try{if(function(t){t||v(s.AuthNoToken);const e="iat",i=t.getClaim(e);b(e,g,i);const o=t.getClaim(m);b(m,g,o),o<=i&&v(s.AuthExpLessThanIat);const r="channelId",n=t.getClaim(r);b(r,d,n);const a="userId",c=t.getClaim(a);b(a,d,c)}(this.Kh),f(this.Kh))return void t(this.Kh);v(s.AuthExpiredToken)}catch(t){e(t)}}))}))}reset(){this.Kh=void 0}setFetch(t){if(!n(t))throw new Error("'generateAuthToken' is not a function. Create a function that returns a Promise that resolves to a new JWT when called.");this.Xh=t,this.reset()}}const d="string",g="number",m="exp";function f(t){const e=Math.floor((Date.now()+2e4)/1e3);return t.getClaim(m)>e}function b(t,e,i){null==i&&v(`AuthNo${t}`),typeof i!==e&&v(`AuthInvalid${t}`),"number"==typeof i?i<=0&&v(`AuthNegative${t}`):i.length||v(`AuthEmpty${t}`)}function v(t){throw Error(t)}const w={Return:"Enter",Esc:"Escape",Space:"Space",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Tab:"Tab",PageDown:"PageDown",PageUp:"PageUp",Home:"Home",End:"End",Backspace:"Backspace"};function x(){let t={};return{bind:(e,i)=>{e&&i&&n(i)&&(Object.prototype.hasOwnProperty.call(t,e)?t[e].push(i):t[e]=[i])},trigger:(e,...i)=>{if(Object.prototype.hasOwnProperty.call(t,e)){const s=null!=i?i:[];t[e].forEach((t=>{try{t.call(null,...s)}catch(t){console.error(`${e} listener error`,t)}}))}},unbind:(e,i)=>{e?i||!Object.prototype.hasOwnProperty.call(t,e)?t[e]&&(t[e]=t[e].filter((t=>t!==i))):t[e].splice(0,t[e].length):t={}}}}const y=(t,{pattern:e,locale:i})=>{const s=new Date(t);if("string"==typeof e)try{return k(s,e)}catch(t){}else if(r(e))return new Intl.DateTimeFormat(i,e).format(s);return _(s,i)},k=(t,e)=>{const i=t.getDate(),s=t.getDay(),o=z[s],r=t.getMonth()+1,n=M[r-1],a=`${t.getFullYear()}`,c=t.getHours(),h=t.getMinutes(),l=t.getSeconds(),u=t.getMilliseconds(),p=c>=S?"PM":"AM",d=C(t),g=c%S||S,m={DD:$(i),Do:`${i}${T(i)}`,D:`${i}`,dddd:o,ddd:o.substring(0,3),d:`${s}`,MMMM:n,MMM:n.substring(0,3),MM:$(r),M:`${r}`,YYYY:a,YY:a.slice(-2),HH:$(c),H:`${c}`,hh:$(g),h:`${g}`,mm:$(h),m:`${h}`,ss:$(l),s:`${l}`,SSS:`${u}`,SS:""+u%100,S:""+u%1e3,A:p,a:p.toLowerCase(),ZZ:d.replace(":",""),Z:d};return e.replace(/DD|Do|D|dddd|ddd|d|MMMM|MMM|MM|M|YYYY|YY|HH|H|hh|h|mm|m|ss|s|SSS|SS|S|A|a|ZZ|Z/g,(t=>m[t]))},_=(t,e)=>`${t.toLocaleDateString(e,{weekday:"short",month:"short",day:"numeric"}).replace(/,/g,"")}, ${t.toLocaleTimeString(e,{hour:"numeric",minute:"numeric",hour12:!0})}`,z=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],M=["January","February","March","April","May","June","July","August","September","October","November","December"],S=12,C=t=>{const e=t.getTimezoneOffset(),i=Math.abs(e);return`${i===e?"+":"-"}${$(Math.floor(i/60))}:${$(i%60)}`},T=t=>{let e="th";if(t>=11&&t<=13)return e;switch(t%10){case 1:e="st";break;case 2:e="nd";break;case 3:e="rd"}return e},$=t=>`${t}`.padStart(2,"0"),I=(t,e)=>{const i=new Date(t),s=new Date(e);return i.getDate()===s.getDate()&&i.getMonth()===s.getMonth()&&i.getFullYear()===s.getFullYear()},A=(t,e,i,s)=>L(`${t}${e}${s}`,i),O=(t,e,i=!0,s="websdk")=>A(`ws${i?"s":""}://`,t,e,`/chat/v1/chats/sockets/${s}`),E=(t,e,i=!0)=>A(`http${i?"s":""}://`,t,e,"/chat/v1/chats/message"),L=(t,e)=>{const i=Object.keys(e).map((t=>`${t}=${e[t]}`)).join("&");return i.length?`${t}?${i}`:t},P=t=>t.replace(/^https?:\/\//i,""),j=()=>/Android/i.test(navigator.userAgent),F=()=>/iPhone|iPad/i.test(navigator.userAgent)&&!window.MSStream,V=()=>j()||F(),H=()=>j()?"android":F()?"ios":"desktop",D=t=>{const e=document.createElement("div");e.style.display="none",document.body.appendChild(e),e.innerHTML=t,R(e);const i=e.innerText;return e.remove(),i},R=t=>{for(let e=t.childElementCount-1;e>=0;e--){const i=t.children[e],s=window.getComputedStyle(i);"none"===s.display||"hidden"===s.visibility?i.remove():R(i)}},N=t=>{const e=(new DOMParser).parseFromString(t.replace(/\r\n|\n|\r/g,"
"),"text/html");return e&&e.body},U=t=>{const e=N(t);e.querySelectorAll("script, iframe, link, object").forEach((t=>{t.remove()}));return e.querySelectorAll("*").forEach((t=>{for(const e of t.attributes)B(e)&&t.removeAttribute(e.name)})),e.innerHTML},B=t=>{const e=t.name.toLowerCase(),i=t.value.toLowerCase();return e.startsWith("on")||"style"===e||i.startsWith("javascript")},W=t=>{const e=document.createElement("div");return e.innerHTML=t.trim(),e.firstElementChild};class Z{constructor(){this.promise=new Promise(((t,e)=>{this.resolve=t,this.reject=e})),Object.freeze(this)}}const G=(t,e,i="#000")=>{const s=e.height,o=e.width,r=Math.floor(s/2);let n=q(t,31);n=Y(n,s/255);const a=e.getContext("2d");if(a){a.fillStyle=i,a.clearRect(0,0,o,s),a.save();let t=0;n.forEach((e=>{const i=Math.ceil(e/2)+1;a.fillRect(t,r-i,2,2*i),t+=8})),a.save()}},q=(t,e)=>{const i=Math.ceil(e/2),s=t.length/i,o=[],r=[];for(let e=0;et*t)).reduce(((t,e)=>t+e),0)/s;o.push(i),r.unshift(i)}return o.splice(0,1),r.concat(o)},Y=(t,e)=>t.map((t=>t*e)),J=window.setInterval,K=window.setTimeout,X=36e5,Q=864e5;let tt;const et=()=>{clearTimeout(tt),clearInterval(tt)},it=(t,e,i,s,o,r)=>{var n;let a=1;et(),t((null===(n=e[o])||void 0===n?void 0:n.replace("{0}",`${a}`))||""),tt=J((()=>{var s;a++,i&&r&&a>=i?r(t,e):t((null===(s=e[o])||void 0===s?void 0:s.replace("{0}",`${a}`))||"")}),s)},st=(t,e)=>{it(t,e,60,6e4,"relTimeMin",ot)},ot=(t,e)=>{it(t,e,24,X,"relTimeHr",rt)},rt=(t,e)=>{it(t,e,30,Q,"relTimeDay",nt)},nt=(t,e)=>{it(t,e,12,2592e6,"relTimeMon",at)},at=(t,e)=>{it(t,e,0,31536e6,"relTimeYr")},ct=(t,e)=>{et(),t(e.relTimeNow||""),tt=K((()=>{((t,e)=>{et(),t(e.relTimeMoment||""),tt=K((()=>{st(t,e)}),5e4)})(t,e)}),1e4)}},8:function(t,e){Object.defineProperty(e,"Qh",{value:!0}),e.Constants=e.SEC_MULTIPLIER=e.ATTACHMENT_MAX_HEIGHT=e.MESSAGE_BLOCK_THRESOLD=e.ATTACHMENT_MAX_SIZE=e.BYTE_MULTIPLIER=e.SDK_VERSION=void 0;var i=function(){function t(){}return t.GEOLOCATION_REQUEST_DENIED=1,t.CHAT_SCROLL_DELAY=300,t.WEBSOCKET_READY_STATE=["CONNECTING","OPEN","CLOSING","CLOSED"],t.WEBSOCKET_CLOSE_EVENT={CODE:{ABNORMAL_CLOSURE:1006}},t.ATTACHMENT_HEADER={AUTHORIZATION:"Authorization",FILE_AUTH_TYPE:"x-oda-meta-file-authType",FILE_IS_PROTECTED:"x-oda-meta-file-isProtected",FILE_SIZE:"x-oda-meta-file-size"},t.MAX_SUGGESTIONS_COUNT=5,t.MIN_SUGGESTIONS_COUNT=1,t.SUGGESTIONS_COUNT_THRESHOLD=30,t.TIME={MIN_FIFTY:3e6},t}();e.Constants=i;e.SDK_VERSION="{version}",e.BYTE_MULTIPLIER=1024,e.ATTACHMENT_MAX_SIZE=25*e.BYTE_MULTIPLIER*e.BYTE_MULTIPLIER,e.MESSAGE_BLOCK_THRESOLD=1e4,e.ATTACHMENT_MAX_HEIGHT=211,e.SEC_MULTIPLIER=1e3},720:function(t,e,i){Object.defineProperty(e,"Qh",{value:!0}),e.defaultSettings=void 0;var s=i(396),o=i(75),r="Please try sharing it again, or else type it in.";e.defaultSettings={badgePosition:{right:"-5px",top:"-5px"},clientAuthEnabled:!1,conversationBeginPosition:"bottom",disablePastActions:"all",displayActionsAsPills:!1,searchBarMode:!1,sidepanel:!1,embedded:!1,embeddedVideo:!0,enableAgentSneakPreview:!1,enableAttachment:!0,enableAttachmentSecurity:!1,enableHeaderActionCollapse:!0,enableAutocomplete:!1,enableAutocompleteClientCache:!1,enableBotAudioResponse:!1,enableDefaultClientResponse:!1,enableClearMessage:!1,enableEndConversation:!0,enableHeadless:!1,enableLocalConversationHistory:!1,enableLongPolling:!1,enableResizableWidget:!1,enableSendTypingStatus:!1,enableSecureConnection:!0,enableSpeech:!1,enableSpeechAutoSend:!0,enableTabsSync:!0,enableTimestamp:!0,enableVoiceOnlyMode:!1,focusOnNewMessage:"input",height:"620px",i18n:{en:{agent:"Agent",agentMessage:"{0} says",attachment_audio:"Audio attachment",attachment_file:"File attachment",attachment_image:"Image attachment",attachment_video:"Video attachment",attachmentAudioFallback:"Your browser does not support embedded audio. However you can {0}download it{/0}.",attachmentVideoFallback:"Your browser does not support embedded video. However you can {0}download it{/0}.",audioResponseOff:"Turn audio response on",audioResponseOn:"Turn audio response off",avatarAgent:"Agent icon",avatarBot:"Bot icon",avatarUser:"User icon",card:"Card {0}",cardImagePlaceholder:"Card image",cardNavNext:"Next card",cardNavPrevious:"Previous card",chatTitle:"Chat",clear:"Clear conversation",close:"Close widget",closing:"Closing",connected:"Connected",connecting:"Connecting",connectionFailureMessage:"Sorry, the assistant is unavailable right now. If the issue persists, contact your help desk.",connectionRetryLabel:"Try Again",copyFailureMessage:"Sorry, copying is not available on this device.",copySuccessMessage:"Successfully copied the response text to the clipboard.",defaultGreetingMessage:"Hey, Nice to meet you! Allow me a moment to get back to you.",defaultWaitMessage:"I'm still working on your request. Thank you for your patience!",defaultSorryMessage:"I'm sorry. I can't get you the right content. Please try again.",disconnected:"Disconnected",download:"Download",editFieldErrorMessage:"Field input is invalid",editFormErrorMessage:"Some of the fields need your attention",endConversation:"End Conversation",endConversationConfirmMessage:"Are you sure you want to end the conversation?",endConversationDescription:"This will also clear your conversation history.",errorSpeechInvalidUrl:"ODA URL for connection is not set. Please pass 'URI' parameter during SDK initialization.",errorSpeechMultipleConnection:"Another voice recognition is ongoing. Can't start a new one.",errorSpeechTooMuchTimeout:"The voice message is too long to recognize and generate text.",errorSpeechUnavailable:"To allow voice messaging, update your browser settings to enable access to your microphone.",errorSpeechUnsupportedLocale:"The locale set for voice recognition is not supported. Please use a valid locale in 'speechLocale' setting.",inputPlaceholder:"Type a message",imageViewerClose:"Close image viewer",imageViewerOpen:"Open image viewer",itemIterator:"Item {0}",language_ar:"Arabic",language_de:"German",language_detect:"Detect Language",language_en:"English",language_es:"Spanish",language_fr:"French",language_hi:"Hindi",language_it:"Italian",language_nl:"Dutch",language_pt:"Portuguese",languageSelectDropdown:"Select chat language",linkField:"Click on the highlighted text to open Link for {0}",noResultText:"No more results",noSpeechTimeout:"The voice could not be detected to perform recognition.",noText:"No",openMap:"Open Map",previousChats:"End of previous conversation",ratingStar:"Rate {0} star",recognitionTextPlaceholder:"Speak your message",relTimeDay:"{0}d ago",relTimeHr:"{0}hr ago",relTimeMin:"{0}min ago",relTimeMoment:"A few seconds ago",relTimeMon:"{0}mth ago",relTimeNow:"Now",relTimeYr:"{0}yr ago",requestLocation:"Requesting location",requestLocationDeniedPermission:"To allow sharing your location, update your browser settings to enable access to your location. You can also type in the location instead.",requestLocationDeniedTimeout:"It is taking too long to get your location. ".concat(r),requestLocationDeniedUnavailable:"Your current location is unavailable. ".concat(r),retryMessage:"Try again",send:"Send message",shareAudio:"Share Audio",shareFailureMessage:"Sorry, sharing is not available on this device.",shareFile:"Share File",shareLocation:"Share Location",shareVisual:"Share Image/Video",skillMessage:"Skill says",showOptions:"Show Options",speak:"Speak a message",typingIndicator:"Waiting for response",upload:"Share popup",uploadFailed:"Upload Failed.",uploadFileNetworkFailure:"Upload not completed due to network failure.",uploadFileSizeLimitExceeded:"File size should not be more than {0}MB.",uploadFileSizeZeroByte:"Files of size zero bytes can't be uploaded.",uploadUnauthorized:"Upload request is unauthorized.",uploadUnsupportedFileType:"Unsupported file type.",userMessage:"I say",utteranceGeneric:"Message from skill.",webViewAccessibilityTitle:"In-widget WebView to display links",webViewClose:"Done",webViewErrorInfoDismiss:"Dismiss",webViewErrorInfoText:"Don't see the page? {0}Click here{/0} to open it in a browser.",yesText:"Yes"},ar:{language_ar:"اَلْعَرَبِيَّةُ"},de:{language_de:"Deutsch"},es:{language_es:"Español"},fr:{language_fr:"Français"},hi:{language_hi:"हिन्दी"},it:{language_it:"Italiano"},nl:{language_nl:"Nederlands"},pt:{language_pt:"Português"}},initBotAudioMuted:!0,initMessageOptions:{sendAt:"expand"},disableInlineCSS:!1,isDebugMode:!1,locale:"en",messageCacheSizeLimit:2e3,name:"oda-chat",openChatOnLoad:!1,openLinksInNewWindow:!1,readMark:"✓",reconnectInterval:5,reconnectMaxAttempts:5,shareMenuItems:[o.ShareCategory.AUDIO,o.ShareCategory.FILE,o.ShareCategory.LOCATION,o.ShareCategory.VISUAL],showConnectionStatus:!1,showPrevConvStatus:!0,showTypingIndicator:!0,speechLocale:s.RecognitionLocale.EN_US,theme:o.WidgetTheme.DEFAULT,timestampMode:"default",defaultGreetingTimeout:5,defaultWaitMessageInterval:5,typingIndicatorTimeout:30,typingStatusInterval:3,typingDelay:0,upgradeToWebSocketInterval:300,webViewConfig:{},width:"375px",actionsLayout:"vertical",globalActionsLayout:"vertical",cardActionsLayout:"vertical",formActionsLayout:"vertical",wcfsEnableEndConversationButtonToClose:!1}},549:function(t,e,i){var s=this&&this.tl||function(t,e,i,s){return new(i||(i=Promise))((function(o,r){function n(t){try{c(s.next(t))}catch(t){r(t)}}function a(t){try{c(s.throw(t))}catch(t){r(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(n,a)}c((s=s.apply(t,e||[])).next())}))},o=this&&this.el||function(t,e){var i,s,o,r,n={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return r={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function a(a){return function(c){return function(a){if(i)throw new TypeError("Generator is already executing.");for(;r&&(r=0,a[0]&&(n=0)),n;)try{if(i=1,s&&(o=2&a[0]?s.return:a[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,a[1])).done)return o;switch(s=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return n.label++,{value:a[1],done:!1};case 5:n.label++,s=a[1],a=[0];continue;case 7:a=n.ops.pop(),n.trys.pop();continue;default:if(!(o=n.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){n=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]').concat(i,"")}},f=function(t,e){var i,s;try{var o=t.toLowerCase().startsWith("https")?new URL(t):new URL("https://".concat(t));i=o.hostname.toLowerCase()}catch(t){return s}return z.some((function(o){var r=i.includes(o.name);if(r){var n=C();"videohub"!==o.name&&b(o.url,t,e,n),s=o.getEmbed(o.getId(t),n,e)}return r})),s};e.getEmbeddedVideo=f;var b=function(t,e,i,n){return s(void 0,void 0,void 0,(function(){var s,a,c,h,l;return o(this,(function(o){switch(o.label){case 0:s="".concat(t,"?url=").concat(e),o.label=1;case 1:return o.trys.push([1,4,,5]),[4,fetch(s)];case 2:return(a=o.sent()).ok?[4,a.json()]:[2];case 3:return(c=o.sent())&&c.html&&(h=c.html.replace("')}},609:function(t,e){Object.defineProperty(e,"Qh",{value:!0}),e.iconStartOver=e.iconInlineError=e.iconInlineLogo=e.iconInlineLaunch=e.iconThumbsUp=e.iconThumbsDown=e.iconSuccess=e.iconGenerating=e.iconCheck=e.iconZoom=e.iconWarn=e.iconVideo=e.iconTTSUnmute=e.iconTTSMute=e.iconShareMedia=e.iconShareLocation=e.iconShareFile=e.iconShareAudio=e.iconSend=e.iconSearch=e.iconRating=e.iconMic=e.iconLogo=e.iconLaunchButton=e.iconLanguage=e.iconKeyboard=e.iconImage=e.iconFile=e.iconExternalLink=e.iconExpandArrow=e.iconExpand=e.iconError=e.iconDownload=e.iconCollapse=e.iconClose=e.iconClearHistory=e.iconChevronPrevious=e.iconChevronNext=e.iconChevronDown=e.iconCaretDown=e.iconAudio=e.iconAttach=void 0;var i=R('');e.iconAttach=i;var s=R('');e.iconAudio=s;var o=R('');e.iconCaretDown=o;var r=R('');e.iconChevronDown=r;var n=R('');e.iconChevronNext=n;var a=R('');e.iconChevronPrevious=a;var c=R('');e.iconClearHistory=c;var h=R('');e.iconClose=h;var l=R('');e.iconCollapse=l;var u=R('');e.iconDownload=u;var p=R('');e.iconError=p;e.iconExpand='';var d=R('');e.iconExternalLink=d;var g=R('');e.iconFile=g;var m=R('');e.iconImage=m;var f=R('');e.iconKeyboard=f;var b=R('');e.iconLanguage=b;e.iconLaunchButton='';var v=R('');e.iconLogo=v;var w=R('');e.iconMic=w;var x=R('');e.iconRating=x;var y=R('');e.iconSearch=y;var k=R('');e.iconSend=k;var _=R('');e.iconShareAudio=_;var z=R('');e.iconShareFile=z;var M=R('');e.iconShareLocation=M;var S=R('');e.iconShareMedia=S;var C=R('');e.iconSuccess=C;var T=R('');e.iconTTSMute=T;var $=R('');e.iconTTSUnmute=$;var I=R('');e.iconVideo=I;var A=R('');e.iconWarn=A;var O=R('');e.iconZoom=O;var E=R('');e.iconCheck=E;var L=R('');e.iconGenerating=L;var P=R('',"20");e.iconThumbsDown=P;var j=R('',"20");e.iconThumbsUp=j;var F=R('',"20");e.iconInlineLaunch=F;var V=R('',"16");e.iconInlineLogo=V;var H=R('',"16");e.iconInlineError=H;var D=R('');function R(t,e){return'').concat(t,"")}e.iconStartOver=D},168:function(t,e,i){var s=this&&this.il||function(){return s=Object.assign||function(t){for(var e,i=1,s=arguments.length;i=0){e=!0;break}}return e}))},e.getFooterFormComponent=function(t,e,i,s){var r=a.MessageComponentFactory.fromMessage(i,t,{messagePayload:{type:o.MessageType.Form,forms:[e]}},s);return r.onActionClick=s.onMessageActionClicked,r},e.getPopupContent=function(t,e,i,s){var r=t.createDiv(["wrapper","popup-content-wrapper","none"]),n=t.createDiv(["popup-dialog"]),c=a.MessageComponentFactory.fromMessage(i,t,{messagePayload:e});return c.onActionClick=function(e){(e.type!==o.ActionType.SubmitForm||c.validateForm())&&(t.addCSSClass(r,"none"),s(e))},n.appendChild(c.render()),r.appendChild(n),r.onclick=function(e){n.contains(e.target)||t.addCSSClass(r,"none")},r},e.isFeedbackComponent=function(t){return void 0!==t.ratingId};e.isInteger=function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t};e.isSVG=function(t){var e=t.match(/0};var h=//g;e.convertBreakTagsToNewLines=function(t){return t.replace(h,"\n")},e.matchStringIgnoreCase=function(t,e){return t.toLowerCase()===e.toLowerCase()};var l=[{match:/<([a-z])/gi,replace:function(t,e){return"<".concat(e)}},{match:/<\/([a-z])/gi,replace:function(t,e){return"</".concat(e)}}];e.sanitizeText=function(t){return l.forEach((function(e){t=t.replace((0,n.resetRegex)(e.match),e.replace)})),t},e.setEmbeddedLinksHandler=function t(e,i){for(var s=0;s=e){i.unshift("[".concat(t.appName,".").concat(t.appVersion,".").concat(this.Ze,"]"));var s=void 0;switch(e){case t.LOG_LEVEL.ERROR:s=console.error;break;case t.LOG_LEVEL.WARN:s=console.warn;break;case t.LOG_LEVEL.INFO:s=console.info;break;case t.LOG_LEVEL.DEBUG:s=console.debug}s.apply(console,i)}},t.LOG_LEVEL=i,t.logLevel=t.LOG_LEVEL.NONE,t}();e.Logger=s},305:function(t,e){Object.defineProperty(e,"Qh",{value:!0}),e.getMessageDigest=e.isBotMessage=void 0,e.isBotMessage=function(t){return!!t.source},e.getMessageDigest=function(t){if(t.msgId)return t.msgId;var e=JSON.stringify(t.messagePayload);return"".concat(i(e))};var i=function(t){for(var e=0,i=0,s=Math.pow(9,9);e>>9}},75:function(t,e){Object.defineProperty(e,"Qh",{value:!0}),e.WidgetTheme=e.StorageType=e.ShareCategory=void 0;e.StorageType={SESSION:"sessionStorage",LOCAL:"localStorage",CUSTOM:"custom"};e.WidgetTheme={CLASSIC:"classic",DEFAULT:"default",REDWOOD_DARK:"redwood-dark"};e.ShareCategory={AUDIO:"audio",FILE:"file",LOCATION:"location",VISUAL:"visual"}},777:function(t,e,i){Object.defineProperty(e,"Qh",{value:!0}),e.ActionComponent=void 0;var s=i(549),o=i(396),r=function(){function t(t,e){var i,s;this.util=t,this.Te=!1,this.$e=e.type,this.Ie=e.label,this.Ae=e.imageUrl,this.Oe=e.style,this.Ee=e.tooltip,this.Le=e.displayType,this.Pe=null===(i=e.channelExtensions)||void 0===i?void 0:i.activeImageUrl,this.je=null===(s=e.channelExtensions)||void 0===s?void 0:s.c2kText,this.$e!==o.ActionType.SubmitForm||this.Oe||(this.Oe=o.ActionStyle.Primary)}return t.prototype.render=function(){var t=this,e=this.util,i=e.createButton(["action-postback",this.Oe===o.ActionStyle.Primary?"primary":this.Oe===o.ActionStyle.Danger?"danger":""]);if(this.Le===o.ActionDisplayType.Icon&&e.addCSSClass(i,o.ActionDisplayType.Icon),i.onclick=this.handleOnClick.bind(this),this.Ae&&i.appendChild(e.createImage(this.Ae,["action-image"],this.Ie||"")),this.Ie){var r=(0,s.linkify)(this.Ie,e.cssPrefix),n=e.createTextDiv();if(this.Le===o.ActionDisplayType.Link){var a=e.createAnchor("",r);a.onclick=function(t){return t.preventDefault()},n.appendChild(a),e.addCSSClass(i,"display-link")}else this.je?(n.innerHTML=String.fromCharCode(parseInt(this.Ie)+10111),e.addCSSClass(i,"c2k-action"),i.addEventListener("mouseover",(function(){n.innerHTML=String.fromCharCode(parseInt(t.Ie)+10121);for(var i=0,s=Array.from(document.getElementsByClassName(t.je));i=0&&!this.ti.test(i.url)){var u=null==o?void 0:o.authToken;(null==u?void 0:u.length)&&(i.url="".concat(i.url,"?token=").concat(u))}switch(i.type){case l.AttachmentType.Image:return new a.ImageAttachmentComponent(t,e,i,s,h);case l.AttachmentType.Video:return new c.VideoAttachmentComponent(t,e,i,s,h);case l.AttachmentType.Audio:return new r.AudioAttachmentComponent(t,e,i,s,h);case l.AttachmentType.File:return new n.FileAttachmentComponent(t,e,i,s,h);default:throw Error("Payload contains wrong attachment type")}},e.prototype.getContent=function(){return t.prototype.getContent.call(this,this.ei.render())},e.ti=/token=[a-z\.\d]+/i,e}(h.MessageComponent);e.AttachmentMessageComponent=u},61:function(t,e,i){Object.defineProperty(e,"Qh",{value:!0}),e.AttachmentComponent=void 0;var s=i(609),o=i(398),r=i(396),n=i(8),a=function(){function t(t,e,i,s,o){this.settings=t,this.util=e,this.side=s,this.Je=o,this.P=i.url,this.$e=i.type;var r=i.url.split("/");this.Ke=i.title||decodeURI(r[r.length-1]),this.Xe=i.filename}return t.capitalize=function(t){return t.charAt(0).toUpperCase()+t.slice(1)},t.prototype.Qe=function(t,e){var i=this.util,o=this.settings,r=i.createElement("a",[],!0),n=i.createIconButton({css:["attachment-control-icon","attachment-button","flex"],icon:o.icons.download||s.iconDownload,iconCss:["attachment-download-icon"],title:o.i18n[o.locale].download});return r.setAttribute("href",t),r.setAttribute("download",e||""),r.setAttribute("target","_blank"),r.appendChild(n),r},t.prototype.createAttachment=function(t,e){var i=this,a=this.util,c=this.settings,h=a.createDiv(["attachment"]),l=a.createDiv(["attachment-placeholder","flex"]),u=a.createDiv(["attachment-icon"]),p=a.createImageIcon({icon:t});u.appendChild(p);var d=this.Ke,g=a.createDiv(["attachment-footer","flex",this.Je&&"with-actions"]),m=a.createLabel(["attachment-title"]),f=a.createDiv(["attachment-controls","flex"]);if(m.innerText=d,m.setAttribute("title",d),g.appendChild(m),this.$e===r.AttachmentType.Image){var b=a.createIconButton({css:["attachment-control-icon","attachment-button","flex"],icon:c.icons.expandImage||s.iconZoom,iconCss:["attachment-expand-icon"],title:c.i18n[c.locale].imageViewerOpen});b.onclick=function(){i.createImagePreview(i.P,d)},f.appendChild(b)}if(this.side===o.MESSAGE_SIDE.LEFT&&f.appendChild(this.Qe(this.P,this.Xe)),e)switch(l.appendChild(e),e.onerror=function(){e.remove(),l.appendChild(u)},this.$e){case r.AttachmentType.Image:e.onload=function(){e.clientHeight>n.ATTACHMENT_MAX_HEIGHT&&(l.style.alignItems="flex-start"),g.appendChild(f)},e.onclick=function(){i.createImagePreview(i.P,i.Ke)};break;case r.AttachmentType.Audio:case r.AttachmentType.Video:e.onloadeddata=function(){g.appendChild(f)}}else l.appendChild(u),g.appendChild(f);return h.appendChild(l),null==h||h.appendChild(g),h},t.prototype.createImagePreview=function(t,e){var i=this.util,o="image-preview",r=this.settings,n=i.createDiv(["".concat(o,"-wrapper")]),a=i.createImage(t,[o]),c=i.createLabel(["".concat(o,"-title")]);c.innerText=e;var h=document.querySelector(".".concat(this.settings.name,"-wrapper")),l=r.icons.close||s.iconClose,u=i.createIconButton({css:["".concat(o,"-close")],icon:l,iconCss:["".concat(o,"-close-icon")],title:r.i18n[r.locale].imageViewerClose});u.onclick=function(){n.remove()},u.onkeydown=function(t){"Tab"===t.code&&(n.focus(),t.preventDefault())};var p=i.createDiv(["".concat(o,"-header")]);p.appendChild(c),p.appendChild(u),n.appendChild(p),n.appendChild(a),n.setAttribute("tabindex","-1"),n.onkeydown=function(t){"Escape"===t.code&&n.remove()},h.appendChild(n),n.focus()},t}();e.AttachmentComponent=a},72:function(t,e,i){var s,o=this&&this.sl||(s=function(t,e){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},s(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}s(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"Qh",{value:!0}),e.AudioAttachmentComponent=void 0;var r=i(609),n=i(168),a=i(398),c=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.render=function(){var t=this.util,e=this.settings,i=e.icons.fileAudio||r.iconAudio,s=t.createMedia("video",this.P,["attachment-audio"]);s.controls=!0,s.preload="metadata",a.MESSAGE_SIDE.RIGHT===this.side&&s.setAttribute("controlsList","nodownload");var o=''),c=e.i18n[e.locale].attachmentAudioFallback.replace("{0}",o).replace("{/0}","");return s.innerHTML=c,e.linkHandler?(0,n.setEmbeddedLinksHandler)(s,e.linkHandler):e.openLinksInNewWindow&&(0,n.setLinksOpenInNewWindow)(s),this.createAttachment(i,s)},e}(i(61).AttachmentComponent);e.AudioAttachmentComponent=c},212:function(t,e,i){var s,o=this&&this.sl||(s=function(t,e){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},s(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}s(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"Qh",{value:!0}),e.FileAttachmentComponent=void 0;var r=i(609),n=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.render=function(){var t=this.settings.icons.fileGeneric||r.iconFile;return this.createAttachment(t)},e}(i(61).AttachmentComponent);e.FileAttachmentComponent=n},717:function(t,e,i){var s,o=this&&this.sl||(s=function(t,e){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},s(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}s(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"Qh",{value:!0}),e.ImageAttachmentComponent=void 0;var r=i(61),n=i(609),a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.render=function(){var t=this.util,e=this.settings.icons.fileImage||n.iconImage,i=t.createImage(this.P,["attachment-image"],this.Ke);return this.createAttachment(e,i)},e}(r.AttachmentComponent);e.ImageAttachmentComponent=a},495:function(t,e,i){var s,o=this&&this.sl||(s=function(t,e){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},s(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}s(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"Qh",{value:!0}),e.VideoAttachmentComponent=void 0;var r=i(549),n=i(609),a=i(168),c=i(398),h=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.render=function(){var t=this.util,e=this.settings,i=this.P,s=e.icons.fileVideo||n.iconVideo,o=(0,r.getEmbeddedVideo)(i,t.cssPrefix);if(o){var h=t.createElement("span");return h.innerHTML=o,h}var l=t.createMedia("video",this.P,["attachment-video"]);l.controls=!0,l.preload="metadata",c.MESSAGE_SIDE.RIGHT===this.side&&l.setAttribute("controlsList","nodownload");var u=''),p=e.i18n[e.locale].attachmentVideoFallback.replace("{0}",u).replace("{/0}","");return l.innerHTML=p,this.settings.linkHandler?(0,a.setEmbeddedLinksHandler)(l,e.linkHandler):this.settings.openLinksInNewWindow&&(0,a.setLinksOpenInNewWindow)(l),this.createAttachment(s,l)},e}(i(61).AttachmentComponent);e.VideoAttachmentComponent=h},548:function(t,e,i){var s,o=this&&this.sl||(s=function(t,e){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},s(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}s(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"Qh",{value:!0}),e.C2SQLBaseMessageComponent=void 0;var r=i(398),n=i(396),a=i(752),c=function(t){function e(e,i,s,o,r,n){var a=t.call(this,e,i,s,o,r,n)||this;return a.si=[],a.cssPrefix=e.name,a.te=n,a.qe=s,a}return o(e,t),e.prototype.disableActions=function(){t.prototype.disableActions.call(this),this.si.forEach((function(t){t.disable()}))},e.prototype.disablePostbacks=function(){t.prototype.disablePostbacks.call(this),(0,a.getPostActions)(this.si).forEach((function(t){t.disable()}))},e.prototype.enableActions=function(){t.prototype.enableActions.call(this),this.si.forEach((function(t){t.enable()}))},e.prototype.enablePostbacks=function(){t.prototype.enablePostbacks.call(this),(0,a.getPostActions)(this.si).forEach((function(t){t.enable()}))},e.prototype.render=function(){return t.prototype.render.call(this)},e.prototype.getHeader=function(){var e=this.util,i=t.prototype.getHeader.call(this);return e.addCSSClass(i,"message-header-yellow"),i},e.prototype.getContent=function(t){var e=this.util,i="message-bubble",s=this.qe.type,o=e.createDiv([i]);s===n.MessageType.Table||s===n.MessageType.TableForm?e.addCSSClass(o,"".concat(i,"-tabular-message")):e.addCSSClass(o,"".concat(i,"-form-message"),s===n.MessageType.EditForm?"edit-form-message":""),t&&o.appendChild(t);var r=this.getPageStatus();return r&&o.appendChild(r),o},e.prototype.getPageStatus=function(){var t,e=this.util,i=this.qe.paginationInfo;return i&&i.totalCount>i.rangeSize&&((t=e.createTextDiv(["results-page-status"])).innerText=i.status),t},e}(r.MessageComponent);e.C2SQLBaseMessageComponent=c},462:function(t,e,i){var s,o=this&&this.sl||(s=function(t,e){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},s(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}s(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}),r=this&&this.il||function(){return r=Object.assign||function(t){for(var e,i=1,s=arguments.length;i2&&(i.formColumns=2),i.fields.filter((function(t){return t})).forEach((function(t){h.appendChild(e.Bi(t,r,!1,i.formColumns))}))):i.formRows.forEach((function(t){var i=(0,d.getFormRow)(t,e.si,o,s,e.shareText,e.handleOnActionClick.bind(e),e.options),n=t.columns.length;t.columns.forEach((function(t){var s=(0,d.getFormRowColumn)(t,o);t.fields.filter((function(t){return t})).forEach((function(i){s.appendChild(e.Bi(i,r,!0)),(0,d.setMaxColumnWidth)(t.width,i.displayType,s,n)})),i.appendChild(s)})),h.appendChild(i)})),this.actions.concat(this.si).some((function(t){return t.getActionType()===n.ActionType.SubmitForm}))||this.Ri.error("Payload does not contain submit-form action"),this.Wi(h,i.errorMessage||(this.Hi&&this.Vi>1?this.translations.editFormErrorMessage:""),!0),c.appendChild(h),this.Zi=h,t.prototype.getContent.call(this,c)},e.prototype.validateForm=function(){var t,e=this,i=!0;return null===(t=this.Ui)||void 0===t||t.remove(),this.Di.forEach((function(t){i=e.Gi(t)&&i})),!i&&this.Vi>1&&this.Wi(this.Zi,this.translations.editFormErrorMessage,!0),i},e.prototype.getSubmittedFields=function(){var t=this;return this.Di.filter((function(e){var i=e.tagName.toLowerCase();return"textarea"===i&&(t.Ni[e.id]=e.value),"input"===i})).forEach((function(e){var i=e;switch(i.type){case"checkbox":t.Ni[i.id]=i.checked?i.getAttribute("valueOn"):i.getAttribute("valueOff");break;case"number":t.Ni[i.id]=i.valueAsNumber;break;default:t.Ni[i.id]=i.value}})),this.Ni},e.prototype.Bi=function(t,e,i,s){var o=this.shareText,r=this.util;if(this.Vi++,(0,n.isReadOnlyField)(t)){var a=new p.FieldComponent(this.settings,r,t,o,this.options,s);return a.isColumnField=i,a.onActionClick=this.handleOnActionClick.bind(this),a.action&&this.si.push(a.action),a.render()}return i?(0,p.applyMarginTop)(this.qi(t,s,e,r),t.marginTop,r):this.qi(t,s,e,r)},e.prototype.qi=function(t,e,i,s){var o,r,c,h,u,d,m,f=this,b="".concat(i,"-field"),v=[b,"".concat(b,"-col-").concat(e),"edit-".concat(b)],w=s.createDiv(v),x=s.createDiv(["".concat(i,"-key"),"with-margin"]),y=t.labelFontSize,k=t.labelFontWeight,_=t.id,z=t.displayType,M=t.placeholder,S=t.required,C=t.clientErrorMessage,T=t.serverErrorMessage,$=t.autoSubmit;switch(x.innerHTML=t.label||"",(0,p.applyFontStyles)(x,y,k,s),w.appendChild(x),z){case n.DisplayType.SingleSelect:var I=t;if(d=I.defaultValue,m=I.layoutStyle,d&&(this.Ni[_]=d),m&&"list"!==m)if("radioGroup"===m){var A=s.createElement("form",["".concat(i,"-value"),"form-container","col"]);s.setAttributes(A,{id:_,ariaLabel:z,errorMsg:C}),A.onclick=function(t){return t.stopPropagation()},I.options.forEach((function(t){var e=s.createInputElement({type:"radio",name:_,value:t.label,required:S,checked:t.value===d},["radio-input"]);e.onchange=function(){e.checked&&(f.Ni[_]=t.value),f.Yi(_,$,A)};var i=s.createLabel();i.innerText=t.label,i.prepend(e),A.appendChild(i)})),this.Di.push(A),w.appendChild(A),this.Wi(A,T)}else this.Ri.error("Payload contains wrong layout style:".concat(m," for single select field"));else{var O,E=s.createDiv(["select-wrapper","".concat(i,"-value")]),L=s.createInputElement({type:"text",placeholder:M,required:S,id:_,autocomplete:"off"},["".concat(i,"-value")]),P=s.createDiv(),j=s.createDiv(["listbox","popup","none"]),F=s.createElement("ul",["single-select-list"]),V=F.getElementsByTagName("li"),H=s.createIconButton({css:["select-icon"],icon:a.iconCaretDown,iconCss:[],title:""}),D=function(t){"true"!==E.getAttribute(g)||P.contains(t.target)||(O||(L.value=""),N(!1))},R=function(){"false"===E.getAttribute(g)&&(E.setAttribute(g,"true"),s.removeCSSClass(j,"none"),setTimeout((function(){return document.addEventListener("click",D)})),L.focus())},N=function(t){void 0===t&&(t=!0),"true"===E.getAttribute(g)&&(O&&(L.value=O.textContent||O.innerText),E.setAttribute(g,"false"),s.addCSSClass(j,"none"),document.removeEventListener("click",D),f.Ji("",V,U),t&&L.focus())},U=[];s.setAttributes(E,{errorMsg:C}),E.setAttribute(g,"false"),E.setAttribute("aria-label",z),E.onclick=function(t){t.stopPropagation(),R()},E.oninput=function(){f.Ji(L.value,V,U)?R():N()},E.onkeydown=function(t){var e,i=t.key;i===l.KeyCode.Down||i===l.KeyCode.Up?!O||O.classList.contains("".concat(f.cssPrefix,"-none"))?null===(e=U[0])||void 0===e||e.focus():null==O||O.focus():i!==l.KeyCode.Esc&&i!==l.KeyCode.Tab||N()},L.onfocus=function(){return s.addCSSClass(E,"focused")},L.onblur=function(){return s.removeCSSClass(E,"focused")},H.onclick=function(t){t.stopPropagation(),"true"===E.getAttribute(g)?N():R()},null===(o=I.options)||void 0===o||o.forEach((function(t){var e=s.createListItem(t.label,t.label,t.label,"","",(function(){s.addCSSClass(e,"selected"),O&&s.removeCSSClass(O,"selected"),O=e,N(),f.Ni[_]=t.value,f.Yi(_,$,E)}),!1,!1);e.onkeydown=function(t){return f.Ki(t,e,F,L,U)},t.value===d&&(s.addCSSClass(e,"selected"),O=e,L.value=t.label),F.appendChild(e)})),U=Array.from(V),P.onclick=function(t){return t.stopPropagation()},E.appendChild(L),E.appendChild(H),j.appendChild(F),P.appendChild(j),w.appendChild(E),w.appendChild(P),this.Di.push(E),this.Wi(L,T)}break;case n.DisplayType.MultiSelect:var B=t;if(d=B.defaultValue,m=B.layoutStyle,this.Ni[_]=d||[],m&&"list"!==m)if("checkboxes"===m){var W=s.createElement("form",["".concat(i,"-value"),"form-container","col"]);s.setAttributes(W,{id:_,ariaLabel:z,errorMsg:C,ariaRequired:S?"true":""}),W.onclick=function(t){return t.stopPropagation()},B.options.forEach((function(t){var e=s.createInputElement({type:"checkbox",name:_,value:t.label,checked:null==d?void 0:d.includes(t.value),required:S},["radio-input"]),i=s.createLabel();i.innerText=t.label,i.prepend(e),e.onchange=function(){if(e.checked)f.Ni[_].push(t.value);else{var i=f.Ni[_];i.splice(i.indexOf(t.value),1)}f.Yi(_,$,W)},W.appendChild(i)})),this.Di.push(W),w.appendChild(W),this.Wi(W,T)}else this.Ri.error("Payload contains wrong layout style:".concat(m," for multi select field"));else{var Z=s.createDiv(["".concat(i,"-value"),"text-field-container"]),G=s.createElement("ul",["selected-options"]),q=s.createDiv(),Y=s.createDiv(["listbox","popup","none"]),J=[],K=s.createDiv(["filter-message-box"]),X=s.createDiv(["filter-message-text","none"]),Q=s.createInputElement({type:"text"},["".concat(i,"-value"),"listbox-search","none"]),tt=s.createElement("ul",["multi-select-list"]),et=tt.getElementsByTagName("li"),it=s.createDiv(["search-icon-wrapper","none"]),st=s.createImageIcon({icon:a.iconSearch,iconCss:["search-icon"]});X.textContent=this.translations.noResultText,K.appendChild(X),Q.oninput=function(){return f.Ji(Q.value,et,J)?s.addCSSClass(X,"none"):s.removeCSSClass(X,"none")},Q.onkeydown=function(t){var e,i=t.key;i===l.KeyCode.Down?(f.Ji(Q.value,et,J),null===(e=J[0])||void 0===e||e.focus()):i!==l.KeyCode.Esc&&i!==l.KeyCode.Tab||Z.click()},M&&G.setAttribute("data-placeholder",M),Z.setAttribute(g,"false");var ot=function(t){"true"!==Z.getAttribute(g)||q.contains(t.target)||rt()},rt=function(){Z.setAttribute(g,"false"),s.addCSSClass(Y,"none"),document.removeEventListener("click",ot),Q.value="",f.Ji(Q.value,et,J),s.addCSSClass(Q,"none"),s.addCSSClass(it,"none"),s.addCSSClass(X,"none")};Z.onclick=function(t){if(t.stopPropagation(),"true"===Z.getAttribute(g))rt(),Z.focus();else{Z.setAttribute(g,"true"),s.removeCSSClass(Y,"none");var e=tt.firstElementChild;e?e.focus():s.removeCSSClass(X,"none"),setTimeout((function(){return document.addEventListener("click",ot)}))}},Z.onkeydown=function(t){var e=t.code;t.ctrlKey||t.altKey||t.metaKey||t.shiftKey||e===l.KeyCode.Esc||e===l.KeyCode.Tab||(Z.click(),s.removeCSSClass(Q,"none"),s.removeCSSClass(it,"none"),Q.focus())},Z.setAttribute("aria-required",S?"true":"false"),Z.tabIndex=0,C&&Z.setAttribute("data-error",C),B.options.forEach((function(t){var e=function(e){var i=s.createDiv(["multi-select-option"]);i.innerText=t.label;var o=s.createImageIcon({icon:a.iconClose,iconCss:["opt-close"]});o.onclick=function(){G.removeChild(i),tt.appendChild(e);var s=f.Ni[_];s.splice(s.indexOf(t.value),1),f.Yi(_,$,Z)},i.appendChild(o),i.onclick=function(t){t.stopPropagation(),"true"===Z.getAttribute(g)&&Z.click()},G.appendChild(i)},i=s.createListItem(t.label,t.label,t.label,"","",(function(){Z.click(),tt.removeChild(i),f.Ni[_].push(t.value),e(i),f.Yi(_,$,Z)}),!1,!1);i.onkeydown=function(t){return f.Ki(t,i,tt,Z,J)},(null==d?void 0:d.includes(t.value))?e(i):tt.appendChild(i)})),q.onclick=function(t){return t.stopPropagation()},Z.appendChild(G),this.Di.push(Z),w.appendChild(Z),it.appendChild(st),Y.appendChild(K),Y.appendChild(Q),Y.appendChild(it),Y.appendChild(tt),q.appendChild(Y),w.appendChild(q),this.Wi(Z,T)}break;case n.DisplayType.Toggle:var nt=t,at=s.createLabel(["".concat(i,"-value"),"toggle"]);at.tabIndex=0,at.onclick=function(t){return t.stopPropagation()},u=s.createInputElement({id:_,placeholder:M,required:S,type:"checkbox",checked:nt.defaultValue===nt.valueOn,errorMsg:C,valueOn:nt.valueOn,valueOff:nt.valueOff});var ct=nt.labelOn||nt.valueOn,ht=nt.labelOff||nt.valueOff;u.setAttribute("aria-label",u.checked?ct:ht),u.oninput=function(){u.setAttribute("aria-label",u.checked?ct:ht),f.Yi(_,$,u)},at.appendChild(u),at.appendChild(s.createDiv(["round-slider"])),w.appendChild(at),this.Wi(u.parentElement,T);break;case n.DisplayType.DatePicker:var lt=t;u=s.createInputElement({type:"date",id:_,title:M,required:S,defaultValue:lt.defaultValue,min:lt.minDate,max:lt.maxDate,errorMsg:C},["".concat(i,"-value")]);break;case n.DisplayType.TimePicker:var ut=t;u=s.createInputElement({type:"time",id:_,title:M,required:S,defaultValue:ut.defaultValue,min:ut.minTime,max:ut.maxTime,errorMsg:C},["".concat(i,"-value")]);break;case n.DisplayType.TextInput:var pt=t;if(pt.multiLine){var dt=s.createElement("textarea",["".concat(i,"-value")],!0);s.setAttributes(dt,{id:_,required:S,minLength:pt.minLength,maxLength:pt.maxLength,defaultValue:pt.defaultValue,placeholder:pt.placeholder,errorMsg:C}),dt.rows=3,dt.onchange=function(){return f.Yi(_,$,dt)},dt.onclick=function(t){return t.stopPropagation()},w.appendChild(dt),this.Di.push(dt),this.Wi(dt,T)}else u=s.createInputElement({type:pt.inputStyle||"text",id:_,placeholder:M,required:S,defaultValue:pt.defaultValue,errorMsg:C,minLength:pt.minLength,maxLength:pt.maxLength,pattern:pt.validationRegularExpression},["".concat(i,"-value")]);break;case n.DisplayType.NumberInput:var gt=t;u=s.createInputElement({type:"number",id:_,placeholder:M,required:S,defaultValue:null===(r=gt.defaultValue)||void 0===r?void 0:r.toString(),min:null===(c=gt.minValue)||void 0===c?void 0:c.toString(),max:null===(h=gt.maxValue)||void 0===h?void 0:h.toString(),errorMsg:C},["".concat(i,"-value")]);break;default:this.Ri.error("Payload contains wrong display type:".concat(z," for editable field"))}return u&&("checkbox"!==u.type&&(w.appendChild(u),this.Wi(u,T),u.onchange=function(){return f.Yi(_,$,u)},u.onclick=function(t){return t.stopPropagation()}),this.Di.push(u)),w},e.prototype.Gi=function(t,e){var i=this;void 0===e&&(e=!1);var s,o=t.dataset.error,r=function(){e||("SPAN"===(null==a?void 0:a.tagName)&&(i.util.removeCSSClass(t.parentElement,"error"),a.remove(),i.Hi--),c||i.Wi(t,s||i.translations.editFieldErrorMessage))},a=t.nextElementSibling,c=!0;switch(t.tagName.toLowerCase()){case"form":var h=t,l=h.getAttribute("aria-label");if(l===n.DisplayType.MultiSelect&&"true"===h.ariaRequired)h.querySelectorAll("input[type='checkbox']:checked").length||(c=!1,s=o||h.querySelector("input").validationMessage);else l!==n.DisplayType.SingleSelect||h.checkValidity()||(c=!1,s=o||h.querySelector("input").validationMessage);break;case"input":var u=t;"checkbox"===u.type?a=a.parentElement.nextElementSibling:u.checkValidity()||(s=o||u.validationMessage,c=!1);break;case"textarea":var p=t;p.checkValidity()||(s=o||p.validationMessage,c=!1);break;case"div":var d=t;a=a.nextElementSibling,d.getAttribute("aria-label")===n.DisplayType.SingleSelect?setTimeout((function(){var t=d.firstElementChild;return t.checkValidity()||(c=!1,s=o||t.validationMessage),r(),c})):"true"===d.getAttribute("aria-required")&&(s=o,c=!!d.firstElementChild.firstElementChild)}return r(),c},e.prototype.Ji=function(t,e,i){var s=this.util;i.length=0;for(var o=0;o)|(<\/b>)/g,"")):(n.innerHTML=t?a.replace(new RegExp("".concat(t),"gi"),"$&"):a.replace(/()|(<\/b>)/g,""),s.removeCSSClass(r,"none"),i.push(r))}return i.length>0},e.prototype.Ki=function(t,e,i,s,o){var r,n,a,c,h=this.cssPrefix,u=o.indexOf(e),p=o.length,d=!1;if(!(t.ctrlKey||t.altKey||t.metaKey)){if(t.shiftKey&&t.code===l.KeyCode.Tab)s.click();else switch(t.code){case l.KeyCode.Return:case l.KeyCode.Space:e.click(),d=!0;break;case l.KeyCode.Esc:case l.KeyCode.Tab:s.click(),t.code===l.KeyCode.Esc&&(s.focus(),d=!0);break;case l.KeyCode.Up:var g=e.previousElementSibling||i.lastElementChild;g.classList.contains("".concat(h,"-none"))?null===(r=o[(u+p-1)%p])||void 0===r||r.focus():g.focus(),d=!0;break;case l.KeyCode.Down:var m=e.nextElementSibling||i.firstElementChild;m.classList.contains("".concat(h,"-none"))?null===(n=o[(u+1)%p])||void 0===n||n.focus():m.focus(),d=!0;break;case l.KeyCode.Home:case l.KeyCode.PageUp:var f=i.firstElementChild;f.classList.contains("".concat(h,"-none"))?null===(a=o[0])||void 0===a||a.focus():f.focus(),d=!0;break;case l.KeyCode.End:case l.KeyCode.PageDown:var b=i.lastElementChild;b.classList.contains("".concat(h,"-none"))?null===(c=o[p-1])||void 0===c||c.focus():b.focus(),d=!0;break;default:if(s instanceof HTMLInputElement)s.focus();else{var v=i.previousElementSibling,w=v.previousElementSibling,x=this.util;x.removeCSSClass(w,"none"),x.removeCSSClass(v,"none"),w.focus()}}d&&(t.stopPropagation(),t.preventDefault())}},e.prototype.Yi=function(t,e,i){var s=this;if(this.Gi(i)&&e){var o=JSON.parse(JSON.stringify(this.getSubmittedFields()));this.Di.forEach((function(t){s.Gi(t,!0)||delete o[t.id]})),Object.keys(o).forEach((function(t){var e=o[t];Array.isArray(e)?0===e.length&&delete o[t]:0===e||e||delete o[t]}));var a=this.settings.sdkMetadata?r({version:c.SDK_VERSION},this.settings.sdkMetadata):{version:c.SDK_VERSION};this.te.webCore.sendMessage((0,n.buildUserMessage)({submittedFields:o,partialSubmitField:t,type:n.MessageType.FormSubmission}),{sdkMetadata:a}).then((function(){var t=s.settings.disablePastActions;"all"===t?s.disableActions():"postback"===t&&s.disablePostbacks()})).catch((function(t){return s.Ri.error("[partialSubmit] Failed to send postback message:",t)}))}},e.prototype.Wi=function(t,e,i){if(void 0===i&&(i=!1),e){var s=this.util,o=s.createTextSpan(["field-error",i?"form-error":""]),r=s.createImageIcon({icon:a.iconError,iconCss:["form-error-icon"]}),n=s.createTextSpan(["error-text"]);if(n.innerText=e,o.appendChild(r),o.appendChild(n),i)t.appendChild(o),this.Ui=o;else{var c=t.parentElement;s.addCSSClass(c,"error"),c.appendChild(o),this.Hi++}}},e}(h.C2SQLBaseMessageComponent);function f(t,e,i,s){void 0===s&&(s=!0),t&&(s?i.addCSSClass(t,"disabled"):i.removeCSSClass(t,"disabled")),e.forEach((function(t){switch(t.tagName.toLowerCase()){case"form":var e=t.getElementsByTagName("input");s?i.addCSSClass(t,"disabled"):i.removeCSSClass(t,"disabled");for(var o=0;o2&&(o.formColumns=2);var a=o.forms;return a.forEach((function(t,c){if(t.title){var h=i.createTextDiv(["".concat(r,"-header")]);h.innerText=t.title,n.appendChild(h)}var l=u(i,t,o.formColumns,s,e.handleOnActionClick.bind(e),e.te),p=l[0],d=l[1];e.si=e.si.concat(d);var g=c+1;g===a.length||a[g].title||i.addCSSClass(p,"with-border"),n.appendChild(p)})),t.prototype.getContent.call(this,n)},e}(n.C2SQLBaseMessageComponent);function u(t,e,i,s,o,n){var l,u,f="form-message",b="".concat(f,"-actions-col"),v=null===(l=e.channelExtensions)||void 0===l?void 0:l.c2kReferences,w=t.createDiv(["".concat(f,"-item"),v?"c2k-reference":""]),x=(0,h.getFormShareText)(e,!0),y=function(t,e,i,s,o,r){var n,c=[];if((null===(n=t.actions)||void 0===n?void 0:n.length)>0)for(var h=0,l=t.actions;h=0&&t.width<=h}))){var i=0,s=0;if(t.forEach((function(t){t.width?s+=t.width:i++})),i)if(s2&&(s.formColumns=2);var d=s.forms[l],g=(0,n.createTableCell)(i,["".concat(r,"-item"),"button-cell"]),m=i.createIconButton({css:["".concat(r,"-item"),"".concat(r,"-item-form-toggle")],icon:c.iconChevronDown,iconCss:[],title:d.title||""});g.appendChild(m),p.appendChild(g);var f="none",b="rotate-180",v=(0,a.getFormItem)(i,d,s.formColumns,e.settings,e.handleOnActionClick.bind(e),e.te),w=v[0],x=v[1];e.si=e.si.concat(x),i.addCSSClass(w,f);var y=!1;p.onclick=function(){y?(i.addCSSClass(w,f),i.removeCSSClass(m,b)):(i.removeCSSClass(w,f),i.addCSSClass(m,b)),y=!y},u.appendChild(p),u.appendChild(w)})),t.prototype.getContent.call(this,l)},e}(r.C2SQLBaseMessageComponent);e.TableFormMessageComponent=l},512:function(t,e,i){var s,o=this&&this.sl||(s=function(t,e){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},s(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}s(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}),r=this&&this.ol||function(t,e,i){if(i||2===arguments.length)for(var s,o=0,r=e.length;o0||this.globalActions.length>0},e.prototype.disableActions=function(){t.prototype.disableActions.call(this),this.ni.forEach((function(t){t.disableActions()}))},e.prototype.disablePostbacks=function(){t.prototype.disablePostbacks.call(this),this.ni.forEach((function(t){t.disablePostbacks()}))},e.prototype.enableActions=function(){t.prototype.enableActions.call(this),this.ni.forEach((function(t){t.enableActions()}))},e.prototype.enablePostbacks=function(){t.prototype.enablePostbacks.call(this),this.ni.forEach((function(t){t.enablePostbacks()}))},e.prototype.render=function(){var e=this.util,i=this.settings.name,s=["card-message-".concat(this.ai)],o=t.prototype.render.call(this);if(o.querySelector(".".concat(i,"-icon-wrapper"))){s.push("has-message-icon");var n=o.querySelector(".".concat(i,"-content-wrapper"));e.addCSSClass(n,"with-icon")}return e.addCSSClass.apply(e,r([o],s,!1)),o},e.prototype.setCardsScrollDirection=function(){this.li="rtl"===getComputedStyle(this.ui).direction},e.prototype.getContent=function(){var t,e=this,i=this.util,s=this.ci,o=i.createDiv(["card-message-content"]),r=i.createDiv(["card-message-cards"]),n=!0;(this.ni.forEach((function(t){t.onActionClick=e.handleOnActionClick.bind(e);var i=t.render();n&&t.hasActions()&&(e.firstActionButton=t.getFirstActionButton(),n=!1),r.appendChild(i)})),o.appendChild(r),"horizontal"===this.ai&&s>1)&&(o.appendChild(this.pi()),this.di=0,r.addEventListener("scroll",(function(){window.clearTimeout(t),t=window.setTimeout((function(){for(var t=0,i=0;i0&&(this.di--,this.gi())},e.prototype.gi=function(){var t,e,i,s,o=this.ui.children[this.di];o&&(this.ui.scrollLeft=o.offsetLeft-56,0===this.di?null===(t=this.xi)||void 0===t||t.remove():(null===(e=this.xi)||void 0===e?void 0:e.parentElement)||this.fi.prepend(this.wi()),this.di===this.ci-1?null===(i=this.bi)||void 0===i||i.remove():(null===(s=this.bi)||void 0===s?void 0:s.parentElement)||this.fi.appendChild(this.pi()))},e.prototype.mi=function(){this.ui.scrollWidth===this.ui.offsetWidth?(this.bi&&(this.bi.hidden=!0),this.xi&&(this.xi.hidden=!0)):(this.bi&&(this.bi.hidden=!1),this.xi&&(this.xi.hidden=!1))},e}(c.MessageComponent);e.CardMessageComponent=l},101:function(t,e,i){Object.defineProperty(e,"Qh",{value:!0}),e.CardComponent=void 0;var s=i(752),o=i(820),r=i(168),n=i(549),a=function(){function t(t,e,i,r,n){var a;if(this.He=t,this.ii=e,this.te=n,this.si=[],this.Ye=[],this.Ke=i.title,this.oi=i.description,this.Ae=i.imageUrl,this.P=i.url,i.actions){for(var c=0,h=i.actions;c0){for(var g=t.createDiv("horizontal"!==e.cardActionsLayout?["card-actions","col"]:["card-actions"]),m=!0,f=0,b=this.si;f0},t.prototype.disableActions=function(){this.si.forEach((function(t){return t.disable()}))},t.prototype.disablePostbacks=function(){this.Ye.forEach((function(t){return t.disable()}))},t.prototype.enableActions=function(){this.si.forEach((function(t){return t.enable()}))},t.prototype.enablePostbacks=function(){this.Ye.forEach((function(t){return t.enable()}))},t.prototype.getFirstActionButton=function(){return this.ri},t}();e.CardComponent=a},346:function(t,e,i){var s,o=this&&this.sl||(s=function(t,e){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},s(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}s(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"Qh",{value:!0}),e.LocationMessageComponent=void 0;var r=i(398),n=i(609),a=function(t){function e(e,i,s,o,r,n){var a=t.call(this,e,i,s,o,r,n)||this,c=s.location;return a.Ke=c.title,a.P=c.url,a.ki=c.longitude,a._i=c.latitude,a}return o(e,t),e.prototype.render=function(){var t=this.util,e=t.createDiv(["message"]);e.lang=this.locale;var i=t.createDiv(["message-wrapper"]);e.appendChild(i);var s=t.createDiv(["attachment"]),o=t.createDiv(["attachment-placeholder","flex"]),r=t.createDiv(["attachment-icon"]),a=t.createImageIcon({icon:this.settings.icons.shareMenuLocation||n.iconShareLocation}),c=t.createDiv(["attachment-footer","flex"]),h=t.createLabel(["attachment-title"]);if(h.innerText=this.Ke?this.Ke:"".concat(this._i.toFixed(4),", ").concat(this.ki.toFixed(4)),c.appendChild(h),r.appendChild(a),o.appendChild(r),!this.actions.length){var l=t.createDiv(["attachment-controls"]),u=t.createIconButton({css:["attachment-control-icon","attachment-button","flex"],icon:this.settings.icons.externalLink||n.iconExternalLink,iconCss:[],title:this.translations.openMap}),p=t.createAnchor(this.P||"https://www.google.com/maps/@".concat(this._i,",").concat(this.ki,",12z"),"",[],this.settings.openLinksInNewWindow,this.settings.linkHandler);u.onclick=function(){p.click()},l.appendChild(u),c.appendChild(l)}return s.appendChild(o),s.appendChild(c),i.appendChild(this.getContent(s)),e},e}(r.MessageComponent);e.LocationMessageComponent=a},752:function(t,e,i){Object.defineProperty(e,"Qh",{value:!0}),e.getPostActions=void 0;var s=i(396);e.getPostActions=function(t){return t.filter((function(t){var e=t.getActionType();return e===s.ActionType.Postback||e===s.ActionType.Location||e===s.ActionType.SubmitForm}))}},398:function(t,e,i){var s=this&&this.il||function(){return s=Object.assign||function(t){for(var e,i=1,s=arguments.length;i0||this.globalActions.length>0},t.prototype.focusFirstAction=function(){var t;null===(t=this.firstActionButton)||void 0===t||t.focus()},t.prototype.disableActions=function(){this.actions.forEach((function(t){t.disable()})),this.globalActions.forEach((function(t){t.disable()})),this.footerFormComponent&&this.footerFormComponent.disableActions()},t.prototype.disablePostbacks=function(){this.Ye.forEach((function(t){t.disable()})),this.footerFormComponent&&this.footerFormComponent.disablePostbacks()},t.prototype.enableActions=function(){this.actions.forEach((function(t){t.enable()})),this.globalActions.forEach((function(t){t.enable()})),this.footerFormComponent&&this.footerFormComponent.enableActions()},t.prototype.enablePostbacks=function(){this.Ye.forEach((function(t){t.enable()})),this.footerFormComponent&&this.footerFormComponent.enablePostbacks()},t.prototype.render=function(t){var e=this,i=this,s=i.util,o=i.actions,n=i.globalActions,a=this.payload.embeddedActions,c="embeddedAction";this.element&&(this.element.innerHTML="");var h=this.element?this.element:s.createDiv(["message"]);h.lang=i.locale;var l=s.createDiv(["message-wrapper"]);h.appendChild(l);var u=i.getContent(t);if(i.headerText&&l.appendChild(i.getHeader()),l.appendChild(u),o&&o.length){var p=i.getActions();(this.settings.displayActionsAsPills?l:u).appendChild(p),i.firstActionButton||(i.firstActionButton=p.firstElementChild),this.actionsWrapper=p}if(i.footerText&&l.appendChild(i.getFooter()),this.footerFormComponent){var d=s.createDiv(["footer-form"]);d.appendChild(this.footerFormComponent.render()),l.appendChild(d)}if(n&&n.length){p=i.getGlobalActions();h.appendChild(p),i.firstActionButton||(i.firstActionButton=p.firstElementChild)}return this.element=h,h.querySelectorAll("span.".concat(c)).forEach((function(t){var i=t,o=a.find((function(e){return e.id===t.id}));if(o){s.addCSSClass(t,c,"display-".concat(o.displayType));var n=r.ActionComponentFactory.fromActionPayload(o,s,e.settings,e.shareText,e.options);n&&(n.onActionClick=e.handleOnActionClick.bind(e),n.render(),i.onclick=function(t){return n.handleOnClick(t)})}})),h},t.prototype.getHeader=function(){return h(this.headerText,"message-header",this.util,this.settings.embeddedVideo)},t.prototype.getContent=function(t){var e=this.util.createDiv(["message-bubble"]);return e.style.padding=this.settings.messagePadding||e.style.padding,t&&e.appendChild(t),e},t.prototype.getActions=function(){var t=this.settings,e=t.displayActionsAsPills?["message-global-actions"]:["message-actions"];return"horizontal"!==t.actionsLayout&&e.push("col"),l(this.actions,e,this.util)},t.prototype.getFooter=function(){return h(this.footerText,"message-footer",this.util,this.settings.embeddedVideo)},t.prototype.getGlobalActions=function(){var t=["message-global-actions"];return this.settings.icons.avatarBot&&t.push("has-message-icon"),"horizontal"!==this.settings.globalActionsLayout&&t.push("col"),l(this.globalActions,t,this.util)},t.prototype.buildActions=function(t,e){var i=this.settings;return function(t,e,i,s,o,n){var a=[];return t.forEach((function(t){var c=r.ActionComponentFactory.fromActionPayload(t,e,i,s,o);c&&(c.onActionClick=n,a.push(c))})),a}(t,this.util,i,e,this.options,this.handleOnActionClick.bind(this))},t}();function h(t,e,i,s){var o=i.createDiv(["message-bubble",e]),r=i.createTextDiv();return r.innerHTML=(0,a.linkify)(t,i.cssPrefix,s),o.appendChild(r),o}function l(t,e,i){var s=i.createTextDiv(e);return t.forEach((function(t){s.appendChild(t.render())})),s}e.MessageComponent=c},913:function(t,e,i){var s,o=this&&this.sl||(s=function(t,e){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},s(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}s(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"Qh",{value:!0}),e.RawMessageComponent=void 0;var r=function(t){function e(e,i,s,o,r,n){var a=t.call(this,e,i,s,o,r,n)||this;return a.qe=JSON.stringify(s.payload),a}return o(e,t),e.prototype.getContent=function(){var e=this.util.createTextSpan();return e.innerText=this.qe,t.prototype.getContent.call(this,e)},e}(i(398).MessageComponent);e.RawMessageComponent=r},774:function(t,e,i){var s,o=this&&this.sl||(s=function(t,e){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},s(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}s(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"Qh",{value:!0}),e.FeedbackComponent=void 0;var r=i(858),n=i(609),a=function(t){function e(e,i,s,o,r,n){var a=t.call(this,e,i,s,o,r,n)||this;return a.$i=0,a.Ii=s.actions,a.ratingId=Date.now(),a}return o(e,t),e.prototype.focusFirstAction=function(){this.Ai[0].focus()},e.prototype.disableActions=function(){this.Oi(!0),t.prototype.disableActions.call(this)},e.prototype.disablePostbacks=function(){this.Oi(!0),t.prototype.disablePostbacks.call(this)},e.prototype.enableActions=function(){this.Oi(!1),t.prototype.enableActions.call(this)},e.prototype.enablePostbacks=function(){this.Oi(!1),t.prototype.enablePostbacks.call(this)},e.prototype.highlightRating=function(t){if(this.actions&&this.Ai)for(var e=this.util,i="active",s="string"==typeof t?this.Ei(t):t,o=1;o<=this.Ai.length;o++){var r=this.Ai[o-1];if(!r)break;s&&o<=s||0===s&&o<=this.$i?e.addCSSClass(r,i):e.removeCSSClass(r,i)}},e.prototype.getActions=function(){var t=this,e=this.util,i=this.settings,s=i.i18n[i.locale].ratingStar,o=e.createDiv(["rating-wrapper"]);this.Ai=this.Ii.map((function(r){var a=e.createElement("input",["star-input","rating-hidden"]);a.id="rating-".concat(r.label,"-").concat(t.ratingId),a.type="radio",a.name="rating-".concat(t.ratingId),a.value=r.label;var c=e.createLabel(["star-label"]);c.htmlFor="rating-".concat(r.label,"-").concat(t.ratingId),c.setAttribute("data-rating",r.label);var h=e.createTextSpan(["rating-hidden"]),l=s.replace("{0}","".concat(r.label));h.innerText=l;var u=i.icons&&i.icons.rating||n.iconRating,p=e.createImageIcon({icon:u,iconCss:["rating-star-icon"]});return c.appendChild(h),c.appendChild(p),a.onfocus=function(){a.disabled||(t.$i=t.Li(a))},a.onkeydown=function(e){"Enter"===e.key&&t.Pi(r)},c.onclick=function(){a.disabled||(t.$i=t.Li(c),t.Pi(r))},c.onmouseover=function(){a.disabled||t.Li(c)},c.onmouseleave=function(){a.disabled||t.Li(null)},o.appendChild(a),o.appendChild(c),a})),this.$i&&this.Li(null);var r=e.createDiv(["rating-root"]);return r.appendChild(o),r},e.prototype.Oi=function(t){this.Ai&&this.Ai.forEach((function(e){e.disabled=t}))},e.prototype.Pi=function(t){var e={getPayload:function(){return Promise.resolve(t.postback)},label:t.label,type:t.type};this.handleOnActionClick(e)},e.prototype.Li=function(t){var e=0;if(t){var i="value"in t?t.value:null==t?void 0:t.getAttribute("data-rating");e=i?parseInt(i,10):0}return this.highlightRating(e),e},e.prototype.Ei=function(t){var e=0;if(t.match(/^\d+$/)){var i=parseInt(t,10);i>0&&i<=this.actions.length&&(e=i)}return e},e}(r.TextMessageComponent);e.FeedbackComponent=a},858:function(t,e,i){var s,o=this&&this.sl||(s=function(t,e){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},s(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}s(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"Qh",{value:!0}),e.TextMessageComponent=void 0;var r=i(168),n=i(398),a=i(396),c=i(549),h=function(t){function e(e,i,s,o,r,n){var a=t.call(this,e,i,s,o,r,n)||this;return a.zi=s.text,a}return o(e,t),e.prototype.getContent=function(){var e=this.settings,i=this.util,s=this.zi,o=i.createTextDiv(["message-text"]);return this.side===n.MESSAGE_SIDE.RIGHT?(0,a.isPostbackPayload)(this.payload)&&l(s)?(i.addCSSClass(o,"message-user-postback"),o.innerHTML=s):o.textContent=u(s):(o.innerHTML=(0,c.linkify)(s,i.cssPrefix,e.embeddedVideo),e.linkHandler?(0,r.setEmbeddedLinksHandler)(o,e.linkHandler):e.openLinksInNewWindow&&(0,r.setLinksOpenInNewWindow)(o)),t.prototype.getContent.call(this,o)},e}(n.MessageComponent);e.TextMessageComponent=h;var l=function(t){return!!t&&/^=0){var o=t.text.substring(s+i.length);this.Ti.push(o.split("")),this.isCoPilot||this.setAddOnComponents(t);break}}}this.renderClean(t)}},e.prototype.getContent=function(){var e,i=this.settings,s=this.util,o=s.createTextDiv();return o.setAttribute("aria-hidden","true"),!this.Si||this.Ci!==h&&this.textElement?(o.innerHTML=(0,c.linkify)(this.zi,s.cssPrefix,i.embeddedVideo),this.Ci===l&&o.removeAttribute("aria-hidden"),i.linkHandler?(0,a.setEmbeddedLinksHandler)(o,i.linkHandler):i.openLinksInNewWindow&&(0,a.setLinksOpenInNewWindow)(o)):(this.textElement=o,this.Ti.push(null===(e=this.zi)||void 0===e?void 0:e.split(""))),t.prototype.getContent.call(this,o)},e.prototype.renderClean=function(t){this.Ti.clear(),this.zi=t.text,this.isCoPilot||(this.setAddOnComponents(t),this.render())},e.prototype.setAddOnComponents=function(t){this.headerText=t.headerText,t.actions&&(this.actions=this.buildActions(t.actions)),this.footerText=t.footerText,t.footerForm&&(this.footerFormComponent=(0,a.getFooterFormComponent)(this.util,t.footerForm,this.settings,this.options)),t.globalActions&&(this.globalActions=this.buildActions(t.globalActions)),this.Ye=(0,n.getPostActions)(this.actions).concat((0,n.getPostActions)(this.globalActions))},e}(r.MessageComponent);e.TextStreamMessageComponent=u;var p=function(t,e,i){var s=[],o=!0,r=function(){if(!s.length)return o=!0,void setTimeout((function(){return e()}));setTimeout((function(){s.length&&(t(s.shift()),r())}),i)};return{push:function(t){s.push.apply(s,t),o&&(o=!1,r())},clear:function(){s.length=0}}}},682:function(t,e,i){var s=this&&this.il||function(){return s=Object.assign||function(t){for(var e,i=1,s=arguments.length;i=0;if(d.speechLocale=t,v.setRecognitionLocale(t),i.setVoiceRecognitionService(e),e&&d.enableBotAudioResponse){var s=(0,r.syncTTSLocaleIfUnavailable)({hasRecognition:d.enableSpeech,hasSynthesis:d.enableBotAudioResponse,recognitionLocale:d.speechLocale,synthesisLocales:d.ttsVoice});s!==d.ttsVoice&&(d.ttsVoice=s,s.length&&v.setTTSVoice(s))}return e},this.getUnreadMessagesCount=function(){if(d.enableHeadless)return 0;var t=i.getUnreadMsgsCount();return t!==u&&(u=t,g.trigger(r.ChatEvent.UNREAD,t)),t},this.setAllMessagesAsRead=function(){d.enableHeadless||(p.getUnreadMessagesCount(),i.updateNotificationBadge(0))},this.showTypingIndicator=function(){if(!d.showTypingIndicator)throw new Error("Typing indicator is configured not to be shown.");if(d.enableHeadless)throw new Error("Typing indicator cannot be shown in headless mode.");p.isConnected()&&i.showTypingIndicator()},this.setWebViewConfig=function(t){if(d.enableHeadless)throw new Error("WebView cannot be configured in headless mode.");i.refreshWebView(t)},this.setUserInputMessage=function(t){if(d.enableHeadless)throw new Error("User input cannot be set in headless mode.");i.setUserInputMessage(t)},this.setUserInputPlaceholder=function(t){if(d.enableHeadless)throw new Error("Placeholder cannot be set in headless mode.");t?i.setUserInputPlaceholder(t):x("setUserInputPlaceholder","placeholder text")},this.setHeight=function(t){t?null==i||i.setHeight(t):x("setHeight","height")},this.setWidth=function(t){t?null==i||i.setWidth(t):x("setWidth","width")},this.setSize=function(t,e){t||e?null==i||i.setSize(t,e):x("setSize","width","height")},this.setMessagePadding=function(t){t?null==i||i.setMessagePadding(t):x("setMessagePadding","padding")},this.setChatBubbleIconHeight=function(t){t?null==i||i.setChatBubbleIconHeight(t):x("setChatBubbleIconHeight","height")},this.setChatBubbleIconWidth=function(t){t?null==i||i.setChatBubbleIconWidth(t):x("setChatBubbleIconWidth","width")},this.setChatBubbleIconSize=function(t,e){t||!e?null==i||i.setChatBubbleIconSize(t,e):x("setChatBubbleIconSize","width","height")},this.setFont=function(t){t?(f.updateCSSVar("font",t),d.font=t):x("setFont","font")},this.setFontFamily=function(t){t?(f.updateCSSVar("font-family",t),d.fontFamily=t):x("setFontFamily","fontFamily")},this.setFontSize=function(t){t?f.updateCSSVar("font-size",t):x("setFontSize","fontSize")},this.setTextColor=function(t){t?(f.updateCSSVar("--color-bot-text",t),f.updateCSSVar("--color-user-text",t)):x("setTextColor","color")},this.setTextColorLight=function(t){t?(f.updateCSSVar("--color-text-light",t),d.colors.textLight=t):x("setTextColorLight","color")},b.debug("onLoad","load chat widget"),z(),(0,n.setReadOnly)(this);var C=window;C&&"function"==typeof C.define&&C.define.amd&&(C.WebSDK=c)}e.default=c;var h="Text-to-speech is not available.";function l(){return t=h,Promise.reject(Error(t));var t}c.EVENT=r.ChatEvent,c.SPEECH_LOCALE=o.RecognitionLocale,c.THEME=r.WidgetTheme,c.Version=r.SDK_VERSION,(0,n.deepFreeze)(c)}},e={};function i(s){var o=e[s];if(void 0!==o)return o.exports;var r=e[s]={exports:{}};return t[s].call(r.exports,r,r.exports,i),r.exports}i.d=function(t,e){for(var s in e)i.o(e,s)&&!i.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"Qh",{value:!0})};var s=i(682);return s=s.default}()})); \ No newline at end of file diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-web/styles/artie.css b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-web/styles/artie.css new file mode 100644 index 00000000..34a0d0d5 --- /dev/null +++ b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-web/styles/artie.css @@ -0,0 +1,3 @@ +/*! + * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. + */:root{--artie-black:#161513;--artie-gray:#3a3631;--artie-white:#fcfbfa;--artie-yellow:#f7e0a1;--artie-red:#e6081a;--artie-lightgray:#d4cfca}.oda-chat-wrapper.oda-chat-collapsed .oda-chat-notification-badge,.oda-chat-wrapper.oda-chat-redwood-dark.oda-chat-expanded{--color-footer-background:var(--artie-black);--color-text:var(--artie-black);--color-text-light:var(--artie-white);--color-header-button-fill:var(--artie-white);--color-header-button-fill-hover:var(--artie-white);--color-header-text:var(--artie-white);--color-typing-indicator:var(--artie-white);--color-bot-text:var(--artie-white);--color-user-message-background:var(--artie-lightgray);--color-user-text:var(--artie-black);--color-actions-border:var(--artie-white);--color-actions-text:var(--artie-white);--color-actions-text-focus:var(--artie-white);--color-actions-text-hover:var(--artie-white);--color-global-actions-border:var(--artie-white);--color-global-actions-text:var(--artie-white);--color-global-actions-text-focus:var(--artie-white);--color-global-actions-text-hover:var(--artie-white);--color-links:var(--artie-yellow);--color-footer-background:var(--artie-black);--color-footer-button-fill:var(--artie-black);--color-input-background:var(--artie-white);--color-input-text:var(--artie-black);--color-recognition-view-text:var(--artie-white);--color-visualizer-container-background:var(--artie-white);--color-notification-badge-background:var(--artie-red);--color-notification-badge-text:var(--artie-white)}.oda-chat-message-global-actions button.oda-chat-action-postback[title='\f37d'] div,.oda-chat-message-global-actions button.oda-chat-action-postback[title='\f37e'] div{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-size:16px;line-height:1;speak:none}.oda-chat-wrapper .oda-chat-icon-wrapper{z-index:0!important}.oda-chat-wrapper .oda-chat-footer a{text-decoration:none}.oda-chat-wrapper .oda-chat-footer a:hover{text-decoration:underline}.oda-chat-wrapper .more{display:none}.oda-chat-wrapper .oda-chat-message-global-actions{display:block!important}.oda-chat-message-global-actions .oda-chat-action-postback{display:inline;margin-inline-end:8px;margin-top:4px}.oda-chat-wrapper .oda-chat-button,.oda-chat-wrapper .oda-chat-button:focus{outline:0}.oda-chat-wrapper .oda-chat-button:not(.oda-chat-none){background-color:var(--artie-gray)!important;border-radius:500px!important}.oda-chat-wrapper .oda-chat-card .oda-chat-card-description:not(.artie-expanded){overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-line-clamp:4;line-clamp:4;-webkit-box-orient:vertical}.oda-chat-collapsed.oda-chat-drag .oda-chat-button.lets-chat-enabled,.oda-chat-collapsed:not(.oda-chat-drag) .oda-chat-button.lets-chat-enabled{animation-name:increaseWidth!important;animation-duration:21s!important;animation-timing-function:ease-in-out!important;animation-fill-mode:forwards!important;display:inline-flex!important}.oda-chat-wrapper .oda-chat-button img{width:48px;height:48px}@keyframes increaseWidth{0%{width:48px}5%{width:166px}95%{width:166px}100%{width:48px}}@keyframes increaseWidthLarge{0%{width:64px}5%{width:200px}95%{width:200px}100%{width:64px}}@keyframes fadeInOut{0%{opacity:0}5%{opacity:1}95%{opacity:1}100%{opacity:0}}.oda-chat-wrapper .oda-chat-letschat{background-color:var(--artie-gray);width:100%;height:inherit;border-radius:0 500px 500px 0;position:relative;left:-24px;z-index:-1;display:flex;overflow:hidden;white-space:nowrap}.oda-chat-wrapper .lets-chat-enabled .oda-chat-letschat *{color:var(--artie-white);position:relative;margin:0 0 0 30px;font-size:20px;font-style:italic;align-self:center;animation-name:fadeInOut;animation-delay:1.2s;animation-duration:19s;animation-timing-function:ease-in-out;opacity:0;animation-fill-mode:forwards;left:-6px}.oda-chat-wrapper .oda-chat-footer a,.oda-chat-wrapper .oda-chat-header .oda-chat-subtitle,.oda-chat-wrapper .oda-chat-header .oda-chat-title,.oda-chat-wrapper .oda-chat-left .oda-chat-message-bubble{color:var(--artie-white)}.oda-chat-wrapper .oda-chat-card-actions .oda-chat-action-postback,.oda-chat-wrapper .oda-chat-message-actions .oda-chat-action-postback{border-color:var(--artie-white);color:var(--artie-white)}.oda-chat-wrapper .oda-chat-footer-button svg,.oda-chat-wrapper .oda-chat-header-button svg{fill:var(--artie-white)}.oda-chat-wrapper .oda-chat-header-actions button.oda-chat-icon{margin-inline-start:2px!important;padding:0}.oda-chat-wrapper .oda-chat-header-button svg{height:24px;width:24px}.oda-chat-wrapper .oda-chat-widget{border-radius:0!important}@media screen and (min-width:426px){.oda-chat-wrapper .oda-chat-widget{border-radius:6px!important}}.oda-chat-wrapper,.oda-chat-wrapper *{font-family:"Oracle Sans","Helvetica Neue",Helvetica,Arial,sans-serif,ojuxIconFont!important}.oda-chat-wrapper{font-weight:400}.oda-chat-wrapper a{font-size:16px}.oda-chat-wrapper .oda-chat-notification-badge{background-color:var(--artie-red)}.oda-chat-wrapper .oda-chat-footer,.oda-chat-wrapper .oda-chat-header{background-color:var(--artie-black)}.oda-chat-wrapper .oda-chat-logo{background-color:var(--artie-gray);width:42px!important;height:42px!important;max-height:42px!important;max-width:42px!important;border-radius:50%}.oda-chat-wrapper .oda-chat-left .oda-chat-message-icon{background-color:#655f5c;border-radius:50%}.oda-chat-wrapper .oda-chat-user-input{border-width:0;background-color:var(--artie-white);border-radius:10px}.oda-chat-wrapper .oda-chat-subtitle{font-style:italic;padding-right:5px}.oda-chat-wrapper .oda-chat-footer-mode-keyboard{padding:8px 6px 4px 4px}.oda-chat-wrapper .oda-chat-card-title{font-size:14px;font-weight:700}.oda-chat-wrapper .oda-chat-card-description,.oda-chat-wrapper .oda-chat-card-description a{font-size:13px}.oda-chat-wrapper .oda-chat-button:not(.lets-chat-enabled) .oda-chat-letschat{display:none}@media screen and (min-width:769px){.oda-chat-wrapper .oda-chat-letschat{left:-24px}.oda-chat-wrapper .oda-chat-button img,.oda-chat-wrapper .oda-chat-flex.oda-chat-button{width:85px;height:85px}.oda-chat-collapsed.oda-chat-drag .oda-chat-button.lets-chat-enabled,.oda-chat-collapsed:not(.oda-chat-drag) .oda-chat-button.lets-chat-enabled{animation-name:increaseWidthLarge!important}.oda-chat-wrapper button.oda-chat-button.oda-chat-icon{width:85px;height:85px}.oda-chat-wrapper .lets-chat-enabled .oda-chat-letschat *{margin:0 0 0 36px;font-size:24px}} diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-web/styles/design.css b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-web/styles/design.css new file mode 100644 index 00000000..2303cb13 --- /dev/null +++ b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oda-web/styles/design.css @@ -0,0 +1,375 @@ +/** + * Copyright (c) 2021 Oracle and/or its affiliates. + * Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + */ + +body, +input { + font-family: "Oracle Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif; + font-weight: 400; + color: #100f0e; + font-size: 1rem; + line-height: 1.4; + margin: 20px auto; + padding: 0 20px; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; +} + +/*! BASE - REDWOOD */ + +* { + box-sizing: border-box; + margin: 0; + padding: 0; + list-style: none; + background-repeat: no-repeat; + -webkit-tap-highlight-color: transparent; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale +} + +html { + height: 100% +} + +body { + padding: 0; + margin: 0; + color: #100f0e; + min-width: 280px; + height: 100%; + font-size: 1.6rem; + line-height: 1.4; + opacity: 1 !important +} + +html { + font-size: 62.5%; + height: 100% +} + +@media (max-width: 2560px) { + html { + font-size: 50%; + -webkit-text-size-adjust: 100%; + -moz-text-size-adjust: 100%; + -ms-text-size-adjust: 100% + } +} + +@media only screen and (max-width: 1024px) { + body { + font-size: 1.85rem + } + html { + font-size: 50%; + -webkit-text-size-adjust: 100%; + -moz-text-size-adjust: 100%; + -ms-text-size-adjust: 100% + } +} + +/* Card Layout CSS */ + +.oda-chat-footer-form { + display: none; +} + +.oda-chat-card{ + border-radius: 0px !important; + padding: 2px !important; +} +.oda-chat-card-image { + height: 188px !important; + max-width: 100%; + width: 330px !important; +} +.oda-chat-card-title{ + font-weight: bold !important; + margin: 0px !important; + white-space: normal !important; + text-align: left !important; + padding: 10px; +} + +.oda-chat-card-description{ + font-size: small !important; +} + +.oda-chat-message-global-actions { + justify-content: space-evenly !important; + flex-direction: row !important; + margin-top: 5px !important; + width: 330px !important; +} + +.oda-chat-action-postback:first-of-type { + margin-top: 4px !important; +} + +.oda-chat-action-postback:last-of-type { + margin-bottom: 4px !important; +} + +.oda-chat-action-postback { + padding: 10px !important; + font-size: 13px !important; + display: inline !important; + flex: none !important; +} + +.oda-chat-round{ + height: 36px !important; + width: 24px !important; +} + +.video-player{ + height: 181px !important; + max-width: 100%; + width: 330px !important; +} + +/* Message Layout CSS */ + +.oda-chat-message-bubble{ + padding: 10px !important; +} + +.oda-chat-left .oda-chat-message-bubble{ + border-radius: 20px 20px 20px 0 !important; +} + +.oda-chat-message-content{ + margin: 1px !important; + white-space: normal !important; +} + + +/* Story Layout CSS */ + +.Bot-SE2-Story-readNext { + outline:none; +} +.Bot-SE2-Story-readNext .Bot-contentWrapper { + height: 100%; +} +.Bot-SE2-Story-readNext .Bot-imgDiv { + float: right; + width: 43%; + height: 100%; + padding-right: 0px; + background-color: #655f5c; + position: relative; + outline:none; + display: flex; +} +.Bot-SE2-Story-readNext .Bot-imgDiv img { + width:100%; + height: 100%; + object-fit: contain; + object-position: top; + outline:none; +} +.Bot-SE2-Story-readNext .Bot-imgDiv video { + width:100%; + height: 100%; + object-fit: contain; + object-position: top; + background: black; + outline:none; +} +.Bot-SE2-Story-readNext .Bot-imgDiv video:hover, +.Bot-SE2-Story-readNext .Bot-imgDiv video:focus { + cursor: pointer; +} +.Bot-SE2-Story-readNext .Bot-TextDiv { + float: left; + width: 53%; + height: 100%; + position: relative; + outline:none; +} +.Bot-SE2-Story-readNext .Bot-NoMediaTextDiv { + width:100%; + height:100%; + position: relative; + outline:none; +} +.Bot-SE2-Story-readNext .Bot-AuthorTitle { + width: 100%; +} +.Bot-SE2-Story-readNext .Bot-Author { + color:#FFFFFF; + font-family: HelveticaNeue; + display: flex; +} +.Bot-SE2-Story-readNext .Bot-Date { + padding-left: .2rem; +} +.Bot-SE2-Story-readNext .Bot-Title { + font-weight: bold; + position: relative; + outline:none; + padding-bottom: 3px; + padding-top: 2px; +} +.Bot-SE2-Story-readNext .Bot-Summary { + margin-top: 0.3125rem; + margin-bottom: 0.3125rem; + position: relative; + outline:none; +} +.Bot-font14 { + font-size: 13px; + color:#FFFFFF; +} +.Bot-font14-2LineEllipsis { + line-height: 1.214em; + -webkit-line-clamp: 2; + display: -webkit-box; + overflow: hidden; + -webkit-box-orient: vertical; + text-overflow: ellipsis; + max-height: 2.428em; +} +.Bot-font12 { + font-weight: normal; + font-size: 9px; + letter-spacing: 0.43px; + color:#FFFFFF; + line-height: 1.333em; +} +.Bot-font12-3LineEllipsis { + display: -webkit-box; + -webkit-box-orient: vertical; + text-overflow: ellipsis; + overflow: hidden; + -webkit-line-clamp: 3; + max-height: 4.5em; +} +.Bot-font16-1LineEllipsis { + -webkit-line-clamp: 1; + max-height: 1.375em; +} + + + +/* Index page CSS */ + +.landing-page{ + min-width: 426px; + height: 100%; + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + font-style: normal; + font-size: 1vw; + line-height: 1.4em; +} +.page-header{ + display: flex; + align-items: center; + width: 100%; + height: 7.833vw; + background: #201E1C; + box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.31); +} +.page-logo { + margin-left: 4vw; + width: 6.5vw; +} +.headerText{ + font-weight: normal; + font-size: 1.6em; + color: #FFFFFF; + line-height: 1.4em; +} +.footerText { + font-weight: normal; + font-size: 1em; + color: #FFFFFF; + line-height: 1.4em; + margin-left: 6.125vw; +} + +img { + width: 100%; + height: 100%; + object-fit: contain; + outline: none; +} +.page-banner{ + display: flex; + height: 52rem; + background-color: rgba(2,10,19,255); +} +.page-content{ + display: flex; + /* min-height: 100vh; */ +} +.column1{ + flex: auto; + background: #3a3631; + padding-bottom: 5rem; +} +.column2{ + background: #655F5C; + min-width: 416px; + padding-bottom: 5rem; +} +.page-desc{ + margin: 6.389vw 4vw auto 4vw; +} +.page-topic{ + font-weight: normal; + font-size: 2em; + color: #FEFEFE; + line-height: 1.4em; +} +.topic-underline{ + width: 3.542vw; + height: 5.56px; + background: #2A9F8C; + margin-top: 1em; +} +.page-details{ + font-style: normal; + font-size: 1.35em; + line-height: 2em; + margin-top: 3.82vw; + color: #FEFEFE; +} +.sub-Topic{ + font-weight: 700; +} +.sub-details{ + font-weight: 400; + padding-bottom: 0.798vw; + padding-left: 0.347vw; +} +.page-footer { + width: 100%; + height: 7.833vw; + background: #201E1C; + display: flex; + align-items: center; +} +.footer-img{ + width: 22.75vw; + height: 7.833vw; + margin-left: 6.125vw; + float: left; +} +@media only screen and (max-width: 767px){ + .column2 { + display: none; + } + .landing-page{ + font-size: 7.68px; + } + .page-header{ + height: 60.16px; + } + .page-logo { + width: 41.59px; + } +} diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oracle-partner-award-official-rules.pdf b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oracle-partner-award-official-rules.pdf new file mode 100644 index 00000000..9d3c4055 Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oracle-partner-award-official-rules.pdf differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oracle_vector_db.py b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oracle_vector_db.py new file mode 100644 index 00000000..3ec385e0 --- /dev/null +++ b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/oracle_vector_db.py @@ -0,0 +1,365 @@ +""" +File name: oracle_vector_db.py +Author: Luigi Saetta +Date created: 2023-12-15 +Date last modified: 2024-03-16 +Python Version: 3.11 + +Description: + This module provides the class to integrate Oracle Vector DB + as Vector Store in llama-index + +Inspired by: + https://docs.llamaindex.ai/en/stable/examples/low_level/vector_store.html + +Usage: + Import this module into other scripts to use its functions. + Example: + ... + +License: + This code is released under the MIT License. + +Notes: + This is a part of a set of demo showing how to use Oracle Vector DB, + OCI GenAI service, Oracle GenAI Embeddings, to build a RAG solution, + where all he data (text + embeddings) are stored in Oracle DB 23c + +Warnings: + This module is in development, may change in future versions. +""" + +import time +import logging + +import array +from typing import List, Any, Dict +from contextlib import contextmanager +from tqdm import tqdm +import oracledb +import json +from llama_index.core.vector_stores.types import ( + VectorStore, + VectorStoreQuery, + VectorStoreQueryResult, +) + +import json +from llama_index.core.schema import TextNode, BaseNode + + +# load configs from here +from config_private import DB_USER, DB_PWD, DB_HOST_IP, DB_SERVICE + +# But for now we don't need to compute the id.. it is set in the driving +# code when the doc list is created +#from config import EMBEDDINGS_BITS, ADD_PHX_TRACING + +# Phoenix tracing +EMBEDDINGS_BITS = 64 +ADD_PHX_TRACING = True + +if ADD_PHX_TRACING: + from opentelemetry import trace as trace_api + from opentelemetry.trace import Status, StatusCode + from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter + from opentelemetry.sdk import trace as trace_sdk + from opentelemetry.sdk.trace.export import SimpleSpanProcessor + from openinference.semconv.trace import SpanAttributes + + +logger = logging.getLogger("ConsoleLogger") +# +# to add Phoenix tracing +# +tracer = None + +if ADD_PHX_TRACING: + # local app + TRACING_ENDPOINT = "http://127.0.0.1:7777/v1/traces" + tracer_provider = trace_sdk.TracerProvider() + trace_api.set_tracer_provider(tracer_provider) + tracer_provider.add_span_processor( + SimpleSpanProcessor(OTLPSpanExporter(TRACING_ENDPOINT)) + ) + tracer = trace_api.get_tracer(__name__) + OPENINFERENCE_SPAN_KIND = "openinference.span.kind" + + +# +# supporting functions +# + + +# added to handle the tracing in oracle_query +@contextmanager +def optional_tracing(span_name): + """ + enable tracing using Phoenix traces + """ + if ADD_PHX_TRACING: + with tracer.start_as_current_span(name=span_name) as span: + # to set the span kind (avoid unknown) + span.set_attribute(OPENINFERENCE_SPAN_KIND, "Retriever") + span.set_attribute(SpanAttributes.TOOL_NAME, "oracle_vector_store") + span.set_attribute(SpanAttributes.TOOL_DESCRIPTION, "Oracle DB 23c") + span.set_status(Status(StatusCode.OK)) + + yield span + else: + # provide a neutral context if no context is required + yield None + +def oracle_query( + embed_query: List[float], top_k: int = 2, verbose=False, approximate=False +): + """ + Executes a query against an Oracle database to find the top_k closest + vectors to the given embedding. + + History: + 23/12/2023: modified to return some metadata (book_name, page_num) + 05/03 added approximate to support approximate (index) query + Args: + embed_query (List[float]): A list of floats representing + the query vector embedding. + top_k (int, optional): The number of closest vectors + to retrieve. Defaults to 2. + verbose (bool, optional): If set to True, additional information + about the query and execution time will be printed. Defaults to False. + + Returns: + VectorStoreQueryResult: Object containing the query results, + including nodes, similarities, and ids. + """ + start_time = time.time() + + # build the DSN from data taken from config.py + DSN = f"{DB_HOST_IP}/{DB_SERVICE}" + + + try: + with oracledb.connect(user=DB_USER, password=DB_PWD, dsn=DSN) as connection: + with connection.cursor() as cursor: + # 'f' single precision 'd' double precision + array_type = "d" if EMBEDDINGS_BITS == 64 else "f" + array_query = array.array(array_type, embed_query) + vector_list = array_query.tolist() + vector_str = json.dumps(vector_list) + approx_clause = "" + + if approximate: + # mean use HNSW indexes + approx_clause = "APPROXIMATE" + + # changed select adding books (39/12/2023) + # changed distance to COSINE + select = f"""select V.id, C.CHUNK, C.PAGE_NUM, + VECTOR_DISTANCE(V.VEC, :1, COSINE) as d, + B.NAME + from VECTORS V, CHUNKS C, DOCUMENTS B + where C.ID = V.ID and + C.DOCUMENTS_ID = B.ID + order by d + FETCH {approx_clause} FIRST {top_k} ROWS ONLY""" + + if verbose: + logger.info(f"SQL Query: {select}") + + cursor.execute(select, [array_query]) + rows = cursor.fetchall() + + result_nodes, node_ids, similarities = [], [], [] + + # prepare output + for row in rows: + # row[1] is a clob + full_clob_data = row[1].read() + + # 29/12: added book_name to metadata + result_nodes.append( + TextNode( + id_=row[0], + text=full_clob_data, + metadata={"file_name": row[4], "page_label": row[2]}, + ) + ) + node_ids.append(row[0]) + similarities.append(row[3]) + + except Exception as e: + logger.error(f"Error occurred in oracle_query: {e}") + return None + + q_result = VectorStoreQueryResult( + nodes=result_nodes, similarities=similarities, ids=node_ids + ) + + elapsed_time = time.time() - start_time + + if verbose: + logger.info(f"Query duration: {round(elapsed_time, 1)} sec.") + + return q_result + + +def save_embeddings_in_db(embeddings, pages_id, connection): + """ + save the embeddings vector in Oracle DB + pages_id: list with page numbers to save as metadata + """ + tot_errors = 0 + + with connection.cursor() as cursor: + logging.info("Saving embeddings to DB...") + + for id, vector in zip(tqdm(pages_id), embeddings): + # 'f' single precision 'd' double precision + array_type = "d" if EMBEDDINGS_BITS == 64 else "f" + logging.info(array_type) + input_array = array.array(array_type, vector) + vector_list = input_array.tolist() + vector_str = json.dumps(vector_list) + + try: + # insert single embedding + cursor.execute("insert into VECTORS values (:1, :2)", [id, vector_str]) + except Exception as e: + logging.error("Error in save embeddings...") + logging.error(e) + tot_errors += 1 + + logging.info(f"Tot. errors in save_embeddings: {tot_errors}") + +def save_chunks_in_db(pages_text, pages_id, pages_num, book_id, connection): + """ + Save the chunks of text in the DB + """ + tot_errors = 0 + + with connection.cursor() as cursor: + logger.info("Saving texts to DB...") + cursor.setinputsizes(None, oracledb.DB_TYPE_CLOB) + + for id, text, page_num in zip(tqdm(pages_id), pages_text, pages_num): + try: + cursor.execute( + "insert into CHUNKS (ID, CHUNK, PAGE_NUM, BOOK_ID) values (:1, :2, :3, :4)", + [id, text, page_num, book_id], + ) + except Exception as e: + logger.error("Error in save chunks...") + logger.error(e) + tot_errors += 1 + + logger.info(f"Tot. errors in save_chunks: {tot_errors}") + + +# +# The class wrapping the Oracle DB Vector Store +# +class OracleVectorStore(VectorStore): + """ + Interface with Oracle DB Vector Store + + """ + + stores_text: bool = True + verbose: bool = False + DSN = f"{DB_HOST_IP}/{DB_SERVICE}" + + def __init__(self, verbose=False, enable_hnsw_indexes=False) -> None: + """Init params.""" + self.verbose = verbose + self.enable_hnsw_indexes = enable_hnsw_indexes + + # initialize the cache + self.node_dict: Dict[str, BaseNode] = {} + + # get method is NOT needed + + def add( + self, + nodes: List[BaseNode], + ) -> List[str]: + """Add nodes to index.""" + ids_list = [] + for node in nodes: + # the node contains already the embedding + # regarding the id, it is already set in the right way + # is it generated by llama-index, hash or book_name + page_num + # so we don't need to do anything here + self.node_dict[node.id_] = node + ids_list.append(node.id_) + + return ids_list + + def delete(self, node_id: str, **delete_kwargs: Any) -> None: + """ + Delete nodes using with ref_doc_id. + + Args: + ref_doc_id (str): The doc_id of the document to delete. + + """ + raise NotImplementedError("Delete not yet implemented for Oracle Vector Store.") + + def query( + self, + query: VectorStoreQuery, + **kwargs: Any, + ) -> VectorStoreQueryResult: + """Get nodes for response.""" + + if self.verbose: + logging.info("---> Calling query on DB") + + # added to handle, optionally, Phoenix tracing + with optional_tracing("oracle_vector_db"): + # (5/03) added to handle hnsw indexes + return oracle_query( + query.query_embedding, + top_k=query.similarity_top_k, + verbose=self.verbose, + approximate=self.enable_hnsw_indexes, + ) + + def persist(self, persist_path=None, fs=None) -> None: + """ + Persist VectorStore to Oracle DB + + """ + + if self.node_dict: + # not empty, persist + logging.info("Persisting to DB...") + + embeddings = [] + pages_id = [] + pages_text = [] + pages_num = [] + + for _, node in self.node_dict.items(): + pages_id.append(node.id_) + pages_text.append(node.text) + embeddings.append(node.embedding) + pages_num.append(node.metadata["page_label"]) + + with oracledb.connect( + user=DB_USER, password=DB_PWD, dsn=self.DSN + ) as connection: + save_embeddings_in_db(embeddings, pages_id, connection) + + # TODO: where should I get book_id? + save_chunks_in_db( + pages_text, + pages_id, + pages_num=pages_num, + book_id=None, + connection=connection, + ) + + connection.commit() + + # after persisting empty the cache + self.node_dict = {} diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/python-oracledb_Vector_support_LA2_v2.pdf b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/python-oracledb_Vector_support_LA2_v2.pdf new file mode 100644 index 00000000..02b1b899 Binary files /dev/null and b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/python-oracledb_Vector_support_LA2_v2.pdf differ diff --git a/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/requirements.txt b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/requirements.txt new file mode 100644 index 00000000..c1a58f1e --- /dev/null +++ b/LLM/oda_examples/oda-oci-data-science-oracledb-23ai-nl2sql-llm/requirements.txt @@ -0,0 +1,97 @@ +accelerate==0.32.1 +annotated-types==0.7.0 +coloredlogs==15.0.1 +dataclasses-json==0.6.7 +datasets==2.14.4 +Deprecated==1.2.14 +dill==0.3.7 +dirtyjson==1.0.8 +fastjsonschema==2.20.0 +filelock==3.15.4 +FlagEmbedding==1.2.10 +flatbuffers==24.3.25 +googleapis-common-protos==1.63.1 +greenlet==3.0.3 +grpcio==1.65.1 +h11==0.14.0 +httpcore==1.0.5 +httpx==0.27.0 +huggingface-hub==0.23.3 +humanfriendly==10.0 +langchain==0.2.5 +langchain-community==0.2.5 +langchain-core==0.2.7 +langchain-text-splitters==0.2.1 +langsmith==0.1.77 +llama-index==0.10.45 +llama-index-agent-openai==0.2.7 +llama-index-cli==0.1.12 +llama-index-core==0.10.44 +llama-index-embeddings-openai==0.1.10 +llama-index-indices-managed-llama-cloud==0.1.6 +llama-index-legacy==0.9.48 +llama-index-llms-openai==0.1.22 +llama-index-multi-modal-llms-openai==0.1.6 +llama-index-program-openai==0.1.6 +llama-index-question-gen-openai==0.1.3 +llama-index-readers-file==0.1.25 +llama-index-readers-llama-parse==0.1.4 +llama-parse==0.4.4 +llamaindex-py-client==0.1.19 +marshmallow==3.21.3 +mpmath==1.3.0 +multiprocess==0.70.15 +mypy-extensions==1.0.0 +networkx==3.1 +nltk==3.8.1 +nvidia-cublas-cu12==12.1.3.1 +nvidia-cuda-cupti-cu12==12.1.105 +nvidia-cuda-nvrtc-cu12==12.1.105 +nvidia-cuda-runtime-cu12==12.1.105 +nvidia-cudnn-cu12==8.9.2.26 +nvidia-cufft-cu12==11.0.2.54 +nvidia-curand-cu12==10.3.2.106 +nvidia-cusolver-cu12==11.4.5.107 +nvidia-cusparse-cu12==12.1.0.106 +nvidia-nccl-cu12==2.20.5 +nvidia-nvjitlink-cu12==12.5.82 +nvidia-nvtx-cu12==12.1.105 +oci==2.128.2 +oci-cli==3.43.2 +onnxruntime==1.16.3 +openai==1.34.0 +openinference-instrumentation==0.1.7 +openinference-instrumentation-llama-index==2.0.0 +openinference-semantic-conventions==0.1.6 +opentelemetry-api==1.25.0 +opentelemetry-exporter-otlp==1.25.0 +opentelemetry-exporter-otlp-proto-common==1.25.0 +opentelemetry-exporter-otlp-proto-grpc==1.25.0 +opentelemetry-exporter-otlp-proto-http==1.25.0 +opentelemetry-instrumentation==0.46b0 +opentelemetry-proto==1.25.0 +opentelemetry-sdk==1.25.0 +opentelemetry-semantic-conventions==0.46b0 +orjson==3.10.5 +protobuf==4.25.3 +pyarrow==17.0.0 +pydantic==2.8.2 +pydantic_core==2.20.1 +pypdf==4.2.0 +regex==2024.5.15 +safetensors==0.4.3 +sentence-transformers==3.0.1 +SQLAlchemy==2.0.30 +striprtf==0.0.26 +sympy==1.13.1 +tenacity==8.4.1 +tiktoken==0.7.0 +tokenizers==0.19.1 +torch==2.3.1 +tqdm==4.66.4 +transformers==4.41.2 +triton==2.3.1 +typing-inspect==0.9.0 +wrapt==1.16.0 +xxhash==3.4.1 +oracledb==2.4.1 \ No newline at end of file