mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-16 14:39:31 -05:00
[GH-ISSUE #8472] document_chunk table missing when using PGVector #15137
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @GanizaniSitara on GitHub (Jan 10, 2025).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/8472
Installation Method
Python on Windows
Environment
Expected Behavior:
document_chunk table gets created in Postgres when starting instance with new Postgres database (using DATABASE_URL)
Actual Behavior:
document_chunk table missing
Description
white the document_chunk table is defined in the pgvector.py file, I cannot find it actually being created anywhere in the code base.
Aslo check_vector_lenght() requires the document_chunk talbe, but create_all only runs after (but even that doesn't create it_
Bug Summary:
see below for console output
Reproduction Details
Steps to Reproduce:
setup new empty postgres database
point DATABASE_URL to it
start open-webui
WORAROUND - create table manually
CREATE TABLE document_chunk (
id TEXT PRIMARY KEY,
vector VECTOR(1536),
collection_name TEXT NOT NULL,
text TEXT,
vmetadata JSONB
);
Logs and Screenshots
│ ┌────────────────────────────────────── locals ──────────────────────────────────────┐ │
│ │ PgvectorClient = <class 'open_webui.retrieval.vector.dbs.pgvector.PgvectorClient'> │ │
│ │ VECTOR_DB = 'pgvector' │ │
│ └────────────────────────────────────────────────────────────────────────────────────┘ │
│ │
│ C:\Anaconda3\envs\ollama311\Lib\site-packages\open_webui\retrieval\vector\dbs\pgvector.py:61 in init │
│ │
│ 58 │ │ │ self.session.execute(text("CREATE EXTENSION IF NOT EXISTS vector;")) │
│ 59 │ │ │ │
│ 60 │ │ │ # Check vector length consistency │
│ > 61 │ │ │ self.check_vector_length() │
│ 62 │ │ │ │
│ 63 │ │ │ # Create the tables if they do not exist │
│ 64 │ │ │ # Base.metadata.create_all requires a bind (engine or connection) │
│ │
│ ┌────────────────────────────────────────────────────────────────── locals ──────────────────────────────────────────────────────────────────┐ │
│ │ engine = Engine(postgresql://postgres:@127.0.0.1:5432/openwebui) │ │
│ │ self = <open_webui.retrieval.vector.dbs.pgvector.PgvectorClient object at 0x0000025131E14890> │ │
│ │ SessionLocal = sessionmaker(class_='Session', autocommit=False, bind=Engine(postgresql://postgres:@127.0.0.1:5432/openwebui), │ │
│ │ autoflush=False, expire_on_commit=False) │ │
│ └────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ │
│ │
│ C:\Anaconda3\envs\ollama311\Lib\site-packages\open_webui\retrieval\vector\dbs\pgvector.py:95 in check_vector_length │
│ │
│ 92 │ │ Raises an exception if there is a mismatch. │
│ 93 │ │ """ │
│ 94 │ │ metadata = MetaData() │
│ > 95 │ │ metadata.reflect(bind=self.session.bind, only=["document_chunk"]) │
│ 96 │ │ │
│ 97 │ │ if "document_chunk" in metadata.tables: │
│ 98 │ │ │ document_chunk_table = metadata.tables["document_chunk"]
@beastech commented on GitHub (Jan 11, 2025):
I'm going to try that workaround for sure. Thanks for sharing that!
@carlosnatalino commented on GitHub (Jan 14, 2025):
I also had the same issue. However, I found that the issue comes from this line:
4269df041f/backend/open_webui/retrieval/vector/dbs/pgvector.py (L95)where it is trying to reflect the
document_chunktable which may not exist:To fix this, I changed the line to:
@tjbck commented on GitHub (Jan 16, 2025):
Might have been addressed by @jk-f5 in dev, confirmation wanted here!
@jk-f5 commented on GitHub (Jan 16, 2025):
Yep, fixed in dev. See #8385.