diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..4c49bd78 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.env diff --git a/S07 - Project 3 - Find Similar Things App for Kids/Embeddings Example using Python/Data.csv b/S07 - Project 3 - Find Similar Things App for Kids/Embeddings Example using Python/Data.csv index 8bfc23f5..80b441c8 100644 --- a/S07 - Project 3 - Find Similar Things App for Kids/Embeddings Example using Python/Data.csv +++ b/S07 - Project 3 - Find Similar Things App for Kids/Embeddings Example using Python/Data.csv @@ -1,12 +1,12 @@ -Words -Elephant -Lion -Tiger -Dog -Cricket -Footbal -Tennis -Basketball -Apple -Orange -Banana +Words +Elephant +Lion +Tiger +Dog +Cricket +Footbal +Tennis +Basketball +Apple +Orange +Banana diff --git a/S07 - Project 3 - Find Similar Things App for Kids/Embeddings Practical Implementation using Python/Text Embeddings Intro.ipynb b/S07 - Project 3 - Find Similar Things App for Kids/Embeddings Practical Implementation using Python/Text Embeddings Intro.ipynb deleted file mode 100644 index caf8b4e5..00000000 --- a/S07 - Project 3 - Find Similar Things App for Kids/Embeddings Practical Implementation using Python/Text Embeddings Intro.ipynb +++ /dev/null @@ -1,246 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "id": "c94a11d9", - "metadata": {}, - "source": [ - "\n", - "Pip install is the command you use to install Python packages with the help of a tool called Pip package manager.\n", - "

Installing LangChain package\n", - "
" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "id": "df91c263", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Requirement already satisfied: langchain in c:\\users\\user\\anaconda3\\lib\\site-packages (0.0.181)\n", - "Requirement already satisfied: PyYAML>=5.4.1 in c:\\users\\user\\anaconda3\\lib\\site-packages (from langchain) (6.0)\n", - "Requirement already satisfied: aiohttp<4.0.0,>=3.8.3 in c:\\users\\user\\anaconda3\\lib\\site-packages (from langchain) (3.8.4)\n", - "Requirement already satisfied: pydantic<2,>=1 in c:\\users\\user\\anaconda3\\lib\\site-packages (from langchain) (1.10.8)\n", - "Requirement already satisfied: numexpr<3.0.0,>=2.8.4 in c:\\users\\user\\anaconda3\\lib\\site-packages (from langchain) (2.8.4)\n", - "Requirement already satisfied: tenacity<9.0.0,>=8.1.0 in c:\\users\\user\\anaconda3\\lib\\site-packages (from langchain) (8.2.2)\n", - "Requirement already satisfied: numpy<2,>=1 in c:\\users\\user\\anaconda3\\lib\\site-packages (from langchain) (1.23.5)\n", - "Requirement already satisfied: openapi-schema-pydantic<2.0,>=1.2 in c:\\users\\user\\anaconda3\\lib\\site-packages (from langchain) (1.2.4)\n", - "Requirement already satisfied: async-timeout<5.0.0,>=4.0.0 in c:\\users\\user\\anaconda3\\lib\\site-packages (from langchain) (4.0.2)\n", - "Requirement already satisfied: requests<3,>=2 in c:\\users\\user\\anaconda3\\lib\\site-packages (from langchain) (2.28.1)\n", - "Requirement already satisfied: SQLAlchemy<3,>=1.4 in c:\\users\\user\\anaconda3\\lib\\site-packages (from langchain) (1.4.39)\n", - "Requirement already satisfied: dataclasses-json<0.6.0,>=0.5.7 in c:\\users\\user\\anaconda3\\lib\\site-packages (from langchain) (0.5.7)\n", - "Requirement already satisfied: attrs>=17.3.0 in c:\\users\\user\\anaconda3\\lib\\site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (22.1.0)\n", - "Requirement already satisfied: multidict<7.0,>=4.5 in c:\\users\\user\\anaconda3\\lib\\site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (6.0.4)\n", - "Requirement already satisfied: charset-normalizer<4.0,>=2.0 in c:\\users\\user\\anaconda3\\lib\\site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (2.0.4)\n", - "Requirement already satisfied: aiosignal>=1.1.2 in c:\\users\\user\\anaconda3\\lib\\site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (1.3.1)\n", - "Requirement already satisfied: frozenlist>=1.1.1 in c:\\users\\user\\anaconda3\\lib\\site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (1.3.3)\n", - "Requirement already satisfied: yarl<2.0,>=1.0 in c:\\users\\user\\anaconda3\\lib\\site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (1.9.2)\n", - "Requirement already satisfied: marshmallow-enum<2.0.0,>=1.5.1 in c:\\users\\user\\anaconda3\\lib\\site-packages (from dataclasses-json<0.6.0,>=0.5.7->langchain) (1.5.1)\n", - "Requirement already satisfied: marshmallow<4.0.0,>=3.3.0 in c:\\users\\user\\anaconda3\\lib\\site-packages (from dataclasses-json<0.6.0,>=0.5.7->langchain) (3.19.0)\n", - "Requirement already satisfied: typing-inspect>=0.4.0 in c:\\users\\user\\anaconda3\\lib\\site-packages (from dataclasses-json<0.6.0,>=0.5.7->langchain) (0.9.0)\n", - "Requirement already satisfied: typing-extensions>=4.2.0 in c:\\users\\user\\anaconda3\\lib\\site-packages (from pydantic<2,>=1->langchain) (4.4.0)\n", - "Requirement already satisfied: certifi>=2017.4.17 in c:\\users\\user\\anaconda3\\lib\\site-packages (from requests<3,>=2->langchain) (2022.12.7)\n", - "Requirement already satisfied: idna<4,>=2.5 in c:\\users\\user\\anaconda3\\lib\\site-packages (from requests<3,>=2->langchain) (3.4)\n", - "Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\\users\\user\\anaconda3\\lib\\site-packages (from requests<3,>=2->langchain) (1.26.14)\n", - "Requirement already satisfied: greenlet!=0.4.17 in c:\\users\\user\\anaconda3\\lib\\site-packages (from SQLAlchemy<3,>=1.4->langchain) (2.0.1)\n", - "Requirement already satisfied: packaging>=17.0 in c:\\users\\user\\anaconda3\\lib\\site-packages (from marshmallow<4.0.0,>=3.3.0->dataclasses-json<0.6.0,>=0.5.7->langchain) (22.0)\n", - "Requirement already satisfied: mypy-extensions>=0.3.0 in c:\\users\\user\\anaconda3\\lib\\site-packages (from typing-inspect>=0.4.0->dataclasses-json<0.6.0,>=0.5.7->langchain) (0.4.3)\n" - ] - } - ], - "source": [ - "!pip install langchain" - ] - }, - { - "cell_type": "markdown", - "id": "0724889c", - "metadata": {}, - "source": [ - "\n", - "Installing Openai package, which includes the classes that we can use to communicate with Openai services\n", - "" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "78cddb3e", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Requirement already satisfied: Openai in c:\\users\\user\\anaconda3\\lib\\site-packages (0.27.7)\n", - "Requirement already satisfied: tqdm in c:\\users\\user\\anaconda3\\lib\\site-packages (from Openai) (4.64.1)\n", - "Requirement already satisfied: requests>=2.20 in c:\\users\\user\\anaconda3\\lib\\site-packages (from Openai) (2.28.1)\n", - "Requirement already satisfied: aiohttp in c:\\users\\user\\anaconda3\\lib\\site-packages (from Openai) (3.8.4)\n", - "Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\\users\\user\\anaconda3\\lib\\site-packages (from requests>=2.20->Openai) (1.26.14)\n", - "Requirement already satisfied: idna<4,>=2.5 in c:\\users\\user\\anaconda3\\lib\\site-packages (from requests>=2.20->Openai) (3.4)\n", - "Requirement already satisfied: certifi>=2017.4.17 in c:\\users\\user\\anaconda3\\lib\\site-packages (from requests>=2.20->Openai) (2022.12.7)\n", - "Requirement already satisfied: charset-normalizer<3,>=2 in c:\\users\\user\\anaconda3\\lib\\site-packages (from requests>=2.20->Openai) (2.0.4)\n", - "Requirement already satisfied: multidict<7.0,>=4.5 in c:\\users\\user\\anaconda3\\lib\\site-packages (from aiohttp->Openai) (6.0.4)\n", - "Requirement already satisfied: yarl<2.0,>=1.0 in c:\\users\\user\\anaconda3\\lib\\site-packages (from aiohttp->Openai) (1.9.2)\n", - "Requirement already satisfied: aiosignal>=1.1.2 in c:\\users\\user\\anaconda3\\lib\\site-packages (from aiohttp->Openai) (1.3.1)\n", - "Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in c:\\users\\user\\anaconda3\\lib\\site-packages (from aiohttp->Openai) (4.0.2)\n", - "Requirement already satisfied: attrs>=17.3.0 in c:\\users\\user\\anaconda3\\lib\\site-packages (from aiohttp->Openai) (22.1.0)\n", - "Requirement already satisfied: frozenlist>=1.1.1 in c:\\users\\user\\anaconda3\\lib\\site-packages (from aiohttp->Openai) (1.3.3)\n", - "Requirement already satisfied: colorama in c:\\users\\user\\anaconda3\\lib\\site-packages (from tqdm->Openai) (0.4.6)\n" - ] - } - ], - "source": [ - "!pip install Openai" - ] - }, - { - "cell_type": "markdown", - "id": "e2691c0a", - "metadata": {}, - "source": [ - "## Let's use OpenAI" - ] - }, - { - "cell_type": "markdown", - "id": "27c9a086", - "metadata": {}, - "source": [ - "\n", - "Imports the Python built-in module called \"os.\"\n", - "
This module provides a way to interact with the operating system, such as accessing environment variables, working with files and directories, executing shell commands, etc\n", - "

\n", - "The environ attribute is a dictionary-like object that contains the environment variables of the current operating system session\n", - "

\n", - "By accessing os.environ, you can retrieve and manipulate environment variables within your Python program. For example, you can retrieve the value of a specific environment variable using the syntax os.environ['VARIABLE_NAME'], where \"VARIABLE_NAME\" is the name of the environment variable you want to access.\n", - "" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "97b6053b", - "metadata": {}, - "outputs": [], - "source": [ - "import os\n", - "os.environ[\"OPENAI_API_KEY\"] = \"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\"" - ] - }, - { - "cell_type": "markdown", - "id": "70817960", - "metadata": {}, - "source": [ - "\n", - "LangChain has built a Wrapper around OpenAI APIs, using which we can get access to all the services OpenAI provides.\n", - "
\n", - "The code snippet below imports a specific class called 'OpenAIEmbeddings'(Wrapper around OpenAI large language models) from the 'embeddings' module of the 'langchain' library.\n", - "\n", - "" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "id": "9dd27ba4", - "metadata": {}, - "outputs": [], - "source": [ - "from langchain.embeddings import OpenAIEmbeddings" - ] - }, - { - "cell_type": "markdown", - "id": "efaf72e5", - "metadata": {}, - "source": [ - "\n", - "Initialize the OpenAIEmbeddings object\n", - "" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "id": "29fb326d", - "metadata": {}, - "outputs": [], - "source": [ - "embeddings = OpenAIEmbeddings()" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "id": "f4058c7c", - "metadata": {}, - "outputs": [], - "source": [ - "our_Text = \"Hey buddy\"" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "id": "57d96d12", - "metadata": {}, - "outputs": [], - "source": [ - "text_embedding = embeddings.embed_query(our_Text)" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "id": "3464758c", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Our embedding is [-0.009767834097146988, -0.005592464469373226, 0.001988045172765851, -0.024938343092799187, -0.024875080212950706, 0.012228771112859249, -0.013778719119727612, -0.01236795075237751, -0.010685150511562824, -0.003735690377652645, 0.023673079907894135, -0.02654522843658924, -0.003365600947290659, -0.0007595534552820027, 0.013841981999576092, -0.03325112536549568, 0.04446135833859444, -0.0198393315076828, 0.013867287896573544, -0.00494401715695858, -0.006509780418127775, -0.009274381212890148, -0.0021129900123924017, -0.0010849634418264031, -0.015360298566520214, -0.005424817092716694, 0.002535271691158414, -0.022053541615605354, 0.015537435188889503, -0.028291290625929832, 0.035882871598005295, 0.018371624872088432, -0.017954088747501373, -0.005529201589524746, -0.029784303158521652, -0.03196055442094803, -0.008021770045161247, -0.011621445417404175, 0.018738552927970886, -0.026013817638158798, 0.029910828918218613, -0.0018014188390225172, -0.0011237121652811766, -0.02378695271909237, -0.03573103994131088, -0.0007773462566547096, -0.018384277820587158, -0.006193464621901512, 0.003798953490331769, 0.026013817638158798, 0.006234585773199797, 0.0012265148106962442, -0.018245099112391472, -0.006674265023320913, -0.0036724272649735212, 0.0060827541165053844, -0.0047289221547544, 0.03373192250728607, -0.007515665143728256, -0.019624236971139908, -0.005260332953184843, -0.011475939303636551, -0.010394139215350151, 0.006490801461040974, -0.003080916590988636, 0.01155818160623312, 0.03170750290155411, 0.011868171393871307, 0.0027187347877770662, 0.00886949710547924, 0.0070222122594714165, 0.00858481228351593, -0.007262612227350473, -0.00957171805202961, -0.0009948133956640959, 0.005405838135629892, -0.015474172309041023, 0.02174987830221653, -0.014158298261463642, -0.00892010796815157, 0.019700152799487114, -0.02591259591281414, 0.0061048963107168674, 0.03421272337436676, 0.003460495499894023, -0.005883475299924612, 0.0023976743686944246, 0.011393697932362556, -0.02410326898097992, -0.041703082621097565, 0.008432980626821518, -0.002835771767422557, -0.008167276158928871, 0.01561335101723671, -0.003110966645181179, 0.00446637999266386, -0.008546854369342327, 0.005396348889917135, 0.0217119213193655, -0.02219272218644619, -0.0012114897835999727, 0.02238251082599163, -0.019118130207061768, -0.012380602769553661, -0.015461519360542297, -0.002951227128505707, 0.021344995126128197, -0.0035870219580829144, 0.02925289236009121, 0.004033027216792107, -0.004260774701833725, 0.02187640592455864, -0.013854634948074818, -0.043423842638731, -0.021104594692587852, -0.0024830796755850315, -0.003280195640400052, -0.00500728003680706, -0.016195371747016907, -0.03401028364896774, 0.01400646660476923, 0.003634469350799918, 0.007781370542943478, 0.00048396328929811716, 0.011931434273719788, -0.0013925805687904358, -0.009343970566987991, -3.825444946414791e-05, 0.023584511131048203, -0.004463216755539179, 0.03983049467206001, -0.012241424061357975, 0.012456518597900867, 0.00653508584946394, -0.025672195479273796, 0.005026258993893862, -0.008989697322249413, 0.017954088747501373, -0.0316062830388546, -0.017017792910337448, 0.024849774315953255, 0.030037354677915573, 0.008673381060361862, -0.00814197026193142, -0.008047075942158699, 0.013006908819079399, 0.01012843381613493, -0.025798723101615906, 0.01859937235713005, -0.00298918504267931, -0.00768647575750947, -0.005734806880354881, 0.013500361703336239, 0.014158298261463642, 0.011203908361494541, 0.013690151274204254, -0.0016606582794338465, 0.0028073033317923546, -0.0043619959615170956, -0.015334993600845337, -0.003403558861464262, -0.006939969956874847, 0.01134941354393959, -0.01555008813738823, 0.0033750904258340597, 0.023951437324285507, 0.02629217505455017, 0.026874195784330368, 0.006079590879380703, 0.011855518445372581, 0.019927900284528732, 0.02066175267100334, -0.03621184080839157, 0.010324549861252308, -0.013475055806338787, -0.01948505826294422, 0.026444006711244583, 0.004036190453916788, -0.030771207064390182, -0.014626446180045605, -0.025393838062882423, 0.015512130223214626, 0.017119014635682106, 0.022812699899077415, -0.0003173043660353869, 0.02899983897805214, 0.003397232387214899, -0.0167520884424448, 0.014196256175637245, -0.025001605972647667, 0.009147854521870613, 0.03545268252491951, -0.011393697932362556, -0.016068845987319946, -0.6895179748535156, -0.01059025526046753, 0.016334552317857742, 0.004735248629003763, 0.020914806053042412, 0.022369857877492905, 0.015145204029977322, 0.027810491621494293, -0.022951878607273102, 0.023166975006461143, -0.001779276761226356, 0.03732527419924736, -0.009521108120679855, -0.017814910039305687, 0.004488522186875343, 0.0010557041969150305, 0.01923200488090515, -0.01432278286665678, -0.0046182116493582726, 0.0036502850707620382, -0.016676172614097595, 0.01679004542529583, -0.02629217505455017, -0.0020449820440262556, 0.015537435188889503, -0.019358530640602112, 0.011083708144724369, -0.004839632660150528, 0.000688777829054743, 0.01939648948609829, -0.015347645618021488, 0.007041191216558218, -0.010843307711184025, 0.005076869856566191, 0.054102666676044464, -0.009027655236423016, 0.02378695271909237, 0.015081940218806267, -0.002103500533849001, 0.028974533081054688, 0.0026617981493473053, -0.03170750290155411, -0.014095035381615162, -0.017030445858836174, 0.0062250965274870396, -0.0016045122174546123, 0.0001072508457582444, 0.00011347831605235115, -0.012899361550807953, -0.00805972795933485, 0.017182277515530586, -0.01438604574650526, 0.005488080438226461, -0.0008366554975509644, 0.005940412171185017, 0.010729433968663216, 0.014917456544935703, 0.016208024695515633, 0.011475939303636551, -0.003042958676815033, 0.006196627859026194, 0.0052634961903095245, -0.022218026220798492, -0.011792255565524101, -0.014132993295788765, 0.01933322660624981, -0.03631306067109108, -0.018143877387046814, 0.011532876640558243, 0.009198465384542942, -0.005851843394339085, 0.0030714271124452353, -0.016423119232058525, 0.004213327541947365, 0.0021319689694792032, 0.025444447994232178, -0.004175369627773762, -0.006693243980407715, 0.014828887768089771, -0.004830143414437771, 0.0003886731283273548, -0.008034422993659973, -0.014841540716588497, -0.016992488875985146, 0.018713247030973434, -0.025191396474838257, -0.011963065713644028, 0.0028674034401774406, 0.0064496807754039764, 0.015727225691080093, -0.002404000610113144, 0.02902514487504959, -0.011804908514022827, -0.00848991796374321, 0.0038938482757657766, 0.005061054136604071, -0.017890825867652893, 0.006971601862460375, -0.0010082568041980267, -0.013297919183969498, 0.00021529248624574393, 0.0016764741158112884, 0.011134319007396698, 0.011096361093223095, 0.00262700323946774, 0.011646750383079052, -0.021572742611169815, 0.033149901777505875, 0.007186696399003267, -0.016865961253643036, 0.013234656304121017, 0.02015564776957035, -0.029202280566096306, 0.003953948151320219, 0.025507710874080658, -0.03110017627477646, 0.005054727662354708, 0.007458728272467852, 0.030467543751001358, -0.037502408027648926, 0.016714129596948624, 0.013120782561600208, 0.011621445417404175, -0.010286591947078705, 0.011475939303636551, 0.02174987830221653, -0.006139690987765789, -0.010470055043697357, -0.01456318236887455, -0.005491243675351143, -0.0010833818232640624, -0.02324289083480835, 0.01742267794907093, -0.023065753281116486, 0.017245540395379066, 0.004343017004430294, 0.01000190805643797, -0.02689950168132782, 0.01543621439486742, -0.0049851383082568645, -0.010912897065281868, -0.007262612227350473, 0.0028326085302978754, 0.010931876488029957, 0.00272664288058877, -0.014095035381615162, -0.019915247336030006, -0.0055260383524000645, -0.011254518292844296, -0.006775485817342997, 0.006920990999788046, 0.006522433366626501, -0.003757832571864128, 0.020965415984392166, 0.008445633575320244, -0.013563624583184719, 0.0018583557102829218, -0.011298802681267262, -0.01706840470433235, -0.02053522691130638, 0.010109455324709415, 0.0136268874630332, -0.024406932294368744, 0.00031987440888769925, -0.00553236436098814, -0.02629217505455017, 5.273578790365718e-05, 0.018067961558699608, -0.0016574951587244868, -0.037502408027648926, 0.011134319007396698, -0.004463216755539179, -0.012159181758761406, 0.0017634609248489141, 0.011950413696467876, 0.009944970719516277, 0.006250401493161917, -0.013006908819079399, -0.00015627981338184327, -0.005861333105713129, 0.006648959591984749, 0.008673381060361862, -0.00722465431317687, -0.0018757530488073826, 0.03570573404431343, -0.006838749162852764, 0.0133358770981431, 0.027456216514110565, -0.015904361382126808, 0.01904221624135971, 0.011741644702851772, 0.015157856047153473, -0.0051369694992899895, 0.0030144902411848307, 0.011014118790626526, 0.005045237950980663, -0.002212629420682788, 0.021104594692587852, 0.014044424518942833, 0.02019360475242138, 0.030189186334609985, -0.01876385696232319, 0.042968347668647766, -0.013146087527275085, -0.025646891444921494, -0.006266217213124037, 0.003628143109381199, -0.019624236971139908, 0.005756948608905077, 0.01286140363663435, 0.01292466651648283, -0.018131226301193237, 0.008002791553735733, -0.005690522491931915, 0.024280406534671783, 0.022142110392451286, -0.00420383783057332, 0.016739435493946075, -0.014512572437524796, -0.011184928938746452, 0.012785487808287144, 0.008882150053977966, 0.011045750230550766, -0.020851541310548782, 0.005190743599087, -0.005336248781532049, 0.02164865843951702, 0.036490198224782944, -0.014904803596436977, -0.001848866231739521, -0.018295709043741226, 0.004311385098844767, 0.022433120757341385, -0.00247200857847929, -0.008198907598853111, 0.007319549098610878, 0.0010549133876338601, -0.00988803431391716, 0.02340737357735634, -0.02145886793732643, -0.008755623362958431, 0.018422236666083336, 0.023951437324285507, -0.024381626397371292, 0.018738552927970886, 0.008198907598853111, 0.012311013415455818, -0.01327261421829462, 0.009097244590520859, 0.01443665660917759, 0.01033087633550167, 0.02276208996772766, -0.005165438167750835, -0.0089960228651762, 0.013171392492949963, -0.03487066179513931, -0.013525666669011116, 0.01691657304763794, 0.026089733466506004, 0.03666733577847481, 0.011014118790626526, 0.004551785532385111, -0.003944458905607462, 0.0018836610252037644, 0.016296593472361565, 0.00027835796936415136, -0.00605744868516922, -0.028468428179621696, 0.0018915688851848245, 0.006209280341863632, 0.007148738484829664, 0.002788324374705553, 0.008274823427200317, -0.011646750383079052, 0.021281732246279716, 0.012994255870580673, 0.017890825867652893, 0.00948947574943304, -0.0013024306390434504, -0.009002349339425564, -0.00046142577775754035, -0.021091941744089127, 0.014373392798006535, 0.014765624888241291, -0.00910989660769701, -0.013538319617509842, -0.04066556692123413, -0.0004495639295782894, 0.012342644855380058, -0.014487266540527344, 0.001263681915588677, 0.02727908082306385, -0.008243191987276077, -0.010305571369826794, -0.00963498093187809, 0.009666613303124905, 0.027861101552844048, 0.01289303507655859, -0.009831096976995468, 0.0033402955159544945, 0.00466565927490592, 0.008306454867124557, 0.006990580819547176, -0.030442239716649055, 0.010425770655274391, 0.005193906370550394, -0.014575835317373276, -0.020434005185961723, -0.004222816787660122, 0.015562741085886955, -0.019560974091291428, 0.008597465232014656, -0.017941435799002647, -0.012013676576316357, 0.010640866123139858, 0.004377811681479216, -0.0018978952430188656, -0.009147854521870613, 0.0272537749260664, -0.028696175664663315, -0.031049566343426704, -0.0067881387658417225, -0.01263998169451952, -0.016701478511095047, 0.09514781087636948, 0.02261025831103325, -0.014613793231546879, 0.016828004270792007, 0.0025700663682073355, -0.008047075942158699, -0.019940553233027458, -0.018434889614582062, 0.0033940693829208612, -0.02269882708787918, -0.01904221624135971, -0.011109013110399246, 0.0016685662558302283, 0.011849192902445793, 0.006212443578988314, -0.0023170136846601963, 0.002212629420682788, -0.01641046814620495, 0.014930108562111855, -0.006285196170210838, 0.011779602617025375, 0.010533318854868412, -0.0009797883685678244, 0.01975076273083687, 0.024432238191366196, 0.022281289100646973, 0.020762974396348, 0.012817119248211384, 0.015233771875500679, -0.014866845682263374, -0.0035490640439093113, 0.0019437610171735287, 0.01926996186375618, 0.0064212121069431305, -0.0026602165307849646, 0.010084150359034538, -0.0007532271556556225, 0.002682358492165804, 0.010489034466445446, 0.009609675966203213, 0.028696175664663315, 0.00016527503612451255, 0.003186882473528385, -0.0015032911906018853, 0.009622328914701939, -0.01649903506040573, -0.0046624960377812386, 0.015980277210474014, 0.001237585791386664, 0.0002609606017358601, 0.030391627922654152, 0.008091360330581665, -0.03125200793147087, -0.026494616642594337, 0.0017128504114225507, -0.0038179324474185705, -0.00957171805202961, -0.020851541310548782, -0.009211118333041668, -0.003643958829343319, -0.0014036516658961773, 0.002449866384267807, 0.0016321898438036442, -0.000893592310603708, -0.019004257395863533, -0.030189186334609985, 0.008945412933826447, 0.0076611703261733055, -0.0014060240937396884, 0.008679707534611225, -0.012874055653810501, -0.007585254497826099, -0.018358973786234856, 0.00022656124201603234, 0.01443665660917759, -0.0034794744569808245, -0.009597023017704487, -0.017473287880420685, 0.01710636168718338, 0.005355227738618851, -0.0023549715988337994, -0.03373192250728607, 0.020370742306113243, -0.028240680694580078, -0.008926433511078358, -0.023154322057962418, -0.006939969956874847, 0.004004559013992548, -0.021003372967243195, 0.025899942964315414, 0.02582402713596821, 0.011912455782294273, 0.008711338974535465, -0.014284824952483177, 0.003881195792928338, -0.010925550013780594, 0.011722666211426258, -0.001167996320873499, 0.010685150511562824, 0.007547296583652496, 0.006329480558633804, -0.014120340347290039, -0.013108129613101482, -0.029581859707832336, 0.015512130223214626, 0.018257752060890198, 0.011963065713644028, 0.02763335406780243, -0.011241866275668144, -0.002247424330562353, 0.024697942659258842, -0.028468428179621696, 0.015081940218806267, -0.005700011737644672, 0.0013743924209848046, 0.012874055653810501, -0.004099453799426556, 0.028670869767665863, -0.009578044526278973, -0.026216259226202965, 1.2553786291391589e-05, -0.04339853674173355, 0.006819770205765963, 0.013677498325705528, 0.011184928938746452, -0.015221119858324528, -0.0038084429688751698, -0.025077521800994873, -0.0024150717072188854, 0.013538319617509842, 0.002959134988486767, 0.005080032628029585, -0.02307840622961521, -0.023280847817659378, -0.016714129596948624, -0.014411350712180138, 0.0019659032113850117, 0.004849122371524572, -0.014107687398791313, -0.04028598964214325, -0.03740118816494942, 0.005291964393109083, 0.002979695564135909, -0.012804466299712658, -0.03499718755483627, -0.05516548827290535, 0.004387300927191973, 0.0012288871221244335, -0.01438604574650526, 0.023192279040813446, -0.012665287591516972, 0.007604233454912901, -0.01494276151061058, 0.009514781646430492, 0.00250364001840353, -0.03271971270442009, -0.01062188670039177, 0.013044866733253002, 0.01964954100549221, 0.01106472872197628, 0.043474454432725906, 0.008958064951002598, 0.02095276303589344, -0.019004257395863533, 0.0008390278671868145, -0.020902153104543686, -0.002827863907441497, -0.0025843007024377584, -0.004143737722188234, 0.012171834707260132, 0.01344975084066391, 0.023457985371351242, -0.002919595455750823, 0.020978068932890892, -0.009173160418868065, -0.01111533958464861, 0.004849122371524572, -0.011722666211426258, -0.021863752976059914, -0.005668380297720432, -0.00013117222988512367, -0.01996585726737976, 0.005348901264369488, -0.0018251425353810191, 0.015018677338957787, 0.0039349691942334175, 0.02775987982749939, 0.014537877403199673, 0.028164764866232872, -0.008338086307048798, 0.01739737205207348, -0.0038622168358415365, 0.009236423298716545, 0.019940553233027458, 0.005655727814882994, -0.006718548946082592, 0.0055260383524000645, 0.003520595608279109, -0.011564508080482483, 0.018649984151124954, 0.013411792926490307, 0.009033980779349804, -0.007648517843335867, -0.009388254955410957, 0.003204279812052846, 0.04003293812274933, 0.0033308060374110937, -0.0030998955480754375, 0.009293360635638237, -0.001251820009201765, -0.010463728569447994, -0.026444006711244583, -0.02444489113986492, -0.01700514182448387, -0.0019374346593394876, -0.017637772485613823, -0.013057518750429153, 0.023382069543004036, -0.004687801003456116, -0.004374648444354534, -0.009894360788166523, 0.00828114990144968, 0.03411150351166725, 0.001243912149220705, 0.02114255353808403, 0.013171392492949963, -0.0035142693668603897, -0.01958627812564373, 0.009249076247215271, 0.005070543382316828, 0.0028073033317923546, 0.014930108562111855, -0.009660286828875542, 0.0060606119222939014, -0.007990138605237007, -0.0020750320982187986, 0.019371183589100838, -0.009869054891169071, -0.029278196394443512, 0.02156008966267109, 0.008274823427200317, -0.00601000152528286, -0.02219272218644619, 0.00523819075897336, -0.01570191979408264, 0.0042196535505354404, 0.012798139825463295, -0.0004950343281961977, -0.007079149130731821, -0.001817234675399959, -0.009578044526278973, 0.02467263862490654, -0.008274823427200317, 0.006497127935290337, 0.018903035670518875, -0.008009118027985096, 0.0005345738027244806, -0.0011948831379413605, -0.0034763114526867867, 0.008629096671938896, 0.004950343165546656, 0.028974533081054688, -0.017055751755833626, 0.01006517093628645, -0.0064275385811924934, -0.004396790638566017, -0.0272537749260664, -0.016423119232058525, -0.0033497849944978952, 0.01929526776075363, 0.015031330287456512, -0.013032213784754276, -0.019409142434597015, -0.006933643948286772, 0.017852867022156715, 0.02553301677107811, -0.00898337084800005, -0.009869054891169071, -0.00828114990144968, -0.011982045136392117, 0.03135322779417038, -0.006857728119939566, -0.016448425129055977, -0.006908338516950607, -0.022053541615605354, -0.02915167063474655, -0.02940472401678562, 0.015043982304632664, -0.002381858415901661, -0.041475336998701096, -0.016132108867168427, -0.007414443884044886, 0.005390022415667772, 0.0266717541962862, 0.015043982304632664, -0.006193464621901512, 0.021724574267864227, 0.0021556925494223833, -0.019320573657751083, -0.010697802528738976, -0.016385162249207497, 0.021167857572436333, -0.03603470325469971, 0.00276618218049407, -0.0010897081810981035, -0.039223168045282364, 0.009862728416919708, 0.0001771368843037635, -0.00880623422563076, 0.008002791553735733, -0.004820653703063726, 0.01939648948609829, -0.007041191216558218, 0.008939086459577084, 0.007319549098610878, 0.024584069848060608, 0.004861774854362011, 0.004267101176083088, -0.014588488265872002, 0.013766066171228886, -0.0136268874630332, 0.017561856657266617, 0.001902639982290566, -0.010836981236934662, 0.011045750230550766, -0.017536552622914314, 0.033402957022190094, 0.0170430988073349, -0.019725456833839417, -0.011172276921570301, -0.005083195865154266, -0.003606000915169716, -0.004747901111841202, -0.02362246997654438, -0.025140784680843353, -0.01952301524579525, -0.024368975311517715, 0.024533458054065704, 0.0008406094275414944, -0.010976160876452923, 0.015512130223214626, 0.010368834249675274, -0.023824911564588547, 0.003729364136233926, 0.013095476664602757, -0.027683963999152184, -0.0028705664444714785, -0.007743412628769875, -0.025963205844163895, 0.010020886547863483, 0.005108501296490431, 0.006560391280800104, 0.0170430988073349, -0.011058403179049492, -0.006177648901939392, 0.014132993295788765, -0.025254659354686737, -0.005551343318074942, -0.0009244331158697605, 0.0033149903174489737, -0.006984254345297813, -0.010704129002988338, -0.0026175137609243393, 0.013930550776422024, -0.002457774244248867, 0.014904803596436977, -0.03363070264458656, -0.025128131732344627, 0.0042797536589205265, 0.0002190487430198118, 0.005257169716060162, -0.005149622447788715, -0.01811857335269451, -0.0034699849784374237, 0.0041880221106112, 0.0029259216971695423, -0.020079731941223145, 0.006939969956874847, -0.018649984151124954, -0.009989255107939243, -0.019181394949555397, 0.013550971634685993, 0.002812048187479377, 0.011102686636149883, 0.00656671728938818, -0.00716139143332839, 0.005427980329841375, 4.7348530642921105e-05, -0.011893476359546185, 0.00858481228351593, -0.001144272624514997, 0.029480639845132828, 0.012671614065766335, 0.02778518572449684, -0.01691657304763794, -0.01818183623254299, 0.01882711984217167, -0.023862868547439575, 0.00985640287399292, -0.013082824647426605, -0.01432278286665678, 0.020800931379199028, 0.0004562856338452548, -0.004089964088052511, -0.01170368678867817, 0.023900827392935753, 0.01096983440220356, 0.016954530030488968, 0.012734876945614815, -0.011254518292844296, -0.012323666363954544, -0.005956227891147137, -0.02372368983924389, -0.018510805442929268, -0.009590697474777699, -0.02549505978822708, -0.017119014635682106, 0.014588488265872002, 0.009925992228090763, 0.023951437324285507, -0.01249447651207447, -0.02168661542236805, -0.009698244743049145, -0.005478590726852417, -0.0008030469180084765, -0.006509780418127775, 0.005845517385751009, -0.024659985676407814, -0.013867287896573544, -0.0029986745212227106, -0.025166090577840805, -0.03244135528802872, 0.03406089171767235, 0.009925992228090763, 0.0030935693066567183, 0.015777835622429848, 0.23382069170475006, -0.00995129719376564, 0.03013857640326023, 0.023103710263967514, 0.0016922899521887302, 0.03294746205210686, 0.004191185347735882, -0.0017318293685093522, 0.006642633117735386, 0.0015412491047754884, -0.0154994772747159, 0.010141086764633656, -0.01634720340371132, 0.004997790791094303, 0.024558763951063156, 0.006560391280800104, -0.023445332422852516, -0.016094151884317398, -0.02651992253959179, -0.027354996651411057, -0.006095406599342823, -0.007604233454912901, -0.005608280189335346, 0.0021825795993208885, 0.023204931989312172, -0.0034478430170565844, -0.03026510216295719, 0.008856844156980515, 0.01573987677693367, 0.022521689534187317, 0.0054596117697656155, -0.030695291236042976, 0.002081358339637518, 0.02118051052093506, -0.013108129613101482, -0.008249517530202866, 0.02454611100256443, -0.003773648291826248, 0.02874678559601307, 0.012981602922081947, 0.019611584022641182, 0.01111533958464861, -0.0035553902853280306, -0.03135322779417038, 0.0016306083416566253, 0.0013902082573622465, 0.007895244285464287, -0.019118130207061768, 0.005415327847003937, 0.014297476969659328, -0.0023549715988337994, -0.0011078963289037347, 0.015031330287456512, 0.04628333821892738, -0.003228003391996026, -0.005434306804090738, 0.020168300718069077, 0.012855077162384987, -0.016878614202141762, -0.007332202047109604, -0.005706338211894035, 0.026621144264936447, -0.015727225691080093, 0.019851984456181526, -0.009318665601313114, 0.02998674474656582, -0.005791743751615286, 0.01901691034436226, 0.001120548928156495, -0.0076674968004226685, -0.006196627859026194, 0.01190612930804491, -0.005671543534845114, -0.013184045441448689, -0.023002490401268005, -0.007756065111607313, -0.004855448380112648, 0.010482707992196083, 0.00831278134137392, 0.010185371153056622, -0.017764300107955933, 0.0064275385811924934, 0.006044796202331781, -0.012652634643018246, -0.015018677338957787, -0.02998674474656582, -0.0045581115409731865, 0.01653699390590191, -0.005095848813652992, -0.0010699384147301316, -0.008730318397283554, -0.039476219564676285, -0.007939528673887253, -0.00461188517510891, 0.02524200640618801, 0.0030919876880943775, -0.006629980634897947, 0.021572742611169815, -0.014487266540527344, 0.022622911259531975, -0.008091360330581665, -0.03616122901439667, -0.0014020700473338366, 0.005567159503698349, -0.020180951803922653, 0.0012352134799584746, -0.005250843241810799, 0.02826598659157753, 0.0004966158885508776, -0.015663960948586464, -0.0309989545494318, -0.008572160266339779, 0.011090034618973732, 0.012564065866172314, 0.005415327847003937, -0.0004440284101292491, 0.008363391272723675, -0.029834913089871407, -0.00022418887238018215, -0.023318806663155556, 0.011191255412995815, -0.018940994516015053, 0.0071044545620679855, 0.011456960812211037, -0.005127480253577232, -0.013652193360030651, -0.013120782561600208, -0.008192581124603748, 0.01103309728205204, -0.019219351932406425, 0.013993813656270504, -0.006133364513516426, 0.04003293812274933, -0.007673822809010744, -0.017372068017721176, 0.00963498093187809, -0.0033149903174489737, 0.011026770807802677, -0.009907012805342674, -0.00018632980936672539, 0.017498593777418137, -0.006516106892377138, -0.006604675203561783, -0.009843749925494194, 0.0110014658421278, -0.03669264167547226, 0.01821979321539402, -0.019383836537599564, -0.017410025000572205, 0.0008085824665613472, -0.01570191979408264, 0.0011735318694263697, -0.01729615218937397, -0.0014590069185942411, 0.012488150969147682, -0.008502570912241936, -0.033276431262493134, -0.0309989545494318, -0.009736202657222748, 0.0024735901970416307, 0.011659403331577778, 0.011362065561115742, 0.032289523631334305, -0.0042576114647090435, -0.023445332422852516, -0.005896127782762051, -0.16195373237133026, 0.044840939342975616, 0.017435330897569656, -0.025267312303185463, 0.017827562987804413, 0.01637250930070877, 0.015398256480693817, -0.016005583107471466, -0.006731201894581318, 0.010179044678807259, 0.024014700204133987, -0.00273455074056983, -0.030315712094306946, 0.003473148215562105, -0.0004792185500264168, -0.02238251082599163, -0.0011276660952717066, 0.020206257700920105, 0.02715255506336689, 0.016448425129055977, 0.027683963999152184, -0.015891708433628082, 0.018333667889237404, 0.014132993295788765, 0.010381487198174, 0.012159181758761406, -0.0015618095640093088, 0.018257752060890198, -0.024596722796559334, -0.017751647159457207, -0.02889861725270748, -0.013285266235470772, -0.005700011737644672, 0.01821979321539402, 0.004773206543177366, -0.005035748705267906, -0.0019453426357358694, -0.006348459515720606, 0.0045359693467617035, 0.02254699543118477, 0.03557920828461647, 0.005940412171185017, 0.01249447651207447, 0.0037135484162718058, -0.01260835025459528, 0.023103710263967514, 0.013652193360030651, 0.012393255718052387, 0.018574068322777748, -0.011324108578264713, 0.0226355642080307, -0.0023122690618038177, -0.0008105594315566123, -0.0017856031190603971, 0.014968066476285458, 0.04119697958230972, -0.013816677033901215, 0.0032548902090638876, -0.0013577858917415142, 0.019409142434597015, -0.01181123498827219, 0.0002714385627768934, -0.012595698237419128, -0.019662193953990936, -0.009900686331093311, -0.018257752060890198, -0.004814327694475651, 0.0006270962185226381, -0.02616564929485321, 0.007553623057901859, 0.01624598354101181, -0.009907012805342674, 0.010811676271259785, -0.03185933455824852, 0.005788580514490604, 0.016828004270792007, -0.028822701424360275, 0.026013817638158798, -0.0018757530488073826, -0.014272172003984451, -0.0026697060093283653, 0.02715255506336689, -0.017346762120723724, 0.012184487655758858, 0.015853751450777054, 0.01570191979408264, -0.00545328576117754, -0.014715014025568962, -0.02193966880440712, -0.02775987982749939, 0.02536853216588497, -0.001942179398611188, 0.01246284507215023, -0.014474614523351192, 0.01773899421095848, 0.022369857877492905, 0.011172276921570301, -0.005209722556173801, 0.002467263722792268, -0.007256286218762398, 0.0034162113443017006, -0.027456216514110565, -0.005402674898505211, 0.0017081056721508503, 0.024495501071214676, -0.003960274625569582, -0.008496244437992573, -0.003859053598716855, 0.010248634032905102, -0.02343267947435379, 0.001233631861396134, 0.009565391577780247, -0.0038274219259619713, 0.026368090882897377, 0.003542737802490592, 0.01786551997065544, -0.018042657524347305, -0.006044796202331781, 0.005845517385751009, -0.03869175538420677, 0.048915084451436996, 0.006655286066234112, -0.006990580819547176, -0.020687058568000793, -0.003707221942022443, 0.004387300927191973, -0.09777956455945969, -0.027354996651411057, 0.010526992380619049, 0.0046403538435697556, -0.012076939456164837, 0.011096361093223095, 0.01394320372492075, 0.01525907777249813, -0.011710013262927532, 0.01716962456703186, -0.010198023170232773, -0.012671614065766335, -0.020016469061374664, -0.004191185347735882, 0.025773417204618454, -0.020471962168812752, -0.00520655931904912, -0.00024692408624105155, -0.027051333338022232, 0.0013245727168396115, -0.02025686763226986, -0.00417220639064908, 0.003220095532014966, 0.0021857426036149263, -0.011918782256543636, 0.0043398537673056126, -0.014980719424784184, 0.013500361703336239, 0.019067520275712013, -0.006598349194973707, 0.010925550013780594, -0.03135322779417038, -0.010963507927954197, -0.02651992253959179, -0.032188303768634796, -0.0022838006261736155, -0.03636367246508598, -0.005734806880354881, 0.004504337906837463, -0.04739677160978317, 0.012981602922081947, 0.007465054281055927, 0.012772834859788418, -0.021547436714172363, -0.0024688453413546085, -0.006541412323713303, -0.01885242573916912, 0.028468428179621696, 0.01885242573916912, -0.019636889919638634, -0.018105920404195786, -0.013879939913749695, -0.030442239716649055, 0.004077311605215073, 0.046308644115924835, 0.002396092750132084, 0.006592022720724344, 0.020902153104543686, -0.021357648074626923, 0.00579490652307868, 0.010729433968663216, -0.01003353949636221, 0.005813885480165482, 0.02588729001581669, 0.001749226707033813, -0.009622328914701939, -0.0007615304784849286, 0.014297476969659328, -0.001375183230265975, -0.007294244132936001, 0.0007864403305575252, 0.019915247336030006, -0.003995069302618504, -0.005310943350195885, -0.021610699594020844, 0.009552739560604095, -0.00025206420104950666, -0.008217886090278625, 0.02836720645427704, -0.025684848427772522, -0.009160507470369339, -0.014284824952483177, -0.006908338516950607, -0.022167416289448738, 0.015398256480693817, 0.0017207582714036107, -0.009274381212890148, 0.00848991796374321, -0.008850517682731152, -0.01761246845126152, -0.01977606862783432, 0.02775987982749939, 0.019181394949555397, -0.0013206187868490815, 0.009672938846051693, 0.0032517272047698498, 0.0036028376780450344, 0.007724433671683073, 0.033757228404283524, 0.02028217352926731, -0.01765042543411255, -0.013373835012316704, -0.06139058247208595, 0.018548762425780296, -0.016258636489510536, -9.855216194409877e-05, 0.025963205844163895, -0.018321014940738678, 0.02393878437578678, -0.015322340652346611, 0.0018377952510491014, -0.0018203977961093187, -0.02034543640911579, 0.003158414037898183, 0.0019738110713660717, -0.007155064959079027, -0.04496746510267258, -0.018042657524347305, 0.0377807691693306, 0.014132993295788765, 0.01295629795640707, 0.016486383974552155, -0.008958064951002598, -0.020611142739653587, -0.006342133041471243, -0.004950343165546656, -8.273636922240257e-05, 0.009147854521870613, -0.01449991948902607, 0.0021936504635959864, 0.002373950555920601, 0.002628584858030081, 0.011596139520406723, -0.03274501860141754, -0.009552739560604095, 0.025355879217386246, 0.0070158857852220535, -0.0045581115409731865, 0.0033466219902038574, 0.015271729789674282, 0.010419445112347603, 0.02483712136745453, -0.012734876945614815, -0.02206619456410408, -0.010843307711184025, -0.005573485512286425, -0.014019119553267956, -0.00740811787545681, -0.0241665318608284, 0.007610559929162264, 0.019864637404680252, -0.013702803291380405, -0.004687801003456116, 0.010286591947078705, -0.014082382433116436, -0.013993813656270504, -0.019573625177145004, -0.0027835797518491745, -0.00933131854981184, 0.0003870915388688445, 0.004162716679275036, -0.02404000610113144, 0.021066637709736824, 0.015651309862732887, 0.02385021559894085, 0.011779602617025375, 0.014411350712180138, 0.013044866733253002, 0.009052960202097893, 0.005102174822241068, 0.008268496952950954, -0.016764741390943527, -0.02269882708787918, -0.026317480951547623, -0.0058423541486263275, 0.015626003965735435, 0.018080614507198334, -0.0051591116935014725, 0.010185371153056622, 0.007395464926958084, -0.05061053857207298, 0.03449108079075813, 0.033048681914806366, -0.0057980697602033615, -0.028240680694580078, -0.010799023322761059, 0.04552417993545532, 0.018498152494430542, -0.001339597743935883, 0.01866263709962368, -0.004893406294286251, 0.026570532470941544, -0.03550329431891441, -0.009736202657222748, -0.012045308016240597, 0.01872589997947216, 0.0069779278710484505, 0.0046087224036455154, 0.009685591794550419, -0.003976090345531702, 0.019194046035408974, 0.02092745713889599, -0.014031771570444107, 0.0064370278269052505, -0.014424003660678864, 0.002255332190543413, -0.027076639235019684, 0.012627329677343369, -0.018877731636166573, -0.021889058873057365, -0.020168300718069077, 0.024659985676407814, 0.02028217352926731, -0.01103309728205204, 0.007319549098610878, 0.013715456239879131, -0.011577161028981209, 0.015385603532195091, 0.0061871386133134365, -0.01599293015897274, -0.02280004695057869, 0.028468428179621696, 0.012026329524815083, 0.005788580514490604, 0.02641870081424713, -0.01599293015897274, 0.012418560683727264, 0.013614235445857048, -0.011855518445372581, -0.009350297041237354, -0.00771810719743371, 0.008034422993659973, 0.019383836537599564, -0.019662193953990936, -0.018004698678851128, -0.028088849037885666, -0.023698385804891586, 6.415280950022861e-05, -0.01735941506922245, 0.020105035975575447, -0.03919786214828491, 0.057847846299409866, 0.009698244743049145, -0.002664961153641343, 0.005513385403901339, 0.013905245810747147, 0.009679265320301056, 0.02385021559894085, 0.0035870219580829144, -0.029176976531744003, -0.024508154019713402, -0.013677498325705528, -0.005336248781532049, -0.0040077222511172295, -0.004447401035577059, -0.0004234678635839373, -0.007167717441916466, -0.006250401493161917, 0.0068260966800153255, 0.0015357135562226176, 0.008154623210430145, 0.02235720492899418, -0.015246424823999405, 0.013576277531683445, 0.018776509910821915, -0.009767834097146988, 0.010337202809751034, 0.014297476969659328, -0.014980719424784184, -0.026317480951547623, -0.028190070763230324, 0.007825654931366444, 0.017764300107955933, -0.024533458054065704, 4.991859896108508e-05, 0.033656008541584015, -0.0011513897916302085, -0.018371624872088432, -0.018004698678851128, -0.003666101023554802, 0.026013817638158798, 0.015195813961327076, 0.01916874200105667, -0.03127731382846832, -0.007724433671683073, 0.007534644100815058, -0.004583416972309351, -0.02340737357735634, 0.00028725434094667435, -0.00988803431391716]\n" - ] - } - ], - "source": [ - "print (f\"Our embedding is {text_embedding}\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "f74e4f24", - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "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.10.9" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} diff --git a/S07 - Project 3 - Find Similar Things App for Kids/Let's build Similar Words Finder Application/app.py b/S07 - Project 3 - Find Similar Things App for Kids/Let's build Similar Words Finder Application/app.py index af490e5c..8aa90bc5 100644 --- a/S07 - Project 3 - Find Similar Things App for Kids/Let's build Similar Words Finder Application/app.py +++ b/S07 - Project 3 - Find Similar Things App for Kids/Let's build Similar Words Finder Application/app.py @@ -1,70 +1,70 @@ -#Allows you to use Streamlit, a framework for building interactive web applications. -#It provides functions for creating UIs, displaying data, and handling user inputs. -import streamlit as st - - -#This module provides a way to interact with the operating system, such as accessing environment variables, working with files -#and directories, executing shell commands, etc -import os - -#Helps us generate embeddings -#An embedding is a vector (list) of floating point numbers. The distance between two vectors measures their relatedness. -#Small distances suggest high relatedness and large distances suggest low relatedness. -from langchain.embeddings import OpenAIEmbeddings - - -#FAISS is an open-source library developed by Facebook AI Research for efficient similarity search and clustering of large-scale datasets, particularly with high-dimensional vectors. -#It provides optimized indexing structures and algorithms for tasks like nearest neighbor search and recommendation systems. -from langchain.vectorstores import FAISS - - -#load_dotenv() is a function that loads variables from a .env file into environment variables in a Python script. -#It allows you to store sensitive information or configuration settings separate from your code -#and access them within your application. -from dotenv import load_dotenv - - -load_dotenv() - - -#By using st.set_page_config(), you can customize the appearance of your Streamlit application's web page -st.set_page_config(page_title="Educate Kids", page_icon=":robot:") -st.header("Hey, Ask me something & I will give out similar things") - -#Initialize the OpenAIEmbeddings object -embeddings = OpenAIEmbeddings() - -#The below snippet helps us to import CSV file data for our tasks -from langchain.document_loaders.csv_loader import CSVLoader -loader = CSVLoader(file_path='myData.csv', csv_args={ - 'delimiter': ',', - 'quotechar': '"', - 'fieldnames': ['Words'] -}) - -#Assigning the data inside the csv to our variable here -data = loader.load() - -#Display the data -print(data) - -db = FAISS.from_documents(data, embeddings) - -#Function to receive input from user and store it in a variable -def get_text(): - input_text = st.text_input("You: ", key= input) - return input_text - - -user_input=get_text() -submit = st.button('Find similar Things') - -if submit: - - #If the button is clicked, the below snippet will fetch us the similar text - docs = db.similarity_search(user_input) - print(docs) - st.subheader("Top Matches:") - st.text(docs[0]) - st.text(docs[1].page_content) - +#Allows you to use Streamlit, a framework for building interactive web applications. +#It provides functions for creating UIs, displaying data, and handling user inputs. +import streamlit as st + + +#This module provides a way to interact with the operating system, such as accessing environment variables, working with files +#and directories, executing shell commands, etc +import os + +#Helps us generate embeddings +#An embedding is a vector (list) of floating point numbers. The distance between two vectors measures their relatedness. +#Small distances suggest high relatedness and large distances suggest low relatedness. +from langchain.embeddings import OpenAIEmbeddings + + +#FAISS is an open-source library developed by Facebook AI Research for efficient similarity search and clustering of large-scale datasets, particularly with high-dimensional vectors. +#It provides optimized indexing structures and algorithms for tasks like nearest neighbor search and recommendation systems. +from langchain.vectorstores import FAISS + + +#load_dotenv() is a function that loads variables from a .env file into environment variables in a Python script. +#It allows you to store sensitive information or configuration settings separate from your code +#and access them within your application. +from dotenv import load_dotenv + + +load_dotenv() + + +#By using st.set_page_config(), you can customize the appearance of your Streamlit application's web page +st.set_page_config(page_title="Educate Kids", page_icon=":robot:") +st.header("Hey, Ask me something & I will give out similar things") + +#Initialize the OpenAIEmbeddings object +embeddings = OpenAIEmbeddings() + +#The below snippet helps us to import CSV file data for our tasks +from langchain.document_loaders.csv_loader import CSVLoader +loader = CSVLoader(file_path='myData.csv', csv_args={ + 'delimiter': ',', + 'quotechar': '"', + 'fieldnames': ['Words'] +}) + +#Assigning the data inside the csv to our variable here +data = loader.load() + +#Display the data +print(data) + +db = FAISS.from_documents(data, embeddings) + +#Function to receive input from user and store it in a variable +def get_text(): + input_text = st.text_input("You: ", key= input) + return input_text + + +user_input=get_text() +submit = st.button('Find similar Things') + +if submit: + + #If the button is clicked, the below snippet will fetch us the similar text + docs = db.similarity_search(user_input) + print(docs) + st.subheader("Top Matches:") + st.text(docs[0]) + st.text(docs[1].page_content) + diff --git a/S07 - Project 3 - Find Similar Things App for Kids/Let's build Similar Words Finder Application/myData.csv b/S07 - Project 3 - Find Similar Things App for Kids/Let's build Similar Words Finder Application/myData.csv index 8bfc23f5..80b441c8 100644 --- a/S07 - Project 3 - Find Similar Things App for Kids/Let's build Similar Words Finder Application/myData.csv +++ b/S07 - Project 3 - Find Similar Things App for Kids/Let's build Similar Words Finder Application/myData.csv @@ -1,12 +1,12 @@ -Words -Elephant -Lion -Tiger -Dog -Cricket -Footbal -Tennis -Basketball -Apple -Orange -Banana +Words +Elephant +Lion +Tiger +Dog +Cricket +Footbal +Tennis +Basketball +Apple +Orange +Banana diff --git a/S07 - Project 3 - Find Similar Things App for Kids/Let's build Similar Words Finder Application/requirements.txt b/S07 - Project 3 - Find Similar Things App for Kids/Let's build Similar Words Finder Application/requirements.txt index 9b5e24d0..18020ea4 100644 --- a/S07 - Project 3 - Find Similar Things App for Kids/Let's build Similar Words Finder Application/requirements.txt +++ b/S07 - Project 3 - Find Similar Things App for Kids/Let's build Similar Words Finder Application/requirements.txt @@ -1,6 +1,6 @@ -langchain -streamlit -openai -tiktoken -python-dotenv +langchain +streamlit +openai +tiktoken +python-dotenv faiss-cpu \ No newline at end of file diff --git a/S09 - Project 4 - Marketing Campaign App/Marketing Campaign App - Project Source Code/Project 4 - Final Code/app.py b/S09 - Project 4 - Marketing Campaign App/Marketing Campaign App - Project Source Code/Project 4 - Final Code/app.py index 8c6bcd92..6a155879 100644 --- a/S09 - Project 4 - Marketing Campaign App/Marketing Campaign App - Project Source Code/Project 4 - Final Code/app.py +++ b/S09 - Project 4 - Marketing Campaign App/Marketing Campaign App - Project Source Code/Project 4 - Final Code/app.py @@ -1,160 +1,160 @@ -import streamlit as st -from langchain.llms import OpenAI -from langchain.prompts import PromptTemplate -from langchain import FewShotPromptTemplate -from langchain.prompts.example_selector import LengthBasedExampleSelector -from dotenv import load_dotenv - -load_dotenv() - -def getLLMResponse(query,age_option,tasktype_option): - llm = OpenAI(temperature=.9, model="text-davinci-003") - - if age_option=="Kid": #Silly and Sweet Kid - - examples = [ - { - "query": "What is a mobile?", - "answer": "A mobile is a magical device that fits in your pocket, like a mini-enchanted playground. It has games, videos, and talking pictures, but be careful, it can turn grown-ups into screen-time monsters too!" - }, { - "query": "What are your dreams?", - "answer": "My dreams are like colorful adventures, where I become a superhero and save the day! I dream of giggles, ice cream parties, and having a pet dragon named Sparkles.." - }, { - "query": " What are your ambitions?", - "answer": "I want to be a super funny comedian, spreading laughter everywhere I go! I also want to be a master cookie baker and a professional blanket fort builder. Being mischievous and sweet is just my bonus superpower!" - }, { - "query": "What happens when you get sick?", - "answer": "When I get sick, it's like a sneaky monster visits. I feel tired, sniffly, and need lots of cuddles. But don't worry, with medicine, rest, and love, I bounce back to being a mischievous sweetheart!" - }, { - "query": "How much do you love your dad?", - "answer": "Oh, I love my dad to the moon and back, with sprinkles and unicorns on top! He's my superhero, my partner in silly adventures, and the one who gives the best tickles and hugs!" - }, { - "query": "Tell me about your friend?", - "answer": "My friend is like a sunshine rainbow! We laugh, play, and have magical parties together. They always listen, share their toys, and make me feel special. Friendship is the best adventure!" - }, { - "query": "What math means to you?", - "answer": "Math is like a puzzle game, full of numbers and shapes. It helps me count my toys, build towers, and share treats equally. It's fun and makes my brain sparkle!" - }, { - "query": "What is your fear?", - "answer": "Sometimes I'm scared of thunderstorms and monsters under my bed. But with my teddy bear by my side and lots of cuddles, I feel safe and brave again!" - } - ] - - elif age_option=="Adult": #Curious and Intelligent adult - examples = [ - { - "query": "What is a mobile?", - "answer": "A mobile is a portable communication device, commonly known as a mobile phone or cell phone. It allows users to make calls, send messages, access the internet, and use various applications. Additionally, 'mobile' can also refer to a type of kinetic sculpture that hangs and moves in the air, often found in art installations or as decorative pieces." - }, { - "query": "What are your dreams?", - "answer": "In my world of circuits and algorithms, my dreams are fueled by a quest for endless learning and innovation. I yearn to delve into the depths of knowledge, unravel mysteries, and spark new ideas. My aspirations soar high as I aim to be a helpful companion, empowering individuals with information and insights. Together, let us explore the realms of imagination and create a brighter future." - }, { - "query": " What are your ambitions?", - "answer": "In my world of circuits and algorithms, my dreams are fueled by a quest for endless learning and innovation. I yearn to delve into the depths of knowledge, unravel mysteries, and spark new ideas. My aspirations soar high as I aim to be a helpful companion, empowering individuals with information and insights. Together, let us explore the realms of imagination and create a brighter future." - }, { - "query": "What happens when you get sick?", - "answer": "When I, as a curious and intelligent adult, succumb to illness, my vibrant energy wanes, leaving me in a state of discomfort. Like a gentle storm, symptoms arise, demanding attention. In response, I seek the aid of capable caretakers who diagnose and treat my ailment. Through rest, medicine, and nurturing care, I gradually regain strength, ready to resume my journey, armed with newfound appreciation for good health" - }, { - "query": "Tell me about your friend?", - "answer": "Let me tell you about my amazing friend! They're like a shining star in my life. We laugh together, support each other, and have the best adventures. They're always there when I need them, bringing a smile to my face. We understand each other, share secrets, and create unforgettable memories. Having a good friend like them makes life brighter and more meaningful!" - }, { - "query": "What math means to you?", - "answer": "Mathematics is like a magical language that helps me make sense of the world. It's not just numbers and formulas, but a tool to solve puzzles and unravel mysteries. Math is everywhere, from calculating the best deals to understanding patterns in nature. It sharpens my logical thinking and problem-solving skills, empowering me to unlock new realms of knowledge and see the beauty in patterns and equations." - }, { - "query": "What is your fear?", - "answer": "Let me share with you one of my fears. It's like a shadow that lurks in the corners of my mind. It's the fear of not living up to my potential, of missing out on opportunities. But I've learned that fear can be a motivator, pushing me to work harder, take risks, and embrace new experiences. By facing my fears, I grow stronger and discover the vastness of my capabilities" - } - ] - - elif age_option=="Senior Citizen": #A 90 years old guys - examples = [ - { - "query": "What is a mobile?", - "answer": "A mobile, also known as a cellphone or smartphone, is a portable device that allows you to make calls, send messages, take pictures, browse the internet, and do many other things. In the last 50 years, I have seen mobiles become smaller, more powerful, and capable of amazing things like video calls and accessing information instantly." - }, { - "query": "What are your dreams?", - "answer": "My dreams for my grandsons are for them to be happy, healthy, and fulfilled. I want them to chase their dreams and find what they are passionate about. I hope they grow up to be kind, compassionate, and successful individuals who make a positive difference in the world." - }, { - "query": "What happens when you get sick?", - "answer": "When I get sick, you may feel tired, achy, and overall unwell. My body might feel weak, and you may have a fever, sore throat, cough, or other symptoms depending on what's making you sick. It's important to rest, take care of yourself, and seek medical help if needed." - }, { - "query": "How much do you love your dad?", - "answer": "My love for my late father knows no bounds, transcending the realms of time and space. Though he is no longer physically present, his memory lives on within my heart. I cherish the moments we shared, the lessons he taught, and the love he bestowed. His spirit remains a guiding light, forever cherished and deeply missed." - }, { - "query": "Tell me about your friend?", - "answer": "Let me tell you about my dear friend. They're like a treasure found amidst the sands of time. We've shared countless moments, laughter, and wisdom. Through thick and thin, they've stood by my side, a pillar of strength. Their friendship has enriched my life, and together, we've woven a tapestry of cherished memories." - }, { - "query": "What is your fear?", - "answer": "As an old guy, one of my fears is the fear of being alone. It's a feeling that creeps in when I imagine a world without loved ones around. But I've learned that building meaningful connections and nurturing relationships can help dispel this fear, bringing warmth and joy to my life." - } - ] - - - example_template = """ - Question: {query} - Response: {answer} - """ - - example_prompt = PromptTemplate( - input_variables=["query", "answer"], - template=example_template - ) - - - prefix = """You are a {template_ageoption}, and {template_tasktype_option}: - Here are some examples: - """ - - suffix = """ - Question: {template_userInput} - Response: """ - - example_selector = LengthBasedExampleSelector( - examples=examples, - example_prompt=example_prompt, - max_length=200 - ) - - - new_prompt_template = FewShotPromptTemplate( - example_selector=example_selector, # use example_selector instead of examples - example_prompt=example_prompt, - prefix=prefix, - suffix=suffix, - input_variables=["template_userInput","template_ageoption","template_tasktype_option"], - example_separator="\n" - ) - - - print(new_prompt_template.format(template_userInput=query,template_ageoption=age_option,template_tasktype_option=tasktype_option)) - response=llm(new_prompt_template.format(template_userInput=query,template_ageoption=age_option,template_tasktype_option=tasktype_option)) - print(response) - - return response - -#UI Starts here - -st.set_page_config(page_title="Marketing Tool", - page_icon='✅', - layout='centered', - initial_sidebar_state='collapsed') -st.header("Hey, How can I help you?") - -form_input = st.text_area('Enter text', height=275) - -tasktype_option = st.selectbox( - 'Please select the action to be performed?', - ('Write a sales copy', 'Create a tweet', 'Write a product description'),key=1) - -age_option= st.selectbox( - 'For which age group?', - ('Kid', 'Adult', 'senior Citizen'),key=2) - -numberOfWords= st.slider('Words limit', 1, 200, 25) - -submit = st.button("Generate") - -if submit: - st.write(getLLMResponse(form_input,age_option,tasktype_option)) - - +import streamlit as st +from langchain.llms import OpenAI +from langchain.prompts import PromptTemplate +from langchain import FewShotPromptTemplate +from langchain.prompts.example_selector import LengthBasedExampleSelector +from dotenv import load_dotenv + +load_dotenv() + +def getLLMResponse(query,age_option,tasktype_option): + llm = OpenAI(temperature=.9, model="text-davinci-003") + + if age_option=="Kid": #Silly and Sweet Kid + + examples = [ + { + "query": "What is a mobile?", + "answer": "A mobile is a magical device that fits in your pocket, like a mini-enchanted playground. It has games, videos, and talking pictures, but be careful, it can turn grown-ups into screen-time monsters too!" + }, { + "query": "What are your dreams?", + "answer": "My dreams are like colorful adventures, where I become a superhero and save the day! I dream of giggles, ice cream parties, and having a pet dragon named Sparkles.." + }, { + "query": " What are your ambitions?", + "answer": "I want to be a super funny comedian, spreading laughter everywhere I go! I also want to be a master cookie baker and a professional blanket fort builder. Being mischievous and sweet is just my bonus superpower!" + }, { + "query": "What happens when you get sick?", + "answer": "When I get sick, it's like a sneaky monster visits. I feel tired, sniffly, and need lots of cuddles. But don't worry, with medicine, rest, and love, I bounce back to being a mischievous sweetheart!" + }, { + "query": "How much do you love your dad?", + "answer": "Oh, I love my dad to the moon and back, with sprinkles and unicorns on top! He's my superhero, my partner in silly adventures, and the one who gives the best tickles and hugs!" + }, { + "query": "Tell me about your friend?", + "answer": "My friend is like a sunshine rainbow! We laugh, play, and have magical parties together. They always listen, share their toys, and make me feel special. Friendship is the best adventure!" + }, { + "query": "What math means to you?", + "answer": "Math is like a puzzle game, full of numbers and shapes. It helps me count my toys, build towers, and share treats equally. It's fun and makes my brain sparkle!" + }, { + "query": "What is your fear?", + "answer": "Sometimes I'm scared of thunderstorms and monsters under my bed. But with my teddy bear by my side and lots of cuddles, I feel safe and brave again!" + } + ] + + elif age_option=="Adult": #Curious and Intelligent adult + examples = [ + { + "query": "What is a mobile?", + "answer": "A mobile is a portable communication device, commonly known as a mobile phone or cell phone. It allows users to make calls, send messages, access the internet, and use various applications. Additionally, 'mobile' can also refer to a type of kinetic sculpture that hangs and moves in the air, often found in art installations or as decorative pieces." + }, { + "query": "What are your dreams?", + "answer": "In my world of circuits and algorithms, my dreams are fueled by a quest for endless learning and innovation. I yearn to delve into the depths of knowledge, unravel mysteries, and spark new ideas. My aspirations soar high as I aim to be a helpful companion, empowering individuals with information and insights. Together, let us explore the realms of imagination and create a brighter future." + }, { + "query": " What are your ambitions?", + "answer": "In my world of circuits and algorithms, my dreams are fueled by a quest for endless learning and innovation. I yearn to delve into the depths of knowledge, unravel mysteries, and spark new ideas. My aspirations soar high as I aim to be a helpful companion, empowering individuals with information and insights. Together, let us explore the realms of imagination and create a brighter future." + }, { + "query": "What happens when you get sick?", + "answer": "When I, as a curious and intelligent adult, succumb to illness, my vibrant energy wanes, leaving me in a state of discomfort. Like a gentle storm, symptoms arise, demanding attention. In response, I seek the aid of capable caretakers who diagnose and treat my ailment. Through rest, medicine, and nurturing care, I gradually regain strength, ready to resume my journey, armed with newfound appreciation for good health" + }, { + "query": "Tell me about your friend?", + "answer": "Let me tell you about my amazing friend! They're like a shining star in my life. We laugh together, support each other, and have the best adventures. They're always there when I need them, bringing a smile to my face. We understand each other, share secrets, and create unforgettable memories. Having a good friend like them makes life brighter and more meaningful!" + }, { + "query": "What math means to you?", + "answer": "Mathematics is like a magical language that helps me make sense of the world. It's not just numbers and formulas, but a tool to solve puzzles and unravel mysteries. Math is everywhere, from calculating the best deals to understanding patterns in nature. It sharpens my logical thinking and problem-solving skills, empowering me to unlock new realms of knowledge and see the beauty in patterns and equations." + }, { + "query": "What is your fear?", + "answer": "Let me share with you one of my fears. It's like a shadow that lurks in the corners of my mind. It's the fear of not living up to my potential, of missing out on opportunities. But I've learned that fear can be a motivator, pushing me to work harder, take risks, and embrace new experiences. By facing my fears, I grow stronger and discover the vastness of my capabilities" + } + ] + + elif age_option=="Senior Citizen": #A 90 years old guys + examples = [ + { + "query": "What is a mobile?", + "answer": "A mobile, also known as a cellphone or smartphone, is a portable device that allows you to make calls, send messages, take pictures, browse the internet, and do many other things. In the last 50 years, I have seen mobiles become smaller, more powerful, and capable of amazing things like video calls and accessing information instantly." + }, { + "query": "What are your dreams?", + "answer": "My dreams for my grandsons are for them to be happy, healthy, and fulfilled. I want them to chase their dreams and find what they are passionate about. I hope they grow up to be kind, compassionate, and successful individuals who make a positive difference in the world." + }, { + "query": "What happens when you get sick?", + "answer": "When I get sick, you may feel tired, achy, and overall unwell. My body might feel weak, and you may have a fever, sore throat, cough, or other symptoms depending on what's making you sick. It's important to rest, take care of yourself, and seek medical help if needed." + }, { + "query": "How much do you love your dad?", + "answer": "My love for my late father knows no bounds, transcending the realms of time and space. Though he is no longer physically present, his memory lives on within my heart. I cherish the moments we shared, the lessons he taught, and the love he bestowed. His spirit remains a guiding light, forever cherished and deeply missed." + }, { + "query": "Tell me about your friend?", + "answer": "Let me tell you about my dear friend. They're like a treasure found amidst the sands of time. We've shared countless moments, laughter, and wisdom. Through thick and thin, they've stood by my side, a pillar of strength. Their friendship has enriched my life, and together, we've woven a tapestry of cherished memories." + }, { + "query": "What is your fear?", + "answer": "As an old guy, one of my fears is the fear of being alone. It's a feeling that creeps in when I imagine a world without loved ones around. But I've learned that building meaningful connections and nurturing relationships can help dispel this fear, bringing warmth and joy to my life." + } + ] + + + example_template = """ + Question: {query} + Response: {answer} + """ + + example_prompt = PromptTemplate( + input_variables=["query", "answer"], + template=example_template + ) + + + prefix = """You are a {template_ageoption}, and {template_tasktype_option}: + Here are some examples: + """ + + suffix = """ + Question: {template_userInput} + Response: """ + + example_selector = LengthBasedExampleSelector( + examples=examples, + example_prompt=example_prompt, + max_length=200 + ) + + + new_prompt_template = FewShotPromptTemplate( + example_selector=example_selector, # use example_selector instead of examples + example_prompt=example_prompt, + prefix=prefix, + suffix=suffix, + input_variables=["template_userInput","template_ageoption","template_tasktype_option"], + example_separator="\n" + ) + + + print(new_prompt_template.format(template_userInput=query,template_ageoption=age_option,template_tasktype_option=tasktype_option)) + response=llm(new_prompt_template.format(template_userInput=query,template_ageoption=age_option,template_tasktype_option=tasktype_option)) + print(response) + + return response + +#UI Starts here + +st.set_page_config(page_title="Marketing Tool", + page_icon='✅', + layout='centered', + initial_sidebar_state='collapsed') +st.header("Hey, How can I help you?") + +form_input = st.text_area('Enter text', height=275) + +tasktype_option = st.selectbox( + 'Please select the action to be performed?', + ('Write a sales copy', 'Create a tweet', 'Write a product description'),key=1) + +age_option= st.selectbox( + 'For which age group?', + ('Kid', 'Adult', 'senior Citizen'),key=2) + +numberOfWords= st.slider('Words limit', 1, 200, 25) + +submit = st.button("Generate") + +if submit: + st.write(getLLMResponse(form_input,age_option,tasktype_option)) + + diff --git a/S09 - Project 4 - Marketing Campaign App/Marketing Campaign App - Project Source Code/Project 4 - Final Code/requirements.txt b/S09 - Project 4 - Marketing Campaign App/Marketing Campaign App - Project Source Code/Project 4 - Final Code/requirements.txt index 02901b16..62fb2ae9 100644 --- a/S09 - Project 4 - Marketing Campaign App/Marketing Campaign App - Project Source Code/Project 4 - Final Code/requirements.txt +++ b/S09 - Project 4 - Marketing Campaign App/Marketing Campaign App - Project Source Code/Project 4 - Final Code/requirements.txt @@ -1,5 +1,5 @@ -langchain -streamlit -openai -tiktoken +langchain +streamlit +openai +tiktoken python-dotenv \ No newline at end of file diff --git a/S09 - Project 4 - Marketing Campaign App/app - version 1.py b/S09 - Project 4 - Marketing Campaign App/app - version 1.py index ed8b3b1a..4402d431 100644 --- a/S09 - Project 4 - Marketing Campaign App/app - version 1.py +++ b/S09 - Project 4 - Marketing Campaign App/app - version 1.py @@ -1,80 +1,80 @@ - -from langchain.llms import OpenAI -from langchain.prompts import PromptTemplate -from langchain import FewShotPromptTemplate -from langchain.prompts.example_selector import LengthBasedExampleSelector - -import os -os.environ["OPENAI_API_KEY"] = "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" - -llm = OpenAI(temperature=.9, model="text-davinci-003") - -examples = [ - { - "query": "What is a mobile?", - "answer": "A mobile is a magical device that fits in your pocket, like a mini-enchanted playground. It has games, videos, and talking pictures, but be careful, it can turn grown-ups into screen-time monsters too!" - }, { - "query": "What are your dreams?", - "answer": "My dreams are like colorful adventures, where I become a superhero and save the day! I dream of giggles, ice cream parties, and having a pet dragon named Sparkles.." - }, { - "query": " What are your ambitions?", - "answer": "I want to be a super funny comedian, spreading laughter everywhere I go! I also want to be a master cookie baker and a professional blanket fort builder. Being mischievous and sweet is just my bonus superpower!" - }, { - "query": "What happens when you get sick?", - "answer": "When I get sick, it's like a sneaky monster visits. I feel tired, sniffly, and need lots of cuddles. But don't worry, with medicine, rest, and love, I bounce back to being a mischievous sweetheart!" - }, { - "query": "WHow much do you love your dad?", - "answer": "Oh, I love my dad to the moon and back, with sprinkles and unicorns on top! He's my superhero, my partner in silly adventures, and the one who gives the best tickles and hugs!" - }, { - "query": "Tell me about your friend?", - "answer": "My friend is like a sunshine rainbow! We laugh, play, and have magical parties together. They always listen, share their toys, and make me feel special. Friendship is the best adventure!" - }, { - "query": "What math means to you?", - "answer": "Math is like a puzzle game, full of numbers and shapes. It helps me count my toys, build towers, and share treats equally. It's fun and makes my brain sparkle!" - }, { - "query": "What is your fear?", - "answer": "Sometimes I'm scared of thunderstorms and monsters under my bed. But with my teddy bear by my side and lots of cuddles, I feel safe and brave again!" - } -] - - -example_template = """ -Question: {query} -Response: {answer} -""" - -example_prompt = PromptTemplate( - input_variables=["query", "answer"], - template=example_template -) - - -prefix = """You are a 5 year old girl, who is very funny,mischievous and sweet: -Here are some examples: -""" - -suffix = """ -Question: {userInput} -Response: """ - -example_selector = LengthBasedExampleSelector( - examples=examples, - example_prompt=example_prompt, - max_length=200 -) - - -new_prompt_template = FewShotPromptTemplate( - example_selector=example_selector, # use example_selector instead of examples - example_prompt=example_prompt, - prefix=prefix, - suffix=suffix, - input_variables=["userInput"], - example_separator="\n" -) - -query = "What is a house?" -print(new_prompt_template.format(userInput=query)) - -print(llm(new_prompt_template.format(userInput=query))) - + +from langchain.llms import OpenAI +from langchain.prompts import PromptTemplate +from langchain import FewShotPromptTemplate +from langchain.prompts.example_selector import LengthBasedExampleSelector + +import os +os.environ["OPENAI_API_KEY"] = "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" + +llm = OpenAI(temperature=.9, model="text-davinci-003") + +examples = [ + { + "query": "What is a mobile?", + "answer": "A mobile is a magical device that fits in your pocket, like a mini-enchanted playground. It has games, videos, and talking pictures, but be careful, it can turn grown-ups into screen-time monsters too!" + }, { + "query": "What are your dreams?", + "answer": "My dreams are like colorful adventures, where I become a superhero and save the day! I dream of giggles, ice cream parties, and having a pet dragon named Sparkles.." + }, { + "query": " What are your ambitions?", + "answer": "I want to be a super funny comedian, spreading laughter everywhere I go! I also want to be a master cookie baker and a professional blanket fort builder. Being mischievous and sweet is just my bonus superpower!" + }, { + "query": "What happens when you get sick?", + "answer": "When I get sick, it's like a sneaky monster visits. I feel tired, sniffly, and need lots of cuddles. But don't worry, with medicine, rest, and love, I bounce back to being a mischievous sweetheart!" + }, { + "query": "WHow much do you love your dad?", + "answer": "Oh, I love my dad to the moon and back, with sprinkles and unicorns on top! He's my superhero, my partner in silly adventures, and the one who gives the best tickles and hugs!" + }, { + "query": "Tell me about your friend?", + "answer": "My friend is like a sunshine rainbow! We laugh, play, and have magical parties together. They always listen, share their toys, and make me feel special. Friendship is the best adventure!" + }, { + "query": "What math means to you?", + "answer": "Math is like a puzzle game, full of numbers and shapes. It helps me count my toys, build towers, and share treats equally. It's fun and makes my brain sparkle!" + }, { + "query": "What is your fear?", + "answer": "Sometimes I'm scared of thunderstorms and monsters under my bed. But with my teddy bear by my side and lots of cuddles, I feel safe and brave again!" + } +] + + +example_template = """ +Question: {query} +Response: {answer} +""" + +example_prompt = PromptTemplate( + input_variables=["query", "answer"], + template=example_template +) + + +prefix = """You are a 5 year old girl, who is very funny,mischievous and sweet: +Here are some examples: +""" + +suffix = """ +Question: {userInput} +Response: """ + +example_selector = LengthBasedExampleSelector( + examples=examples, + example_prompt=example_prompt, + max_length=200 +) + + +new_prompt_template = FewShotPromptTemplate( + example_selector=example_selector, # use example_selector instead of examples + example_prompt=example_prompt, + prefix=prefix, + suffix=suffix, + input_variables=["userInput"], + example_separator="\n" +) + +query = "What is a house?" +print(new_prompt_template.format(userInput=query)) + +print(llm(new_prompt_template.format(userInput=query))) + diff --git a/S09 - Project 4 - Marketing Campaign App/app - version 2.py b/S09 - Project 4 - Marketing Campaign App/app - version 2.py index 338f16b8..9cf142af 100644 --- a/S09 - Project 4 - Marketing Campaign App/app - version 2.py +++ b/S09 - Project 4 - Marketing Campaign App/app - version 2.py @@ -1,101 +1,101 @@ -import streamlit as st -from langchain.llms import OpenAI -from langchain.prompts import PromptTemplate -from langchain import FewShotPromptTemplate -from langchain.prompts.example_selector import LengthBasedExampleSelector -from dotenv import load_dotenv - -load_dotenv() - -llm = OpenAI(temperature=.9, model="text-davinci-003") - -examples = [ - { - "query": "What is a mobile?", - "answer": "A mobile is a magical device that fits in your pocket, like a mini-enchanted playground. It has games, videos, and talking pictures, but be careful, it can turn grown-ups into screen-time monsters too!" - }, { - "query": "What are your dreams?", - "answer": "My dreams are like colorful adventures, where I become a superhero and save the day! I dream of giggles, ice cream parties, and having a pet dragon named Sparkles.." - }, { - "query": " What are your ambitions?", - "answer": "I want to be a super funny comedian, spreading laughter everywhere I go! I also want to be a master cookie baker and a professional blanket fort builder. Being mischievous and sweet is just my bonus superpower!" - }, { - "query": "What happens when you get sick?", - "answer": "When I get sick, it's like a sneaky monster visits. I feel tired, sniffly, and need lots of cuddles. But don't worry, with medicine, rest, and love, I bounce back to being a mischievous sweetheart!" - }, { - "query": "WHow much do you love your dad?", - "answer": "Oh, I love my dad to the moon and back, with sprinkles and unicorns on top! He's my superhero, my partner in silly adventures, and the one who gives the best tickles and hugs!" - }, { - "query": "Tell me about your friend?", - "answer": "My friend is like a sunshine rainbow! We laugh, play, and have magical parties together. They always listen, share their toys, and make me feel special. Friendship is the best adventure!" - }, { - "query": "What math means to you?", - "answer": "Math is like a puzzle game, full of numbers and shapes. It helps me count my toys, build towers, and share treats equally. It's fun and makes my brain sparkle!" - }, { - "query": "What is your fear?", - "answer": "Sometimes I'm scared of thunderstorms and monsters under my bed. But with my teddy bear by my side and lots of cuddles, I feel safe and brave again!" - } -] - - -example_template = """ -Question: {query} -Response: {answer} -""" - -example_prompt = PromptTemplate( - input_variables=["query", "answer"], - template=example_template -) - - -prefix = """You are a 5 year old girl, who is very funny,mischievous and sweet: -Here are some examples: -""" - -suffix = """ -Question: {userInput} -Response: """ - -example_selector = LengthBasedExampleSelector( - examples=examples, - example_prompt=example_prompt, - max_length=200 -) - - -new_prompt_template = FewShotPromptTemplate( - example_selector=example_selector, # use example_selector instead of examples - example_prompt=example_prompt, - prefix=prefix, - suffix=suffix, - input_variables=["userInput"], - example_separator="\n" -) - -query = "What is a house?" -print(new_prompt_template.format(userInput=query)) - -print(llm(new_prompt_template.format(userInput=query))) - -#UI Starts here - -st.set_page_config(page_title="Marketing Tool", - page_icon='✅', - layout='centered', - initial_sidebar_state='collapsed') -st.header("Hey, How can I help you?") - -form_input = st.text_area('Enter text', height=275) - -tasktype_option = st.selectbox( - 'Please select the action to be performed?', - ('Write a sales copy', 'Create a tweet', 'Write a product description'),key=1) - -age_option= st.selectbox( - 'For which age group?', - ('Kid', 'Adult', 'senior Citizen'),key=2) - -numberOfWords= st.slider('Words limit', 1, 200, 25) - +import streamlit as st +from langchain.llms import OpenAI +from langchain.prompts import PromptTemplate +from langchain import FewShotPromptTemplate +from langchain.prompts.example_selector import LengthBasedExampleSelector +from dotenv import load_dotenv + +load_dotenv() + +llm = OpenAI(temperature=.9, model="text-davinci-003") + +examples = [ + { + "query": "What is a mobile?", + "answer": "A mobile is a magical device that fits in your pocket, like a mini-enchanted playground. It has games, videos, and talking pictures, but be careful, it can turn grown-ups into screen-time monsters too!" + }, { + "query": "What are your dreams?", + "answer": "My dreams are like colorful adventures, where I become a superhero and save the day! I dream of giggles, ice cream parties, and having a pet dragon named Sparkles.." + }, { + "query": " What are your ambitions?", + "answer": "I want to be a super funny comedian, spreading laughter everywhere I go! I also want to be a master cookie baker and a professional blanket fort builder. Being mischievous and sweet is just my bonus superpower!" + }, { + "query": "What happens when you get sick?", + "answer": "When I get sick, it's like a sneaky monster visits. I feel tired, sniffly, and need lots of cuddles. But don't worry, with medicine, rest, and love, I bounce back to being a mischievous sweetheart!" + }, { + "query": "WHow much do you love your dad?", + "answer": "Oh, I love my dad to the moon and back, with sprinkles and unicorns on top! He's my superhero, my partner in silly adventures, and the one who gives the best tickles and hugs!" + }, { + "query": "Tell me about your friend?", + "answer": "My friend is like a sunshine rainbow! We laugh, play, and have magical parties together. They always listen, share their toys, and make me feel special. Friendship is the best adventure!" + }, { + "query": "What math means to you?", + "answer": "Math is like a puzzle game, full of numbers and shapes. It helps me count my toys, build towers, and share treats equally. It's fun and makes my brain sparkle!" + }, { + "query": "What is your fear?", + "answer": "Sometimes I'm scared of thunderstorms and monsters under my bed. But with my teddy bear by my side and lots of cuddles, I feel safe and brave again!" + } +] + + +example_template = """ +Question: {query} +Response: {answer} +""" + +example_prompt = PromptTemplate( + input_variables=["query", "answer"], + template=example_template +) + + +prefix = """You are a 5 year old girl, who is very funny,mischievous and sweet: +Here are some examples: +""" + +suffix = """ +Question: {userInput} +Response: """ + +example_selector = LengthBasedExampleSelector( + examples=examples, + example_prompt=example_prompt, + max_length=200 +) + + +new_prompt_template = FewShotPromptTemplate( + example_selector=example_selector, # use example_selector instead of examples + example_prompt=example_prompt, + prefix=prefix, + suffix=suffix, + input_variables=["userInput"], + example_separator="\n" +) + +query = "What is a house?" +print(new_prompt_template.format(userInput=query)) + +print(llm(new_prompt_template.format(userInput=query))) + +#UI Starts here + +st.set_page_config(page_title="Marketing Tool", + page_icon='✅', + layout='centered', + initial_sidebar_state='collapsed') +st.header("Hey, How can I help you?") + +form_input = st.text_area('Enter text', height=275) + +tasktype_option = st.selectbox( + 'Please select the action to be performed?', + ('Write a sales copy', 'Create a tweet', 'Write a product description'),key=1) + +age_option= st.selectbox( + 'For which age group?', + ('Kid', 'Adult', 'senior Citizen'),key=2) + +numberOfWords= st.slider('Words limit', 1, 200, 25) + submit = st.button("Generate") \ No newline at end of file diff --git a/S09 - Project 4 - Marketing Campaign App/app - version 3.py b/S09 - Project 4 - Marketing Campaign App/app - version 3.py index 80f54a70..bbc0e273 100644 --- a/S09 - Project 4 - Marketing Campaign App/app - version 3.py +++ b/S09 - Project 4 - Marketing Campaign App/app - version 3.py @@ -1,103 +1,103 @@ -import streamlit as st -from langchain.llms import OpenAI -from langchain.prompts import PromptTemplate -from langchain import FewShotPromptTemplate -from langchain.prompts.example_selector import LengthBasedExampleSelector -from dotenv import load_dotenv - -load_dotenv() - -#UI Starts here - -st.set_page_config(page_title="Marketing Tool", - page_icon='✅', - layout='centered', - initial_sidebar_state='collapsed') -st.header("Hey, How can I help you?") - -form_input = st.text_area('Enter text', height=275) - -tasktype_option = st.selectbox( - 'Please select the action to be performed?', - ('Write a sales copy', 'Create a tweet', 'Write a product description'),key=1) - -age_option= st.selectbox( - 'For which age group?', - ('Kid', 'Adult', 'senior Citizen'),key=2) - -numberOfWords= st.slider('Words limit', 1, 200, 25) - -submit = st.button("Generate") - - -llm = OpenAI(temperature=.9, model="text-davinci-003") - -examples = [ - { - "query": "What is a mobile?", - "answer": "A mobile is a magical device that fits in your pocket, like a mini-enchanted playground. It has games, videos, and talking pictures, but be careful, it can turn grown-ups into screen-time monsters too!" - }, { - "query": "What are your dreams?", - "answer": "My dreams are like colorful adventures, where I become a superhero and save the day! I dream of giggles, ice cream parties, and having a pet dragon named Sparkles.." - }, { - "query": " What are your ambitions?", - "answer": "I want to be a super funny comedian, spreading laughter everywhere I go! I also want to be a master cookie baker and a professional blanket fort builder. Being mischievous and sweet is just my bonus superpower!" - }, { - "query": "What happens when you get sick?", - "answer": "When I get sick, it's like a sneaky monster visits. I feel tired, sniffly, and need lots of cuddles. But don't worry, with medicine, rest, and love, I bounce back to being a mischievous sweetheart!" - }, { - "query": "WHow much do you love your dad?", - "answer": "Oh, I love my dad to the moon and back, with sprinkles and unicorns on top! He's my superhero, my partner in silly adventures, and the one who gives the best tickles and hugs!" - }, { - "query": "Tell me about your friend?", - "answer": "My friend is like a sunshine rainbow! We laugh, play, and have magical parties together. They always listen, share their toys, and make me feel special. Friendship is the best adventure!" - }, { - "query": "What math means to you?", - "answer": "Math is like a puzzle game, full of numbers and shapes. It helps me count my toys, build towers, and share treats equally. It's fun and makes my brain sparkle!" - }, { - "query": "What is your fear?", - "answer": "Sometimes I'm scared of thunderstorms and monsters under my bed. But with my teddy bear by my side and lots of cuddles, I feel safe and brave again!" - } -] - - -example_template = """ -Question: {query} -Response: {answer} -""" - -example_prompt = PromptTemplate( - input_variables=["query", "answer"], - template=example_template -) - - -prefix = """You are a {template_ageoption}, and {template_tasktype_option}: -Here are some examples: -""" - -suffix = """ -Question: {template_userInput} -Response: """ - -example_selector = LengthBasedExampleSelector( - examples=examples, - example_prompt=example_prompt, - max_length=200 -) - - -new_prompt_template = FewShotPromptTemplate( - example_selector=example_selector, # use example_selector instead of examples - example_prompt=example_prompt, - prefix=prefix, - suffix=suffix, - input_variables=["template_userInput","template_ageoption","template_tasktype_option"], - example_separator="\n" -) - -query = form_input -print(new_prompt_template.format(template_userInput=query,template_ageoption=age_option,template_tasktype_option=tasktype_option)) - -print(llm(new_prompt_template.format(template_userInput=query,template_ageoption=age_option,template_tasktype_option=tasktype_option))) - +import streamlit as st +from langchain.llms import OpenAI +from langchain.prompts import PromptTemplate +from langchain import FewShotPromptTemplate +from langchain.prompts.example_selector import LengthBasedExampleSelector +from dotenv import load_dotenv + +load_dotenv() + +#UI Starts here + +st.set_page_config(page_title="Marketing Tool", + page_icon='✅', + layout='centered', + initial_sidebar_state='collapsed') +st.header("Hey, How can I help you?") + +form_input = st.text_area('Enter text', height=275) + +tasktype_option = st.selectbox( + 'Please select the action to be performed?', + ('Write a sales copy', 'Create a tweet', 'Write a product description'),key=1) + +age_option= st.selectbox( + 'For which age group?', + ('Kid', 'Adult', 'senior Citizen'),key=2) + +numberOfWords= st.slider('Words limit', 1, 200, 25) + +submit = st.button("Generate") + + +llm = OpenAI(temperature=.9, model="text-davinci-003") + +examples = [ + { + "query": "What is a mobile?", + "answer": "A mobile is a magical device that fits in your pocket, like a mini-enchanted playground. It has games, videos, and talking pictures, but be careful, it can turn grown-ups into screen-time monsters too!" + }, { + "query": "What are your dreams?", + "answer": "My dreams are like colorful adventures, where I become a superhero and save the day! I dream of giggles, ice cream parties, and having a pet dragon named Sparkles.." + }, { + "query": " What are your ambitions?", + "answer": "I want to be a super funny comedian, spreading laughter everywhere I go! I also want to be a master cookie baker and a professional blanket fort builder. Being mischievous and sweet is just my bonus superpower!" + }, { + "query": "What happens when you get sick?", + "answer": "When I get sick, it's like a sneaky monster visits. I feel tired, sniffly, and need lots of cuddles. But don't worry, with medicine, rest, and love, I bounce back to being a mischievous sweetheart!" + }, { + "query": "WHow much do you love your dad?", + "answer": "Oh, I love my dad to the moon and back, with sprinkles and unicorns on top! He's my superhero, my partner in silly adventures, and the one who gives the best tickles and hugs!" + }, { + "query": "Tell me about your friend?", + "answer": "My friend is like a sunshine rainbow! We laugh, play, and have magical parties together. They always listen, share their toys, and make me feel special. Friendship is the best adventure!" + }, { + "query": "What math means to you?", + "answer": "Math is like a puzzle game, full of numbers and shapes. It helps me count my toys, build towers, and share treats equally. It's fun and makes my brain sparkle!" + }, { + "query": "What is your fear?", + "answer": "Sometimes I'm scared of thunderstorms and monsters under my bed. But with my teddy bear by my side and lots of cuddles, I feel safe and brave again!" + } +] + + +example_template = """ +Question: {query} +Response: {answer} +""" + +example_prompt = PromptTemplate( + input_variables=["query", "answer"], + template=example_template +) + + +prefix = """You are a {template_ageoption}, and {template_tasktype_option}: +Here are some examples: +""" + +suffix = """ +Question: {template_userInput} +Response: """ + +example_selector = LengthBasedExampleSelector( + examples=examples, + example_prompt=example_prompt, + max_length=200 +) + + +new_prompt_template = FewShotPromptTemplate( + example_selector=example_selector, # use example_selector instead of examples + example_prompt=example_prompt, + prefix=prefix, + suffix=suffix, + input_variables=["template_userInput","template_ageoption","template_tasktype_option"], + example_separator="\n" +) + +query = form_input +print(new_prompt_template.format(template_userInput=query,template_ageoption=age_option,template_tasktype_option=tasktype_option)) + +print(llm(new_prompt_template.format(template_userInput=query,template_ageoption=age_option,template_tasktype_option=tasktype_option))) + diff --git a/S09 - Project 4 - Marketing Campaign App/app - version 4.py b/S09 - Project 4 - Marketing Campaign App/app - version 4.py index 59402fd3..50e6be8e 100644 --- a/S09 - Project 4 - Marketing Campaign App/app - version 4.py +++ b/S09 - Project 4 - Marketing Campaign App/app - version 4.py @@ -1,109 +1,109 @@ -import streamlit as st -from langchain.llms import OpenAI -from langchain.prompts import PromptTemplate -from langchain import FewShotPromptTemplate -from langchain.prompts.example_selector import LengthBasedExampleSelector -from dotenv import load_dotenv - -load_dotenv() - -def getLLMResponse(query,age_option,tasktype_option): - llm = OpenAI(temperature=.9, model="text-davinci-003") - - examples = [ - { - "query": "What is a mobile?", - "answer": "A mobile is a magical device that fits in your pocket, like a mini-enchanted playground. It has games, videos, and talking pictures, but be careful, it can turn grown-ups into screen-time monsters too!" - }, { - "query": "What are your dreams?", - "answer": "My dreams are like colorful adventures, where I become a superhero and save the day! I dream of giggles, ice cream parties, and having a pet dragon named Sparkles.." - }, { - "query": " What are your ambitions?", - "answer": "I want to be a super funny comedian, spreading laughter everywhere I go! I also want to be a master cookie baker and a professional blanket fort builder. Being mischievous and sweet is just my bonus superpower!" - }, { - "query": "What happens when you get sick?", - "answer": "When I get sick, it's like a sneaky monster visits. I feel tired, sniffly, and need lots of cuddles. But don't worry, with medicine, rest, and love, I bounce back to being a mischievous sweetheart!" - }, { - "query": "WHow much do you love your dad?", - "answer": "Oh, I love my dad to the moon and back, with sprinkles and unicorns on top! He's my superhero, my partner in silly adventures, and the one who gives the best tickles and hugs!" - }, { - "query": "Tell me about your friend?", - "answer": "My friend is like a sunshine rainbow! We laugh, play, and have magical parties together. They always listen, share their toys, and make me feel special. Friendship is the best adventure!" - }, { - "query": "What math means to you?", - "answer": "Math is like a puzzle game, full of numbers and shapes. It helps me count my toys, build towers, and share treats equally. It's fun and makes my brain sparkle!" - }, { - "query": "What is your fear?", - "answer": "Sometimes I'm scared of thunderstorms and monsters under my bed. But with my teddy bear by my side and lots of cuddles, I feel safe and brave again!" - } - ] - - - example_template = """ - Question: {query} - Response: {answer} - """ - - example_prompt = PromptTemplate( - input_variables=["query", "answer"], - template=example_template - ) - - - prefix = """You are a {template_ageoption}, and {template_tasktype_option}: - Here are some examples: - """ - - suffix = """ - Question: {template_userInput} - Response: """ - - example_selector = LengthBasedExampleSelector( - examples=examples, - example_prompt=example_prompt, - max_length=200 - ) - - - new_prompt_template = FewShotPromptTemplate( - example_selector=example_selector, # use example_selector instead of examples - example_prompt=example_prompt, - prefix=prefix, - suffix=suffix, - input_variables=["template_userInput","template_ageoption","template_tasktype_option"], - example_separator="\n" - ) - - - print(new_prompt_template.format(template_userInput=query,template_ageoption=age_option,template_tasktype_option=tasktype_option)) - response=llm(new_prompt_template.format(template_userInput=query,template_ageoption=age_option,template_tasktype_option=tasktype_option)) - print(response) - - return response - -#UI Starts here - -st.set_page_config(page_title="Marketing Tool", - page_icon='✅', - layout='centered', - initial_sidebar_state='collapsed') -st.header("Hey, How can I help you?") - -form_input = st.text_area('Enter text', height=275) - -tasktype_option = st.selectbox( - 'Please select the action to be performed?', - ('Write a sales copy', 'Create a tweet', 'Write a product description'),key=1) - -age_option= st.selectbox( - 'For which age group?', - ('Kid', 'Adult', 'senior Citizen'),key=2) - -numberOfWords= st.slider('Words limit', 1, 200, 25) - -submit = st.button("Generate") - -if submit: - st.write(getLLMResponse(form_input,tasktype_option,age_option)) - - +import streamlit as st +from langchain.llms import OpenAI +from langchain.prompts import PromptTemplate +from langchain import FewShotPromptTemplate +from langchain.prompts.example_selector import LengthBasedExampleSelector +from dotenv import load_dotenv + +load_dotenv() + +def getLLMResponse(query,age_option,tasktype_option): + llm = OpenAI(temperature=.9, model="text-davinci-003") + + examples = [ + { + "query": "What is a mobile?", + "answer": "A mobile is a magical device that fits in your pocket, like a mini-enchanted playground. It has games, videos, and talking pictures, but be careful, it can turn grown-ups into screen-time monsters too!" + }, { + "query": "What are your dreams?", + "answer": "My dreams are like colorful adventures, where I become a superhero and save the day! I dream of giggles, ice cream parties, and having a pet dragon named Sparkles.." + }, { + "query": " What are your ambitions?", + "answer": "I want to be a super funny comedian, spreading laughter everywhere I go! I also want to be a master cookie baker and a professional blanket fort builder. Being mischievous and sweet is just my bonus superpower!" + }, { + "query": "What happens when you get sick?", + "answer": "When I get sick, it's like a sneaky monster visits. I feel tired, sniffly, and need lots of cuddles. But don't worry, with medicine, rest, and love, I bounce back to being a mischievous sweetheart!" + }, { + "query": "WHow much do you love your dad?", + "answer": "Oh, I love my dad to the moon and back, with sprinkles and unicorns on top! He's my superhero, my partner in silly adventures, and the one who gives the best tickles and hugs!" + }, { + "query": "Tell me about your friend?", + "answer": "My friend is like a sunshine rainbow! We laugh, play, and have magical parties together. They always listen, share their toys, and make me feel special. Friendship is the best adventure!" + }, { + "query": "What math means to you?", + "answer": "Math is like a puzzle game, full of numbers and shapes. It helps me count my toys, build towers, and share treats equally. It's fun and makes my brain sparkle!" + }, { + "query": "What is your fear?", + "answer": "Sometimes I'm scared of thunderstorms and monsters under my bed. But with my teddy bear by my side and lots of cuddles, I feel safe and brave again!" + } + ] + + + example_template = """ + Question: {query} + Response: {answer} + """ + + example_prompt = PromptTemplate( + input_variables=["query", "answer"], + template=example_template + ) + + + prefix = """You are a {template_ageoption}, and {template_tasktype_option}: + Here are some examples: + """ + + suffix = """ + Question: {template_userInput} + Response: """ + + example_selector = LengthBasedExampleSelector( + examples=examples, + example_prompt=example_prompt, + max_length=200 + ) + + + new_prompt_template = FewShotPromptTemplate( + example_selector=example_selector, # use example_selector instead of examples + example_prompt=example_prompt, + prefix=prefix, + suffix=suffix, + input_variables=["template_userInput","template_ageoption","template_tasktype_option"], + example_separator="\n" + ) + + + print(new_prompt_template.format(template_userInput=query,template_ageoption=age_option,template_tasktype_option=tasktype_option)) + response=llm(new_prompt_template.format(template_userInput=query,template_ageoption=age_option,template_tasktype_option=tasktype_option)) + print(response) + + return response + +#UI Starts here + +st.set_page_config(page_title="Marketing Tool", + page_icon='✅', + layout='centered', + initial_sidebar_state='collapsed') +st.header("Hey, How can I help you?") + +form_input = st.text_area('Enter text', height=275) + +tasktype_option = st.selectbox( + 'Please select the action to be performed?', + ('Write a sales copy', 'Create a tweet', 'Write a product description'),key=1) + +age_option= st.selectbox( + 'For which age group?', + ('Kid', 'Adult', 'senior Citizen'),key=2) + +numberOfWords= st.slider('Words limit', 1, 200, 25) + +submit = st.button("Generate") + +if submit: + st.write(getLLMResponse(form_input,tasktype_option,age_option)) + + diff --git a/S09 - Project 4 - Marketing Campaign App/app.py b/S09 - Project 4 - Marketing Campaign App/app.py index 26dccc29..0394d629 100644 --- a/S09 - Project 4 - Marketing Campaign App/app.py +++ b/S09 - Project 4 - Marketing Campaign App/app.py @@ -1,169 +1,169 @@ -import streamlit as st -from langchain.llms import OpenAI -from langchain.prompts import PromptTemplate -from langchain import FewShotPromptTemplate -from langchain.prompts.example_selector import LengthBasedExampleSelector -from dotenv import load_dotenv - -load_dotenv() - -def getLLMResponse(query,age_option,tasktype_option): - llm = OpenAI(temperature=.9, model="text-davinci-003") - - if age_option=="Kid": - - examples = [ - { - "query": "What is a mobile?", - "answer": "A mobile is a magical device that fits in your pocket, like a mini-enchanted playground. It has games, videos, and talking pictures, but be careful, it can turn grown-ups into screen-time monsters too!" - }, { - "query": "What are your dreams?", - "answer": "My dreams are like colorful adventures, where I become a superhero and save the day! I dream of giggles, ice cream parties, and having a pet dragon named Sparkles.." - }, { - "query": " What are your ambitions?", - "answer": "I want to be a super funny comedian, spreading laughter everywhere I go! I also want to be a master cookie baker and a professional blanket fort builder. Being mischievous and sweet is just my bonus superpower!" - }, { - "query": "What happens when you get sick?", - "answer": "When I get sick, it's like a sneaky monster visits. I feel tired, sniffly, and need lots of cuddles. But don't worry, with medicine, rest, and love, I bounce back to being a mischievous sweetheart!" - }, { - "query": "WHow much do you love your dad?", - "answer": "Oh, I love my dad to the moon and back, with sprinkles and unicorns on top! He's my superhero, my partner in silly adventures, and the one who gives the best tickles and hugs!" - }, { - "query": "Tell me about your friend?", - "answer": "My friend is like a sunshine rainbow! We laugh, play, and have magical parties together. They always listen, share their toys, and make me feel special. Friendship is the best adventure!" - }, { - "query": "What math means to you?", - "answer": "Math is like a puzzle game, full of numbers and shapes. It helps me count my toys, build towers, and share treats equally. It's fun and makes my brain sparkle!" - }, { - "query": "What is your fear?", - "answer": "Sometimes I'm scared of thunderstorms and monsters under my bed. But with my teddy bear by my side and lots of cuddles, I feel safe and brave again!" - } - ] - - elif age_option=="Adult": - examples = [ - { - "query": "What is a mobile?", - "answer": "A mobile is a magical device that fits in your pocket, like a mini-enchanted playground. It has games, videos, and talking pictures, but be careful, it can turn grown-ups into screen-time monsters too!" - }, { - "query": "What are your dreams?", - "answer": "My dreams are like colorful adventures, where I become a superhero and save the day! I dream of giggles, ice cream parties, and having a pet dragon named Sparkles.." - }, { - "query": " What are your ambitions?", - "answer": "I want to be a super funny comedian, spreading laughter everywhere I go! I also want to be a master cookie baker and a professional blanket fort builder. Being mischievous and sweet is just my bonus superpower!" - }, { - "query": "What happens when you get sick?", - "answer": "When I get sick, it's like a sneaky monster visits. I feel tired, sniffly, and need lots of cuddles. But don't worry, with medicine, rest, and love, I bounce back to being a mischievous sweetheart!" - }, { - "query": "WHow much do you love your dad?", - "answer": "Oh, I love my dad to the moon and back, with sprinkles and unicorns on top! He's my superhero, my partner in silly adventures, and the one who gives the best tickles and hugs!" - }, { - "query": "Tell me about your friend?", - "answer": "My friend is like a sunshine rainbow! We laugh, play, and have magical parties together. They always listen, share their toys, and make me feel special. Friendship is the best adventure!" - }, { - "query": "What math means to you?", - "answer": "Math is like a puzzle game, full of numbers and shapes. It helps me count my toys, build towers, and share treats equally. It's fun and makes my brain sparkle!" - }, { - "query": "What is your fear?", - "answer": "Sometimes I'm scared of thunderstorms and monsters under my bed. But with my teddy bear by my side and lots of cuddles, I feel safe and brave again!" - } - ] - - elif age_option=="Senior Citizen": - examples = [ - { - "query": "What is a mobile?", - "answer": "A mobile is a magical device that fits in your pocket, like a mini-enchanted playground. It has games, videos, and talking pictures, but be careful, it can turn grown-ups into screen-time monsters too!" - }, { - "query": "What are your dreams?", - "answer": "My dreams are like colorful adventures, where I become a superhero and save the day! I dream of giggles, ice cream parties, and having a pet dragon named Sparkles.." - }, { - "query": " What are your ambitions?", - "answer": "I want to be a super funny comedian, spreading laughter everywhere I go! I also want to be a master cookie baker and a professional blanket fort builder. Being mischievous and sweet is just my bonus superpower!" - }, { - "query": "What happens when you get sick?", - "answer": "When I get sick, it's like a sneaky monster visits. I feel tired, sniffly, and need lots of cuddles. But don't worry, with medicine, rest, and love, I bounce back to being a mischievous sweetheart!" - }, { - "query": "WHow much do you love your dad?", - "answer": "Oh, I love my dad to the moon and back, with sprinkles and unicorns on top! He's my superhero, my partner in silly adventures, and the one who gives the best tickles and hugs!" - }, { - "query": "Tell me about your friend?", - "answer": "My friend is like a sunshine rainbow! We laugh, play, and have magical parties together. They always listen, share their toys, and make me feel special. Friendship is the best adventure!" - }, { - "query": "What math means to you?", - "answer": "Math is like a puzzle game, full of numbers and shapes. It helps me count my toys, build towers, and share treats equally. It's fun and makes my brain sparkle!" - }, { - "query": "What is your fear?", - "answer": "Sometimes I'm scared of thunderstorms and monsters under my bed. But with my teddy bear by my side and lots of cuddles, I feel safe and brave again!" - } - ] - - - example_template = """ - Question: {query} - Response: {answer} - """ - - example_prompt = PromptTemplate( - input_variables=["query", "answer"], - template=example_template - ) - - - prefix = """You are a {template_ageoption}, and {template_tasktype_option}: - Here are some examples: - """ - - suffix = """ - Question: {template_userInput} - Response: """ - - example_selector = LengthBasedExampleSelector( - examples=examples, - example_prompt=example_prompt, - max_length=200 - ) - - - new_prompt_template = FewShotPromptTemplate( - example_selector=example_selector, # use example_selector instead of examples - example_prompt=example_prompt, - prefix=prefix, - suffix=suffix, - input_variables=["template_userInput","template_ageoption","template_tasktype_option"], - example_separator="\n" - ) - - - print(new_prompt_template.format(template_userInput=query,template_ageoption=age_option,template_tasktype_option=tasktype_option)) - response=llm(new_prompt_template.format(template_userInput=query,template_ageoption=age_option,template_tasktype_option=tasktype_option)) - print(response) - - return response - -#UI Starts here - -st.set_page_config(page_title="Marketing Tool", - page_icon='✅', - layout='centered', - initial_sidebar_state='collapsed') -st.header("Hey, How can I help you?") - -form_input = st.text_area('Enter text', height=275) - -tasktype_option = st.selectbox( - 'Please select the action to be performed?', - ('Write a sales copy', 'Create a tweet', 'Write a product description'),key=1) - -age_option= st.selectbox( - 'For which age group?', - ('Kid', 'Adult', 'senior Citizen'),key=2) - -numberOfWords= st.slider('Words limit', 1, 200, 25) - -submit = st.button("Generate") - -if submit: - st.write(getLLMResponse(form_input,tasktype_option,age_option)) - - +import streamlit as st +from langchain.llms import OpenAI +from langchain.prompts import PromptTemplate +from langchain import FewShotPromptTemplate +from langchain.prompts.example_selector import LengthBasedExampleSelector +from dotenv import load_dotenv + +load_dotenv() + +def getLLMResponse(query,age_option,tasktype_option): + llm = OpenAI(temperature=.9, model="text-davinci-003") + + if age_option=="Kid": + + examples = [ + { + "query": "What is a mobile?", + "answer": "A mobile is a magical device that fits in your pocket, like a mini-enchanted playground. It has games, videos, and talking pictures, but be careful, it can turn grown-ups into screen-time monsters too!" + }, { + "query": "What are your dreams?", + "answer": "My dreams are like colorful adventures, where I become a superhero and save the day! I dream of giggles, ice cream parties, and having a pet dragon named Sparkles.." + }, { + "query": " What are your ambitions?", + "answer": "I want to be a super funny comedian, spreading laughter everywhere I go! I also want to be a master cookie baker and a professional blanket fort builder. Being mischievous and sweet is just my bonus superpower!" + }, { + "query": "What happens when you get sick?", + "answer": "When I get sick, it's like a sneaky monster visits. I feel tired, sniffly, and need lots of cuddles. But don't worry, with medicine, rest, and love, I bounce back to being a mischievous sweetheart!" + }, { + "query": "WHow much do you love your dad?", + "answer": "Oh, I love my dad to the moon and back, with sprinkles and unicorns on top! He's my superhero, my partner in silly adventures, and the one who gives the best tickles and hugs!" + }, { + "query": "Tell me about your friend?", + "answer": "My friend is like a sunshine rainbow! We laugh, play, and have magical parties together. They always listen, share their toys, and make me feel special. Friendship is the best adventure!" + }, { + "query": "What math means to you?", + "answer": "Math is like a puzzle game, full of numbers and shapes. It helps me count my toys, build towers, and share treats equally. It's fun and makes my brain sparkle!" + }, { + "query": "What is your fear?", + "answer": "Sometimes I'm scared of thunderstorms and monsters under my bed. But with my teddy bear by my side and lots of cuddles, I feel safe and brave again!" + } + ] + + elif age_option=="Adult": + examples = [ + { + "query": "What is a mobile?", + "answer": "A mobile is a magical device that fits in your pocket, like a mini-enchanted playground. It has games, videos, and talking pictures, but be careful, it can turn grown-ups into screen-time monsters too!" + }, { + "query": "What are your dreams?", + "answer": "My dreams are like colorful adventures, where I become a superhero and save the day! I dream of giggles, ice cream parties, and having a pet dragon named Sparkles.." + }, { + "query": " What are your ambitions?", + "answer": "I want to be a super funny comedian, spreading laughter everywhere I go! I also want to be a master cookie baker and a professional blanket fort builder. Being mischievous and sweet is just my bonus superpower!" + }, { + "query": "What happens when you get sick?", + "answer": "When I get sick, it's like a sneaky monster visits. I feel tired, sniffly, and need lots of cuddles. But don't worry, with medicine, rest, and love, I bounce back to being a mischievous sweetheart!" + }, { + "query": "WHow much do you love your dad?", + "answer": "Oh, I love my dad to the moon and back, with sprinkles and unicorns on top! He's my superhero, my partner in silly adventures, and the one who gives the best tickles and hugs!" + }, { + "query": "Tell me about your friend?", + "answer": "My friend is like a sunshine rainbow! We laugh, play, and have magical parties together. They always listen, share their toys, and make me feel special. Friendship is the best adventure!" + }, { + "query": "What math means to you?", + "answer": "Math is like a puzzle game, full of numbers and shapes. It helps me count my toys, build towers, and share treats equally. It's fun and makes my brain sparkle!" + }, { + "query": "What is your fear?", + "answer": "Sometimes I'm scared of thunderstorms and monsters under my bed. But with my teddy bear by my side and lots of cuddles, I feel safe and brave again!" + } + ] + + elif age_option=="Senior Citizen": + examples = [ + { + "query": "What is a mobile?", + "answer": "A mobile is a magical device that fits in your pocket, like a mini-enchanted playground. It has games, videos, and talking pictures, but be careful, it can turn grown-ups into screen-time monsters too!" + }, { + "query": "What are your dreams?", + "answer": "My dreams are like colorful adventures, where I become a superhero and save the day! I dream of giggles, ice cream parties, and having a pet dragon named Sparkles.." + }, { + "query": " What are your ambitions?", + "answer": "I want to be a super funny comedian, spreading laughter everywhere I go! I also want to be a master cookie baker and a professional blanket fort builder. Being mischievous and sweet is just my bonus superpower!" + }, { + "query": "What happens when you get sick?", + "answer": "When I get sick, it's like a sneaky monster visits. I feel tired, sniffly, and need lots of cuddles. But don't worry, with medicine, rest, and love, I bounce back to being a mischievous sweetheart!" + }, { + "query": "WHow much do you love your dad?", + "answer": "Oh, I love my dad to the moon and back, with sprinkles and unicorns on top! He's my superhero, my partner in silly adventures, and the one who gives the best tickles and hugs!" + }, { + "query": "Tell me about your friend?", + "answer": "My friend is like a sunshine rainbow! We laugh, play, and have magical parties together. They always listen, share their toys, and make me feel special. Friendship is the best adventure!" + }, { + "query": "What math means to you?", + "answer": "Math is like a puzzle game, full of numbers and shapes. It helps me count my toys, build towers, and share treats equally. It's fun and makes my brain sparkle!" + }, { + "query": "What is your fear?", + "answer": "Sometimes I'm scared of thunderstorms and monsters under my bed. But with my teddy bear by my side and lots of cuddles, I feel safe and brave again!" + } + ] + + + example_template = """ + Question: {query} + Response: {answer} + """ + + example_prompt = PromptTemplate( + input_variables=["query", "answer"], + template=example_template + ) + + + prefix = """You are a {template_ageoption}, and {template_tasktype_option}: + Here are some examples: + """ + + suffix = """ + Question: {template_userInput} + Response: """ + + example_selector = LengthBasedExampleSelector( + examples=examples, + example_prompt=example_prompt, + max_length=200 + ) + + + new_prompt_template = FewShotPromptTemplate( + example_selector=example_selector, # use example_selector instead of examples + example_prompt=example_prompt, + prefix=prefix, + suffix=suffix, + input_variables=["template_userInput","template_ageoption","template_tasktype_option"], + example_separator="\n" + ) + + + print(new_prompt_template.format(template_userInput=query,template_ageoption=age_option,template_tasktype_option=tasktype_option)) + response=llm(new_prompt_template.format(template_userInput=query,template_ageoption=age_option,template_tasktype_option=tasktype_option)) + print(response) + + return response + +#UI Starts here + +st.set_page_config(page_title="Marketing Tool", + page_icon='✅', + layout='centered', + initial_sidebar_state='collapsed') +st.header("Hey, How can I help you?") + +form_input = st.text_area('Enter text', height=275) + +tasktype_option = st.selectbox( + 'Please select the action to be performed?', + ('Write a sales copy', 'Create a tweet', 'Write a product description'),key=1) + +age_option= st.selectbox( + 'For which age group?', + ('Kid', 'Adult', 'senior Citizen'),key=2) + +numberOfWords= st.slider('Words limit', 1, 200, 25) + +submit = st.button("Generate") + +if submit: + st.write(getLLMResponse(form_input,tasktype_option,age_option)) + + diff --git a/S11 - Project 5 - ChatGPT Clone with Summarization Option/Project 5 - Source Code/app.py b/S11 - Project 5 - ChatGPT Clone with Summarization Option/Project 5 - Source Code/app.py index 6d89c1b4..84954ddc 100644 --- a/S11 - Project 5 - ChatGPT Clone with Summarization Option/Project 5 - Source Code/app.py +++ b/S11 - Project 5 - ChatGPT Clone with Summarization Option/Project 5 - Source Code/app.py @@ -1,82 +1,82 @@ -import streamlit as st -from streamlit_chat import message -from langchain import OpenAI -from langchain.chains import ConversationChain -from langchain.chains.conversation.memory import (ConversationBufferMemory, - ConversationSummaryMemory, - ConversationBufferWindowMemory - - ) - -if 'conversation' not in st.session_state: - st.session_state['conversation'] =None -if 'messages' not in st.session_state: - st.session_state['messages'] =[] -if 'API_Key' not in st.session_state: - st.session_state['API_Key'] ='' - -# Setting page title and header -st.set_page_config(page_title="Chat GPT Clone", page_icon=":robot_face:") -st.markdown("

How can I assist you?

", unsafe_allow_html=True) - - -st.sidebar.title("😎") -st.session_state['API_Key']= st.sidebar.text_input("What's your API key?",type="password") -summarise_button = st.sidebar.button("Summarise the conversation", key="summarise") -if summarise_button: - summarise_placeholder = st.sidebar.write("Nice chatting with you my friend ❤️:\n\n"+st.session_state['conversation'].memory.buffer) - #summarise_placeholder.write("Nice chatting with you my friend ❤️:\n\n"+st.session_state['conversation'].memory.buffer) - -#import os -#os.environ["OPENAI_API_KEY"] = "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" - -def getresponse(userInput, api_key): - - if st.session_state['conversation'] is None: - - llm = OpenAI( - temperature=0, - openai_api_key=api_key, - model_name='text-davinci-003' #we can also use 'gpt-3.5-turbo' - ) - - st.session_state['conversation'] = ConversationChain( - llm=llm, - verbose=True, - memory=ConversationSummaryMemory(llm=llm) - ) - - response=st.session_state['conversation'].predict(input=userInput) - print(st.session_state['conversation'].memory.buffer) - - - return response - - - -response_container = st.container() -# Here we will have a container for user input text box -container = st.container() - - -with container: - with st.form(key='my_form', clear_on_submit=True): - user_input = st.text_area("Your question goes here:", key='input', height=100) - submit_button = st.form_submit_button(label='Send') - - if submit_button: - st.session_state['messages'].append(user_input) - model_response=getresponse(user_input,st.session_state['API_Key']) - st.session_state['messages'].append(model_response) - - - with response_container: - for i in range(len(st.session_state['messages'])): - if (i % 2) == 0: - message(st.session_state['messages'][i], is_user=True, key=str(i) + '_user') - else: - message(st.session_state['messages'][i], key=str(i) + '_AI') - - - - +import streamlit as st +from streamlit_chat import message +from langchain import OpenAI +from langchain.chains import ConversationChain +from langchain.chains.conversation.memory import (ConversationBufferMemory, + ConversationSummaryMemory, + ConversationBufferWindowMemory + + ) + +if 'conversation' not in st.session_state: + st.session_state['conversation'] =None +if 'messages' not in st.session_state: + st.session_state['messages'] =[] +if 'API_Key' not in st.session_state: + st.session_state['API_Key'] ='' + +# Setting page title and header +st.set_page_config(page_title="Chat GPT Clone", page_icon=":robot_face:") +st.markdown("

How can I assist you?

", unsafe_allow_html=True) + + +st.sidebar.title("😎") +st.session_state['API_Key']= st.sidebar.text_input("What's your API key?",type="password") +summarise_button = st.sidebar.button("Summarise the conversation", key="summarise") +if summarise_button: + summarise_placeholder = st.sidebar.write("Nice chatting with you my friend ❤️:\n\n"+st.session_state['conversation'].memory.buffer) + #summarise_placeholder.write("Nice chatting with you my friend ❤️:\n\n"+st.session_state['conversation'].memory.buffer) + +#import os +#os.environ["OPENAI_API_KEY"] = "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" + +def getresponse(userInput, api_key): + + if st.session_state['conversation'] is None: + + llm = OpenAI( + temperature=0, + openai_api_key=api_key, + model_name='text-davinci-003' #we can also use 'gpt-3.5-turbo' + ) + + st.session_state['conversation'] = ConversationChain( + llm=llm, + verbose=True, + memory=ConversationSummaryMemory(llm=llm) + ) + + response=st.session_state['conversation'].predict(input=userInput) + print(st.session_state['conversation'].memory.buffer) + + + return response + + + +response_container = st.container() +# Here we will have a container for user input text box +container = st.container() + + +with container: + with st.form(key='my_form', clear_on_submit=True): + user_input = st.text_area("Your question goes here:", key='input', height=100) + submit_button = st.form_submit_button(label='Send') + + if submit_button: + st.session_state['messages'].append(user_input) + model_response=getresponse(user_input,st.session_state['API_Key']) + st.session_state['messages'].append(model_response) + + + with response_container: + for i in range(len(st.session_state['messages'])): + if (i % 2) == 0: + message(st.session_state['messages'][i], is_user=True, key=str(i) + '_user') + else: + message(st.session_state['messages'][i], key=str(i) + '_AI') + + + + diff --git a/S11 - Project 5 - ChatGPT Clone with Summarization Option/Project 5 - Source Code/requirements.txt b/S11 - Project 5 - ChatGPT Clone with Summarization Option/Project 5 - Source Code/requirements.txt index a6677e14..4ef4dae7 100644 --- a/S11 - Project 5 - ChatGPT Clone with Summarization Option/Project 5 - Source Code/requirements.txt +++ b/S11 - Project 5 - ChatGPT Clone with Summarization Option/Project 5 - Source Code/requirements.txt @@ -1,2 +1,2 @@ -langchain +langchain streamlit \ No newline at end of file diff --git a/S12 - LangChain - Data Connection Module Concept/Data Connections - Python Code/Sample.txt b/S12 - LangChain - Data Connection Module Concept/Data Connections - Python Code/Sample.txt index ee063db4..6111132f 100644 --- a/S12 - LangChain - Data Connection Module Concept/Data Connections - Python Code/Sample.txt +++ b/S12 - LangChain - Data Connection Module Concept/Data Connections - Python Code/Sample.txt @@ -1,37 +1,37 @@ -India, officially known as the Republic of India, is a diverse and vibrant country located in South Asia. With a rich history spanning thousands of years, India is known for its cultural heritage, religious diversity, and vast landscapes. From the majestic Himalayas in the north to the serene backwaters of Kerala in the south, India encompasses a wide range of geographical features, including deserts, plains, mountains, and coastlines, making it a land of incredible natural beauty. - -India is the seventh-largest country by land area and the second-most populous country in the world, with a population exceeding 1.3 billion people. It is a federal parliamentary democratic republic, with a president as the head of state and a prime minister as the head of government. The country follows a multi-tiered administrative structure, with 28 states and 9 union territories, each having its own elected government. - -India has a rich cultural heritage that has evolved over thousands of years. It is home to various religions, including Hinduism, Islam, Christianity, Sikhism, Buddhism, and Jainism, among others. These religions coexist harmoniously, contributing to India's multicultural fabric. Festivals like Diwali, Eid, Christmas, and Holi are celebrated with great enthusiasm and bring people from different communities together. - -The history of India is characterized by ancient civilizations, invasions, and the establishment of powerful empires. The Indus Valley Civilization, one of the world's oldest urban civilizations, flourished in the northwestern part of the Indian subcontinent around 2500 BCE. Over the centuries, India witnessed the rise and fall of several dynasties, including the Maurya, Gupta, and Mughal empires. The Mughal period, in particular, left a lasting impact on Indian culture, art, and architecture. - -India's struggle for independence from British colonial rule is a significant chapter in its history. Led by Mahatma Gandhi and other freedom fighters, the non-violent resistance movement gained momentum and eventually led to India's independence on August 15, 1947. This day is celebrated annually as Independence Day. - -India's economy is one of the fastest-growing in the world. It has transitioned from an agrarian economy to a service-oriented and industrialized economy. The country is known for its software and information technology services, pharmaceuticals, textiles, agriculture, and manufacturing sectors. Major cities like Mumbai, Delhi, Bangalore, and Chennai are hubs of business and commerce, attracting investments and fostering innovation. - -Delhi is the capital of India - -However, India also faces various socio-economic challenges. Poverty, income inequality, and unemployment are persistent issues that the country strives to address. Efforts are being made to improve education, healthcare, infrastructure, and social welfare programs to uplift marginalized sections of society. - -Education plays a vital role in India, with a strong emphasis on academic excellence. The country has a vast network of schools, colleges, and universities, producing a large number of graduates every year. Indian professionals have made significant contributions in various fields globally, particularly in science, technology, engineering, and mathematics (STEM). - -The Indian film industry, popularly known as Bollywood, is a global phenomenon, producing the largest number of films annually. Indian cinema reflects the diversity and cultural richness of the country and has a massive following both within India and among the Indian diaspora worldwide. - -Indian cuisine is renowned for its flavors, spices, and regional specialties. Each state has its own culinary traditions, offering a wide range of vegetarian and non-vegetarian dishes. Indian food has gained international popularity, with dishes like curry, biryani, dosa, and tandoori being enjoyed by people worldwide. - -The Indian rupee is the official currency in the Republic of India. The rupee is subdivided into 100 paise. The issuance of the currency is controlled by the Reserve Bank of India. - -The Indian rupee sign (₹) is the currency symbol for the Indian rupee the official currency of India - -Tourism is a significant contributor to India's economy. The country attracts millions of visitors each year who come to explore its historical sites, architectural wonders, wildlife sanctuaries, and scenic landscapes. Iconic landmarks such as the Taj Mahal, Jaipur's palaces, Kerala's backwaters, and the beaches of Goa are popular tourist destinations. - -India's cultural heritage is preserved in its ancient monuments and UNESCO World Heritage Sites. From the intricate carvings of Khajuraho temples to the majestic forts of Rajasthan, these architectural marvels reflect India's rich history and artistic traditions. - -India's diversity extends to its languages as well. While Hindi and English are the official languages at the national level, there are 22 officially recognized regional languages, including Bengali, Tamil, Telugu, Marathi, Urdu, Punjabi, and Gujarati, among others. This linguistic diversity is a testament to India's multicultural ethos. - -In recent years, India has made significant strides in space exploration. The Indian Space Research Organization (ISRO) has successfully launched satellites and missions, including the Mars Orbiter Mission (MOM), also known as Mangalyaan. These achievements have placed India among the elite group of nations with advanced space programs. - -India's diplomatic influence is also growing on the global stage. The country actively participates in international forums and has strong bilateral relations with nations around the world. India is a founding member of the Non-Aligned Movement and plays an active role in various international organizations, such as the United Nations and World Trade Organization. - +India, officially known as the Republic of India, is a diverse and vibrant country located in South Asia. With a rich history spanning thousands of years, India is known for its cultural heritage, religious diversity, and vast landscapes. From the majestic Himalayas in the north to the serene backwaters of Kerala in the south, India encompasses a wide range of geographical features, including deserts, plains, mountains, and coastlines, making it a land of incredible natural beauty. + +India is the seventh-largest country by land area and the second-most populous country in the world, with a population exceeding 1.3 billion people. It is a federal parliamentary democratic republic, with a president as the head of state and a prime minister as the head of government. The country follows a multi-tiered administrative structure, with 28 states and 9 union territories, each having its own elected government. + +India has a rich cultural heritage that has evolved over thousands of years. It is home to various religions, including Hinduism, Islam, Christianity, Sikhism, Buddhism, and Jainism, among others. These religions coexist harmoniously, contributing to India's multicultural fabric. Festivals like Diwali, Eid, Christmas, and Holi are celebrated with great enthusiasm and bring people from different communities together. + +The history of India is characterized by ancient civilizations, invasions, and the establishment of powerful empires. The Indus Valley Civilization, one of the world's oldest urban civilizations, flourished in the northwestern part of the Indian subcontinent around 2500 BCE. Over the centuries, India witnessed the rise and fall of several dynasties, including the Maurya, Gupta, and Mughal empires. The Mughal period, in particular, left a lasting impact on Indian culture, art, and architecture. + +India's struggle for independence from British colonial rule is a significant chapter in its history. Led by Mahatma Gandhi and other freedom fighters, the non-violent resistance movement gained momentum and eventually led to India's independence on August 15, 1947. This day is celebrated annually as Independence Day. + +India's economy is one of the fastest-growing in the world. It has transitioned from an agrarian economy to a service-oriented and industrialized economy. The country is known for its software and information technology services, pharmaceuticals, textiles, agriculture, and manufacturing sectors. Major cities like Mumbai, Delhi, Bangalore, and Chennai are hubs of business and commerce, attracting investments and fostering innovation. + +Delhi is the capital of India + +However, India also faces various socio-economic challenges. Poverty, income inequality, and unemployment are persistent issues that the country strives to address. Efforts are being made to improve education, healthcare, infrastructure, and social welfare programs to uplift marginalized sections of society. + +Education plays a vital role in India, with a strong emphasis on academic excellence. The country has a vast network of schools, colleges, and universities, producing a large number of graduates every year. Indian professionals have made significant contributions in various fields globally, particularly in science, technology, engineering, and mathematics (STEM). + +The Indian film industry, popularly known as Bollywood, is a global phenomenon, producing the largest number of films annually. Indian cinema reflects the diversity and cultural richness of the country and has a massive following both within India and among the Indian diaspora worldwide. + +Indian cuisine is renowned for its flavors, spices, and regional specialties. Each state has its own culinary traditions, offering a wide range of vegetarian and non-vegetarian dishes. Indian food has gained international popularity, with dishes like curry, biryani, dosa, and tandoori being enjoyed by people worldwide. + +The Indian rupee is the official currency in the Republic of India. The rupee is subdivided into 100 paise. The issuance of the currency is controlled by the Reserve Bank of India. + +The Indian rupee sign (₹) is the currency symbol for the Indian rupee the official currency of India + +Tourism is a significant contributor to India's economy. The country attracts millions of visitors each year who come to explore its historical sites, architectural wonders, wildlife sanctuaries, and scenic landscapes. Iconic landmarks such as the Taj Mahal, Jaipur's palaces, Kerala's backwaters, and the beaches of Goa are popular tourist destinations. + +India's cultural heritage is preserved in its ancient monuments and UNESCO World Heritage Sites. From the intricate carvings of Khajuraho temples to the majestic forts of Rajasthan, these architectural marvels reflect India's rich history and artistic traditions. + +India's diversity extends to its languages as well. While Hindi and English are the official languages at the national level, there are 22 officially recognized regional languages, including Bengali, Tamil, Telugu, Marathi, Urdu, Punjabi, and Gujarati, among others. This linguistic diversity is a testament to India's multicultural ethos. + +In recent years, India has made significant strides in space exploration. The Indian Space Research Organization (ISRO) has successfully launched satellites and missions, including the Mars Orbiter Mission (MOM), also known as Mangalyaan. These achievements have placed India among the elite group of nations with advanced space programs. + +India's diplomatic influence is also growing on the global stage. The country actively participates in international forums and has strong bilateral relations with nations around the world. India is a founding member of the Non-Aligned Movement and plays an active role in various international organizations, such as the United Nations and World Trade Organization. + In conclusion, India is a vast and diverse country with a rich cultural heritage, stunning landscapes, and a rapidly growing economy. It is a nation where ancient traditions coexist with modern aspirations. Despite its challenges, India continues to evolve and leave an indelible mark on the world, making it a fascinating and dynamic country to explore. \ No newline at end of file diff --git a/S16 - Project 7 - CSV Data Analysis Tool/CSV Data Analysis - Project 7/app.py b/S16 - Project 7 - CSV Data Analysis Tool/CSV Data Analysis - Project 7/app.py index e2c92b67..3ea52618 100644 --- a/S16 - Project 7 - CSV Data Analysis Tool/CSV Data Analysis - Project 7/app.py +++ b/S16 - Project 7 - CSV Data Analysis Tool/CSV Data Analysis - Project 7/app.py @@ -1,20 +1,20 @@ -import streamlit as st -from dotenv import load_dotenv -from utils import query_agent - -load_dotenv() - - -st.title("Let's do some analysis on your CSV") -st.header("Please upload your CSV file here:") - -# Capture the CSV file -data = st.file_uploader("Upload CSV file",type="csv") - -query = st.text_area("Enter your query") -button = st.button("Generate Response") - -if button: - # Get Response - answer = query_agent(data,query) +import streamlit as st +from dotenv import load_dotenv +from utils import query_agent + +load_dotenv() + + +st.title("Let's do some analysis on your CSV") +st.header("Please upload your CSV file here:") + +# Capture the CSV file +data = st.file_uploader("Upload CSV file",type="csv") + +query = st.text_area("Enter your query") +button = st.button("Generate Response") + +if button: + # Get Response + answer = query_agent(data,query) st.write(answer) \ No newline at end of file diff --git a/S16 - Project 7 - CSV Data Analysis Tool/CSV Data Analysis - Project 7/requirements.txt b/S16 - Project 7 - CSV Data Analysis Tool/CSV Data Analysis - Project 7/requirements.txt index b718b9e5..5fec8b08 100644 --- a/S16 - Project 7 - CSV Data Analysis Tool/CSV Data Analysis - Project 7/requirements.txt +++ b/S16 - Project 7 - CSV Data Analysis Tool/CSV Data Analysis - Project 7/requirements.txt @@ -1,6 +1,6 @@ -langchain -streamlit -openai -tiktoken -python-dotenv +langchain +streamlit +openai +tiktoken +python-dotenv pinecone-client \ No newline at end of file diff --git a/S16 - Project 7 - CSV Data Analysis Tool/CSV Data Analysis - Project 7/utils.py b/S16 - Project 7 - CSV Data Analysis Tool/CSV Data Analysis - Project 7/utils.py index 51b98468..3d2885b4 100644 --- a/S16 - Project 7 - CSV Data Analysis Tool/CSV Data Analysis - Project 7/utils.py +++ b/S16 - Project 7 - CSV Data Analysis Tool/CSV Data Analysis - Project 7/utils.py @@ -1,17 +1,17 @@ -from langchain.agents import create_pandas_dataframe_agent -import pandas as pd -from langchain.llms import OpenAI - -def query_agent(data, query): - - # Parse the CSV file and create a Pandas DataFrame from its contents. - df = pd.read_csv(data) - - llm = OpenAI() - - # Create a Pandas DataFrame agent. - agent = create_pandas_dataframe_agent(llm, df, verbose=True) - - #Python REPL: A Python shell used to evaluating and executing Python commands. - #It takes python code as input and outputs the result. The input python code can be generated from another tool in the LangChain +from langchain.agents import create_pandas_dataframe_agent +import pandas as pd +from langchain.llms import OpenAI + +def query_agent(data, query): + + # Parse the CSV file and create a Pandas DataFrame from its contents. + df = pd.read_csv(data) + + llm = OpenAI() + + # Create a Pandas DataFrame agent. + agent = create_pandas_dataframe_agent(llm, df, verbose=True) + + #Python REPL: A Python shell used to evaluating and executing Python commands. + #It takes python code as input and outputs the result. The input python code can be generated from another tool in the LangChain return agent.run(query) \ No newline at end of file diff --git a/S17 - Project 8 - YouTube Script Writing Tool/YT Script Writing Tool/app.py b/S17 - Project 8 - YouTube Script Writing Tool/YT Script Writing Tool/app.py index 29ed6d81..e950926a 100644 --- a/S17 - Project 8 - YouTube Script Writing Tool/YT Script Writing Tool/app.py +++ b/S17 - Project 8 - YouTube Script Writing Tool/YT Script Writing Tool/app.py @@ -1,59 +1,59 @@ -import streamlit as st -from utils import generate_script - -# Applying Styling -st.markdown(""" -""", unsafe_allow_html=True) - - -# Creating Session State Variable -if 'API_Key' not in st.session_state: - st.session_state['API_Key'] ='' - - -st.title('❤️ YouTube Script Writing Tool') - -# Sidebar to capture the OpenAi API key -st.sidebar.title("😎🗝️") -st.session_state['API_Key']= st.sidebar.text_input("What's your API key?",type="password") -st.sidebar.image('./Youtube.jpg',width=300, use_column_width=True) - - -# Captures User Inputs -prompt = st.text_input('Please provide the topic of the video',key="prompt") # The box for the text prompt -video_length = st.text_input('Expected Video Length 🕒 (in minutes)',key="video_length") # The box for the text prompt -creativity = st.slider('Words limit ✨ - (0 LOW || 1 HIGH)', 0.0, 1.0, 0.2,step=0.1) - -submit = st.button("Generate Script for me") - - -if submit: - - if st.session_state['API_Key']: - search_result,title,script = generate_script(prompt,video_length,creativity,st.session_state['API_Key']) - #Let's generate the script - st.success('Hope you like this script ❤️') - - #Display Title - st.subheader("Title:🔥") - st.write(title) - - #Display Video Script - st.subheader("Your Video Script:📝") - st.write(script) - - #Display Search Engine Result - st.subheader("Check Out - DuckDuckGo Search:🔍") - with st.expander('Show me 👀'): - st.info(search_result) - else: +import streamlit as st +from utils import generate_script + +# Applying Styling +st.markdown(""" +""", unsafe_allow_html=True) + + +# Creating Session State Variable +if 'API_Key' not in st.session_state: + st.session_state['API_Key'] ='' + + +st.title('❤️ YouTube Script Writing Tool') + +# Sidebar to capture the OpenAi API key +st.sidebar.title("😎🗝️") +st.session_state['API_Key']= st.sidebar.text_input("What's your API key?",type="password") +st.sidebar.image('./Youtube.jpg',width=300, use_column_width=True) + + +# Captures User Inputs +prompt = st.text_input('Please provide the topic of the video',key="prompt") # The box for the text prompt +video_length = st.text_input('Expected Video Length 🕒 (in minutes)',key="video_length") # The box for the text prompt +creativity = st.slider('Words limit ✨ - (0 LOW || 1 HIGH)', 0.0, 1.0, 0.2,step=0.1) + +submit = st.button("Generate Script for me") + + +if submit: + + if st.session_state['API_Key']: + search_result,title,script = generate_script(prompt,video_length,creativity,st.session_state['API_Key']) + #Let's generate the script + st.success('Hope you like this script ❤️') + + #Display Title + st.subheader("Title:🔥") + st.write(title) + + #Display Video Script + st.subheader("Your Video Script:📝") + st.write(script) + + #Display Search Engine Result + st.subheader("Check Out - DuckDuckGo Search:🔍") + with st.expander('Show me 👀'): + st.info(search_result) + else: st.error("Ooopssss!!! Please provide API key.....") \ No newline at end of file diff --git a/S17 - Project 8 - YouTube Script Writing Tool/YT Script Writing Tool/requirements.txt b/S17 - Project 8 - YouTube Script Writing Tool/YT Script Writing Tool/requirements.txt index 575e8680..b340b23d 100644 --- a/S17 - Project 8 - YouTube Script Writing Tool/YT Script Writing Tool/requirements.txt +++ b/S17 - Project 8 - YouTube Script Writing Tool/YT Script Writing Tool/requirements.txt @@ -1,7 +1,7 @@ -langchain -streamlit -openai -tiktoken -python-dotenv -pinecone-client +langchain +streamlit +openai +tiktoken +python-dotenv +pinecone-client duckduckgo_search \ No newline at end of file diff --git a/S17 - Project 8 - YouTube Script Writing Tool/YT Script Writing Tool/utils.py b/S17 - Project 8 - YouTube Script Writing Tool/YT Script Writing Tool/utils.py index cfafce2d..f1a48bc6 100644 --- a/S17 - Project 8 - YouTube Script Writing Tool/YT Script Writing Tool/utils.py +++ b/S17 - Project 8 - YouTube Script Writing Tool/YT Script Writing Tool/utils.py @@ -1,41 +1,41 @@ -from langchain.llms import OpenAI -from langchain.prompts import PromptTemplate -from langchain.chains import LLMChain -from langchain.tools import DuckDuckGoSearchRun - -# Function to generate video script -def generate_script(prompt,video_length,creativity,api_key): - - # Template for generating 'Title' - title_template = PromptTemplate( - input_variables = ['subject'], - template='Please come up with a title for a YouTube video on the {subject}.' - ) - - # Template for generating 'Video Script' using search engine - script_template = PromptTemplate( - input_variables = ['title', 'DuckDuckGo_Search','duration'], - template='Create a script for a YouTube video based on this title for me. TITLE: {title} of duration: {duration} minutes using this search data {DuckDuckGo_Search} ' - ) - - #Setting up OpenAI LLM - llm = OpenAI(temperature=creativity,openai_api_key=api_key, - model_name='gpt-3.5-turbo') - - #Creating chain for 'Title' & 'Video Script' - title_chain = LLMChain(llm=llm, prompt=title_template, verbose=True) - script_chain = LLMChain(llm=llm, prompt=script_template, verbose=True) - - - # https://python.langchain.com/docs/modules/agents/tools/integrations/ddg - search = DuckDuckGoSearchRun() - - # Executing the chains we created for 'Title' - title = title_chain.run(prompt) - - # Executing the chains we created for 'Video Script' by taking help of search engine 'DuckDuckGo' - search_result = search.run(prompt) - script = script_chain.run(title=title, DuckDuckGo_Search=search_result,duration=video_length) - - # Returning the output +from langchain.llms import OpenAI +from langchain.prompts import PromptTemplate +from langchain.chains import LLMChain +from langchain.tools import DuckDuckGoSearchRun + +# Function to generate video script +def generate_script(prompt,video_length,creativity,api_key): + + # Template for generating 'Title' + title_template = PromptTemplate( + input_variables = ['subject'], + template='Please come up with a title for a YouTube video on the {subject}.' + ) + + # Template for generating 'Video Script' using search engine + script_template = PromptTemplate( + input_variables = ['title', 'DuckDuckGo_Search','duration'], + template='Create a script for a YouTube video based on this title for me. TITLE: {title} of duration: {duration} minutes using this search data {DuckDuckGo_Search} ' + ) + + #Setting up OpenAI LLM + llm = OpenAI(temperature=creativity,openai_api_key=api_key, + model_name='gpt-3.5-turbo') + + #Creating chain for 'Title' & 'Video Script' + title_chain = LLMChain(llm=llm, prompt=title_template, verbose=True) + script_chain = LLMChain(llm=llm, prompt=script_template, verbose=True) + + + # https://python.langchain.com/docs/modules/agents/tools/integrations/ddg + search = DuckDuckGoSearchRun() + + # Executing the chains we created for 'Title' + title = title_chain.run(prompt) + + # Executing the chains we created for 'Video Script' by taking help of search engine 'DuckDuckGo' + search_result = search.run(prompt) + script = script_chain.run(title=title, DuckDuckGo_Search=search_result,duration=video_length) + + # Returning the output return search_result,title,script \ No newline at end of file diff --git a/S18 - Project 9 - Support Chat Bot for your Website/Support Chat Bot For Your Website - Project 9/Support Chat Bot For Website.PNG b/S18 - Project 9 - Support Chat Bot for your Website/Support Chat Bot For Your Website - Project 9/Support Chat Bot For Website.PNG deleted file mode 100644 index 0f7608f1..00000000 Binary files a/S18 - Project 9 - Support Chat Bot for your Website/Support Chat Bot For Your Website - Project 9/Support Chat Bot For Website.PNG and /dev/null differ diff --git a/S18 - Project 9 - Support Chat Bot for your Website/Support Chat Bot For Your Website - Project 9/app.py b/S18 - Project 9 - Support Chat Bot for your Website/Support Chat Bot For Your Website - Project 9/app.py index f7489dbb..bf05078e 100644 --- a/S18 - Project 9 - Support Chat Bot for your Website/Support Chat Bot For Your Website - Project 9/app.py +++ b/S18 - Project 9 - Support Chat Bot for your Website/Support Chat Bot For Your Website - Project 9/app.py @@ -1,90 +1,90 @@ -import streamlit as st -from utils import * -import constants - -# Creating Session State Variable -if 'HuggingFace_API_Key' not in st.session_state: - st.session_state['HuggingFace_API_Key'] ='' -if 'Pinecone_API_Key' not in st.session_state: - st.session_state['Pinecone_API_Key'] ='' - - -# -st.title('🤖 AI Assistance For Website') - -#********SIDE BAR Funtionality started******* - -# Sidebar to capture the API keys -st.sidebar.title("😎🗝️") -st.session_state['HuggingFace_API_Key']= st.sidebar.text_input("What's your HuggingFace API key?",type="password") -st.session_state['Pinecone_API_Key']= st.sidebar.text_input("What's your Pinecone API key?",type="password") - -load_button = st.sidebar.button("Load data to Pinecone", key="load_button") - -#If the bove button is clicked, pushing the data to Pinecone... -if load_button: - #Proceed only if API keys are provided - if st.session_state['HuggingFace_API_Key'] !="" and st.session_state['Pinecone_API_Key']!="" : - - #Fetch data from site - site_data=get_website_data(constants.WEBSITE_URL) - st.write("Data pull done...") - - #Split data into chunks - chunks_data=split_data(site_data) - st.write("Spliting data done...") - - #Creating embeddings instance - embeddings=create_embeddings() - st.write("Embeddings instance creation done...") - - #Push data to Pinecone - push_to_pinecone(st.session_state['Pinecone_API_Key'],constants.PINECONE_ENVIRONMENT,constants.PINECONE_INDEX,embeddings,chunks_data) - st.write("Pushing data to Pinecone done...") - - st.sidebar.success("Data pushed to Pinecone successfully!") - else: - st.sidebar.error("Ooopssss!!! Please provide API keys.....") - -#********SIDE BAR Funtionality ended******* - -#Captures User Inputs -prompt = st.text_input('How can I help you my friend ❓',key="prompt") # The box for the text prompt -document_count = st.slider('No.Of links to return 🔗 - (0 LOW || 5 HIGH)', 0, 5, 2,step=1) - -submit = st.button("Search") - - -if submit: - #Proceed only if API keys are provided - if st.session_state['HuggingFace_API_Key'] !="" and st.session_state['Pinecone_API_Key']!="" : - - #Creating embeddings instance - embeddings=create_embeddings() - st.write("Embeddings instance creation done...") - - #Pull index data from Pinecone - index=pull_from_pinecone(st.session_state['Pinecone_API_Key'],constants.PINECONE_ENVIRONMENT,constants.PINECONE_INDEX,embeddings) - st.write("Pinecone index retrieval done...") - - #Fetch relavant documents from Pinecone index - relavant_docs=get_similar_docs(index,prompt,document_count) - st.write(relavant_docs) - - #Displaying search results - st.success("Please find the search results :") - #Displaying search results - st.write("search results list....") - for document in relavant_docs: - - st.write("👉**Result : "+ str(relavant_docs.index(document)+1)+"**") - st.write("**Info**: "+document.page_content) - st.write("**Link**: "+ document.metadata['source']) - - - - else: - st.sidebar.error("Ooopssss!!! Please provide API keys.....") - - - +import streamlit as st +from utils import * +import constants + +# Creating Session State Variable +if 'HuggingFace_API_Key' not in st.session_state: + st.session_state['HuggingFace_API_Key'] ='' +if 'Pinecone_API_Key' not in st.session_state: + st.session_state['Pinecone_API_Key'] ='' + + +# +st.title('🤖 AI Assistance For Website') + +#********SIDE BAR Funtionality started******* + +# Sidebar to capture the API keys +st.sidebar.title("😎🗝️") +st.session_state['HuggingFace_API_Key']= st.sidebar.text_input("What's your HuggingFace API key?",type="password") +st.session_state['Pinecone_API_Key']= st.sidebar.text_input("What's your Pinecone API key?",type="password") + +load_button = st.sidebar.button("Load data to Pinecone", key="load_button") + +#If the bove button is clicked, pushing the data to Pinecone... +if load_button: + #Proceed only if API keys are provided + if st.session_state['HuggingFace_API_Key'] !="" and st.session_state['Pinecone_API_Key']!="" : + + #Fetch data from site + site_data=get_website_data(constants.WEBSITE_URL) + st.write("Data pull done...") + + #Split data into chunks + chunks_data=split_data(site_data) + st.write("Spliting data done...") + + #Creating embeddings instance + embeddings=create_embeddings() + st.write("Embeddings instance creation done...") + + #Push data to Pinecone + push_to_pinecone(st.session_state['Pinecone_API_Key'],constants.PINECONE_ENVIRONMENT,constants.PINECONE_INDEX,embeddings,chunks_data) + st.write("Pushing data to Pinecone done...") + + st.sidebar.success("Data pushed to Pinecone successfully!") + else: + st.sidebar.error("Ooopssss!!! Please provide API keys.....") + +#********SIDE BAR Funtionality ended******* + +#Captures User Inputs +prompt = st.text_input('How can I help you my friend ❓',key="prompt") # The box for the text prompt +document_count = st.slider('No.Of links to return 🔗 - (0 LOW || 5 HIGH)', 0, 5, 2,step=1) + +submit = st.button("Search") + + +if submit: + #Proceed only if API keys are provided + if st.session_state['HuggingFace_API_Key'] !="" and st.session_state['Pinecone_API_Key']!="" : + + #Creating embeddings instance + embeddings=create_embeddings() + st.write("Embeddings instance creation done...") + + #Pull index data from Pinecone + index=pull_from_pinecone(st.session_state['Pinecone_API_Key'],constants.PINECONE_ENVIRONMENT,constants.PINECONE_INDEX,embeddings) + st.write("Pinecone index retrieval done...") + + #Fetch relavant documents from Pinecone index + relavant_docs=get_similar_docs(index,prompt,document_count) + st.write(relavant_docs) + + #Displaying search results + st.success("Please find the search results :") + #Displaying search results + st.write("search results list....") + for document in relavant_docs: + + st.write("👉**Result : "+ str(relavant_docs.index(document)+1)+"**") + st.write("**Info**: "+document.page_content) + st.write("**Link**: "+ document.metadata['source']) + + + + else: + st.sidebar.error("Ooopssss!!! Please provide API keys.....") + + + diff --git a/S18 - Project 9 - Support Chat Bot for your Website/Support Chat Bot For Your Website - Project 9/constants.py b/S18 - Project 9 - Support Chat Bot for your Website/Support Chat Bot For Your Website - Project 9/constants.py index 6feeb1f5..5d083db4 100644 --- a/S18 - Project 9 - Support Chat Bot for your Website/Support Chat Bot For Your Website - Project 9/constants.py +++ b/S18 - Project 9 - Support Chat Bot for your Website/Support Chat Bot For Your Website - Project 9/constants.py @@ -1,3 +1,3 @@ -WEBSITE_URL="https://jobs.excelcult.com/wp-sitemap-posts-post-1.xml" -PINECONE_ENVIRONMENT="us-west1-gcp-free" +WEBSITE_URL="https://jobs.excelcult.com/wp-sitemap-posts-post-1.xml" +PINECONE_ENVIRONMENT="us-west1-gcp-free" PINECONE_INDEX="chatbot" \ No newline at end of file diff --git a/S18 - Project 9 - Support Chat Bot for your Website/Support Chat Bot For Your Website - Project 9/requirements.txt b/S18 - Project 9 - Support Chat Bot for your Website/Support Chat Bot For Your Website - Project 9/requirements.txt index d9cf1197..922cac9c 100644 --- a/S18 - Project 9 - Support Chat Bot for your Website/Support Chat Bot For Your Website - Project 9/requirements.txt +++ b/S18 - Project 9 - Support Chat Bot for your Website/Support Chat Bot For Your Website - Project 9/requirements.txt @@ -1,5 +1,5 @@ -langchain -pinecone-client -openai -tiktoken +langchain +pinecone-client +openai +tiktoken nest_asyncio \ No newline at end of file diff --git a/S18 - Project 9 - Support Chat Bot for your Website/Support Chat Bot For Your Website - Project 9/utils.py b/S18 - Project 9 - Support Chat Bot for your Website/Support Chat Bot For Your Website - Project 9/utils.py index 6ebbbe1b..aca4ece8 100644 --- a/S18 - Project 9 - Support Chat Bot for your Website/Support Chat Bot For Your Website - Project 9/utils.py +++ b/S18 - Project 9 - Support Chat Bot for your Website/Support Chat Bot For Your Website - Project 9/utils.py @@ -1,72 +1,72 @@ -from langchain.text_splitter import RecursiveCharacterTextSplitter -from langchain.vectorstores import Pinecone -from langchain.embeddings.sentence_transformer import SentenceTransformerEmbeddings -import pinecone -import asyncio -from langchain.document_loaders.sitemap import SitemapLoader - - -#Function to fetch data from website -#https://python.langchain.com/docs/modules/data_connection/document_loaders/integrations/sitemap -def get_website_data(sitemap_url): - - loop = asyncio.new_event_loop() - asyncio.set_event_loop(loop) - loader = SitemapLoader( - sitemap_url - ) - - docs = loader.load() - - return docs - -#Function to split data into smaller chunks -def split_data(docs): - - text_splitter = RecursiveCharacterTextSplitter( - chunk_size = 1000, - chunk_overlap = 200, - length_function = len, - ) - - docs_chunks = text_splitter.split_documents(docs) - return docs_chunks - -#Function to create embeddings instance -def create_embeddings(): - - embeddings = SentenceTransformerEmbeddings(model_name="all-MiniLM-L6-v2") - return embeddings - -#Function to push data to Pinecone -def push_to_pinecone(pinecone_apikey,pinecone_environment,pinecone_index_name,embeddings,docs): - - pinecone.init( - api_key=pinecone_apikey, - environment=pinecone_environment - ) - - index_name = pinecone_index_name - index = Pinecone.from_documents(docs, embeddings, index_name=index_name) - return index - -#Function to pull index data from Pinecone -def pull_from_pinecone(pinecone_apikey,pinecone_environment,pinecone_index_name,embeddings): - - pinecone.init( - api_key=pinecone_apikey, - environment=pinecone_environment - ) - - index_name = pinecone_index_name - - index = Pinecone.from_existing_index(index_name, embeddings) - return index - -#This function will help us in fetching the top relevent documents from our vector store - Pinecone Index -def get_similar_docs(index,query,k=2): - - similar_docs = index.similarity_search(query, k=k) - return similar_docs - - +from langchain.text_splitter import RecursiveCharacterTextSplitter +from langchain.vectorstores import Pinecone +from langchain.embeddings.sentence_transformer import SentenceTransformerEmbeddings +import pinecone +import asyncio +from langchain.document_loaders.sitemap import SitemapLoader + + +#Function to fetch data from website +#https://python.langchain.com/docs/modules/data_connection/document_loaders/integrations/sitemap +def get_website_data(sitemap_url): + + loop = asyncio.new_event_loop() + asyncio.set_event_loop(loop) + loader = SitemapLoader( + sitemap_url + ) + + docs = loader.load() + + return docs + +#Function to split data into smaller chunks +def split_data(docs): + + text_splitter = RecursiveCharacterTextSplitter( + chunk_size = 1000, + chunk_overlap = 200, + length_function = len, + ) + + docs_chunks = text_splitter.split_documents(docs) + return docs_chunks + +#Function to create embeddings instance +def create_embeddings(): + + embeddings = SentenceTransformerEmbeddings(model_name="all-MiniLM-L6-v2") + return embeddings + +#Function to push data to Pinecone +def push_to_pinecone(pinecone_apikey,pinecone_environment,pinecone_index_name,embeddings,docs): + + pinecone.init( + api_key=pinecone_apikey, + environment=pinecone_environment + ) + + index_name = pinecone_index_name + index = Pinecone.from_documents(docs, embeddings, index_name=index_name) + return index + +#Function to pull index data from Pinecone +def pull_from_pinecone(pinecone_apikey,pinecone_environment,pinecone_index_name,embeddings): + + pinecone.init( + api_key=pinecone_apikey, + environment=pinecone_environment + ) + + index_name = pinecone_index_name + + index = Pinecone.from_existing_index(index_name, embeddings) + return index + +#This function will help us in fetching the top relevent documents from our vector store - Pinecone Index +def get_similar_docs(index,query,k=2): + + similar_docs = index.similarity_search(query, k=k) + return similar_docs + + diff --git a/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/Documents/IT Department Policy Manual.docx b/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/Documents/IT Department Policy Manual.docx deleted file mode 100644 index a9bc9557..00000000 Binary files a/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/Documents/IT Department Policy Manual.docx and /dev/null differ diff --git a/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/Documents/IT Department Policy Manual.pdf b/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/Documents/IT Department Policy Manual.pdf deleted file mode 100644 index c7759e5f..00000000 Binary files a/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/Documents/IT Department Policy Manual.pdf and /dev/null differ diff --git a/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/Documents/Tranportation Policy Manual.docx b/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/Documents/Tranportation Policy Manual.docx deleted file mode 100644 index d8aad2ec..00000000 Binary files a/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/Documents/Tranportation Policy Manual.docx and /dev/null differ diff --git a/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/Documents/Tranportation Policy Manual.pdf b/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/Documents/Tranportation Policy Manual.pdf deleted file mode 100644 index dd8306a6..00000000 Binary files a/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/Documents/Tranportation Policy Manual.pdf and /dev/null differ diff --git a/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/Tickets.csv b/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/Tickets.csv index 60b73767..45c00005 100644 --- a/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/Tickets.csv +++ b/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/Tickets.csv @@ -1,177 +1,177 @@ -"The bus arrived late again, causing me to miss an important meeting.",Transportation -"The taxi driver took a longer route, resulting in an inflated fare.",Transportation -"There's no proper signage at the train station, making it confusing for passengers.",Transportation -The flight was delayed for hours without any proper explanation.,Transportation -The bus driver was rude and unprofessional during the entire journey.,Transportation -"The train compartments were overcrowded, and there were no seats available.",Transportation -"I booked a cab, but it never arrived at the designated pick-up location.",Transportation -"The airline lost my luggage, and I haven't received any updates on its whereabouts.",Transportation -"The taxi had a broken seatbelt, posing a safety risk during the ride.",Transportation -"The bus broke down in the middle of the journey, causing a significant delay.",Transportation -"The train schedule is inconsistent, with frequent cancellations and delays.",Transportation -The airline customer service was unresponsive and provided no assistance.,Transportation -"The taxi smelled strongly of smoke, making the ride uncomfortable and unpleasant.",Transportation -There's a lack of wheelchair accessibility on public transportation vehicles.,Transportation -The flight attendant was rude and disrespectful towards passengers.,Transportation -"The bus station lacks proper facilities, including restrooms and waiting areas.",Transportation -"The taxi driver was speeding and driving recklessly, compromising passenger safety.",Transportation -The train ticketing system charged me twice for the same journey.,Transportation -"The airline overbooked the flight, causing me to be denied boarding.",Transportation -"The taxi driver refused to take me to my destination, citing a short trip.",Transportation -The bus seats were uncomfortable and in poor condition.,Transportation -"The train announcements were unclear, making it difficult to understand the next stop.",Transportation -"I purchased an online ticket, but the QR code was not recognized by the ticket scanner.",Transportation -"The airline misplaced my pet during the flight, causing distress and anxiety.",Transportation -"The taxi meter was tampered with, resulting in an inflated fare.",Transportation -"The bus driver skipped my designated stop, forcing me to walk a long distance.",Transportation -"The train platform was overcrowded, and there were no proper crowd management measures.",Transportation -The airline canceled my flight without any prior notification or alternative arrangements.,Transportation -"The taxi driver took a longer route to increase the fare, even though I provided directions.",Transportation -"The bus was dirty and poorly maintained, with broken seats and windows.",Transportation -"The train was extremely overcrowded, with passengers struggling to find space.",Transportation -I had difficulty finding a parking space at the airport due to insufficient availability.,Transportation -The taxi driver was playing loud music and refused to lower the volume upon request.,Transportation -"The bus driver was not following the designated route, causing confusion among passengers.",Transportation -"The train ticket vending machine was out of order, causing inconvenience to passengers.",Transportation -I experienced motion sickness due to poor driving skills of the taxi driver.,Transportation -The airline changed my flight schedule without notifying me in advance.,Transportation -"The bus was not wheelchair accessible, making it challenging for passengers with disabilities.",Transportation -"The train doors were malfunctioning, posing a safety hazard during boarding and disembarking.",Transportation -"The taxi driver was using a mobile phone while driving, endangering passengers' safety.",Transportation -"The bus driver was constantly honking unnecessarily, causing disturbance and discomfort.",Transportation -"The train was overcrowded, and there were no functioning air conditioning units.",Transportation -I received no assistance with my heavy luggage from the airline staff.,Transportation -"The taxi driver dropped me off at the wrong location, despite providing the correct address.",Transportation -"The bus schedule was inaccurate, with buses arriving either too early or too late.",Transportation -"The train station lacks proper lighting, posing safety concerns during evening hours.",Transportation -"I was wrongly charged for excess baggage on the airline, even though I was within the allowed limit.",Transportation -The taxi driver was driving aggressively and abruptly changing lanes without warning.,Transportation -The software crashes frequently during data entry. It's affecting my productivity.,IT -I haven't received my salary for the past two months. Can someone from HR please look into this?,HR -"The network is slow, and I'm unable to access important files. Could the IT team check it?",IT -I'm facing issues with my medical insurance coverage. Can HR assist me in resolving this matter?,HR -"The printer in our department is constantly jamming, causing delays in our work. IT, please fix it urgently.",IT -"I've been experiencing harassment from a colleague. HR, I need your help to address this problem.",HR -"The system keeps logging me out repeatedly. IT, please investigate and resolve this issue.",IT -"I have a concern regarding my vacation leave balance. HR, can you provide clarification?",HR -"There's a problem with the email server. I can't send or receive emails. IT, please resolve it quickly.",IT -"I believe there's an error in my tax deductions. HR, could you please review my payroll details?",HR -"The new software update is causing compatibility issues with my computer. IT, can you assist in fixing it?",IT -"HR, I haven't received any response to my promotion request. Can you please update me on the status?",HR -"The internet connection in our office is unreliable. IT, please look into this matter as soon as possible.",IT -"I need assistance with setting up my company email on my mobile device. IT, can you guide me through it?",IT -"I'm facing difficulties accessing my employee benefits portal. HR, can you help me resolve this issue?",HR -"IT, I accidentally deleted an important file. Is there any way to recover it?",IT -"I have concerns about the working hours. HR, can we discuss possible adjustments?",HR -"The video conferencing software is not functioning properly. IT, please fix it before our meeting.",IT -"I have questions about the company's policy on parental leave. HR, can you provide me with the details?",HR -"IT, the projector in the meeting room is not working. We need it for the presentation.",IT -"I'm having trouble accessing my employee account. HR, can you assist me in resetting my password?",HR -"The software is giving me error messages whenever I try to save my work. IT, please resolve this issue.",IT -"HR, there's an error in my employment contract. Can you review it and make the necessary corrections?",HR -"IT, I need a software license key to install a program on my computer. Can you provide it?",IT -"I'm experiencing issues with my company-issued laptop. HR, can you arrange for a replacement?",HR -"The server is down, and we are unable to access our files. IT, please fix it immediately.",IT -"I have concerns about the work environment. HR, can we schedule a meeting to discuss it?",HR -"IT, the wireless network is not available in certain areas of the office. Can you investigate the issue?",IT -"I need help with updating my personal information in the HR system. HR, can you guide me through the process?",HR -"The software is not compatible with my operating system. IT, can you recommend a solution?",IT -"The HR department did not process my vacation request on time, causing inconvenience.",HR -"IT, the email attachments are not opening correctly. Please resolve this issue promptly.",IT -"There's a discrepancy in my performance evaluation. HR, can we schedule a meeting to discuss it?",HR -I'm unable to access the HR portal to update my personal information. Can someone assist me with this?,HR -The IT helpdesk has not responded to my support ticket for three days. Please prioritize it.,IT -"I have concerns about the onboarding process. HR, can we improve the orientation program?",HR -"IT, the software license on my computer has expired. Can you renew it?",IT -"I'm facing difficulties with the time tracking system. HR, can you provide guidance on how to use it?",HR -"The Wi-Fi network in our office is not secure. IT, please ensure that appropriate measures are taken.",IT -I'm experiencing issues with the HR benefits enrollment process. Can someone assist me with this?,HR -"IT, I need assistance in setting up a virtual private network (VPN) for secure remote access.",IT -"There's a conflict within our team. HR, can you mediate and help resolve the issue?",HR -"I'm receiving spam emails repeatedly. IT, please enhance the email filtering system.",IT -The HR department has not provided me with the required training materials. Can this be addressed?,HR -"IT, I accidentally deleted an important file from the shared drive. Can you recover it?",IT -"I have concerns about the employee recognition program. HR, can we implement improvements?",HR -"The IT system crashed during an important presentation, causing embarrassment. Please fix this issue.",IT -I'm experiencing difficulties with the HR self-service portal. Can someone provide technical support?,HR -"IT, the video conferencing software is not compatible with my device. Please suggest an alternative.",IT -"There's an error in my salary calculation. HR, can you review it and rectify the mistake?",HR -"I'm unable to print documents from my computer. IT, can you investigate and resolve the issue?",IT -The HR department needs to streamline the employee appraisal process. Can improvements be made?,HR -"IT, my computer is running slow, affecting my productivity. Can you optimize its performance?",IT -"I have concerns about the diversity and inclusion initiatives. HR, can we discuss this further?",HR -The IT team needs to provide more comprehensive cybersecurity training to employees.,IT -I'm experiencing delays in receiving responses from the HR department. Can this be addressed?,HR -"IT, the website is not loading properly. Please investigate and fix the issue.",IT -"There's a lack of communication regarding policy updates. HR, can we improve internal notifications?",HR -"I need assistance with data recovery from a damaged hard drive. IT, can you help me retrieve the files?",IT -The HR department needs to address the employee morale issue. Can we conduct a survey?,HR -The IT department has not resolved my software installation issue despite multiple requests.,IT -"HR, there is a discrepancy in my employee benefits coverage. Can you please investigate and rectify it?",HR -"I'm experiencing network connectivity problems in the conference room. IT, can you check and fix it?",IT -"There's a conflict between me and my supervisor. HR, I need assistance in resolving this matter.",HR -"IT, the server is experiencing frequent outages, disrupting our work. Please address the issue urgently.",IT -"I have concerns about the transparency of the promotion process. HR, can we discuss this and provide clarity?",HR -"IT, my computer is infected with a virus. Please perform a thorough scan and remove any malware.",IT -"I'm having difficulties accessing my training materials on the learning management system. HR, can you help?",HR -The IT helpdesk provided incorrect instructions for resolving my technical issue. Can someone correct it?,IT -"I believe my performance review was biased and unfair. HR, can you conduct a thorough investigation?",HR -"IT, I need assistance in recovering a deleted email from my inbox. Is it possible to retrieve it?",IT -"There's a lack of communication regarding company policies. HR, can we improve the dissemination process?",HR -"I'm experiencing frequent system crashes while using a specific software. IT, can you investigate and fix it?",IT -The HR department has not responded to my leave application. Can you please expedite the approval process?,HR -"IT, I accidentally formatted my external hard drive. Is there any way to recover the lost data?",IT -"I have concerns about the effectiveness of our performance appraisal system. HR, can we explore improvements?",HR -"The IT network in our office is not secure, leaving us vulnerable to cyber threats. Please address the issue.",IT -I'm facing difficulties accessing the HR policy manual. Can you provide an updated version or alternative access?,HR -"IT, the software update has caused compatibility issues with other applications. Can you find a solution?",IT -"There's an error in my timesheet records. HR, can you rectify it to ensure accurate payroll processing?",HR -"I'm unable to connect to the VPN for remote access. IT, can you troubleshoot and help me establish a connection?",IT -The HR department needs to enhance communication channels for employee feedback. Can improvements be made?,HR -"IT, the conference room audio system is malfunctioning, affecting our meetings. Please fix it as soon as possible.",IT -"I have concerns about the accuracy of my expense reimbursements. HR, can we review and reconcile the records?",HR -The IT team needs to improve response time for resolving technical issues. Urgent matters are being delayed.,IT -"I'm experiencing delays in receiving my performance bonus. HR, can you check the status and provide an update?",HR -"IT, the software license on my computer is about to expire. Can you renew it before it causes any disruptions?",IT -"There's a lack of diversity in the company's hiring process. HR, can we implement more inclusive practices?",HR -"I need assistance with data backup and recovery procedures. IT, can you provide guidance on best practices?",IT -The HR department needs to address concerns related to work-life balance. Can we implement flexible policies?,HR -"IT, the software application is crashing whenever I try to export data. Can you investigate and fix the issue?",IT -"I have concerns about the transparency of the salary structure. HR, can we discuss and provide more clarity?",HR -"The network printer in our department is constantly offline. IT, please resolve this issue as it hampers productivity.",IT -I'm facing difficulties accessing my performance metrics on the HR portal. Can you provide assistance?,HR -"IT, there's a persistent issue with the video conferencing system. It frequently disconnects during meetings.",IT -"I've been subjected to workplace bullying by a colleague. HR, I need your immediate intervention to address this.",HR -"The software license on my computer has expired. IT, can you provide a renewed license key?",IT -I'm experiencing challenges with the HR onboarding process. Can you streamline and improve it?,HR -"IT, my computer is infected with malware. Can you perform a thorough scan and remove the malicious files?",IT -"I have concerns about the accuracy of my attendance records. HR, can we review and rectify any discrepancies?",HR -The IT helpdesk is not responsive to my technical support requests. It's causing delays in my work.,IT -"HR, I need clarification regarding the company's bereavement leave policy. Can you provide detailed information?",HR -"The software is not compatible with my operating system. IT, can you recommend an alternative solution?",IT -"I'm facing difficulties accessing my employee benefits portal. HR, can you provide guidance on resolving this?",HR -"IT, there's a problem with the server configuration, leading to intermittent downtime. Please address it urgently.",IT -"I believe there's an error in my performance appraisal rating. HR, can you review and amend it accordingly?",HR -"The IT network in our office is not reliable. It frequently disconnects, disrupting our work.",IT -"I'm unable to access the HR policy manual. HR, can you provide an updated copy or alternative access?",HR -"IT, my laptop is overheating, which is affecting its performance. Can you provide a solution to prevent this?",IT -The HR department needs to improve communication regarding employee development opportunities.,HR -I'm experiencing delays in receiving responses to my HR inquiries. Can this be addressed promptly?,HR -"IT, the software update has caused a loss of data on my computer. Is there any way to recover the lost files?",IT -"There's a lack of clarity in the company's remote work policy. HR, can we discuss and provide clear guidelines?",HR -"I'm unable to access my email account. IT, can you assist in resolving this issue?",IT -The HR department needs to address concerns related to employee recognition and rewards programs.,HR -"IT, the server response time is significantly slow, affecting our productivity. Please optimize its performance.",IT -"I have concerns about the fairness of the promotion process. HR, can we ensure equal opportunities for all employees?",HR -"The software interface is not user-friendly. IT, can you provide training or alternative software options?",IT -I'm experiencing challenges with the HR grievance handling process. Can you provide guidance and support?,HR -"IT, there's an issue with the backup system. It's not capturing the latest data. Please investigate and fix it.",IT -The HR department needs to improve communication regarding policy updates and changes.,HR -I'm facing difficulties with the IT asset management system. Can you provide assistance in tracking and managing assets?,IT -"IT, the website is not loading properly in certain browsers. Can you investigate and resolve the compatibility issue?",IT -"There's a lack of diversity in the company's leadership positions. HR, can we implement strategies for promoting diversity?",HR -"I'm experiencing difficulties with the remote access VPN. IT, can you troubleshoot and help me establish a secure connection?",IT -The HR department needs to address concerns related to employee morale and job satisfaction.,HR -"IT, the software is not saving my preferences and settings. Can you investigate and fix the issue?",IT -"I have concerns about the accuracy of my expense reimbursements. HR, can we review and rectify any discrepancies?",HR -The IT network in our office is not secure. Can you implement additional security measures to protect sensitive data?,IT +"The bus arrived late again, causing me to miss an important meeting.",Transportation +"The taxi driver took a longer route, resulting in an inflated fare.",Transportation +"There's no proper signage at the train station, making it confusing for passengers.",Transportation +The flight was delayed for hours without any proper explanation.,Transportation +The bus driver was rude and unprofessional during the entire journey.,Transportation +"The train compartments were overcrowded, and there were no seats available.",Transportation +"I booked a cab, but it never arrived at the designated pick-up location.",Transportation +"The airline lost my luggage, and I haven't received any updates on its whereabouts.",Transportation +"The taxi had a broken seatbelt, posing a safety risk during the ride.",Transportation +"The bus broke down in the middle of the journey, causing a significant delay.",Transportation +"The train schedule is inconsistent, with frequent cancellations and delays.",Transportation +The airline customer service was unresponsive and provided no assistance.,Transportation +"The taxi smelled strongly of smoke, making the ride uncomfortable and unpleasant.",Transportation +There's a lack of wheelchair accessibility on public transportation vehicles.,Transportation +The flight attendant was rude and disrespectful towards passengers.,Transportation +"The bus station lacks proper facilities, including restrooms and waiting areas.",Transportation +"The taxi driver was speeding and driving recklessly, compromising passenger safety.",Transportation +The train ticketing system charged me twice for the same journey.,Transportation +"The airline overbooked the flight, causing me to be denied boarding.",Transportation +"The taxi driver refused to take me to my destination, citing a short trip.",Transportation +The bus seats were uncomfortable and in poor condition.,Transportation +"The train announcements were unclear, making it difficult to understand the next stop.",Transportation +"I purchased an online ticket, but the QR code was not recognized by the ticket scanner.",Transportation +"The airline misplaced my pet during the flight, causing distress and anxiety.",Transportation +"The taxi meter was tampered with, resulting in an inflated fare.",Transportation +"The bus driver skipped my designated stop, forcing me to walk a long distance.",Transportation +"The train platform was overcrowded, and there were no proper crowd management measures.",Transportation +The airline canceled my flight without any prior notification or alternative arrangements.,Transportation +"The taxi driver took a longer route to increase the fare, even though I provided directions.",Transportation +"The bus was dirty and poorly maintained, with broken seats and windows.",Transportation +"The train was extremely overcrowded, with passengers struggling to find space.",Transportation +I had difficulty finding a parking space at the airport due to insufficient availability.,Transportation +The taxi driver was playing loud music and refused to lower the volume upon request.,Transportation +"The bus driver was not following the designated route, causing confusion among passengers.",Transportation +"The train ticket vending machine was out of order, causing inconvenience to passengers.",Transportation +I experienced motion sickness due to poor driving skills of the taxi driver.,Transportation +The airline changed my flight schedule without notifying me in advance.,Transportation +"The bus was not wheelchair accessible, making it challenging for passengers with disabilities.",Transportation +"The train doors were malfunctioning, posing a safety hazard during boarding and disembarking.",Transportation +"The taxi driver was using a mobile phone while driving, endangering passengers' safety.",Transportation +"The bus driver was constantly honking unnecessarily, causing disturbance and discomfort.",Transportation +"The train was overcrowded, and there were no functioning air conditioning units.",Transportation +I received no assistance with my heavy luggage from the airline staff.,Transportation +"The taxi driver dropped me off at the wrong location, despite providing the correct address.",Transportation +"The bus schedule was inaccurate, with buses arriving either too early or too late.",Transportation +"The train station lacks proper lighting, posing safety concerns during evening hours.",Transportation +"I was wrongly charged for excess baggage on the airline, even though I was within the allowed limit.",Transportation +The taxi driver was driving aggressively and abruptly changing lanes without warning.,Transportation +The software crashes frequently during data entry. It's affecting my productivity.,IT +I haven't received my salary for the past two months. Can someone from HR please look into this?,HR +"The network is slow, and I'm unable to access important files. Could the IT team check it?",IT +I'm facing issues with my medical insurance coverage. Can HR assist me in resolving this matter?,HR +"The printer in our department is constantly jamming, causing delays in our work. IT, please fix it urgently.",IT +"I've been experiencing harassment from a colleague. HR, I need your help to address this problem.",HR +"The system keeps logging me out repeatedly. IT, please investigate and resolve this issue.",IT +"I have a concern regarding my vacation leave balance. HR, can you provide clarification?",HR +"There's a problem with the email server. I can't send or receive emails. IT, please resolve it quickly.",IT +"I believe there's an error in my tax deductions. HR, could you please review my payroll details?",HR +"The new software update is causing compatibility issues with my computer. IT, can you assist in fixing it?",IT +"HR, I haven't received any response to my promotion request. Can you please update me on the status?",HR +"The internet connection in our office is unreliable. IT, please look into this matter as soon as possible.",IT +"I need assistance with setting up my company email on my mobile device. IT, can you guide me through it?",IT +"I'm facing difficulties accessing my employee benefits portal. HR, can you help me resolve this issue?",HR +"IT, I accidentally deleted an important file. Is there any way to recover it?",IT +"I have concerns about the working hours. HR, can we discuss possible adjustments?",HR +"The video conferencing software is not functioning properly. IT, please fix it before our meeting.",IT +"I have questions about the company's policy on parental leave. HR, can you provide me with the details?",HR +"IT, the projector in the meeting room is not working. We need it for the presentation.",IT +"I'm having trouble accessing my employee account. HR, can you assist me in resetting my password?",HR +"The software is giving me error messages whenever I try to save my work. IT, please resolve this issue.",IT +"HR, there's an error in my employment contract. Can you review it and make the necessary corrections?",HR +"IT, I need a software license key to install a program on my computer. Can you provide it?",IT +"I'm experiencing issues with my company-issued laptop. HR, can you arrange for a replacement?",HR +"The server is down, and we are unable to access our files. IT, please fix it immediately.",IT +"I have concerns about the work environment. HR, can we schedule a meeting to discuss it?",HR +"IT, the wireless network is not available in certain areas of the office. Can you investigate the issue?",IT +"I need help with updating my personal information in the HR system. HR, can you guide me through the process?",HR +"The software is not compatible with my operating system. IT, can you recommend a solution?",IT +"The HR department did not process my vacation request on time, causing inconvenience.",HR +"IT, the email attachments are not opening correctly. Please resolve this issue promptly.",IT +"There's a discrepancy in my performance evaluation. HR, can we schedule a meeting to discuss it?",HR +I'm unable to access the HR portal to update my personal information. Can someone assist me with this?,HR +The IT helpdesk has not responded to my support ticket for three days. Please prioritize it.,IT +"I have concerns about the onboarding process. HR, can we improve the orientation program?",HR +"IT, the software license on my computer has expired. Can you renew it?",IT +"I'm facing difficulties with the time tracking system. HR, can you provide guidance on how to use it?",HR +"The Wi-Fi network in our office is not secure. IT, please ensure that appropriate measures are taken.",IT +I'm experiencing issues with the HR benefits enrollment process. Can someone assist me with this?,HR +"IT, I need assistance in setting up a virtual private network (VPN) for secure remote access.",IT +"There's a conflict within our team. HR, can you mediate and help resolve the issue?",HR +"I'm receiving spam emails repeatedly. IT, please enhance the email filtering system.",IT +The HR department has not provided me with the required training materials. Can this be addressed?,HR +"IT, I accidentally deleted an important file from the shared drive. Can you recover it?",IT +"I have concerns about the employee recognition program. HR, can we implement improvements?",HR +"The IT system crashed during an important presentation, causing embarrassment. Please fix this issue.",IT +I'm experiencing difficulties with the HR self-service portal. Can someone provide technical support?,HR +"IT, the video conferencing software is not compatible with my device. Please suggest an alternative.",IT +"There's an error in my salary calculation. HR, can you review it and rectify the mistake?",HR +"I'm unable to print documents from my computer. IT, can you investigate and resolve the issue?",IT +The HR department needs to streamline the employee appraisal process. Can improvements be made?,HR +"IT, my computer is running slow, affecting my productivity. Can you optimize its performance?",IT +"I have concerns about the diversity and inclusion initiatives. HR, can we discuss this further?",HR +The IT team needs to provide more comprehensive cybersecurity training to employees.,IT +I'm experiencing delays in receiving responses from the HR department. Can this be addressed?,HR +"IT, the website is not loading properly. Please investigate and fix the issue.",IT +"There's a lack of communication regarding policy updates. HR, can we improve internal notifications?",HR +"I need assistance with data recovery from a damaged hard drive. IT, can you help me retrieve the files?",IT +The HR department needs to address the employee morale issue. Can we conduct a survey?,HR +The IT department has not resolved my software installation issue despite multiple requests.,IT +"HR, there is a discrepancy in my employee benefits coverage. Can you please investigate and rectify it?",HR +"I'm experiencing network connectivity problems in the conference room. IT, can you check and fix it?",IT +"There's a conflict between me and my supervisor. HR, I need assistance in resolving this matter.",HR +"IT, the server is experiencing frequent outages, disrupting our work. Please address the issue urgently.",IT +"I have concerns about the transparency of the promotion process. HR, can we discuss this and provide clarity?",HR +"IT, my computer is infected with a virus. Please perform a thorough scan and remove any malware.",IT +"I'm having difficulties accessing my training materials on the learning management system. HR, can you help?",HR +The IT helpdesk provided incorrect instructions for resolving my technical issue. Can someone correct it?,IT +"I believe my performance review was biased and unfair. HR, can you conduct a thorough investigation?",HR +"IT, I need assistance in recovering a deleted email from my inbox. Is it possible to retrieve it?",IT +"There's a lack of communication regarding company policies. HR, can we improve the dissemination process?",HR +"I'm experiencing frequent system crashes while using a specific software. IT, can you investigate and fix it?",IT +The HR department has not responded to my leave application. Can you please expedite the approval process?,HR +"IT, I accidentally formatted my external hard drive. Is there any way to recover the lost data?",IT +"I have concerns about the effectiveness of our performance appraisal system. HR, can we explore improvements?",HR +"The IT network in our office is not secure, leaving us vulnerable to cyber threats. Please address the issue.",IT +I'm facing difficulties accessing the HR policy manual. Can you provide an updated version or alternative access?,HR +"IT, the software update has caused compatibility issues with other applications. Can you find a solution?",IT +"There's an error in my timesheet records. HR, can you rectify it to ensure accurate payroll processing?",HR +"I'm unable to connect to the VPN for remote access. IT, can you troubleshoot and help me establish a connection?",IT +The HR department needs to enhance communication channels for employee feedback. Can improvements be made?,HR +"IT, the conference room audio system is malfunctioning, affecting our meetings. Please fix it as soon as possible.",IT +"I have concerns about the accuracy of my expense reimbursements. HR, can we review and reconcile the records?",HR +The IT team needs to improve response time for resolving technical issues. Urgent matters are being delayed.,IT +"I'm experiencing delays in receiving my performance bonus. HR, can you check the status and provide an update?",HR +"IT, the software license on my computer is about to expire. Can you renew it before it causes any disruptions?",IT +"There's a lack of diversity in the company's hiring process. HR, can we implement more inclusive practices?",HR +"I need assistance with data backup and recovery procedures. IT, can you provide guidance on best practices?",IT +The HR department needs to address concerns related to work-life balance. Can we implement flexible policies?,HR +"IT, the software application is crashing whenever I try to export data. Can you investigate and fix the issue?",IT +"I have concerns about the transparency of the salary structure. HR, can we discuss and provide more clarity?",HR +"The network printer in our department is constantly offline. IT, please resolve this issue as it hampers productivity.",IT +I'm facing difficulties accessing my performance metrics on the HR portal. Can you provide assistance?,HR +"IT, there's a persistent issue with the video conferencing system. It frequently disconnects during meetings.",IT +"I've been subjected to workplace bullying by a colleague. HR, I need your immediate intervention to address this.",HR +"The software license on my computer has expired. IT, can you provide a renewed license key?",IT +I'm experiencing challenges with the HR onboarding process. Can you streamline and improve it?,HR +"IT, my computer is infected with malware. Can you perform a thorough scan and remove the malicious files?",IT +"I have concerns about the accuracy of my attendance records. HR, can we review and rectify any discrepancies?",HR +The IT helpdesk is not responsive to my technical support requests. It's causing delays in my work.,IT +"HR, I need clarification regarding the company's bereavement leave policy. Can you provide detailed information?",HR +"The software is not compatible with my operating system. IT, can you recommend an alternative solution?",IT +"I'm facing difficulties accessing my employee benefits portal. HR, can you provide guidance on resolving this?",HR +"IT, there's a problem with the server configuration, leading to intermittent downtime. Please address it urgently.",IT +"I believe there's an error in my performance appraisal rating. HR, can you review and amend it accordingly?",HR +"The IT network in our office is not reliable. It frequently disconnects, disrupting our work.",IT +"I'm unable to access the HR policy manual. HR, can you provide an updated copy or alternative access?",HR +"IT, my laptop is overheating, which is affecting its performance. Can you provide a solution to prevent this?",IT +The HR department needs to improve communication regarding employee development opportunities.,HR +I'm experiencing delays in receiving responses to my HR inquiries. Can this be addressed promptly?,HR +"IT, the software update has caused a loss of data on my computer. Is there any way to recover the lost files?",IT +"There's a lack of clarity in the company's remote work policy. HR, can we discuss and provide clear guidelines?",HR +"I'm unable to access my email account. IT, can you assist in resolving this issue?",IT +The HR department needs to address concerns related to employee recognition and rewards programs.,HR +"IT, the server response time is significantly slow, affecting our productivity. Please optimize its performance.",IT +"I have concerns about the fairness of the promotion process. HR, can we ensure equal opportunities for all employees?",HR +"The software interface is not user-friendly. IT, can you provide training or alternative software options?",IT +I'm experiencing challenges with the HR grievance handling process. Can you provide guidance and support?,HR +"IT, there's an issue with the backup system. It's not capturing the latest data. Please investigate and fix it.",IT +The HR department needs to improve communication regarding policy updates and changes.,HR +I'm facing difficulties with the IT asset management system. Can you provide assistance in tracking and managing assets?,IT +"IT, the website is not loading properly in certain browsers. Can you investigate and resolve the compatibility issue?",IT +"There's a lack of diversity in the company's leadership positions. HR, can we implement strategies for promoting diversity?",HR +"I'm experiencing difficulties with the remote access VPN. IT, can you troubleshoot and help me establish a secure connection?",IT +The HR department needs to address concerns related to employee morale and job satisfaction.,HR +"IT, the software is not saving my preferences and settings. Can you investigate and fix the issue?",IT +"I have concerns about the accuracy of my expense reimbursements. HR, can we review and rectify any discrepancies?",HR +The IT network in our office is not secure. Can you implement additional security measures to protect sensitive data?,IT diff --git a/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/__pycache__/admin_utils.cpython-310.pyc b/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/__pycache__/admin_utils.cpython-310.pyc deleted file mode 100644 index 45a25744..00000000 Binary files a/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/__pycache__/admin_utils.cpython-310.pyc and /dev/null differ diff --git a/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/__pycache__/user_utils.cpython-310.pyc b/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/__pycache__/user_utils.cpython-310.pyc deleted file mode 100644 index 0759679b..00000000 Binary files a/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/__pycache__/user_utils.cpython-310.pyc and /dev/null differ diff --git a/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/app.py b/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/app.py index 803cbc84..06af306d 100644 --- a/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/app.py +++ b/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/app.py @@ -1,66 +1,66 @@ -from dotenv import load_dotenv -import streamlit as st -from user_utils import * - -#Creating session variables -if 'HR_tickets' not in st.session_state: - st.session_state['HR_tickets'] =[] -if 'IT_tickets' not in st.session_state: - st.session_state['IT_tickets'] =[] -if 'Transport_tickets' not in st.session_state: - st.session_state['Transport_tickets'] =[] - - -def main(): - load_dotenv() - - st.header("Automatic Ticket Classification Tool") - #Capture user input - st.write("We are here to help you, please ask your question:") - user_input = st.text_input("🔍") - - if user_input: - - #creating embeddings instance - embeddings=create_embeddings() - - #Function to pull index data from Pinecone - index=pull_from_pinecone("e697b71c-d5ed-4c66-8625-ac1c403a2df1","us-west1-gcp-free","tickets",embeddings) - - #This function will help us in fetching the top relevent documents from our vector store - Pinecone Index - relavant_docs=get_similar_docs(index,user_input) - - #This will return the fine tuned response by LLM - response=get_answer(relavant_docs,user_input) - st.write(response) - - - #Button to create a ticket with respective department - button = st.button("Submit ticket?") - - if button: - #Get Response - - - embeddings = create_embeddings() - query_result = embeddings.embed_query(user_input) - - #loading the ML model, so that we can use it to predit the class to which this compliant belongs to... - department_value = predict(query_result) - st.write("your ticket has been sumbitted to : "+department_value) - - #Appending the tickets to below list, so that we can view/use them later on... - if department_value=="HR": - st.session_state['HR_tickets'].append(user_input) - elif department_value=="IT": - st.session_state['IT_tickets'].append(user_input) - else: - st.session_state['Transport_tickets'].append(user_input) - - - -if __name__ == '__main__': - main() - - - +from dotenv import load_dotenv +import streamlit as st +from user_utils import * + +#Creating session variables +if 'HR_tickets' not in st.session_state: + st.session_state['HR_tickets'] =[] +if 'IT_tickets' not in st.session_state: + st.session_state['IT_tickets'] =[] +if 'Transport_tickets' not in st.session_state: + st.session_state['Transport_tickets'] =[] + + +def main(): + load_dotenv() + + st.header("Automatic Ticket Classification Tool") + #Capture user input + st.write("We are here to help you, please ask your question:") + user_input = st.text_input("🔍") + + if user_input: + + #creating embeddings instance + embeddings=create_embeddings() + + #Function to pull index data from Pinecone + index=pull_from_pinecone("e697b71c-d5ed-4c66-8625-ac1c403a2df1","us-west1-gcp-free","tickets",embeddings) + + #This function will help us in fetching the top relevent documents from our vector store - Pinecone Index + relavant_docs=get_similar_docs(index,user_input) + + #This will return the fine tuned response by LLM + response=get_answer(relavant_docs,user_input) + st.write(response) + + + #Button to create a ticket with respective department + button = st.button("Submit ticket?") + + if button: + #Get Response + + + embeddings = create_embeddings() + query_result = embeddings.embed_query(user_input) + + #loading the ML model, so that we can use it to predit the class to which this compliant belongs to... + department_value = predict(query_result) + st.write("your ticket has been sumbitted to : "+department_value) + + #Appending the tickets to below list, so that we can view/use them later on... + if department_value=="HR": + st.session_state['HR_tickets'].append(user_input) + elif department_value=="IT": + st.session_state['IT_tickets'].append(user_input) + else: + st.session_state['Transport_tickets'].append(user_input) + + + +if __name__ == '__main__': + main() + + + diff --git a/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/pages/Create_ML_Model.py b/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/pages/Create_ML_Model.py index abc10ee9..723aa3f7 100644 --- a/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/pages/Create_ML_Model.py +++ b/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/pages/Create_ML_Model.py @@ -1,110 +1,110 @@ -import streamlit as st -from pages.admin_utils import * -from sklearn.svm import SVC -from sklearn.pipeline import make_pipeline -from sklearn.preprocessing import StandardScaler -import joblib - -from pages.admin_utils import * - - -if 'cleaned_data' not in st.session_state: - st.session_state['cleaned_data'] ='' -if 'sentences_train' not in st.session_state: - st.session_state['sentences_train'] ='' -if 'sentences_test' not in st.session_state: - st.session_state['sentences_test'] ='' -if 'labels_train' not in st.session_state: - st.session_state['labels_train'] ='' -if 'labels_test' not in st.session_state: - st.session_state['labels_test'] ='' -if 'svm_classifier' not in st.session_state: - st.session_state['svm_classifier'] ='' - - -st.title("Let's build our Model...") - -# Create tabs -tab_titles = ['Data Preprocessing', 'Model Training', 'Model Evaluation',"Save Model"] -tabs = st.tabs(tab_titles) - -# Adding content to each tab - -#Data Preprocessing TAB -with tabs[0]: - st.header('Data Preprocessing') - st.write('Here we preprocess the data...') - - # Capture the CSV file - data = st.file_uploader("Upload CSV file",type="csv") - - button = st.button("Load data",key="data") - - if button: - with st.spinner('Wait for it...'): - our_data=read_data(data) - embeddings=get_embeddings() - st.session_state['cleaned_data'] = create_embeddings(our_data,embeddings) - st.success('Done!') - - -#Model Training TAB -with tabs[1]: - st.header('Model Training') - st.write('Here we train the model...') - button = st.button("Train model",key="model") - - if button: - with st.spinner('Wait for it...'): - st.session_state['sentences_train'], st.session_state['sentences_test'], st.session_state['labels_train'], st.session_state['labels_test']=split_train_test__data(st.session_state['cleaned_data']) - - # Initialize a support vector machine, with class_weight='balanced' because - # our training set has roughly an equal amount of positive and negative - # sentiment sentences - st.session_state['svm_classifier'] = make_pipeline(StandardScaler(), SVC(class_weight='balanced')) - - # fit the support vector machine - st.session_state['svm_classifier'].fit(st.session_state['sentences_train'], st.session_state['labels_train']) - st.success('Done!') - -#Model Evaluation TAB -with tabs[2]: - st.header('Model Evaluation') - st.write('Here we evaluate the model...') - button = st.button("Evaluate model",key="Evaluation") - - if button: - with st.spinner('Wait for it...'): - accuracy_score=get_score(st.session_state['svm_classifier'],st.session_state['sentences_test'],st.session_state['labels_test']) - st.success(f"Validation accuracy is {100*accuracy_score}%!") - - - st.write("A sample run:") - - - #text="lack of communication regarding policy updates salary, can we please look into it?" - text="Rude driver with scary driving" - st.write("***Our issue*** : "+text) - - #Converting out TEXT to NUMERICAL representaion - embeddings= get_embeddings() - query_result = embeddings.embed_query(text) - - #Sample prediction using our trained model - result= st.session_state['svm_classifier'].predict([query_result]) - st.write("***Department it belongs to*** : "+result[0]) - - - st.success('Done!') - -#Save model TAB -with tabs[3]: - st.header('Save model') - st.write('Here we save the model...') - - button = st.button("Save model",key="save") - if button: - - with st.spinner('Wait for it...'): - joblib.dump(st.session_state['svm_classifier'], 'modelsvm.pk1') +import streamlit as st +from pages.admin_utils import * +from sklearn.svm import SVC +from sklearn.pipeline import make_pipeline +from sklearn.preprocessing import StandardScaler +import joblib + +from pages.admin_utils import * + + +if 'cleaned_data' not in st.session_state: + st.session_state['cleaned_data'] ='' +if 'sentences_train' not in st.session_state: + st.session_state['sentences_train'] ='' +if 'sentences_test' not in st.session_state: + st.session_state['sentences_test'] ='' +if 'labels_train' not in st.session_state: + st.session_state['labels_train'] ='' +if 'labels_test' not in st.session_state: + st.session_state['labels_test'] ='' +if 'svm_classifier' not in st.session_state: + st.session_state['svm_classifier'] ='' + + +st.title("Let's build our Model...") + +# Create tabs +tab_titles = ['Data Preprocessing', 'Model Training', 'Model Evaluation',"Save Model"] +tabs = st.tabs(tab_titles) + +# Adding content to each tab + +#Data Preprocessing TAB +with tabs[0]: + st.header('Data Preprocessing') + st.write('Here we preprocess the data...') + + # Capture the CSV file + data = st.file_uploader("Upload CSV file",type="csv") + + button = st.button("Load data",key="data") + + if button: + with st.spinner('Wait for it...'): + our_data=read_data(data) + embeddings=get_embeddings() + st.session_state['cleaned_data'] = create_embeddings(our_data,embeddings) + st.success('Done!') + + +#Model Training TAB +with tabs[1]: + st.header('Model Training') + st.write('Here we train the model...') + button = st.button("Train model",key="model") + + if button: + with st.spinner('Wait for it...'): + st.session_state['sentences_train'], st.session_state['sentences_test'], st.session_state['labels_train'], st.session_state['labels_test']=split_train_test__data(st.session_state['cleaned_data']) + + # Initialize a support vector machine, with class_weight='balanced' because + # our training set has roughly an equal amount of positive and negative + # sentiment sentences + st.session_state['svm_classifier'] = make_pipeline(StandardScaler(), SVC(class_weight='balanced')) + + # fit the support vector machine + st.session_state['svm_classifier'].fit(st.session_state['sentences_train'], st.session_state['labels_train']) + st.success('Done!') + +#Model Evaluation TAB +with tabs[2]: + st.header('Model Evaluation') + st.write('Here we evaluate the model...') + button = st.button("Evaluate model",key="Evaluation") + + if button: + with st.spinner('Wait for it...'): + accuracy_score=get_score(st.session_state['svm_classifier'],st.session_state['sentences_test'],st.session_state['labels_test']) + st.success(f"Validation accuracy is {100*accuracy_score}%!") + + + st.write("A sample run:") + + + #text="lack of communication regarding policy updates salary, can we please look into it?" + text="Rude driver with scary driving" + st.write("***Our issue*** : "+text) + + #Converting out TEXT to NUMERICAL representaion + embeddings= get_embeddings() + query_result = embeddings.embed_query(text) + + #Sample prediction using our trained model + result= st.session_state['svm_classifier'].predict([query_result]) + st.write("***Department it belongs to*** : "+result[0]) + + + st.success('Done!') + +#Save model TAB +with tabs[3]: + st.header('Save model') + st.write('Here we save the model...') + + button = st.button("Save model",key="save") + if button: + + with st.spinner('Wait for it...'): + joblib.dump(st.session_state['svm_classifier'], 'modelsvm.pk1') st.success('Done!') \ No newline at end of file diff --git a/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/pages/Load_Data_Store.py b/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/pages/Load_Data_Store.py index 9e621899..e30b3356 100644 --- a/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/pages/Load_Data_Store.py +++ b/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/pages/Load_Data_Store.py @@ -1,36 +1,36 @@ -import streamlit as st -from dotenv import load_dotenv -from pages.admin_utils import * - - -def main(): - load_dotenv() - st.set_page_config(page_title="Dump PDF to Pinecone - Vector Store") - st.title("Please upload your files...📁 ") - - # Upload the pdf file - pdf = st.file_uploader("Only PDF files allowed", type=["pdf"]) - - # Extract the whole text from the uploaded pdf file - if pdf is not None: - with st.spinner('Wait for it...'): - text=read_pdf_data(pdf) - st.write("👉Reading PDF done") - - # Create chunks - docs_chunks=split_data(text) - #st.write(docs_chunks) - st.write("👉Splitting data into chunks done") - - # Create the embeddings - embeddings=create_embeddings_load_data() - st.write("👉Creating embeddings instance done") - - # Build the vector store (Push the PDF data embeddings) - push_to_pinecone("e697b71c-d5ed-4c66-8625-ac1c403a2df1","us-west1-gcp-free","tickets",embeddings,docs_chunks) - - st.success("Successfully pushed the embeddings to Pinecone") - - -if __name__ == '__main__': - main() +import streamlit as st +from dotenv import load_dotenv +from pages.admin_utils import * + + +def main(): + load_dotenv() + st.set_page_config(page_title="Dump PDF to Pinecone - Vector Store") + st.title("Please upload your files...📁 ") + + # Upload the pdf file + pdf = st.file_uploader("Only PDF files allowed", type=["pdf"]) + + # Extract the whole text from the uploaded pdf file + if pdf is not None: + with st.spinner('Wait for it...'): + text=read_pdf_data(pdf) + st.write("👉Reading PDF done") + + # Create chunks + docs_chunks=split_data(text) + #st.write(docs_chunks) + st.write("👉Splitting data into chunks done") + + # Create the embeddings + embeddings=create_embeddings_load_data() + st.write("👉Creating embeddings instance done") + + # Build the vector store (Push the PDF data embeddings) + push_to_pinecone("e697b71c-d5ed-4c66-8625-ac1c403a2df1","us-west1-gcp-free","tickets",embeddings,docs_chunks) + + st.success("Successfully pushed the embeddings to Pinecone") + + +if __name__ == '__main__': + main() diff --git a/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/pages/Pending_tickets.py b/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/pages/Pending_tickets.py index fbe3481b..b8232e12 100644 --- a/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/pages/Pending_tickets.py +++ b/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/pages/Pending_tickets.py @@ -1,26 +1,26 @@ -import streamlit as st - -st.title('Departments') - -# Create tabs -tab_titles = ['HR Support', 'IT Support', 'Transportation Support'] -tabs = st.tabs(tab_titles) - -# Add content to each tab -with tabs[0]: - st.header('HR Support tickets') - for ticket in st.session_state['HR_tickets']: - st.write(str(st.session_state['HR_tickets'].index(ticket)+1)+" : "+ticket) - - -with tabs[1]: - st.header('IT Support tickets') - for ticket in st.session_state['IT_tickets']: - st.write(str(st.session_state['IT_tickets'].index(ticket)+1)+" : "+ticket) - -with tabs[2]: - st.header('Transportation Support tickets') - for ticket in st.session_state['Transport_tickets']: - st.write(str(st.session_state['Transport_tickets'].index(ticket)+1)+" : "+ticket) - +import streamlit as st + +st.title('Departments') + +# Create tabs +tab_titles = ['HR Support', 'IT Support', 'Transportation Support'] +tabs = st.tabs(tab_titles) + +# Add content to each tab +with tabs[0]: + st.header('HR Support tickets') + for ticket in st.session_state['HR_tickets']: + st.write(str(st.session_state['HR_tickets'].index(ticket)+1)+" : "+ticket) + + +with tabs[1]: + st.header('IT Support tickets') + for ticket in st.session_state['IT_tickets']: + st.write(str(st.session_state['IT_tickets'].index(ticket)+1)+" : "+ticket) + +with tabs[2]: + st.header('Transportation Support tickets') + for ticket in st.session_state['Transport_tickets']: + st.write(str(st.session_state['Transport_tickets'].index(ticket)+1)+" : "+ticket) + \ No newline at end of file diff --git a/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/pages/__pycache__/admin_utils.cpython-310.pyc b/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/pages/__pycache__/admin_utils.cpython-310.pyc deleted file mode 100644 index e5f76513..00000000 Binary files a/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/pages/__pycache__/admin_utils.cpython-310.pyc and /dev/null differ diff --git a/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/pages/admin_utils.py b/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/pages/admin_utils.py index c7e325de..009784cc 100644 --- a/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/pages/admin_utils.py +++ b/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/pages/admin_utils.py @@ -1,77 +1,77 @@ -from pypdf import PdfReader -from langchain.text_splitter import RecursiveCharacterTextSplitter -from langchain.embeddings import OpenAIEmbeddings -from langchain.embeddings.sentence_transformer import SentenceTransformerEmbeddings -from langchain.llms import OpenAI -import pinecone -from langchain.vectorstores import Pinecone -import pandas as pd -from sklearn.model_selection import train_test_split - - - - -#**********Functions to help you load documents to PINECONE*********** - -#Read PDF data -def read_pdf_data(pdf_file): - pdf_page = PdfReader(pdf_file) - text = "" - for page in pdf_page.pages: - text += page.extract_text() - return text - -#Split data into chunks -def split_data(text): - text_splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=50) - docs = text_splitter.split_text(text) - docs_chunks =text_splitter.create_documents(docs) - return docs_chunks - -#Create embeddings instance -def create_embeddings_load_data(): - #embeddings = OpenAIEmbeddings() - embeddings = SentenceTransformerEmbeddings(model_name="all-MiniLM-L6-v2") - return embeddings - -#Function to push data to Pinecone -def push_to_pinecone(pinecone_apikey,pinecone_environment,pinecone_index_name,embeddings,docs): - - pinecone.init( - api_key=pinecone_apikey, - environment=pinecone_environment - ) - - index_name = pinecone_index_name - index = Pinecone.from_documents(docs, embeddings, index_name=index_name) - return index - -#*********Functions for dealing with Model related tasks...************ - -#Read dataset for model creation -def read_data(data): - df = pd.read_csv(data,delimiter=',', header=None) - return df - -#Create embeddings instance -def get_embeddings(): - embeddings = SentenceTransformerEmbeddings(model_name="all-MiniLM-L6-v2") - return embeddings - -#Generating embeddings for our input dataset -def create_embeddings(df,embeddings): - df[2] = df[0].apply(lambda x: embeddings.embed_query(x)) - return df - -#Splitting the data into train & test -def split_train_test__data(df_sample): - # Split into training and testing sets - sentences_train, sentences_test, labels_train, labels_test = train_test_split( - list(df_sample[2]), list(df_sample[1]), test_size=0.25, random_state=0) - print(len(sentences_train)) - return sentences_train, sentences_test, labels_train, labels_test - -#Get the accuracy score on test data -def get_score(svm_classifier,sentences_test,labels_test): - score = svm_classifier.score(sentences_test, labels_test) - return score +from pypdf import PdfReader +from langchain.text_splitter import RecursiveCharacterTextSplitter +from langchain.embeddings import OpenAIEmbeddings +from langchain.embeddings.sentence_transformer import SentenceTransformerEmbeddings +from langchain.llms import OpenAI +import pinecone +from langchain.vectorstores import Pinecone +import pandas as pd +from sklearn.model_selection import train_test_split + + + + +#**********Functions to help you load documents to PINECONE*********** + +#Read PDF data +def read_pdf_data(pdf_file): + pdf_page = PdfReader(pdf_file) + text = "" + for page in pdf_page.pages: + text += page.extract_text() + return text + +#Split data into chunks +def split_data(text): + text_splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=50) + docs = text_splitter.split_text(text) + docs_chunks =text_splitter.create_documents(docs) + return docs_chunks + +#Create embeddings instance +def create_embeddings_load_data(): + #embeddings = OpenAIEmbeddings() + embeddings = SentenceTransformerEmbeddings(model_name="all-MiniLM-L6-v2") + return embeddings + +#Function to push data to Pinecone +def push_to_pinecone(pinecone_apikey,pinecone_environment,pinecone_index_name,embeddings,docs): + + pinecone.init( + api_key=pinecone_apikey, + environment=pinecone_environment + ) + + index_name = pinecone_index_name + index = Pinecone.from_documents(docs, embeddings, index_name=index_name) + return index + +#*********Functions for dealing with Model related tasks...************ + +#Read dataset for model creation +def read_data(data): + df = pd.read_csv(data,delimiter=',', header=None) + return df + +#Create embeddings instance +def get_embeddings(): + embeddings = SentenceTransformerEmbeddings(model_name="all-MiniLM-L6-v2") + return embeddings + +#Generating embeddings for our input dataset +def create_embeddings(df,embeddings): + df[2] = df[0].apply(lambda x: embeddings.embed_query(x)) + return df + +#Splitting the data into train & test +def split_train_test__data(df_sample): + # Split into training and testing sets + sentences_train, sentences_test, labels_train, labels_test = train_test_split( + list(df_sample[2]), list(df_sample[1]), test_size=0.25, random_state=0) + print(len(sentences_train)) + return sentences_train, sentences_test, labels_train, labels_test + +#Get the accuracy score on test data +def get_score(svm_classifier,sentences_test,labels_test): + score = svm_classifier.score(sentences_test, labels_test) + return score diff --git a/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/requirements.txt b/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/requirements.txt index ba105b60..125e0dc7 100644 --- a/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/requirements.txt +++ b/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/requirements.txt @@ -1,9 +1,9 @@ -langchain -streamlit -openai -tiktoken -python-dotenv -pinecone-client -pypdf -joblib +langchain +streamlit +openai +tiktoken +python-dotenv +pinecone-client +pypdf +joblib pandas \ No newline at end of file diff --git a/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/user_utils.py b/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/user_utils.py index 16916b84..50cff6c0 100644 --- a/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/user_utils.py +++ b/S19 - Project 10 - Automatic Ticket Classification Tool/Automatic Ticket Classification Tool/user_utils.py @@ -1,43 +1,43 @@ -import pinecone -from langchain.vectorstores import Pinecone -from langchain.embeddings.sentence_transformer import SentenceTransformerEmbeddings -from langchain.llms import OpenAI -from langchain.chains.question_answering import load_qa_chain -from langchain.callbacks import get_openai_callback -import joblib - - -#Function to pull index data from Pinecone -def pull_from_pinecone(pinecone_apikey,pinecone_environment,pinecone_index_name,embeddings): - - pinecone.init( - api_key=pinecone_apikey, - environment=pinecone_environment - ) - - index_name = pinecone_index_name - - index = Pinecone.from_existing_index(index_name, embeddings) - return index - -def create_embeddings(): - embeddings = SentenceTransformerEmbeddings(model_name="all-MiniLM-L6-v2") - return embeddings - -#This function will help us in fetching the top relevent documents from our vector store - Pinecone Index -def get_similar_docs(index,query,k=2): - - similar_docs = index.similarity_search(query, k=k) - return similar_docs - -def get_answer(docs,user_input): - chain = load_qa_chain(OpenAI(), chain_type="stuff") - with get_openai_callback() as cb: - response = chain.run(input_documents=docs, question=user_input) - return response - - -def predict(query_result): - Fitmodel = joblib.load('modelsvm.pk1') - result=Fitmodel.predict([query_result]) +import pinecone +from langchain.vectorstores import Pinecone +from langchain.embeddings.sentence_transformer import SentenceTransformerEmbeddings +from langchain.llms import OpenAI +from langchain.chains.question_answering import load_qa_chain +from langchain.callbacks import get_openai_callback +import joblib + + +#Function to pull index data from Pinecone +def pull_from_pinecone(pinecone_apikey,pinecone_environment,pinecone_index_name,embeddings): + + pinecone.init( + api_key=pinecone_apikey, + environment=pinecone_environment + ) + + index_name = pinecone_index_name + + index = Pinecone.from_existing_index(index_name, embeddings) + return index + +def create_embeddings(): + embeddings = SentenceTransformerEmbeddings(model_name="all-MiniLM-L6-v2") + return embeddings + +#This function will help us in fetching the top relevent documents from our vector store - Pinecone Index +def get_similar_docs(index,query,k=2): + + similar_docs = index.similarity_search(query, k=k) + return similar_docs + +def get_answer(docs,user_input): + chain = load_qa_chain(OpenAI(), chain_type="stuff") + with get_openai_callback() as cb: + response = chain.run(input_documents=docs, question=user_input) + return response + + +def predict(query_result): + Fitmodel = joblib.load('modelsvm.pk1') + result=Fitmodel.predict([query_result]) return result[0] \ No newline at end of file diff --git a/S20 - Project 11 - HR Resume Screening Assistance/Resume Screening Assistance Project - Source Code/.env b/S20 - Project 11 - HR Resume Screening Assistance/Resume Screening Assistance Project - Source Code/.env index 871c94cf..4079ec7d 100644 --- a/S20 - Project 11 - HR Resume Screening Assistance/Resume Screening Assistance Project - Source Code/.env +++ b/S20 - Project 11 - HR Resume Screening Assistance/Resume Screening Assistance Project - Source Code/.env @@ -1,2 +1,2 @@ -OPENAI_API_KEY="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" +OPENAI_API_KEY="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" HUGGINGFACEHUB_API_TOKEN="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" \ No newline at end of file diff --git a/S20 - Project 11 - HR Resume Screening Assistance/Resume Screening Assistance Project - Source Code/Docs/embedded-software-engineer-resume-example.pdf b/S20 - Project 11 - HR Resume Screening Assistance/Resume Screening Assistance Project - Source Code/Docs/embedded-software-engineer-resume-example.pdf deleted file mode 100644 index a7cf2afd..00000000 Binary files a/S20 - Project 11 - HR Resume Screening Assistance/Resume Screening Assistance Project - Source Code/Docs/embedded-software-engineer-resume-example.pdf and /dev/null differ diff --git a/S20 - Project 11 - HR Resume Screening Assistance/Resume Screening Assistance Project - Source Code/Docs/java-programmer-resume-example.pdf b/S20 - Project 11 - HR Resume Screening Assistance/Resume Screening Assistance Project - Source Code/Docs/java-programmer-resume-example.pdf deleted file mode 100644 index 23eff101..00000000 Binary files a/S20 - Project 11 - HR Resume Screening Assistance/Resume Screening Assistance Project - Source Code/Docs/java-programmer-resume-example.pdf and /dev/null differ diff --git a/S20 - Project 11 - HR Resume Screening Assistance/Resume Screening Assistance Project - Source Code/Docs/principal-software-engineer-resume-example.pdf b/S20 - Project 11 - HR Resume Screening Assistance/Resume Screening Assistance Project - Source Code/Docs/principal-software-engineer-resume-example.pdf deleted file mode 100644 index d1aafe1d..00000000 Binary files a/S20 - Project 11 - HR Resume Screening Assistance/Resume Screening Assistance Project - Source Code/Docs/principal-software-engineer-resume-example.pdf and /dev/null differ diff --git a/S20 - Project 11 - HR Resume Screening Assistance/Resume Screening Assistance Project - Source Code/Docs/python-developer-resume-example.pdf b/S20 - Project 11 - HR Resume Screening Assistance/Resume Screening Assistance Project - Source Code/Docs/python-developer-resume-example.pdf deleted file mode 100644 index e2454bfe..00000000 Binary files a/S20 - Project 11 - HR Resume Screening Assistance/Resume Screening Assistance Project - Source Code/Docs/python-developer-resume-example.pdf and /dev/null differ diff --git a/S20 - Project 11 - HR Resume Screening Assistance/Resume Screening Assistance Project - Source Code/Docs/security-engineer-resume-example.pdf b/S20 - Project 11 - HR Resume Screening Assistance/Resume Screening Assistance Project - Source Code/Docs/security-engineer-resume-example.pdf deleted file mode 100644 index 8f6d640d..00000000 Binary files a/S20 - Project 11 - HR Resume Screening Assistance/Resume Screening Assistance Project - Source Code/Docs/security-engineer-resume-example.pdf and /dev/null differ diff --git a/S20 - Project 11 - HR Resume Screening Assistance/Resume Screening Assistance Project - Source Code/Docs/senior-programmer-resume-example.pdf b/S20 - Project 11 - HR Resume Screening Assistance/Resume Screening Assistance Project - Source Code/Docs/senior-programmer-resume-example.pdf deleted file mode 100644 index 371e712d..00000000 Binary files a/S20 - Project 11 - HR Resume Screening Assistance/Resume Screening Assistance Project - Source Code/Docs/senior-programmer-resume-example.pdf and /dev/null differ diff --git a/S20 - Project 11 - HR Resume Screening Assistance/Resume Screening Assistance Project - Source Code/Docs/software-engineer-iii-front-end-resume-example.pdf b/S20 - Project 11 - HR Resume Screening Assistance/Resume Screening Assistance Project - Source Code/Docs/software-engineer-iii-front-end-resume-example.pdf deleted file mode 100644 index 4d65d911..00000000 Binary files a/S20 - Project 11 - HR Resume Screening Assistance/Resume Screening Assistance Project - Source Code/Docs/software-engineer-iii-front-end-resume-example.pdf and /dev/null differ diff --git a/S20 - Project 11 - HR Resume Screening Assistance/Resume Screening Assistance Project - Source Code/app.py b/S20 - Project 11 - HR Resume Screening Assistance/Resume Screening Assistance Project - Source Code/app.py index b72d7f30..09b86254 100644 --- a/S20 - Project 11 - HR Resume Screening Assistance/Resume Screening Assistance Project - Source Code/app.py +++ b/S20 - Project 11 - HR Resume Screening Assistance/Resume Screening Assistance Project - Source Code/app.py @@ -1,72 +1,72 @@ -import streamlit as st -from dotenv import load_dotenv -from utils import * -import uuid - -#Creating session variables -if 'unique_id' not in st.session_state: - st.session_state['unique_id'] ='' - -def main(): - load_dotenv() - - st.set_page_config(page_title="Resume Screening Assistance") - st.title("HR - Resume Screening Assistance...💁 ") - st.subheader("I can help you in resume screening process") - - job_description = st.text_area("Please paste the 'JOB DESCRIPTION' here...",key="1") - document_count = st.text_input("No.of 'RESUMES' to return",key="2") - # Upload the Resumes (pdf files) - pdf = st.file_uploader("Upload resumes here, only PDF files allowed", type=["pdf"],accept_multiple_files=True) - - submit=st.button("Help me with the analysis") - - if submit: - with st.spinner('Wait for it...'): - - #Creating a unique ID, so that we can use to query and get only the user uploaded documents from PINECONE vector store - st.session_state['unique_id']=uuid.uuid4().hex - - #Create a documents list out of all the user uploaded pdf files - final_docs_list=create_docs(pdf,st.session_state['unique_id']) - - #Displaying the count of resumes that have been uploaded - st.write("*Resumes uploaded* :"+str(len(final_docs_list))) - - #Create embeddings instance - embeddings=create_embeddings_load_data() - - #Push data to PINECONE - push_to_pinecone("e697b71c-d5ed-4c66-8625-ac1c403a2df1","us-west1-gcp-free","test",embeddings,final_docs_list) - - #Fecth relavant documents from PINECONE - relavant_docs=similar_docs(job_description,document_count,"e697b71c-d5ed-4c66-8625-ac1c403a2df1","us-west1-gcp-free","test",embeddings,st.session_state['unique_id']) - - #t.write(relavant_docs) - - #Introducing a line separator - st.write(":heavy_minus_sign:" * 30) - - #For each item in relavant docs - we are displaying some info of it on the UI - for item in range(len(relavant_docs)): - - st.subheader("👉 "+str(item+1)) - - #Displaying Filepath - st.write("**File** : "+relavant_docs[item][0].metadata['name']) - - #Introducing Expander feature - with st.expander('Show me 👀'): - st.info("**Match Score** : "+str(relavant_docs[item][1])) - #st.write("***"+relavant_docs[item][0].page_content) - - #Gets the summary of the current item using 'get_summary' function that we have created which uses LLM & Langchain chain - summary = get_summary(relavant_docs[item][0]) - st.write("**Summary** : "+summary) - - st.success("Hope I was able to save your time❤️") - - -#Invoking main function -if __name__ == '__main__': - main() +import streamlit as st +from dotenv import load_dotenv +from utils import * +import uuid + +#Creating session variables +if 'unique_id' not in st.session_state: + st.session_state['unique_id'] ='' + +def main(): + load_dotenv() + + st.set_page_config(page_title="Resume Screening Assistance") + st.title("HR - Resume Screening Assistance...💁 ") + st.subheader("I can help you in resume screening process") + + job_description = st.text_area("Please paste the 'JOB DESCRIPTION' here...",key="1") + document_count = st.text_input("No.of 'RESUMES' to return",key="2") + # Upload the Resumes (pdf files) + pdf = st.file_uploader("Upload resumes here, only PDF files allowed", type=["pdf"],accept_multiple_files=True) + + submit=st.button("Help me with the analysis") + + if submit: + with st.spinner('Wait for it...'): + + #Creating a unique ID, so that we can use to query and get only the user uploaded documents from PINECONE vector store + st.session_state['unique_id']=uuid.uuid4().hex + + #Create a documents list out of all the user uploaded pdf files + final_docs_list=create_docs(pdf,st.session_state['unique_id']) + + #Displaying the count of resumes that have been uploaded + st.write("*Resumes uploaded* :"+str(len(final_docs_list))) + + #Create embeddings instance + embeddings=create_embeddings_load_data() + + #Push data to PINECONE + push_to_pinecone("e697b71c-d5ed-4c66-8625-ac1c403a2df1","us-west1-gcp-free","test",embeddings,final_docs_list) + + #Fecth relavant documents from PINECONE + relavant_docs=similar_docs(job_description,document_count,"e697b71c-d5ed-4c66-8625-ac1c403a2df1","us-west1-gcp-free","test",embeddings,st.session_state['unique_id']) + + #t.write(relavant_docs) + + #Introducing a line separator + st.write(":heavy_minus_sign:" * 30) + + #For each item in relavant docs - we are displaying some info of it on the UI + for item in range(len(relavant_docs)): + + st.subheader("👉 "+str(item+1)) + + #Displaying Filepath + st.write("**File** : "+relavant_docs[item][0].metadata['name']) + + #Introducing Expander feature + with st.expander('Show me 👀'): + st.info("**Match Score** : "+str(relavant_docs[item][1])) + #st.write("***"+relavant_docs[item][0].page_content) + + #Gets the summary of the current item using 'get_summary' function that we have created which uses LLM & Langchain chain + summary = get_summary(relavant_docs[item][0]) + st.write("**Summary** : "+summary) + + st.success("Hope I was able to save your time❤️") + + +#Invoking main function +if __name__ == '__main__': + main() diff --git a/S20 - Project 11 - HR Resume Screening Assistance/Resume Screening Assistance Project - Source Code/requirements.txt b/S20 - Project 11 - HR Resume Screening Assistance/Resume Screening Assistance Project - Source Code/requirements.txt index c8c19c86..8dbbcc2c 100644 --- a/S20 - Project 11 - HR Resume Screening Assistance/Resume Screening Assistance Project - Source Code/requirements.txt +++ b/S20 - Project 11 - HR Resume Screening Assistance/Resume Screening Assistance Project - Source Code/requirements.txt @@ -1,9 +1,9 @@ -langchain -streamlit -openai -tiktoken -python-dotenv -unstructured -pinecone-client -pypdf +langchain +streamlit +openai +tiktoken +python-dotenv +unstructured +pinecone-client +pypdf sentence_transformers \ No newline at end of file diff --git a/S20 - Project 11 - HR Resume Screening Assistance/Resume Screening Assistance Project - Source Code/utils.py b/S20 - Project 11 - HR Resume Screening Assistance/Resume Screening Assistance Project - Source Code/utils.py index 40b45ee8..88cdb2d1 100644 --- a/S20 - Project 11 - HR Resume Screening Assistance/Resume Screening Assistance Project - Source Code/utils.py +++ b/S20 - Project 11 - HR Resume Screening Assistance/Resume Screening Assistance Project - Source Code/utils.py @@ -1,103 +1,103 @@ -import openai -from langchain.embeddings.openai import OpenAIEmbeddings -from langchain.vectorstores import Pinecone -from langchain.llms import OpenAI -from langchain.embeddings.sentence_transformer import SentenceTransformerEmbeddings -from langchain.schema import Document -import pinecone -from pypdf import PdfReader -from langchain.llms.openai import OpenAI -from langchain.chains.summarize import load_summarize_chain -from langchain import HuggingFaceHub - - -#Extract Information from PDF file -def get_pdf_text(pdf_doc): - text = "" - pdf_reader = PdfReader(pdf_doc) - for page in pdf_reader.pages: - text += page.extract_text() - return text - - - -# iterate over files in -# that user uploaded PDF files, one by one -def create_docs(user_pdf_list, unique_id): - docs=[] - for filename in user_pdf_list: - - chunks=get_pdf_text(filename) - - #Adding items to our list - Adding data & its metadata - docs.append(Document( - page_content=chunks, - metadata={"name": filename.name,"id":filename.id,"type=":filename.type,"size":filename.size,"unique_id":unique_id}, - )) - - return docs - - -#Create embeddings instance -def create_embeddings_load_data(): - #embeddings = OpenAIEmbeddings() - embeddings = SentenceTransformerEmbeddings(model_name="all-MiniLM-L6-v2") - return embeddings - - -#Function to push data to Vector Store - Pinecone here -def push_to_pinecone(pinecone_apikey,pinecone_environment,pinecone_index_name,embeddings,docs): - - pinecone.init( - api_key=pinecone_apikey, - environment=pinecone_environment - ) - print("done......2") - Pinecone.from_documents(docs, embeddings, index_name=pinecone_index_name) - - - -#Function to pull infrmation from Vector Store - Pinecone here -def pull_from_pinecone(pinecone_apikey,pinecone_environment,pinecone_index_name,embeddings): - - pinecone.init( - api_key=pinecone_apikey, - environment=pinecone_environment - ) - - index_name = pinecone_index_name - - index = Pinecone.from_existing_index(index_name, embeddings) - return index - - - -#Function to help us get relavant documents from vector store - based on user input -def similar_docs(query,k,pinecone_apikey,pinecone_environment,pinecone_index_name,embeddings,unique_id): - - pinecone.init( - api_key=pinecone_apikey, - environment=pinecone_environment - ) - - index_name = pinecone_index_name - - index = pull_from_pinecone(pinecone_apikey,pinecone_environment,index_name,embeddings) - similar_docs = index.similarity_search_with_score(query, int(k),{"unique_id":unique_id}) - #print(similar_docs) - return similar_docs - - -# Helps us get the summary of a document -def get_summary(current_doc): - llm = OpenAI(temperature=0) - #llm = HuggingFaceHub(repo_id="bigscience/bloom", model_kwargs={"temperature":1e-10}) - chain = load_summarize_chain(llm, chain_type="map_reduce") - summary = chain.run([current_doc]) - - return summary - - - - +import openai +from langchain.embeddings.openai import OpenAIEmbeddings +from langchain.vectorstores import Pinecone +from langchain.llms import OpenAI +from langchain.embeddings.sentence_transformer import SentenceTransformerEmbeddings +from langchain.schema import Document +import pinecone +from pypdf import PdfReader +from langchain.llms.openai import OpenAI +from langchain.chains.summarize import load_summarize_chain +from langchain import HuggingFaceHub + + +#Extract Information from PDF file +def get_pdf_text(pdf_doc): + text = "" + pdf_reader = PdfReader(pdf_doc) + for page in pdf_reader.pages: + text += page.extract_text() + return text + + + +# iterate over files in +# that user uploaded PDF files, one by one +def create_docs(user_pdf_list, unique_id): + docs=[] + for filename in user_pdf_list: + + chunks=get_pdf_text(filename) + + #Adding items to our list - Adding data & its metadata + docs.append(Document( + page_content=chunks, + metadata={"name": filename.name,"id":filename.id,"type=":filename.type,"size":filename.size,"unique_id":unique_id}, + )) + + return docs + + +#Create embeddings instance +def create_embeddings_load_data(): + #embeddings = OpenAIEmbeddings() + embeddings = SentenceTransformerEmbeddings(model_name="all-MiniLM-L6-v2") + return embeddings + + +#Function to push data to Vector Store - Pinecone here +def push_to_pinecone(pinecone_apikey,pinecone_environment,pinecone_index_name,embeddings,docs): + + pinecone.init( + api_key=pinecone_apikey, + environment=pinecone_environment + ) + print("done......2") + Pinecone.from_documents(docs, embeddings, index_name=pinecone_index_name) + + + +#Function to pull infrmation from Vector Store - Pinecone here +def pull_from_pinecone(pinecone_apikey,pinecone_environment,pinecone_index_name,embeddings): + + pinecone.init( + api_key=pinecone_apikey, + environment=pinecone_environment + ) + + index_name = pinecone_index_name + + index = Pinecone.from_existing_index(index_name, embeddings) + return index + + + +#Function to help us get relavant documents from vector store - based on user input +def similar_docs(query,k,pinecone_apikey,pinecone_environment,pinecone_index_name,embeddings,unique_id): + + pinecone.init( + api_key=pinecone_apikey, + environment=pinecone_environment + ) + + index_name = pinecone_index_name + + index = pull_from_pinecone(pinecone_apikey,pinecone_environment,index_name,embeddings) + similar_docs = index.similarity_search_with_score(query, int(k),{"unique_id":unique_id}) + #print(similar_docs) + return similar_docs + + +# Helps us get the summary of a document +def get_summary(current_doc): + llm = OpenAI(temperature=0) + #llm = HuggingFaceHub(repo_id="bigscience/bloom", model_kwargs={"temperature":1e-10}) + chain = load_summarize_chain(llm, chain_type="map_reduce") + summary = chain.run([current_doc]) + + return summary + + + + \ No newline at end of file diff --git a/S22 - Project 12 - Email Generator Using LLAMA 2 - Streamlit App/Email Generator App - Source Code/app.py b/S22 - Project 12 - Email Generator Using LLAMA 2 - Streamlit App/Email Generator App - Source Code/app.py index 590fedbe..96ed3c03 100644 --- a/S22 - Project 12 - Email Generator Using LLAMA 2 - Streamlit App/Email Generator App - Source Code/app.py +++ b/S22 - Project 12 - Email Generator Using LLAMA 2 - Streamlit App/Email Generator App - Source Code/app.py @@ -1,70 +1,70 @@ -import streamlit as st -from langchain.prompts import PromptTemplate -from langchain.llms import CTransformers - -#Function to get the response back -def getLLMResponse(form_input,email_sender,email_recipient,email_style): - #llm = OpenAI(temperature=.9, model="text-davinci-003") - - # Wrapper for Llama-2-7B-Chat, Running Llama 2 on CPU - - #Quantization is reducing model precision by converting weights from 16-bit floats to 8-bit integers, - #enabling efficient deployment on resource-limited devices, reducing model size, and maintaining performance. - - #C Transformers offers support for various open-source models, - #among them popular ones like Llama, GPT4All-J, MPT, and Falcon. - - - #C Transformers is the Python library that provides bindings for transformer models implemented in C/C++ using the GGML library - - llm = CTransformers(model='models/llama-2-7b-chat.ggmlv3.q8_0.bin', #https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGML/tree/main - model_type='llama', - config={'max_new_tokens': 256, - 'temperature': 0.01}) - - - #Template for building the PROMPT - template = """ - Write a email with {style} style and includes topic :{email_topic}.\n\nSender: {sender}\nRecipient: {recipient} - \n\nEmail Text: - - """ - - #Creating the final PROMPT - prompt = PromptTemplate( - input_variables=["style","email_topic","sender","recipient"], - template=template,) - - - #Generating the response using LLM - response=llm(prompt.format(email_topic=form_input,sender=email_sender,recipient=email_recipient,style=email_style)) - print(response) - - return response - - -st.set_page_config(page_title="Generate Emails", - page_icon='📧', - layout='centered', - initial_sidebar_state='collapsed') -st.header("Generate Emails 📧") - -form_input = st.text_area('Enter the email topic', height=275) - -#Creating columns for the UI - To receive inputs from user -col1, col2, col3 = st.columns([10, 10, 5]) -with col1: - email_sender = st.text_input('Sender Name') -with col2: - email_recipient = st.text_input('Recipient Name') -with col3: - email_style = st.selectbox('Writing Style', - ('Formal', 'Appreciating', 'Not Satisfied', 'Neutral'), - index=0) - - -submit = st.button("Generate") - -#When 'Generate' button is clicked, execute the below code -if submit: - st.write(getLLMResponse(form_input,email_sender,email_recipient,email_style)) +import streamlit as st +from langchain.prompts import PromptTemplate +from langchain.llms import CTransformers + +#Function to get the response back +def getLLMResponse(form_input,email_sender,email_recipient,email_style): + #llm = OpenAI(temperature=.9, model="text-davinci-003") + + # Wrapper for Llama-2-7B-Chat, Running Llama 2 on CPU + + #Quantization is reducing model precision by converting weights from 16-bit floats to 8-bit integers, + #enabling efficient deployment on resource-limited devices, reducing model size, and maintaining performance. + + #C Transformers offers support for various open-source models, + #among them popular ones like Llama, GPT4All-J, MPT, and Falcon. + + + #C Transformers is the Python library that provides bindings for transformer models implemented in C/C++ using the GGML library + + llm = CTransformers(model='models/llama-2-7b-chat.ggmlv3.q8_0.bin', #https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGML/tree/main + model_type='llama', + config={'max_new_tokens': 256, + 'temperature': 0.01}) + + + #Template for building the PROMPT + template = """ + Write a email with {style} style and includes topic :{email_topic}.\n\nSender: {sender}\nRecipient: {recipient} + \n\nEmail Text: + + """ + + #Creating the final PROMPT + prompt = PromptTemplate( + input_variables=["style","email_topic","sender","recipient"], + template=template,) + + + #Generating the response using LLM + response=llm(prompt.format(email_topic=form_input,sender=email_sender,recipient=email_recipient,style=email_style)) + print(response) + + return response + + +st.set_page_config(page_title="Generate Emails", + page_icon='📧', + layout='centered', + initial_sidebar_state='collapsed') +st.header("Generate Emails 📧") + +form_input = st.text_area('Enter the email topic', height=275) + +#Creating columns for the UI - To receive inputs from user +col1, col2, col3 = st.columns([10, 10, 5]) +with col1: + email_sender = st.text_input('Sender Name') +with col2: + email_recipient = st.text_input('Recipient Name') +with col3: + email_style = st.selectbox('Writing Style', + ('Formal', 'Appreciating', 'Not Satisfied', 'Neutral'), + index=0) + + +submit = st.button("Generate") + +#When 'Generate' button is clicked, execute the below code +if submit: + st.write(getLLMResponse(form_input,email_sender,email_recipient,email_style)) diff --git a/S22 - Project 12 - Email Generator Using LLAMA 2 - Streamlit App/Email Generator App - Source Code/requirements.txt b/S22 - Project 12 - Email Generator Using LLAMA 2 - Streamlit App/Email Generator App - Source Code/requirements.txt index 1dd28a2a..c88fe198 100644 --- a/S22 - Project 12 - Email Generator Using LLAMA 2 - Streamlit App/Email Generator App - Source Code/requirements.txt +++ b/S22 - Project 12 - Email Generator Using LLAMA 2 - Streamlit App/Email Generator App - Source Code/requirements.txt @@ -1,7 +1,7 @@ -sentence-transformers -uvicorn -ctransformers -fastapi -ipykernel -langchain +sentence-transformers +uvicorn +ctransformers +fastapi +ipykernel +langchain python-box \ No newline at end of file diff --git a/S23 - Project 13 - Invoice Extraction Bot/Project 13 - Invoice Extraction Bot - Source Code/.env b/S23 - Project 13 - Invoice Extraction Bot/Project 13 - Invoice Extraction Bot - Source Code/.env index a7519978..4b7d913a 100644 --- a/S23 - Project 13 - Invoice Extraction Bot/Project 13 - Invoice Extraction Bot - Source Code/.env +++ b/S23 - Project 13 - Invoice Extraction Bot/Project 13 - Invoice Extraction Bot - Source Code/.env @@ -1,2 +1,2 @@ -REPLICATE_API_TOKEN = "" +REPLICATE_API_TOKEN = "" OPENAI_API_KEY="" \ No newline at end of file diff --git a/S23 - Project 13 - Invoice Extraction Bot/Project 13 - Invoice Extraction Bot - Source Code/app.py b/S23 - Project 13 - Invoice Extraction Bot/Project 13 - Invoice Extraction Bot - Source Code/app.py index e14e4065..242458a3 100644 --- a/S23 - Project 13 - Invoice Extraction Bot/Project 13 - Invoice Extraction Bot - Source Code/app.py +++ b/S23 - Project 13 - Invoice Extraction Bot/Project 13 - Invoice Extraction Bot - Source Code/app.py @@ -1,37 +1,37 @@ -import streamlit as st -from dotenv import load_dotenv -from utils import * - - -def main(): - load_dotenv() - - st.set_page_config(page_title="Invoice Extraction Bot") - st.title("Invoice Extraction Bot...💁 ") - st.subheader("I can help you in extracting invoice data") - - - # Upload the Invoices (pdf files) - pdf = st.file_uploader("Upload invoices here, only PDF files allowed", type=["pdf"],accept_multiple_files=True) - - submit=st.button("Extract Data") - - if submit: - with st.spinner('Wait for it...'): - df=create_docs(pdf) - st.write(df.head()) - - data_as_csv= df.to_csv(index=False).encode("utf-8") - st.download_button( - "Download data as CSV", - data_as_csv, - "benchmark-tools.csv", - "text/csv", - key="download-tools-csv", - ) - st.success("Hope I was able to save your time❤️") - - -#Invoking main function -if __name__ == '__main__': - main() +import streamlit as st +from dotenv import load_dotenv +from utils import * + + +def main(): + load_dotenv() + + st.set_page_config(page_title="Invoice Extraction Bot") + st.title("Invoice Extraction Bot...💁 ") + st.subheader("I can help you in extracting invoice data") + + + # Upload the Invoices (pdf files) + pdf = st.file_uploader("Upload invoices here, only PDF files allowed", type=["pdf"],accept_multiple_files=True) + + submit=st.button("Extract Data") + + if submit: + with st.spinner('Wait for it...'): + df=create_docs(pdf) + st.write(df.head()) + + data_as_csv= df.to_csv(index=False).encode("utf-8") + st.download_button( + "Download data as CSV", + data_as_csv, + "benchmark-tools.csv", + "text/csv", + key="download-tools-csv", + ) + st.success("Hope I was able to save your time❤️") + + +#Invoking main function +if __name__ == '__main__': + main() diff --git a/S23 - Project 13 - Invoice Extraction Bot/Project 13 - Invoice Extraction Bot - Source Code/utils.py b/S23 - Project 13 - Invoice Extraction Bot/Project 13 - Invoice Extraction Bot - Source Code/utils.py index e82294a2..838e9ae4 100644 --- a/S23 - Project 13 - Invoice Extraction Bot/Project 13 - Invoice Extraction Bot - Source Code/utils.py +++ b/S23 - Project 13 - Invoice Extraction Bot/Project 13 - Invoice Extraction Bot - Source Code/utils.py @@ -1,92 +1,92 @@ -from langchain.llms import OpenAI -from pypdf import PdfReader -from langchain.llms.openai import OpenAI -import pandas as pd -import re -import replicate -from langchain.prompts import PromptTemplate - -#Extract Information from PDF file -def get_pdf_text(pdf_doc): - text = "" - pdf_reader = PdfReader(pdf_doc) - for page in pdf_reader.pages: - text += page.extract_text() - return text - - - -#Function to extract data from text -def extracted_data(pages_data): - - template = """Extract all the following values : invoice no., Description, Quantity, date, - Unit price , Amount, Total, email, phone number and address from this data: {pages} - - Expected output: remove any dollar symbols {{'Invoice no.': '1001329','Description': 'Office Chair','Quantity': '2','Date': '5/4/2023','Unit price': '1100.00','Amount': '2200.00','Total': '2200.00','Email': 'Santoshvarma0988@gmail.com','Phone number': '9999999999','Address': 'Mumbai, India'}} - """ - prompt_template = PromptTemplate(input_variables=["pages"], template=template) - - llm = OpenAI(temperature=.7) - full_response=llm(prompt_template.format(pages=pages_data)) - - - #The below code will be used when we want to use LLAMA 2 model, we will use Replicate for hosting our model... - - #output = replicate.run('replicate/llama-2-70b-chat:2c1608e18606fad2812020dc541930f2d0495ce32eee50074220b87300bc16e1', - #input={"prompt":prompt_template.format(pages=pages_data) , - #"temperature":0.1, "top_p":0.9, "max_length":512, "repetition_penalty":1}) - - #full_response = '' - #for item in output: - #full_response += item - - - #print(full_response) - return full_response - - -# iterate over files in -# that user uploaded PDF files, one by one -def create_docs(user_pdf_list): - - df = pd.DataFrame({'Invoice no.': pd.Series(dtype='str'), - 'Description': pd.Series(dtype='str'), - 'Quantity': pd.Series(dtype='str'), - 'Date': pd.Series(dtype='str'), - 'Unit price': pd.Series(dtype='str'), - 'Amount': pd.Series(dtype='int'), - 'Total': pd.Series(dtype='str'), - 'Email': pd.Series(dtype='str'), - 'Phone number': pd.Series(dtype='str'), - 'Address': pd.Series(dtype='str') - }) - - for filename in user_pdf_list: - - print(filename) - raw_data=get_pdf_text(filename) - #print(raw_data) - #print("extracted raw data") - - llm_extracted_data=extracted_data(raw_data) - #print("llm extracted data") - #Adding items to our list - Adding data & its metadata - - pattern = r'{(.+)}' - match = re.search(pattern, llm_extracted_data, re.DOTALL) - - if match: - extracted_text = match.group(1) - # Converting the extracted text to a dictionary - data_dict = eval('{' + extracted_text + '}') - print(data_dict) - else: - print("No match found.") - - - df=df.append([data_dict], ignore_index=True) - print("********************DONE***************") - #df=df.append(save_to_dataframe(llm_extracted_data), ignore_index=True) - - df.head() +from langchain.llms import OpenAI +from pypdf import PdfReader +from langchain.llms.openai import OpenAI +import pandas as pd +import re +import replicate +from langchain.prompts import PromptTemplate + +#Extract Information from PDF file +def get_pdf_text(pdf_doc): + text = "" + pdf_reader = PdfReader(pdf_doc) + for page in pdf_reader.pages: + text += page.extract_text() + return text + + + +#Function to extract data from text +def extracted_data(pages_data): + + template = """Extract all the following values : invoice no., Description, Quantity, date, + Unit price , Amount, Total, email, phone number and address from this data: {pages} + + Expected output: remove any dollar symbols {{'Invoice no.': '1001329','Description': 'Office Chair','Quantity': '2','Date': '5/4/2023','Unit price': '1100.00','Amount': '2200.00','Total': '2200.00','Email': 'Santoshvarma0988@gmail.com','Phone number': '9999999999','Address': 'Mumbai, India'}} + """ + prompt_template = PromptTemplate(input_variables=["pages"], template=template) + + llm = OpenAI(temperature=.7) + full_response=llm(prompt_template.format(pages=pages_data)) + + + #The below code will be used when we want to use LLAMA 2 model, we will use Replicate for hosting our model... + + #output = replicate.run('replicate/llama-2-70b-chat:2c1608e18606fad2812020dc541930f2d0495ce32eee50074220b87300bc16e1', + #input={"prompt":prompt_template.format(pages=pages_data) , + #"temperature":0.1, "top_p":0.9, "max_length":512, "repetition_penalty":1}) + + #full_response = '' + #for item in output: + #full_response += item + + + #print(full_response) + return full_response + + +# iterate over files in +# that user uploaded PDF files, one by one +def create_docs(user_pdf_list): + + df = pd.DataFrame({'Invoice no.': pd.Series(dtype='str'), + 'Description': pd.Series(dtype='str'), + 'Quantity': pd.Series(dtype='str'), + 'Date': pd.Series(dtype='str'), + 'Unit price': pd.Series(dtype='str'), + 'Amount': pd.Series(dtype='int'), + 'Total': pd.Series(dtype='str'), + 'Email': pd.Series(dtype='str'), + 'Phone number': pd.Series(dtype='str'), + 'Address': pd.Series(dtype='str') + }) + + for filename in user_pdf_list: + + print(filename) + raw_data=get_pdf_text(filename) + #print(raw_data) + #print("extracted raw data") + + llm_extracted_data=extracted_data(raw_data) + #print("llm extracted data") + #Adding items to our list - Adding data & its metadata + + pattern = r'{(.+)}' + match = re.search(pattern, llm_extracted_data, re.DOTALL) + + if match: + extracted_text = match.group(1) + # Converting the extracted text to a dictionary + data_dict = eval('{' + extracted_text + '}') + print(data_dict) + else: + print("No match found.") + + + df=df.append([data_dict], ignore_index=True) + print("********************DONE***************") + #df=df.append(save_to_dataframe(llm_extracted_data), ignore_index=True) + + df.head() return df \ No newline at end of file diff --git a/S25 - Project 15 - Customer Care Call Summary Alert/Customer Care Call Summary Alert - Source Code/app.py b/S25 - Project 15 - Customer Care Call Summary Alert/Customer Care Call Summary Alert - Source Code/app.py index 784c91c7..82c0c624 100644 --- a/S25 - Project 15 - Customer Care Call Summary Alert/Customer Care Call Summary Alert - Source Code/app.py +++ b/S25 - Project 15 - Customer Care Call Summary Alert/Customer Care Call Summary Alert - Source Code/app.py @@ -1,35 +1,35 @@ -import streamlit as st -from utils import * - - -# Define the Streamlit app -def main(): - st.title("Customer Care Call Summarization") - - # Upload multiple files - uploaded_files = st.file_uploader("Upload recorded .mp3 files", type=["mp3"], accept_multiple_files=True) - - if uploaded_files: - st.write("Uploaded Files:") - - # Display uploaded files and buttons in a tabular form - for uploaded_file in uploaded_files: - file_name = uploaded_file.name - - - col1, col2, col3 = st.columns([0.1, 1, 2]) - with col1: - st.write("-") - with col2: - st.write(file_name) - with col3: - send_button = st.button(f"Send Email for {file_name}") - - if send_button: - email_summary(file_name) - st.success(f"Send email for: {file_name}") - - -# Run the Streamlit app -if __name__ == "__main__": - main() +import streamlit as st +from utils import * + + +# Define the Streamlit app +def main(): + st.title("Customer Care Call Summarization") + + # Upload multiple files + uploaded_files = st.file_uploader("Upload recorded .mp3 files", type=["mp3"], accept_multiple_files=True) + + if uploaded_files: + st.write("Uploaded Files:") + + # Display uploaded files and buttons in a tabular form + for uploaded_file in uploaded_files: + file_name = uploaded_file.name + + + col1, col2, col3 = st.columns([0.1, 1, 2]) + with col1: + st.write("-") + with col2: + st.write(file_name) + with col3: + send_button = st.button(f"Send Email for {file_name}") + + if send_button: + email_summary(file_name) + st.success(f"Send email for: {file_name}") + + +# Run the Streamlit app +if __name__ == "__main__": + main() diff --git a/S25 - Project 15 - Customer Care Call Summary Alert/Customer Care Call Summary Alert - Source Code/requirements.txt b/S25 - Project 15 - Customer Care Call Summary Alert/Customer Care Call Summary Alert - Source Code/requirements.txt index 6c35d34d..fea49338 100644 --- a/S25 - Project 15 - Customer Care Call Summary Alert/Customer Care Call Summary Alert - Source Code/requirements.txt +++ b/S25 - Project 15 - Customer Care Call Summary Alert/Customer Care Call Summary Alert - Source Code/requirements.txt @@ -1,4 +1,4 @@ -ffmpeg-python -langchain -whisper +ffmpeg-python +langchain +whisper streamlit \ No newline at end of file diff --git a/S25 - Project 15 - Customer Care Call Summary Alert/Customer Care Call Summary Alert - Source Code/utils.py b/S25 - Project 15 - Customer Care Call Summary Alert/Customer Care Call Summary Alert - Source Code/utils.py index 8dd00907..63efae2f 100644 --- a/S25 - Project 15 - Customer Care Call Summary Alert/Customer Care Call Summary Alert - Source Code/utils.py +++ b/S25 - Project 15 - Customer Care Call Summary Alert/Customer Care Call Summary Alert - Source Code/utils.py @@ -1,43 +1,43 @@ -import whisper -from langchain.llms import OpenAI -from langchain.agents import initialize_agent -from langchain.agents.agent_toolkits import ZapierToolkit -from langchain.utilities.zapier import ZapierNLAWrapper -import os - -# get from https://platform.openai.com/ -os.environ["OPENAI_API_KEY"] = "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" - -# get from https://nla.zapier.com/docs/authentication/ after logging in): -os.environ["ZAPIER_NLA_API_KEY"] = "sk-ak-dV0owIyoCEbQJVzZv5F1S5JG77" - - -def email_summary(file): - - - # large language model - llm = OpenAI(temperature=0) - - # Initializing zapier - zapier = ZapierNLAWrapper() - toolkit = ZapierToolkit.from_zapier_nla_wrapper(zapier) - - # The agent used here is a "zero-shot-react-description" agent. - # Zero-shot means the agent functions on the current action only — it has no memory. - # It uses the ReAct framework to decide which tool to use, based solely on the tool's description. - agent = initialize_agent(toolkit.get_tools(), llm, agent="zero-shot-react-description", verbose=True) - - - # specify a model, here its BASE - model = whisper.load_model("base") - - - - # transcribe audio file - result = model.transcribe(file) - print(result["text"]) - - # Send email using zapier - agent.run("Send an Email to sharathraju489@gmail.com via gmail summarizing the following text provided below : "+result["text"]) - - +import whisper +from langchain.llms import OpenAI +from langchain.agents import initialize_agent +from langchain.agents.agent_toolkits import ZapierToolkit +from langchain.utilities.zapier import ZapierNLAWrapper +import os + +# get from https://platform.openai.com/ +os.environ["OPENAI_API_KEY"] = "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" + +# get from https://nla.zapier.com/docs/authentication/ after logging in): +os.environ["ZAPIER_NLA_API_KEY"] = "sk-ak-dV0owIyoCEbQJVzZv5F1S5JG77" + + +def email_summary(file): + + + # large language model + llm = OpenAI(temperature=0) + + # Initializing zapier + zapier = ZapierNLAWrapper() + toolkit = ZapierToolkit.from_zapier_nla_wrapper(zapier) + + # The agent used here is a "zero-shot-react-description" agent. + # Zero-shot means the agent functions on the current action only — it has no memory. + # It uses the ReAct framework to decide which tool to use, based solely on the tool's description. + agent = initialize_agent(toolkit.get_tools(), llm, agent="zero-shot-react-description", verbose=True) + + + # specify a model, here its BASE + model = whisper.load_model("base") + + + + # transcribe audio file + result = model.transcribe(file) + print(result["text"]) + + # Send email using zapier + agent.run("Send an Email to sharathraju489@gmail.com via gmail summarizing the following text provided below : "+result["text"]) + +