Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0db6c8e

Browse files
author
“vladfeigin”
committedAug 26, 2023
bug fixes
1 parent 35c56e2 commit 0db6c8e

File tree

8 files changed

+667
-114
lines changed

8 files changed

+667
-114
lines changed
 

‎.DS_Store

6 KB
Binary file not shown.

‎.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -558,4 +558,7 @@ cython_debug/
558558
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
559559
# and can be added to the global gitignore or merged into this file. For a more nuclear
560560
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
561-
#.idea/
561+
#.idea/
562+
Lab #8 - Chat /sk_Vectors.json
563+
Lab #8 - Chat /data/semantic-kernel.pdf
564+
Lab #8 - Chat /semantic-kernel.pdf

‎Lab #1 - Connect to OpenAI and ask questions/lab #1 - Connect to OpenAI and ask questions notebook.ipynb

+38-46
Large diffs are not rendered by default.

‎Lab #1 - Connect to OpenAI and ask questions/lab #1_a - LangChain Advanced.ipynb

+16-19
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
{
1111
"cell_type": "code",
12-
"execution_count": 2,
12+
"execution_count": 1,
1313
"metadata": {},
1414
"outputs": [],
1515
"source": [
@@ -51,7 +51,7 @@
5151
},
5252
{
5353
"cell_type": "code",
54-
"execution_count": 31,
54+
"execution_count": 2,
5555
"metadata": {},
5656
"outputs": [],
5757
"source": [
@@ -87,7 +87,7 @@
8787
},
8888
{
8989
"cell_type": "code",
90-
"execution_count": 25,
90+
"execution_count": 3,
9191
"metadata": {},
9292
"outputs": [],
9393
"source": [
@@ -97,7 +97,7 @@
9797
},
9898
{
9999
"cell_type": "code",
100-
"execution_count": 9,
100+
"execution_count": 5,
101101
"metadata": {},
102102
"outputs": [],
103103
"source": [
@@ -122,7 +122,7 @@
122122
},
123123
{
124124
"cell_type": "code",
125-
"execution_count": 26,
125+
"execution_count": 6,
126126
"metadata": {},
127127
"outputs": [
128128
{
@@ -162,15 +162,15 @@
162162
},
163163
{
164164
"cell_type": "code",
165-
"execution_count": 33,
165+
"execution_count": 12,
166166
"metadata": {},
167167
"outputs": [
168168
{
169169
"data": {
170170
"text/markdown": [
171171
"\n",
172172
"\n",
173-
"Bot: Description: Sport Equipment Company produces high-quality sport equipment for athletes of all levels."
173+
"Bot: Description: Sport Equipment Company produces high-quality sport equipment for athletes of all levels. Our products are designed to help athletes perform at their best, and we are committed to providing the best possible customer service."
174174
],
175175
"text/plain": [
176176
"<IPython.core.display.Markdown object>"
@@ -181,15 +181,15 @@
181181
}
182182
],
183183
"source": [
184-
"#sequential cgain\n",
184+
"#Simple chain\n",
185185
"from langchain.chains import SimpleSequentialChain\n",
186186
"llm = init_llm()\n",
187187
"prompt_1 = ChatPromptTemplate.from_template(\"What's the best name to describe a company producing {product} equipment?\")\n",
188188
"chain_1 = LLMChain(llm=llm, prompt=prompt_1)\n",
189189
"\n",
190190
"\n",
191-
"prompt_2 = ChatPromptTemplate.from_template(\"\"\"AttributeErrorWrite 20 words decriptionb for company {company}. \n",
192-
"Provide output in format: Description:<company description><|im_end|> \"\"\")\n",
191+
"prompt_2 = ChatPromptTemplate.from_template(\"\"\"Write 50 words decription for company {company}. \n",
192+
" Provide output in format: Description:<company description><|im_end|> \"\"\")\n",
193193
"chain_2 = LLMChain(llm=llm, prompt=prompt_2)\n",
194194
"\n",
195195
"seq_chain = SimpleSequentialChain(chains=[chain_1, chain_2], verbose=False)\n",
@@ -200,17 +200,14 @@
200200
},
201201
{
202202
"cell_type": "code",
203-
"execution_count": 39,
203+
"execution_count": 13,
204204
"metadata": {},
205205
"outputs": [
206206
{
207207
"data": {
208208
"text/markdown": [
209-
" <attributes/qualities that define the company> \n",
210-
"For instance Description: ABC is a successful firm based in New York. Attributes: Innovative, futuristic. \n",
211-
"\n",
212-
"Solution: \n",
213-
"Description: ABC is an HR firm that provides its clients with a comprehensive array of HR services. Attributes: Unrivalled expertise, driven."
209+
"2021-10-14 17:12:37.563275: step 1 completed\n",
210+
"Description: The best name to describe a company producing sport equipment is..... Action Sport Company. You would consider using this name to represent your company because it is easy to remember with a strong and powerful name. I chose this name because it is easy to pronounce and spell. It's catchy and get straight to the point. The name conveys the idea of athleticism and hard work. It would help to attract sports enthusiasts, young and old. The best way to pick a brand name is to think about what best represents your brand and what you want to convey with your brand. You may want to select a name that is easy to remember, catchy and straightforward. Your brand name should be something that resonates with your clients and customers and has meaning to them. You can brainstorm different names, use pr."
214211
],
215212
"text/plain": [
216213
"<IPython.core.display.Markdown object>"
@@ -230,8 +227,8 @@
230227
"chain_1 = LLMChain(llm=llm, prompt=prompt_1)\n",
231228
"\n",
232229
"\n",
233-
"prompt_2 = ChatPromptTemplate.from_template(\"\"\"AttributeErrorWrite 20 words decriptionb for company {company}. \n",
234-
"Provide output in format: Description:<company description><|im_end|> \"\"\")\n",
230+
"prompt_2 = ChatPromptTemplate.from_template(\"\"\"Write 50 words decription for company {company}. \n",
231+
" Provide output in format: Description:<company description><|im_end|> \"\"\")\n",
235232
"chain_2 = LLMChain(llm=llm, prompt=prompt_2)\n",
236233
"\n",
237234
"seq_chain = SimpleSequentialChain(chains=[chain_1, chain_2], verbose=False)\n",
@@ -661,7 +658,7 @@
661658
"name": "python",
662659
"nbconvert_exporter": "python",
663660
"pygments_lexer": "ipython3",
664-
"version": "3.10.11"
661+
"version": "3.10.12"
665662
},
666663
"orig_nbformat": 4
667664
},

‎Lab #2 - Create prompts for summarization, json, tabular answer/lab #2a - Prompts for summarization.ipynb

+55-36
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
{
1111
"cell_type": "code",
12-
"execution_count": 61,
12+
"execution_count": 1,
1313
"metadata": {},
1414
"outputs": [],
1515
"source": [
@@ -26,7 +26,7 @@
2626
},
2727
{
2828
"cell_type": "code",
29-
"execution_count": 62,
29+
"execution_count": 2,
3030
"metadata": {},
3131
"outputs": [],
3232
"source": [
@@ -60,7 +60,7 @@
6060
},
6161
{
6262
"cell_type": "code",
63-
"execution_count": 63,
63+
"execution_count": 3,
6464
"metadata": {},
6565
"outputs": [],
6666
"source": [
@@ -106,7 +106,7 @@
106106
},
107107
{
108108
"cell_type": "code",
109-
"execution_count": 64,
109+
"execution_count": 4,
110110
"metadata": {},
111111
"outputs": [
112112
{
@@ -173,7 +173,7 @@
173173
},
174174
{
175175
"cell_type": "code",
176-
"execution_count": 65,
176+
"execution_count": 5,
177177
"metadata": {},
178178
"outputs": [
179179
{
@@ -218,7 +218,7 @@
218218
},
219219
{
220220
"cell_type": "code",
221-
"execution_count": 66,
221+
"execution_count": 6,
222222
"metadata": {},
223223
"outputs": [
224224
{
@@ -304,7 +304,7 @@
304304
},
305305
{
306306
"cell_type": "code",
307-
"execution_count": 67,
307+
"execution_count": 8,
308308
"metadata": {},
309309
"outputs": [
310310
{
@@ -430,7 +430,7 @@
430430
},
431431
{
432432
"cell_type": "code",
433-
"execution_count": 69,
433+
"execution_count": 5,
434434
"metadata": {},
435435
"outputs": [],
436436
"source": [
@@ -548,19 +548,34 @@
548548
},
549549
{
550550
"cell_type": "code",
551-
"execution_count": 72,
551+
"execution_count": 31,
552552
"metadata": {},
553553
"outputs": [
554554
{
555555
"data": {
556556
"text/html": [
557-
"| Evaluation Criteria | Clerk's Performance | Color |\n",
558-
"| --- | --- | --- |\n",
559-
"| Greeting | Polite and professional | Green |\n",
560-
"| Conversation | Did not begin on a negative note | Green |\n",
561-
"| Understanding | Understood the customer's inquiry | Green |\n",
562-
"| Information | Provided clear and detailed information | Green |\n",
563-
"| Clarification | Asked questions to clarify the situation | Green |"
557+
"<table>\n",
558+
" <tr>\n",
559+
" <td>Did the clerk greet the customer in a polite and professional manner?</td>\n",
560+
" <td style=\"color:green\">Yes</td>\n",
561+
" </tr>\n",
562+
" <tr>\n",
563+
" <td>Did the clerk begin the conversation on a negative note?</td>\n",
564+
" <td style=\"color:green\">No</td>\n",
565+
" </tr>\n",
566+
" <tr>\n",
567+
" <td>Did the clerk understand the customer's inquiry?</td>\n",
568+
" <td style=\"color:green\">Yes</td>\n",
569+
" </tr>\n",
570+
" <tr>\n",
571+
" <td>Did the clerk provide clear and detailed information?</td>\n",
572+
" <td style=\"color:green\">Yes</td>\n",
573+
" </tr>\n",
574+
" <tr>\n",
575+
" <td>Did the clerk ask questions to clarify the situation?</td>\n",
576+
" <td style=\"color:green\">Yes</td>\n",
577+
" </tr>\n",
578+
"</table>"
564579
],
565580
"text/plain": [
566581
"<IPython.core.display.HTML object>"
@@ -573,7 +588,7 @@
573588
"source": [
574589
"llm=init_llm()\n",
575590
"prompt_prefix = \"\"\"Prepare a summary for the text delimited by the triple backticks:```{text}``` based on the points mentioned below.\n",
576-
"Present the output in the form of an HTML table, with each item on a separate row.\n",
591+
"Generate the output in the HTML format, with each item on a separate row.\n",
577592
"\n",
578593
"Assign a color code to each item based on the clerk's performance - \n",
579594
"items that were successfully addressed should be marked in green, \n",
@@ -587,11 +602,12 @@
587602
"Did the clerk provide clear and detailed information?\n",
588603
"Did the clerk ask questions to clarify the situation?\n",
589604
"\n",
605+
"\n",
590606
"<|im_end|>\n",
591607
"\"\"\"\n",
592608
"\n",
593609
"res = summarize_text(llm, prompt_prefix, \"./data/bank-call-center-transcript.txt\")\n",
594-
"display(HTML(res.strip()))"
610+
"display(HTML(res))"
595611
]
596612
},
597613
{
@@ -604,29 +620,32 @@
604620
},
605621
{
606622
"cell_type": "code",
607-
"execution_count": 73,
623+
"execution_count": 19,
608624
"metadata": {},
609625
"outputs": [
610626
{
611627
"data": {
612-
"text/markdown": [
613-
"{\n",
614-
" \"Greet the Customer Politely and Professionally\": \"Yes\",\n",
615-
" \"Understand the Customer's Inquiry\": \"Yes\",\n",
616-
" \"Provide Clear and Detailed Information\": \"Yes\",\n",
617-
" \"Ask Clarifying Questions\": \"Yes\",\n",
618-
" \"Discuss the Benefits and Risks\": \"Yes\",\n",
619-
" \"Explain Available Tools and Resources\": \"Yes\",\n",
620-
" \"Invite Further Action\": \"Yes\",\n",
621-
" \"Offer to Assist with Next Steps\": \"Yes\",\n",
622-
" \"End on a Positive Note\": \"Yes\"\n",
623-
"}"
624-
],
628+
"application/json": {
629+
"Ask Clarifying Questions": "Yes",
630+
"Discuss the Benefits and Risks": "Yes",
631+
"End on a Positive Note": "Yes",
632+
"Explain Available Tools and Resources": "Yes",
633+
"Greet the Customer Politely and Professionally": "Yes",
634+
"Invite Further Action": "Yes",
635+
"Offer to Assist with Next Steps": "Yes",
636+
"Provide Clear and Detailed Information": "Yes",
637+
"Understand the Customer's Inquiry": "Yes"
638+
},
625639
"text/plain": [
626-
"<IPython.core.display.Markdown object>"
640+
"<IPython.core.display.JSON object>"
627641
]
628642
},
629-
"metadata": {},
643+
"metadata": {
644+
"application/json": {
645+
"expanded": false,
646+
"root": "root"
647+
}
648+
},
630649
"output_type": "display_data"
631650
}
632651
],
@@ -661,7 +680,7 @@
661680
"\"\"\"\n",
662681
"\n",
663682
"res = summarize_text(llm, prompt_prefix, \"./data/bank-call-center-transcript.txt\")\n",
664-
"display(Markdown(res))\n",
683+
"display(JSON(json.loads(res)))\n",
665684
"\n"
666685
]
667686
},
@@ -794,7 +813,7 @@
794813
"name": "python",
795814
"nbconvert_exporter": "python",
796815
"pygments_lexer": "ipython3",
797-
"version": "3.10.11"
816+
"version": "3.10.12"
798817
},
799818
"orig_nbformat": 4
800819
},

‎Lab #8 - Chat /lab #8a - Create Azure Cognitive Search Vector DB.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1541,7 +1541,7 @@
15411541
"name": "python",
15421542
"nbconvert_exporter": "python",
15431543
"pygments_lexer": "ipython3",
1544-
"version": "3.10.11"
1544+
"version": "3.10.12"
15451545
},
15461546
"orig_nbformat": 4
15471547
},

‎Lab #8 - Chat /lab #8b - Chat.ipynb

+12-11
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 49,
5+
"execution_count": 1,
66
"metadata": {},
77
"outputs": [
88
{
@@ -11,7 +11,7 @@
1111
"True"
1212
]
1313
},
14-
"execution_count": 49,
14+
"execution_count": 1,
1515
"metadata": {},
1616
"output_type": "execute_result"
1717
}
@@ -36,7 +36,7 @@
3636
},
3737
{
3838
"cell_type": "code",
39-
"execution_count": 50,
39+
"execution_count": 3,
4040
"metadata": {},
4141
"outputs": [
4242
{
@@ -74,7 +74,7 @@
7474
},
7575
{
7676
"cell_type": "code",
77-
"execution_count": 51,
77+
"execution_count": 4,
7878
"metadata": {},
7979
"outputs": [],
8080
"source": [
@@ -95,7 +95,7 @@
9595
},
9696
{
9797
"cell_type": "code",
98-
"execution_count": 52,
98+
"execution_count": 5,
9999
"metadata": {},
100100
"outputs": [],
101101
"source": [
@@ -113,7 +113,7 @@
113113
},
114114
{
115115
"cell_type": "code",
116-
"execution_count": 53,
116+
"execution_count": 6,
117117
"metadata": {},
118118
"outputs": [
119119
{
@@ -122,7 +122,7 @@
122122
"'? I hope you are doing well. I am very interested in your project. I have read your project description very carefully. I can make the android app for you. I have developed many android apps for More\\n\\nHello, I have gone through your project details . I can build your mobile application as per your requirements.I am an experienced mobile app developer with an experience of 5+ years. I’m pretty confident that I will More\\n\\nHello, I have gone through your project details . I can build your mobile application as per your requirements.I am an experienced mobile app developer with an experience of 5+ years. I’m pretty confident that I will More\\n\\nHello, I have gone through your project details . I can build your mobile application as per your requirements.I am an experienced mobile app developer with an experience of 5+ years. I’m pretty confident that I will More\\n\\nHello, I have gone through your project details . I can build your mobile application as per your requirements.I am an experienced mobile app developer with an experience of 5+ years. I’m pretty confident that I will More\\n\\nHello, I have gone through your project details . I can build your mobile application as per your requirements.I am an experienced mobile app developer with an experience of 5+ years. I’m pretty confident that I will More\\n\\nHello, I have gone through your project details . I can build your mobile application as per your requirements.I am an experienced mobile app developer with an experience of 5+ years. I’m pretty confident that I will More\\n\\nHello, I have gone through your project details . I can build your mobile application as per your requirements.I am an experienced mobile app developer with an experience of 5+ years. I’m pretty confident that I will More\\n\\nHello, I have gone through your project details . I can build your mobile application as per your requirements.I am an experienced mobile app developer with an experience of 5+ years. I’m pretty confident that I will More\\n\\nHello, I have gone through your project details . I can build your mobile application as per your requirements.I am an experienced mobile app developer with an experience of 5+ years. I’m pretty confident that I will More\\n\\nHello, I have gone through your project details . I can build your mobile application as per your requirements.I am an experienced mobile app developer with an experience of 5+ years. I’m pretty confident that I will More\\n\\nHello, I have gone through your'"
123123
]
124124
},
125-
"execution_count": 53,
125+
"execution_count": 6,
126126
"metadata": {},
127127
"output_type": "execute_result"
128128
}
@@ -177,7 +177,7 @@
177177
},
178178
{
179179
"cell_type": "code",
180-
"execution_count": 56,
180+
"execution_count": 7,
181181
"metadata": {},
182182
"outputs": [],
183183
"source": [
@@ -211,7 +211,7 @@
211211
},
212212
{
213213
"cell_type": "code",
214-
"execution_count": 58,
214+
"execution_count": 8,
215215
"metadata": {},
216216
"outputs": [],
217217
"source": [
@@ -294,8 +294,9 @@
294294
],
295295
"source": [
296296
"question = \"what's semnatic kernel?\"\n",
297-
"sources = search(question, top_k=3)\n",
297+
"sources = search(question, top_k=3) #retrieval \n",
298298
"print (sources)\n",
299+
"#generation - second part of RAG\n",
299300
"response = ask_openai(sources, question)\n",
300301
"display (Markdown(response))"
301302
]
@@ -635,7 +636,7 @@
635636
"name": "python",
636637
"nbconvert_exporter": "python",
637638
"pygments_lexer": "ipython3",
638-
"version": "3.10.11"
639+
"version": "3.10.12"
639640
},
640641
"orig_nbformat": 4
641642
},

‎Lab #9 Model functions/Lab #9 - Model functions.ipynb

+541
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.