Skip to content

Use Vector DB

To help you create and use LLMs, we are providing a Weaviate database that can be used by the pipelines of the Platform. More informations on the Weaviate database itself on the official site.

Create a VectorDB

To use a Weaviate in your Environment, you need to specify it at the environment creation. There is currently no possibility to add a Weaviate DB once the environment is created. You just need to select the value in the drop-down menu in the Environment Creation form. It will run in a pod near your processing environment and Weaviate will be installed to run its prcessing on the CPU.

create_vectordb

Access the VectorDB

Then, you need to parameter some code to access Weaviate's features.

import os
from craft_ai_sdk import CraftAiSdk
from dotenv import load_dotenv

load_dotenv()

sdk = CraftAiSdk(
    sdk_token=CRAFT_AI_SDK_TOKEN,
    environment_url=CRAFT_AI_ENVIRONMENT_URL,
)

client = sdk.get_weaviate_client()

Use the VectorDB

Once you are connected, you can use your VectorDB as you wish and call all its internal functions.

vectordb_collection_name = "your_collection"

weaviate_collection = client.collections.get(
    name=vectordb_collection_name,
)