MightyOctopus commited on
Commit
a6b086f
·
1 Parent(s): 70ac662

GPT5_mini rag completed

Browse files
Files changed (2) hide show
  1. day2.2.ipynb +0 -0
  2. day2.3.ipynb +405 -0
day2.2.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
day2.3.ipynb ADDED
@@ -0,0 +1,405 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 1,
6
+ "id": "fecdbce2-f2a5-4047-9854-f1ac2906e2c4",
7
+ "metadata": {},
8
+ "outputs": [
9
+ {
10
+ "name": "stderr",
11
+ "output_type": "stream",
12
+ "text": [
13
+ "/Volumes/VTG/Dev/C_5/Projects/week8/.venv/lib/python3.13/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
14
+ " from .autonotebook import tqdm as notebook_tqdm\n"
15
+ ]
16
+ }
17
+ ],
18
+ "source": [
19
+ "# imports\n",
20
+ "\n",
21
+ "import os\n",
22
+ "import re\n",
23
+ "import math\n",
24
+ "import json\n",
25
+ "from tqdm import tqdm\n",
26
+ "import random\n",
27
+ "from dotenv import load_dotenv\n",
28
+ "from huggingface_hub import login\n",
29
+ "# import matplotlib.pyplot as plt\n",
30
+ "import numpy as np\n",
31
+ "import pickle\n",
32
+ "from openai import OpenAI\n",
33
+ "from sentence_transformers import SentenceTransformer\n",
34
+ "from datasets import load_dataset\n",
35
+ "import chromadb\n",
36
+ "\n",
37
+ "### Internal Classes\n",
38
+ "# from testing import Tester"
39
+ ]
40
+ },
41
+ {
42
+ "cell_type": "code",
43
+ "execution_count": 2,
44
+ "id": "ddc04a1a-6c1e-4edc-b924-8762c5d015f5",
45
+ "metadata": {},
46
+ "outputs": [],
47
+ "source": [
48
+ "# environment\n",
49
+ "\n",
50
+ "load_dotenv(override=True)\n",
51
+ "os.environ['OPENAI_API_KEY'] = os.getenv('OPENAI_API_KEY')\n",
52
+ "os.environ['HF_TOKEN'] = os.getenv('HF_TOKEN')"
53
+ ]
54
+ },
55
+ {
56
+ "cell_type": "code",
57
+ "execution_count": 3,
58
+ "id": "fa6abd28-8352-4f87-8659-04e6da934ce2",
59
+ "metadata": {},
60
+ "outputs": [
61
+ {
62
+ "name": "stderr",
63
+ "output_type": "stream",
64
+ "text": [
65
+ "Note: Environment variable`HF_TOKEN` is set and is the current active token independently from the token you've just configured.\n"
66
+ ]
67
+ }
68
+ ],
69
+ "source": [
70
+ "# Log in to HuggingFace\n",
71
+ "\n",
72
+ "hf_token = os.environ['HF_TOKEN']\n",
73
+ "login(hf_token, add_to_git_credential=True)"
74
+ ]
75
+ },
76
+ {
77
+ "cell_type": "code",
78
+ "execution_count": 4,
79
+ "id": "b404ee04-ed86-4fb4-9fea-7f056e4e87b6",
80
+ "metadata": {},
81
+ "outputs": [],
82
+ "source": [
83
+ "openai = OpenAI()"
84
+ ]
85
+ },
86
+ {
87
+ "cell_type": "code",
88
+ "execution_count": 5,
89
+ "id": "41fc420c-6151-422d-a36c-14fc8cf18e87",
90
+ "metadata": {},
91
+ "outputs": [],
92
+ "source": [
93
+ "with open(\"test.pkl\", \"rb\") as f: \n",
94
+ " test = pickle.load(f)"
95
+ ]
96
+ },
97
+ {
98
+ "cell_type": "code",
99
+ "execution_count": 6,
100
+ "id": "752c9a41-d705-49c6-90bc-98b2ec415703",
101
+ "metadata": {},
102
+ "outputs": [],
103
+ "source": [
104
+ "DB = \"products_vectorstore/\"\n",
105
+ "\n",
106
+ "client = chromadb.PersistentClient(path=DB)\n",
107
+ "collection = client.get_or_create_collection(\"product\")"
108
+ ]
109
+ },
110
+ {
111
+ "cell_type": "code",
112
+ "execution_count": 7,
113
+ "id": "6135a9cc-6d6b-47c5-b095-fb2bc7fc0c11",
114
+ "metadata": {},
115
+ "outputs": [],
116
+ "source": [
117
+ "embedding_model = SentenceTransformer(\"sentence-transformers/all-MiniLM-L6-v2\")"
118
+ ]
119
+ },
120
+ {
121
+ "cell_type": "code",
122
+ "execution_count": 8,
123
+ "id": "cbd8ab8e-22f6-4b09-a99b-b783dd97c3e8",
124
+ "metadata": {},
125
+ "outputs": [
126
+ {
127
+ "data": {
128
+ "text/plain": [
129
+ "'How much does this cost to the nearest dollar?\\n\\nMain_Category: Toys & Games\\n\\nMedicom Batman Hush Black Suit Version Batman Real Hero Action Figure\\nFrom the Manufacturer From MEDICOM Toy! Based on the best-selling series Batman Hush by Jeph Loeb and Jim Lee, Medicom unveils two more releases in their DC Comics Real Action Hero line of figures. Superman and Batman (Black Suit) are both sculpted from original designs by Jim Lee and are built using the finest craftsmanship and costume tailoring. If you can find a nicer looking Batman or Superman, buy him! From Medicom Toys Based on the best-selling DC Comics miniseries Batman Hush by Jeph Loeb and Jim Lee 1 figure Sculpted from original designs by Jim Lee Built using the finest craftmanship and costume tailoring \"Product Dimensions\" \"12 x \\n\\nPrice is $'"
130
+ ]
131
+ },
132
+ "execution_count": 8,
133
+ "metadata": {},
134
+ "output_type": "execute_result"
135
+ }
136
+ ],
137
+ "source": [
138
+ "test[0].test_prompt()"
139
+ ]
140
+ },
141
+ {
142
+ "cell_type": "code",
143
+ "execution_count": 9,
144
+ "id": "38149f83-4f2e-4202-89b7-56e90f53959b",
145
+ "metadata": {},
146
+ "outputs": [],
147
+ "source": [
148
+ "def description(item):\n",
149
+ " text = item.prompt.replace(\"How much does this cost to the nearest dollar?\\n\\n\", \"\")\n",
150
+ " return text.split(\"\\n\\nPrice is $\")[0]"
151
+ ]
152
+ },
153
+ {
154
+ "cell_type": "code",
155
+ "execution_count": 10,
156
+ "id": "4bf700c0-0b9a-4579-9d8e-8e368223646a",
157
+ "metadata": {},
158
+ "outputs": [],
159
+ "source": [
160
+ "def vector(item): \n",
161
+ " return embedding_model.encode([description(item)])"
162
+ ]
163
+ },
164
+ {
165
+ "cell_type": "code",
166
+ "execution_count": 11,
167
+ "id": "39bc56fc-cd48-4c69-9a61-4fe0af911d4e",
168
+ "metadata": {},
169
+ "outputs": [],
170
+ "source": [
171
+ "def find_similars(item): \n",
172
+ " results = collection.query(query_embeddings=vector(item))\n",
173
+ " similar_docs = results[\"documents\"][0][:]\n",
174
+ " prices = [meta[\"price\"] for meta in results[\"metadatas\"][0][:]]\n",
175
+ " \n",
176
+ " return similar_docs, prices "
177
+ ]
178
+ },
179
+ {
180
+ "cell_type": "code",
181
+ "execution_count": 12,
182
+ "id": "cfa01f33-0e76-428e-9b55-e27a0232ba43",
183
+ "metadata": {},
184
+ "outputs": [
185
+ {
186
+ "data": {
187
+ "text/plain": [
188
+ "(['Main_Category: Tools & Home Improvement\\n\\nPorlik 8 Inch Heavy Duty Metal Peg Board Shelving Hooks, Seven-Station Waterfall Hook, Pegboard Hook Steel Stainless Hooks Pegs Duty,Heavy Control Wall Hangers,Heavy Duty Pegboard Pack\\nThese hooks are a simple yet brilliant storage solution for any kitchen or work area where space is limited and you might need to something up. These hooks are made of stainless steel which is strong and safe, so you can heavier items without fear of them falling or becoming damaged. Material Stainless Steel. - Take little space for hanging displaying goods or tools, easy to install and use. - for hanging tools, brushes, extension cables, sports equipment, etc., to make your room more concise and tidy. - Hooks used for grid wall brackets to make your products great cube displaying. - ',\n",
189
+ " 'Main_Category: Tools & Home Improvement\\n\\nFactorDuty 200 Pack 2 inch Length Steel Black PEG Board Pegboard Shelving Hooks Wholesale Lot 20 lbs PEG Hooks Organizer Tools for Craft Storage, Garage, Kitchen, Tools and More\\nTHEY LOCK IN PLACE This hook measures 2\" Deep and can hold capacity 20lbs. Insert these steel hooks into your pegboard to hang small packaged goods and other lightweight items. Our pegboard hooks are made out of steel and come in a black finish. SECURE Black peghooks lock securely onto your pegboard. Hooks never fall out or wobble when you remove your items. They are simple to remove so reorganize your storage system whenever you want. HIGH QUALITY MATERIALS These hooks are made from durable steel and come in an attractive black finish',\n",
190
+ " 'Main_Category: Tools & Home Improvement\\n\\nIDEALSV 50 Pcs (304) Stainless Steel Screw Ceiling Hooks 5/8 Inch Small Cup Hook Screw-in Light Hooks Outdoor and Indoor Hanging\\nIndoor and Outdoor Use 304 stainless steel screw cup hooks they are very versatile,hang coffee mugs cup, organizing your wardrobe Belts, hats, scarves,jewelry necklaces, kitchen utensils, towels, curtains, brooms,plants,keys,necklaces, wind chimes,birdcage and more. These heavy duty hooks not rust, not corrosion, perfect for outdoors. Hanging flower baskets, wind chimes and lanterns, chirstmas festival lights,Camping tents etc. SIZE Total length hooks length can fit hang many things. Easy to install With threaded end tapping screw, you can easily screw',\n",
191
+ " \"Main_Category: Tools & Home Improvement\\n\\nS-Hooks - Various Pack Sizes and Dimensions Available\\nGolberg’s S-Hooks are perfect for organizing your closets, bathroom, hallway, kitchen, garage, mudroom, etc. It’s made from durable steel with zinc plating. Various thickness options are available including 1/8”, 1/4”, 9/32”, 5/16” and 3/8”. These S-Hooks can help tidy up your home with ease and they are suitable for hanging hammock, swings, pots and pans. You can choose from various pack sizes including 2, 5, 10, 15, 25, 50 and 100. GOLBERG only sells premium products and refuses anything sub-par so you know it's made from top-quality materials\",\n",
192
+ " 'Main_Category: Industrial & Scientific\\n\\nOnly Hangers Commercial Grade Slatwall Hooks - Combo Pack of 50 Assorted Size Peg Hooks for Slatwall - (10) of Each 8\" and 10\" Hooks\\nThis economical assortment of our most popular slatwall hooks includes 10 of each size 2\", 4\",6\", 8\", and 10\" hooks for all slatwall panels. This assorted set of 50 slatwall hooks are made of heavy gauge wire and are perfect for retail store use as well as for storage and organizing in the home or garage. Durable black powder coat finish on these peg hooks resists scratches and rust. Kit includes (50) Black Slatwall Hooks (10) of Each Size 2\", 4\", 6\" 8\"',\n",
193
+ " 'Main_Category: Tools & Home Improvement\\n\\nOnly Hangers Commercial Grade Black Slatwall Hooks - Combo Pack of 100 Assorted Size Peg Hooks for Slatwall - (20) of Each 8\" and 10\" Hooks\\nThis economical assortment of our most popular slatwall hooks includes 20 of each size 2\", 4\",6\", 8\", and 10\" hooks for all slatwall panels. This assorted set of 100 slatwall hooks are made of heavy gauge wire and are perfect for retail store use as well as for storage and organizing in the home or garage. Durable black powder coat finish on these peg hooks resists scratches and rust. Kit includes (100) Black Slatwall Hooks (20) of Each Size 2\", 4\", 6\" 8',\n",
194
+ " 'Main_Category: Tools & Home Improvement\\n\\nMroMax 40Pcs 1.73\" Length Ceiling Cups Hooks Carbon Steel Screw in Hanger Hook Eye Shape Ring Hooks 1-1/4\" Self Tapping Screws Hook for Home Office Hanging Plants Outdoor Silver Tone\\n【SIZE】- Overall Length 44mm/ 1.73\"; Outer Width 24mm/ 0.94\"; Rod Diameter 2.9mm/ 0.11\"; Opening Width 14mm/ 0.55\"; Thread Length 13mm/ 0.51\" 【MATERIAL】- Made of high-quality Carbon Steel, stable and durable, smooth and burr-free, protecting your hands and the item you hanging, strong bearing capacity and deep inner ring 【ADVANTEGE】- The',\n",
195
+ " 'Main_Category: Industrial & Scientific\\n\\n120 Packs Gridwall Hooks 4/6/8 Inches Gridwall Hooks Gridwall Accessories Gridwall Panel Hooks Display Hooks for Gridwall Retail Shop Trade Show Home Office Garage Storage\\nFeatures These wall grid accessories allow you to conveniently hang and store retail items, photos, paintings, gardening equipment, kitchen utensils, hardware and more. The silver look makes it suitable for most decorating styles. Gridwall display hooks have a sturdy construction, 15° inclination angle and upturned end design, which can store your items well and avoid falling. Specifications Material stainless steel Color silver Size 4 inch, 6 inch, 8 inch Package includes 50 x Grid display hook (4 inch) 40 x Grid display hook (6 inch) 30 x Grid display',\n",
196
+ " 'Main_Category: Tools & Home Improvement\\n\\n100pcs 8\" X 1/4\" Peg Board Hooks Shelf Hanger Kit Garage Storage Hanging Set\\n100 Pc - Pegboard hooks. 8\" x 1/4\" chrome hooks. Heave duty steel constructions, zinc plated. Handy and convenient to organize tools and accessories in garages, basements, kitchens, and market shelves. 100% brand new. 8\" shelf storage hooks Pegboard hooks garage hooks \"Color\" \"Chrome\", \"Brand\" \"Cal-Hawk\", \"Material\" \"Alloy Steel\", \"Finish Type\" \"Polished\", \"Style\" \"Hanging\", \"Item Weight\" \"0.01 ounces\", \"Number of Hooks\" \"100\", \"Maximum Weight Recommendation\" \"100',\n",
197
+ " 'Main_Category: Arts, Crafts & Sewing\\n\\nMetal Pattern Hooks 144 Pcs\\n144 Piece Heavy Duty Metal Pattern Hooks Excellent for hanging patterns, holds up to 5 lb per pattern hooks White color cord \"Color\" \"Steel\", \"Brand\" \"LA Linen\", \"Material\" \"Metal\", \"Finish Type\" \"Painted\", \"Style\" \"Heavy Duty\", \"Special Feature\" \"Heavy Duty\", \"Item Weight\" \"1 pounds\", \"Item Dimensions LxWxH\" \"10 x 5 x 5 inches\", \"Number of Hooks\" \"144\", \"Maximum Weight Recommendation\" \"5 Pounds\", \"Product Dimensions\" \"10 x 5 x 5 inches\", \"Item model number\" \"\" \"Industrial & Scientific\" '],\n",
198
+ " [19.99, 51.28, 10.49, 7.99, 53.65, 75.95, 12.89, 50.99, 43.95, 73.0])"
199
+ ]
200
+ },
201
+ "execution_count": 12,
202
+ "metadata": {},
203
+ "output_type": "execute_result"
204
+ }
205
+ ],
206
+ "source": [
207
+ "find_similars(test[1])"
208
+ ]
209
+ },
210
+ {
211
+ "cell_type": "code",
212
+ "execution_count": 15,
213
+ "id": "49ea78d7-74b4-4ecb-885b-bbcb2b3e596c",
214
+ "metadata": {},
215
+ "outputs": [],
216
+ "source": [
217
+ "def make_context(similars, prices): \n",
218
+ " message = \"To provide some context, here are some other items that might be similar to the item you need to estimate.\\n\\n\"\n",
219
+ " for similar, price in zip(similars, prices): \n",
220
+ " message += f\"Potentially related product:\\n{similar}\\nPrice is ${price:.2f}\\n\\n\"\n",
221
+ " \n",
222
+ " return message"
223
+ ]
224
+ },
225
+ {
226
+ "cell_type": "code",
227
+ "execution_count": 16,
228
+ "id": "c77fc4fa-af47-4baa-b4d7-be365e96d47f",
229
+ "metadata": {},
230
+ "outputs": [],
231
+ "source": [
232
+ "def messages_for(item, similars, prices): \n",
233
+ " system_message = \"You estimate prices of items. Reply only with the price, no explanation.\"\n",
234
+ " user_prompt = make_context(similars, prices)\n",
235
+ " user_prompt += \"And now the question for you:\\n\\n\" \n",
236
+ " user_prompt += item.test_prompt().replace(\"to the nearest dollar\", \"\").replace(\"Price is $\", \"\")\n",
237
+ " \n",
238
+ " return [\n",
239
+ " {\"role\": \"system\", \"content\": system_message}, \n",
240
+ " {\"role\": \"user\", \"content\": user_prompt}, \n",
241
+ " {\"role\": \"assistant\", \"content\": \"Price is $\"}\n",
242
+ " ]"
243
+ ]
244
+ },
245
+ {
246
+ "cell_type": "code",
247
+ "execution_count": 17,
248
+ "id": "24862915-d99d-45aa-a925-38ba07e10bec",
249
+ "metadata": {},
250
+ "outputs": [],
251
+ "source": [
252
+ "docs, prices = find_similars(test[2])"
253
+ ]
254
+ },
255
+ {
256
+ "cell_type": "code",
257
+ "execution_count": 18,
258
+ "id": "67326f8f-3ee2-4058-9d21-c805d964cbbb",
259
+ "metadata": {},
260
+ "outputs": [
261
+ {
262
+ "name": "stdout",
263
+ "output_type": "stream",
264
+ "text": [
265
+ "<Nady RSM-5 Ribbon Microphone - Unique compact shape perfect for close miking, includes microphone clip and soft cloth pouch = $109.99>\n"
266
+ ]
267
+ }
268
+ ],
269
+ "source": [
270
+ "print(test[2])"
271
+ ]
272
+ },
273
+ {
274
+ "cell_type": "code",
275
+ "execution_count": null,
276
+ "id": "9293f970-3e9c-4303-8844-caaa06677faa",
277
+ "metadata": {},
278
+ "outputs": [],
279
+ "source": [
280
+ "print(make_context(docs, prices))"
281
+ ]
282
+ },
283
+ {
284
+ "cell_type": "code",
285
+ "execution_count": 20,
286
+ "id": "f3b47de7-1799-4326-a2c4-0ad7a4ee4cb6",
287
+ "metadata": {},
288
+ "outputs": [
289
+ {
290
+ "name": "stdout",
291
+ "output_type": "stream",
292
+ "text": [
293
+ "[{'role': 'system', 'content': 'You estimate prices of items. Reply only with the price, no explanation.'}, {'role': 'user', 'content': 'To provide some context, here are some other items that might be similar to the item you need to estimate.\\n\\nPotentially related product:\\nMain_Category: Musical Instruments\\n\\nCascade Microphones 98-G-A FAT HEAD Ribbon Microphone, Brown Body/Gold Grill\\nUnlike most ribbon motors designed today with an offset ribbon the new Cascade FAT HEAD houses a hand-tuned ribbon element that incorporates the legendary symmetrical ribbon design. This design offers a true figure 8 pattern. The corrugated aluminum membrane itself is positioned in the center from front to back, thus producing a balanced audio input signal to both sides of the ribbon assembly. This design is very useful when executing a mid-side or Blumlein recording set-up and also great for live stage use. The FAT HEAD warm full-bodied signature and increased sensitivity is what you would expect and demand from a professional ribbon microphone and the FAT HEAD delivers. The FAT HEAD is suited for guitar cabinets, drum over-heads, vocal\\nPrice is $275.00\\n\\nPotentially related product:\\nMain_Category: Musical Instruments\\n\\nRoyer R-10 Ribbon Microphone\\nIncredible Value in a Royer Ribbon Mic Dynamic Ribbon Microphone with Polar Pattern \"Item Weight\" \"2.59 pounds\", \"Product Dimensions\" \"10 x 8 x 4 inches\", \"Item model number\" \"\" \"Musical Instruments\" 14872, \"Ribbon Microphones\" 2, \"Is Discontinued By \" \"No\", \"Date First Available\" \"September 21, 2017\", \"Power Source\" \"Corded Electric\", \"Brand\" \"Royer Corporation\", \"Connectivity Technology\" \"XLR\", \"Included Components\" \"Microphone\", \"Polar Pattern\" \"Bidirectional\", \"Audio Sensitivity\" \\nPrice is $599.00\\n\\nPotentially related product:\\nMain_Category: Musical Instruments\\n\\nTelefunken M80 Supercardioid Dynamic Handheld Vocal Microphone - Cherry Wood\\nDynamic Microphone with Supercardioid Pickup Pattern Frequency Response - Cherry Wood Finish \"Recommended Uses For Product\" \"Singing, Live Performance, Music Recording\", \"Brand\" \"TELEFUNKEN\", \"Connectivity Technology\" \"XLR\", \"Connector Type\" \"XLR Connector\", \"Special Feature\" \"Supercardioid Polar Pattern; Max 135 dB SPL Handling\", \"Compatible Devices\" \"Audio Interfaces, Mixers\", \"Color\" \"Cherry Wood\", \"Included Components\" \"Microphone, Mic Clip, Protective Pouch\", \"Polar Pattern\" \"Unidirectional\", \"Item Weight\" \"1.\\nPrice is $299.00\\n\\nPotentially related product:\\nMain_Category: Musical Instruments\\n\\nCascade Microphones Ribbon Microphone\\nOver the past decade, Cascade Microphones has played a significant role in the “ribbon revolution,” offering quality ribbon mics at affordable prices. Continuing with that tradition, we are excited to announce the newly designed Fat Head II short ribbon microphone. If you already loved the original Fat Head II, fear not! Our new version uses the same 2.5 micron ribbon as its predecessor, so you can expect the same warm and “fat” sound as before. We redesigned the Fat Head II with both form factor and durability in mind. Its new brass body helps protect the microphone from stray RF noise and is larger than its predecessor for easier handling. Also incorporated into the new model is a reinforced neck and grill assembly along with upgraded plating on its hardware. It now\\nPrice is $792.66\\n\\nPotentially related product:\\nMain_Category: Musical Instruments\\n\\nGolden Age Project R2 MKII Ribbon Microphone\\nOutstanding Ribbon Mic Value Ribbon Microphone with Polar Pattern \"Item Weight\" \"3.29 Pounds\", \"Product Dimensions\" \"9.15 x 7.1 x 5.2 inches\", \"Item model number\" \"\" \"Musical Instruments\" 50040, \"Ribbon Microphones\" 6, \"Is Discontinued By \" \"No\", \"Date First Available\" \"May 10, 2011\", \"Color Name\" \"Golden\", \"Material Type\" \"Brass\", \"Power Source\" \"Corded Electric\", \"Brand\" \"Golden Age Project\", \"Connectivity Technology\" \"XLR\", \"Color\" \\nPrice is $169.00\\n\\nPotentially related product:\\nMain_Category: Musical Instruments\\n\\nNady Microphone Stand\\nThe center stage from Nady is a neodymium dynamic microphone with mic clip and tripod stand. Advanced high-output neodymium cartridge provides maximum clarity and definition, even in noisy environments, unidirectional cardioid pattern reduces feedback, special-design internal cartridge mount for lowest handling noise and quiet performance, withstands highest sound pressure levels without overload or distortion, rugged all-metal construction, external on-off switch on handle, and includes 20 foot microphone cable. Also includes mic clip and sturdy metal tripod adjustable for performers up to 6ft four inches. The center stage can be used with any standard mixer, powered Mixer/amp or mic preamp. All-in-One kit includes a high-performance microphone, sturdy metal adjustable tripod microphone stand with clip, and a 20 ft\\nPrice is $34.09\\n\\nPotentially related product:\\nMain_Category: Musical Instruments\\n\\nTelefunken M80 Hand-Held Cardioid Microphone Custom Finish Dynamic Series with Wider Frequency Response and Higher-than-Normal SPL Capabilities (Oak)\\n\"Item Weight\" \"1.65 pounds\", \"Product Dimensions\" \"12 x 6 x 6 inches\", \"Item model number\" \"M80\", \"Is Discontinued By \" \"No\", \"Date First Available\" \"October 15, 2014\", \"Material Type\" \"Wood\", \"Power Source\" \"Corded Electric\", \"Brand\" \"TELEFUNKEN Elektroakustik\", \"Connectivity Technology\" \"XLR\", \"Included Components\" \"Microphone\", \"Polar Pattern\" \"Unidirectional\", \"\\nPrice is $299.00\\n\\nPotentially related product:\\nMain_Category: Musical Instruments\\n\\nSennheiser Professional E 604 Compact Dynamic Cardioid Instrument Microphone\\nOptimized for drum sets and other percussion instrument miking, while also producing exceptional results for brass and woodwind Very high sound pressure handling capability, in excess of 160 dB Balanced, clear, low distortion signal similar to a high-end studio condenser microphone Low sensitivity to impact and handling noise Easy to position, due to compact design \"Brand\" \"Sennheiser Pro Audio\", \"Connectivity Technology\" \"Wired\", \"Connector Type\" \"XLR\", \"Color\" \"Charcoal\", \"Included Components\" \"1 e 604|1 drum clip|1 pouch\", \"Polar Pattern\" \"Unidirectional\", \"Audio Sensitivity\" \"160\\nPrice is $149.95\\n\\nPotentially related product:\\nMain_Category: Musical Instruments\\n\\nShure Cardioid Dynamic Vocal Microphone with Pig Hog XLR Mic Cable 10 Ft\\nDigitaldjgear presents the Shure SM58LC Dynamic Vocal microphone with Free Cable as a Bundle available only from our store. we pride ourselves on providing the best products and packages available today and back it up with a 100% satisfaction Gaurantee. Frequency response tailored for vocals, with brightened midrange and bass rolloff to control proximity effect Effective built-in spherical wind and pop filter. Frequency response 50 to 15,000 Hz Pneumatic shock-mount system cuts down handling noise Uniform cardioid pickup pattern isolates the main sound source and minimizes background noise Includes High Performance Tour Grade Microphone Cable with 8mm high quality rubber outer covering \"Item Weight\" \"\\nPrice is $124.99\\n\\nPotentially related product:\\nMain_Category: Musical Instruments\\n\\nAudio-Technica ATM450 Cardioid Condenser Instrument Microphone\\nOne of the new stars of the Artist Series remake, the ATM450 cardioid condenser offers an innovative side-address stick design for endless placement options and minimal obstructions. The microphone is equipped with an integral 80 Hz hi-pass filter that provides easy switching from a flat frequency response to a low-end roll-off. The ATM450 also features a switchable 10 dB pad that lowers the microphone\\'s sensitivity, providing higher SPL capability for flexible use with a wide range of performers and system configurations. The microphone’s extended flat frequency response makes it ideal for high SPLs as well as for live and amplified acoustic instruments. Includes a professional isolation clamp to provide secure mounting, versatile positioning and effective dampening of unwanted mechanical noise. Unique\\nPrice is $279.00\\n\\nAnd now the question for you:\\n\\nHow much does this cost ?\\n\\nMain_Category: Computers\\n\\nSWITCH by Design Studio, Big Giant Plaid,\\nThe SWITCH by Design Studio lid is custom made for your Inspiron R series laptop, 2011 models. It slides on along the top of the laptop and clicks in, giving it the same look and feel of a permanent laptop lid. When purchasing, make sure you are buying the size that fits your system, and make sure your system is the 2011 model of Inspiron R series which includes a replaceable lid latch. Version SWITCH by Design Studio \"Product Dimensions\" \"10.31 x 14.8 x 1 inches\", \"Item Weight\" \"1 pounds\", \"\" \"Dell\", \"Item model number\" \"Is Discontinued By \" \"No\", \"Date First Available\" \\n\\n'}, {'role': 'assistant', 'content': 'Price is $'}]\n"
294
+ ]
295
+ }
296
+ ],
297
+ "source": [
298
+ "print(messages_for(test[5], docs, prices))"
299
+ ]
300
+ },
301
+ {
302
+ "cell_type": "code",
303
+ "execution_count": 60,
304
+ "id": "a009ad08-bac5-4851-a537-af724eb7151e",
305
+ "metadata": {},
306
+ "outputs": [],
307
+ "source": [
308
+ "def get_price(s): \n",
309
+ " s = s.replace(\"$\", \"\").replace(\",\", \"\")\n",
310
+ " match = re.search(r\"[-+]?\\d*.\\d+|\\d+\", s)\n",
311
+ " return float(match.group()) if match else 0"
312
+ ]
313
+ },
314
+ {
315
+ "cell_type": "code",
316
+ "execution_count": 74,
317
+ "id": "7f535781-93d5-450a-aa9b-46e442f75d97",
318
+ "metadata": {},
319
+ "outputs": [],
320
+ "source": [
321
+ "def gpt_5_mini_rag(item): \n",
322
+ " documents, prices = find_similars(item)\n",
323
+ " response = openai.chat.completions.create(\n",
324
+ " model=\"gpt-5-mini\", \n",
325
+ " messages=messages_for(item, documents, prices), \n",
326
+ " seed=42\n",
327
+ " )\n",
328
+ " print(messages_for(item, documents, prices))\n",
329
+ " reply = response.choices[0].message.content \n",
330
+ " print(reply)\n",
331
+ " return get_price(reply)"
332
+ ]
333
+ },
334
+ {
335
+ "cell_type": "code",
336
+ "execution_count": 97,
337
+ "id": "293888ab-cfe2-4aa8-8e2c-4aaef9810672",
338
+ "metadata": {},
339
+ "outputs": [
340
+ {
341
+ "data": {
342
+ "text/plain": [
343
+ "139.37"
344
+ ]
345
+ },
346
+ "execution_count": 97,
347
+ "metadata": {},
348
+ "output_type": "execute_result"
349
+ }
350
+ ],
351
+ "source": [
352
+ "test[500].price"
353
+ ]
354
+ },
355
+ {
356
+ "cell_type": "code",
357
+ "execution_count": 100,
358
+ "id": "7beffe29-574a-4e02-b7c1-e9719c986f1d",
359
+ "metadata": {},
360
+ "outputs": [
361
+ {
362
+ "name": "stdout",
363
+ "output_type": "stream",
364
+ "text": [
365
+ "$259.99\n"
366
+ ]
367
+ },
368
+ {
369
+ "data": {
370
+ "text/plain": [
371
+ "259.99"
372
+ ]
373
+ },
374
+ "execution_count": 100,
375
+ "metadata": {},
376
+ "output_type": "execute_result"
377
+ }
378
+ ],
379
+ "source": [
380
+ "gpt_5_mini_rag(test[500])"
381
+ ]
382
+ }
383
+ ],
384
+ "metadata": {
385
+ "kernelspec": {
386
+ "display_name": "Python 3 (ipykernel)",
387
+ "language": "python",
388
+ "name": "python3"
389
+ },
390
+ "language_info": {
391
+ "codemirror_mode": {
392
+ "name": "ipython",
393
+ "version": 3
394
+ },
395
+ "file_extension": ".py",
396
+ "mimetype": "text/x-python",
397
+ "name": "python",
398
+ "nbconvert_exporter": "python",
399
+ "pygments_lexer": "ipython3",
400
+ "version": "3.13.1"
401
+ }
402
+ },
403
+ "nbformat": 4,
404
+ "nbformat_minor": 5
405
+ }