Comments (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:
-
Modify Column Definitions: Adjust the
Column
definitions inAbstractData
to reflect yoursmall_db
schema. For example, if your schema includes columns fortext
,metadata_
,node_id
, andembedding
, you should ensure these are represented in the class. -
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},
),
},
)
-
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. -
Integration with Existing Code: Make sure the modified
get_data_model
function is correctly integrated with yourPostgresKVStore
class, particularly in methods that interact with the database, such asput
andget
.
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
- llama-index-core/llama_index/core/storage/kvstore/postgres_kvstore.py
- llama-index-legacy/llama_index/legacy/storage/kvstore/postgres_kvstore.py
- llama-index-legacy/llama_index/legacy/vector_stores/postgres.py
- llama-index-integrations/storage/kvstore/llama-index-storage-kvstore-postgres/llama_index/storage/kvstore/postgres/base.py
- llama-index-integrations/vector_stores/llama-index-vector-stores-postgres/llama_index/vector_stores/postgres/base.py
- llama-index-legacy/tests/storage/kvstore/test_postgres_kvstore.py
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.
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)
- [Bug]: custom_llm_provider not honored in litellm.py HOT 5
- [Question]: Multi-agent capability - using agents as tools for other agents HOT 2
- [Bug]: OpenAI max_retries not working HOT 4
- [Bug]: "Event Loop Closed" error in Evaluator calls - only affects MistralAI (llama-index-llms-mistralai) HOT 10
- [Question]: How to specify datatype Float16 of embeddings in Milvus vector store?
- [Bug]: QdrantVectorStore parser always expects a key called "text" in response HOT 1
- [Question]: How does Agentic RAG judge if the question shall be answered via single RAG retrieval or multiple retrievals by agent? HOT 2
- [Question]: Updating metadata and text in existing pinecone index HOT 1
- [Bug]: HOT 2
- [Bug]: Using the command "pip download llama_index==0.10.19" downloaded the wheel file for version "llama_index_core-0.10.40-py3-none-any.whl" instead HOT 2
- [Question]: Can i use multiple collections in mongo at a time? HOT 1
- [Feature Request]: Add structured_output to Gemini
- [Bug]: Graph Index with Azure OpenAI is impossible to query HOT 2
- [Question]: SmartPDFLoader does not work as a file_extractor HOT 5
- [Bug]: llama-index-llms-mlx does not seem to exist HOT 4
- [Bug]: minor doc issue with MLX HOT 1
- [Question]: How to add new SQLTableSchema to an existing ChromaDB embedding? HOT 3
- [Question]: The retriever failed to fetch the relevant info from chromadb HOT 1
- [Bug]: HOT 1
- [Bug]: index.ref_doc_info does not work with chromadb HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from llama_index.