Giter Site home page Giter Site logo

Comments (3)

dosubot avatar dosubot commented on July 17, 2024 2

To add a new SQLTableSchema to an existing ChromaDB embedding, you can use the add method of the ChromaVectorStore class. Here is an example based on your provided code:

from llama_index.core.objects import SQLTableSchema
from llama_index.vector_stores.chroma import ChromaVectorStore

# Assuming you have an existing ChromaVectorStore instance
vector_store = ChromaVectorStore(chroma_collection=chroma_collection)

# Define your new SQLTableSchema
new_sql_table_schema = SQLTableSchema(
    table_name="new_table",
    columns=[
        {"name": "column1", "type": "TEXT"},
        {"name": "column2", "type": "INTEGER"},
    ],
    primary_key="column1"
)

# Add the new SQLTableSchema to the existing ChromaDB embedding
vector_store.add([new_sql_table_schema])

This code snippet demonstrates how to create a new SQLTableSchema and add it to an existing ChromaDB embedding using the add method of the ChromaVectorStore class [1].

To continue talking to Dosu, mention @dosu.

from llama_index.

dosubot avatar dosubot commented on July 17, 2024 2

To update the existing embedding if there is a change in just the column of an existing SQLTableSchema, you would need to regenerate the TextNode for the updated schema and then update the embedding in the ChromaVectorStore. Here is how you can do it:

  1. Regenerate the TextNode for the updated schema:

    from llama_index.core.objects import SQLTableNodeMapping, SQLTableSchema
    
    # Assuming you have an instance of SQLTableNodeMapping and an updated SQLTableSchema
    sql_table_node_mapping = SQLTableNodeMapping(sql_database)
    updated_schema = SQLTableSchema(table_name="your_table_name", context_str="new_context")
    
    # Generate the updated TextNode
    updated_node = sql_table_node_mapping.to_node(updated_schema)
  2. Update the embedding in the ChromaVectorStore:

    from llama_index.vector_stores.chroma import ChromaVectorStore
    
    # Assuming you have an existing ChromaVectorStore instance
    vector_store = ChromaVectorStore(chroma_collection=chroma_collection)
    
    # Step 1: Delete the existing node
    vector_store.delete(ref_doc_id=updated_node.node_id)
    
    # Step 2: Add the updated node
    vector_store.add(nodes=[updated_node])

This approach ensures that the old embedding is removed and the new embedding is added to the collection, reflecting the updated schema changes [1][2].

To continue talking to Dosu, mention @dosu.

from llama_index.

Chakradhar448 avatar Chakradhar448 commented on July 17, 2024

Hi thanks for the response.

But could you please help me, on what if there was change in just the column. How to update the existing embedding for that tableschema, Please

from llama_index.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.