Bagel Vector Store
Source: llama_index

<a href="https://colab.research.google.com/github/run-llama/llama_index/blob/main/docs/docs/examples/vector_stores/BagelAutoRetriever.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a># Bagel Vector StoreIf you're opening this Notebook on colab, you will probably need to install LlamaIndex 🦙.```python%pip install llama-index-vector-stores-bagel%pip install llama-index%pip install bagelML``````pythonimport loggingimport syslogging.basicConfig(stream=sys.stdout, level=logging.INFO)logging.getLogger().addHandler(logging.StreamHandler(stream=sys.stdout))``````python# set up OpenAIimport osimport getpassos.environ["OPENAI_API_KEY"] = getpass.getpass("OpenAI API Key:")import openaiopenai.api_key = os.environ["OPENAI_API_KEY"]``````pythonimport os# Set environment variableos.environ["BAGEL_API_KEY"] = getpass.getpass("Bagel API Key:")``````pythonimport bagelfrom bagel import Settings``````pythonserver_settings = Settings(    bagel_api_impl="rest", bagel_server_host="api.bageldb.ai")client = bagel.Client(server_settings)collection = client.get_or_create_cluster(    "testing_embeddings_3", embedding_model="custom", dimension=1536)``````pythonfrom llama_index.core import VectorStoreIndex, StorageContextfrom llama_index.vector_stores.bagel import BagelVectorStore``````pythonfrom llama_index.core.schema import TextNodenodes = [    TextNode(        text=(            "Michael Jordan is a retired professional basketball player,"            " widely regarded as one of the greatest basketball players of all"            " time."        ),        metadata={            "category": "Sports",            "country": "United States",        },    ),    TextNode(        text=(            "Angelina Jolie is an American actress, filmmaker, and"            " humanitarian. She has received numerous awards for her acting"            " and is known for her philanthropic work."        ),        metadata={            "category": "Entertainment",            "country": "United States",        },    ),    TextNode(        text=(            "Elon Musk is a business magnate, industrial designer, and"            " engineer. He is the founder, CEO, and lead designer of SpaceX,"            " Tesla, Inc., Neuralink, and The Boring Company."        ),        metadata={            "category": "Business",            "country": "United States",        },    ),    TextNode(        text=(            "Rihanna is a Barbadian singer, actress, and businesswoman. She"            " has achieved significant success in the music industry and is"            " known for her versatile musical style."        ),        metadata={            "category": "Music",            "country": "Barbados",        },    ),    TextNode(        text=(            "Cristiano Ronaldo is a Portuguese professional footballer who is"            " considered one of the greatest football players of all time. He"            " has won numerous awards and set multiple records during his"            " career."        ),        metadata={            "category": "Sports",            "country": "Portugal",        },    ),]``````pythonvector_store = BagelVectorStore(collection=collection)storage_context = StorageContext.from_defaults(vector_store=vector_store)``````pythonindex = VectorStoreIndex(nodes, storage_context=storage_context)``````pythonfrom llama_index.core.retrievers import VectorIndexAutoRetrieverfrom llama_index.core.vector_stores import MetadataInfo, VectorStoreInfovector_store_info = VectorStoreInfo(    content_info="brief biography of celebrities",    metadata_info=[        MetadataInfo(            name="category",            type="str",            description=(                "Category of the celebrity, one of [Sports, Entertainment,"                " Business, Music]"            ),        ),        MetadataInfo(            name="country",            type="str",            description=(                "Country of the celebrity, one of [United States, Barbados,"                " Portugal]"            ),        ),    ],)retriever = VectorIndexAutoRetriever(    index, vector_store_info=vector_store_info)``````pythonretriever.retrieve("celebrity")```