Vector DB
Installation
# you can use a Conda environment
pip install --extra-index-url https://oauth2accesstoken:$(gcloud auth print-access-token)@glsdk.gdplabs.id/gen-ai-internal/simple/ gllm-docproc# you can use a Conda environment
$token = (gcloud auth print-access-token)
pip install --extra-index-url "https://oauth2accesstoken:$token@glsdk.gdplabs.id/gen-ai-internal/simple/" gllm-docproc# you can use a Conda environment
FOR /F "tokens=*" %T IN ('gcloud auth print-access-token') DO SET TOKEN=%T
pip install --extra-index-url "https://oauth2accesstoken:%TOKEN%@glsdk.gdplabs.id/gen-ai-internal/simple/" gllm-docproc1
import json
from gllm_docproc.indexer.vector.vector_db_indexer import VectorDBIndexer
# Read elements from JSON file
file_path = "./structuredelementchunker-output.json"
with open(file_path, "r", encoding="utf-8") as f:
elements = json.load(f)
indexer = VectorDBIndexer()
# Index the elements with required configuration
result = indexer.index(
elements=elements,
file_id="file_001",
vectorizer_kwargs={
"model": "openai/text-embedding-3-small", # Format: "provider/model_name"
"api_key": "<OPENAI_API_KEY>",
},
db_engine="elasticsearch", # Supported: "chroma", "elasticsearch", "opensearch"
db_config={
"url": "http://localhost:9200",
"index_name": "my_index",
},
)2
python main.pyLast updated
Was this helpful?