|
240 | 240 | "record: Record = taskingai.retrieval.create_record(\n",
|
241 | 241 | " collection_id=collection.collection_id,\n",
|
242 | 242 | " type=\"web\",\n",
|
243 |
| - " title=\"Machine learning\",\n", |
| 243 | + " title=\"Tasking AI\",\n", |
244 | 244 | " url=\"https://www.tasking.ai\", # must https\n",
|
245 | 245 | " text_splitter={\"type\": \"token\", \"chunk_size\": 200, \"chunk_overlap\": 20},\n",
|
246 | 246 | ")\n",
|
|
259 | 259 | " collection_id=collection.collection_id,\n",
|
260 | 260 | " record_id=record.record_id,\n",
|
261 | 261 | " type=\"web\",\n",
|
| 262 | + " title=\"Tasking Documentations\",\n", |
262 | 263 | " url=\"https://docs.tasking.ai\",\n",
|
263 | 264 | " text_splitter={\"type\": \"token\", \"chunk_size\": 200, \"chunk_overlap\": 20},\n",
|
264 | 265 | ")\n",
|
|
283 | 284 | "# upload a file first\n",
|
284 | 285 | "from taskingai.file import upload_file\n",
|
285 | 286 | "\n",
|
286 |
| - "file = upload_file(file=\"your file path\", purpose=\"record_file\")\n", |
287 |
| - "# or\n", |
288 |
| - "# file = upload_file(file=open(\"your file path\", \"rb\"), purpose=\"record_file\")\n", |
289 |
| - "print(f\"uploaded file id: {file.file_id}\")\n", |
290 |
| - "\n", |
291 |
| - "# create a new web record\n", |
| 287 | + "file = upload_file(file=open(\"YOUR_FILE_PATH\", \"rb\"), purpose=\"record_file\")\n", |
| 288 | + "print(f\"uploaded file id: {file.file_id}\")" |
| 289 | + ] |
| 290 | + }, |
| 291 | + { |
| 292 | + "cell_type": "code", |
| 293 | + "execution_count": null, |
| 294 | + "outputs": [], |
| 295 | + "source": [ |
| 296 | + "# create a new file record\n", |
292 | 297 | "record: Record = taskingai.retrieval.create_record(\n",
|
293 | 298 | " collection_id=collection.collection_id,\n",
|
294 | 299 | " type=\"file\",\n",
|
295 |
| - " title=\"Machine learning\",\n", |
| 300 | + " title=\"Machine Learning\",\n", |
296 | 301 | " file_id=file.file_id,\n",
|
297 | 302 | " text_splitter={\"type\": \"token\", \"chunk_size\": 200, \"chunk_overlap\": 20},\n",
|
298 | 303 | ")\n",
|
299 | 304 | "print(f\"created record: {record.record_id} for collection: {collection.collection_id}\\n\")"
|
300 |
| - ] |
| 305 | + ], |
| 306 | + "metadata": { |
| 307 | + "collapsed": false |
| 308 | + }, |
| 309 | + "id": "832ae91419da5493" |
| 310 | + }, |
| 311 | + { |
| 312 | + "cell_type": "code", |
| 313 | + "execution_count": null, |
| 314 | + "outputs": [], |
| 315 | + "source": [ |
| 316 | + "new_file = upload_file(file=open(\"NEW_FILE_PATH\", \"rb\"), purpose=\"record_file\")\n", |
| 317 | + "print(f\"new uploaded file id: {new_file.file_id}\")" |
| 318 | + ], |
| 319 | + "metadata": { |
| 320 | + "collapsed": false |
| 321 | + }, |
| 322 | + "id": "8176058e6c15a1e0" |
301 | 323 | },
|
302 | 324 | {
|
303 | 325 | "cell_type": "code",
|
|
306 | 328 | "metadata": {},
|
307 | 329 | "outputs": [],
|
308 | 330 | "source": [
|
309 |
| - "new_file = upload_file(file=\"new_file_path\", purpose=\"record_file\")\n", |
310 |
| - "print(f\"new uploaded file id: {new_file.file_id}\")\n", |
311 |
| - "\n", |
312 | 331 | "# update record - file\n",
|
313 | 332 | "record = taskingai.retrieval.update_record(\n",
|
314 | 333 | " collection_id=collection.collection_id,\n",
|
315 | 334 | " record_id=record.record_id,\n",
|
316 | 335 | " type=\"file\",\n",
|
| 336 | + " title=\"Deep Learning\",\n", |
317 | 337 | " file_id=new_file.file_id,\n",
|
318 | 338 | " text_splitter={\"type\": \"token\", \"chunk_size\": 200, \"chunk_overlap\": 20},\n",
|
319 | 339 | ")\n",
|
|
325 | 345 | "id": "15465ad8",
|
326 | 346 | "metadata": {},
|
327 | 347 | "source": [
|
328 |
| - "### Record Other Cases" |
| 348 | + "### Other Operations" |
329 | 349 | ]
|
330 | 350 | },
|
331 | 351 | {
|
|
503 | 523 | "# create a new text record and a new chunk\n",
|
504 | 524 | "taskingai.retrieval.create_record(\n",
|
505 | 525 | " collection_id=collection.collection_id,\n",
|
| 526 | + " type=\"text\",\n", |
506 | 527 | " content=\"Machine learning is a subfield of artificial intelligence (AI) that involves the development of algorithms that allow computers to learn from and make decisions or predictions based on data. The term \\\"machine learning\\\" was coined by Arthur Samuel in 1959. In other words, machine learning enables a system to automatically learn and improve from experience without being explicitly programmed. This is achieved by feeding the system massive amounts of data, which it uses to learn patterns and make inferences. There are three main types of machine learning: 1. Supervised Learning: This is where the model is given labeled training data and the goal of learning is to generalize from the training data to unseen situations in a principled way. 2. Unsupervised Learning: This involves training on a dataset without explicit labels. The goal might be to discover inherent groupings or patterns within the data. 3. Reinforcement Learning: In this type, an agent learns to perform actions based on reward/penalty feedback to achieve a goal. It's commonly used in robotics, gaming, and navigation. Deep learning, a subset of machine learning, uses neural networks with many layers (\\\"deep\\\" structures) and has been responsible for many recent breakthroughs in AI, including speech recognition, image recognition, and natural language processing. It's important to note that machine learning is a rapidly developing field, with new techniques and applications emerging regularly.\",\n",
|
507 | 528 | " text_splitter=TokenTextSplitter(chunk_size=200, chunk_overlap=20)\n",
|
508 | 529 | ")\n",
|
|
0 commit comments