Skip to content

Commit 02babc9

Browse files
committed
Simplify by replacing generation code with flat data file
1 parent 48392a7 commit 02babc9

File tree

2 files changed

+615
-49
lines changed

2 files changed

+615
-49
lines changed

learn/assistant/pinecone-assistant-getting-started.ipynb

Lines changed: 11 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
"assistant = pc.assistant.create_assistant(\n",
9090
" assistant_name=assistant_name,\n",
9191
" metadata=metadata,\n",
92-
" timeout=30 # Wait 30 seconds for model creation to complete.\n",
92+
" timeout=30 # Wait 30 seconds for assistant creation to complete.\n",
9393
")"
9494
],
9595
"metadata": {
@@ -112,57 +112,17 @@
112112
"outputs": []
113113
},
114114
{
115-
"cell_type": "code",
115+
"cell_type": "markdown",
116116
"source": [
117-
"import random\n",
118-
"\n",
119-
"# Function to generate a random toy title\n",
120-
"def generate_toy_title():\n",
121-
" adjectives = [\"Amazing\", \"Super\", \"Fantastic\", \"Incredible\", \"Awesome\", \"Magical\", \"Ultimate\", \"Deluxe\"]\n",
122-
" nouns = [\"Robot\", \"Doll\", \"Blocks\", \"Puzzle\", \"Car\", \"Train\", \"Spaceship\", \"Dinosaur\", \"Unicorn\", \"Dragon\"]\n",
123-
" return f\"{random.choice(adjectives)} {random.choice(nouns)}\"\n",
124-
"\n",
125-
"# Function to generate a random toy description\n",
126-
"def generate_toy_description():\n",
127-
" features = [\n",
128-
" \"Made from high-quality materials\",\n",
129-
" \"Encourages imaginative play\",\n",
130-
" \"Develops problem-solving skills\",\n",
131-
" \"Suitable for ages 3 and up\",\n",
132-
" \"Battery-operated with flashing lights\",\n",
133-
" \"Includes multiple accessories\",\n",
134-
" \"Educational and fun\",\n",
135-
" \"Easy to clean and store\",\n",
136-
" \"Durable and long-lasting\",\n",
137-
" \"Promotes hand-eye coordination\"\n",
138-
" ]\n",
139-
" return \"\\n\".join(random.sample(features, 4))\n",
140-
"\n",
141-
"# Generate 75 toy entries\n",
142-
"toy_entries = []\n",
143-
"for i in range(75):\n",
144-
" title = generate_toy_title()\n",
145-
" description = generate_toy_description()\n",
146-
" entry = f\"{title}\\n\\n{description}\\n\\n{'='*30}\\n\\n\"\n",
147-
" toy_entries.append(entry)\n",
148-
"\n",
149-
"# Write to a local file in Colab\n",
150-
"file_path = \"/content/toy_descriptions.txt\"\n",
151-
"\n",
152-
"with open(file_path, 'w') as f:\n",
153-
" f.writelines(toy_entries)\n",
117+
"Upload the toys.txt file from the repository to Google Colab:\n",
154118
"\n",
155-
"print(f\"Created toy descriptions file at {file_path}\")\n",
156-
"\n",
157-
"# Display the first few entries as a sample\n",
158-
"with open(file_path, 'r') as f:\n",
159-
" print(f.read().split('='*30)[:3])"
119+
"1. Click the folder icon in Google Colab's left rail <--\n",
120+
"2. Click the upload button and use the file picker to select `toys.txt` from the subdirectory of https://github.com/pinecone-io/examples that contains this notebook\n",
121+
"3. Run the next cell to upload the toys.txt file to your Pinecone assistant\n"
160122
],
161123
"metadata": {
162-
"id": "uqOICQmhNZiY"
163-
},
164-
"execution_count": null,
165-
"outputs": []
124+
"id": "nIyz6gYqAbHn"
125+
}
166126
},
167127
{
168128
"cell_type": "code",
@@ -174,6 +134,8 @@
174134
" assistant_name=assistant_name,\n",
175135
")\n",
176136
"\n",
137+
"file_path = '/content/toys.txt'\n",
138+
"\n",
177139
"# Upload the file\n",
178140
"if os.path.exists(file_path):\n",
179141
" response = assistant.upload_file(\n",
@@ -210,7 +172,7 @@
210172
"# Chat with your Pinecone assistant, which automatically references\n",
211173
"# your uploaded documents in its responses\n",
212174
"from pinecone_plugins.assistant.models.chat import Message\n",
213-
"chat_context = [Message(content='Which toys include Unicorn in their name?')]\n",
175+
"chat_context = [Message(content='Which toys teach STEM skills?')]\n",
214176
"response = assistant.chat_completions(messages=chat_context)\n",
215177
"print(response)"
216178
],

0 commit comments

Comments
 (0)