|
585 | 585 | "all_texts = [\"Apples and oranges\", \"Cars and airplanes\", \"Pineapple\", \"Train\", \"Banana\"]\n", |
586 | 586 | "metadatas = [{\"len\": len(t)} for t in all_texts]\n", |
587 | 587 | "ids = [str(uuid.uuid4()) for _ in all_texts]\n", |
588 | | - "await custom_store.aadd_texts(all_texts, metadatas=metadatas, ids=ids)\n", |
| 588 | + "await custom_store.aadd_texts(all_texts, metadatas=metadatas, ids=ids)" |
| 589 | + ] |
| 590 | + }, |
| 591 | + { |
| 592 | + "cell_type": "markdown", |
| 593 | + "metadata": {}, |
| 594 | + "source": [ |
| 595 | + "#### For v0.15.0+\n", |
| 596 | + "\n", |
| 597 | + "**Important Update:** Support for string filters has been deprecated. Please use dictionaries to add filters." |
| 598 | + ] |
| 599 | + }, |
| 600 | + { |
| 601 | + "cell_type": "code", |
| 602 | + "execution_count": null, |
| 603 | + "metadata": {}, |
| 604 | + "outputs": [], |
| 605 | + "source": [ |
| 606 | + "# Use filter on search\n", |
| 607 | + "docs = await custom_store.asimilarity_search_by_vector(\n", |
| 608 | + " query_vector, filter={\"len\": {\"$gte\": 6}}\n", |
| 609 | + ")\n", |
589 | 610 | "\n", |
| 611 | + "print(docs)" |
| 612 | + ] |
| 613 | + }, |
| 614 | + { |
| 615 | + "cell_type": "markdown", |
| 616 | + "metadata": {}, |
| 617 | + "source": [ |
| 618 | + "#### For v0.14 and under\n", |
| 619 | + "\n", |
| 620 | + "You can make use of the string filters to filter on metadata" |
| 621 | + ] |
| 622 | + }, |
| 623 | + { |
| 624 | + "cell_type": "code", |
| 625 | + "execution_count": null, |
| 626 | + "metadata": {}, |
| 627 | + "outputs": [], |
| 628 | + "source": [ |
590 | 629 | "# Use filter on search\n", |
591 | | - "docs = await custom_store.asimilarity_search_by_vector(query_vector, filter=\"len >= 6\")\n", |
| 630 | + "docs = await custom_store.asimilarity_search(query, filter=\"len >= 6\")\n", |
592 | 631 | "\n", |
593 | 632 | "print(docs)" |
594 | 633 | ] |
|
0 commit comments