Giter Club home page Giter Club logo

Comments (2)

dosubot avatar dosubot commented on June 10, 2024 2

To align the PostgresKVStore class with your small_db vector database schema, you'll need to modify the column definitions in the AbstractData class within the get_data_model function. This involves adjusting the column names and types to match those in your small_db schema. Here's a step-by-step guide:

  1. Modify Column Definitions: Adjust the Column definitions in AbstractData to reflect your small_db schema. For example, if your schema includes columns for text, metadata_, node_id, and embedding, you should ensure these are represented in the class.

  2. Example Modification:

from sqlalchemy import Column, Integer, String
from sqlalchemy.dialects.postgresql import JSON, VECTOR  # Assuming VECTOR is a custom type

def get_data_model(base: Type, index_name: str, schema_name: str, use_jsonb: bool = False) -> Any:
    tablename = f"data_{index_name}"
    class_name = f"Data{index_name}"

    class AbstractData(base):
        __abstract__ = True
        id = Column(Integer, primary_key=True, autoincrement=True)
        text = Column(String, nullable=False)
        metadata_ = Column(JSON)
        node_id = Column(String)
        embedding = Column(VECTOR(1536))

    return type(
        class_name,
        (AbstractData,),
        {
            "__tablename__": tablename,
            "__table_args__": (
                Index(f"{tablename}_idx_text", "text"),
                {"schema": schema_name},
            ),
        },
    )
  1. Adjust for Custom Types or Constraints: If your schema uses custom types (like VECTOR), ensure these are correctly defined or imported. You might need to define custom types if they're not directly supported by SQLAlchemy.

  2. Integration with Existing Code: Make sure the modified get_data_model function is correctly integrated with your PostgresKVStore class, particularly in methods that interact with the database, such as put and get.

This approach requires you to closely align the class definitions with your database schema, ensuring that the column names and types in the AbstractData class match those in your small_db. For more detailed guidance, consider referring to the source code of the PostgresKVStore class in the LlamaIndex repository.

Details

Sources


About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

from llama_index.

logan-markewich avatar logan-markewich commented on June 10, 2024

The kvstore and vector store should be created as two different tables, with different table names and different schemas

It seems like you are querying the vector store thinking it has the same fields as the kv store?

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.