|
89 | 89 | "assistant = pc.assistant.create_assistant(\n",
|
90 | 90 | " assistant_name=assistant_name,\n",
|
91 | 91 | " 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", |
93 | 93 | ")"
|
94 | 94 | ],
|
95 | 95 | "metadata": {
|
|
112 | 112 | "outputs": []
|
113 | 113 | },
|
114 | 114 | {
|
115 |
| - "cell_type": "code", |
| 115 | + "cell_type": "markdown", |
116 | 116 | "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", |
154 | 118 | "\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" |
160 | 122 | ],
|
161 | 123 | "metadata": {
|
162 |
| - "id": "uqOICQmhNZiY" |
163 |
| - }, |
164 |
| - "execution_count": null, |
165 |
| - "outputs": [] |
| 124 | + "id": "nIyz6gYqAbHn" |
| 125 | + } |
166 | 126 | },
|
167 | 127 | {
|
168 | 128 | "cell_type": "code",
|
|
174 | 134 | " assistant_name=assistant_name,\n",
|
175 | 135 | ")\n",
|
176 | 136 | "\n",
|
| 137 | + "file_path = '/content/toys.txt'\n", |
| 138 | + "\n", |
177 | 139 | "# Upload the file\n",
|
178 | 140 | "if os.path.exists(file_path):\n",
|
179 | 141 | " response = assistant.upload_file(\n",
|
|
210 | 172 | "# Chat with your Pinecone assistant, which automatically references\n",
|
211 | 173 | "# your uploaded documents in its responses\n",
|
212 | 174 | "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", |
214 | 176 | "response = assistant.chat_completions(messages=chat_context)\n",
|
215 | 177 | "print(response)"
|
216 | 178 | ],
|
|
0 commit comments