in below code I need to add one more data into chromadb. How to do that?
from llama_index.core import SQLDatabase
from llama_index.core.objects import (
SQLTableNodeMapping,
ObjectIndex,
SQLTableSchema,
)
# chroma db
import chromadb
from llama_index.vector_stores.chroma import ChromaVectorStore
from llama_index.core import StorageContext, VectorStoreIndex
sql_database = SQLDatabase(engine)
# TODO: why we not adding colum description here - chakradhar
table_schema_objs = [
SQLTableSchema(table_name=t.table_name, context_str=t.table_summary +"n Given below are the column Details:n" +
"n".join([f"Column name: {col.column_name} with description: {col.column_description}" for col in t.columns]))
for t in table_infos
] # add a SQLTableSchema for each table
print("Creating chromadb", chroma_path)
# create and save chroma
db = chromadb.PersistentClient(path=chroma_path)
chroma_collection = db.get_or_create_collection("table_schema")
vector_store = ChromaVectorStore(chroma_collection=chroma_collection)
storage_context = StorageContext.from_defaults(vector_store=vector_store)
object_index = ObjectIndex.from_objects(
table_schema_objs,
table_node_mapping,
storage_context=storage_context)
obj_retriever = object_index.as_retriever(similarity_top_k=3)
I gone through this article but it is not working.
https://www.datacamp.com/tutorial/chromadb-tutorial-step-by-step-guide
collection.add(
documents = [student_info, club_info, university_info],
metadatas = [{"source": "student info"},{"source": "club info"},{'source':'university info'}],
ids = ["id1", "id2", "id3"]
)