Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Light RagServer #849

Closed
YanSte opened this issue Feb 18, 2025 · 8 comments
Closed

Light RagServer #849

YanSte opened this issue Feb 18, 2025 · 8 comments
Assignees
Labels
bug Something isn't working docker lightrag-server

Comments

@YanSte
Copy link
Collaborator

YanSte commented Feb 18, 2025

Hey @ArnoChenFx

I'm getting:

2025-02-18 23:01:03 INFO:Using the label default for PostgreSQL as identifier
2025-02-18 23:01:03 INFO:Connected to PostgreSQL database at postgres:5432/mydatabase
2025-02-18 23:01:03 ERROR:PostgreSQL database error: relation "lightrag_doc_full" does not exist
2025-02-18 23:01:03 ERROR:Failed to check table LIGHTRAG_DOC_FULL in PostgreSQL database
2025-02-18 23:01:03 ERROR:PostgreSQL database error: relation "lightrag_doc_full" does not exist
2025-02-18 23:01:03 INFO:Created table LIGHTRAG_DOC_FULL in PostgreSQL database
2025-02-18 23:01:03 ERROR:PostgreSQL database error: relation "lightrag_doc_chunks" does not exist
2025-02-18 23:01:03 ERROR:Failed to check table LIGHTRAG_DOC_CHUNKS in PostgreSQL database
2025-02-18 23:01:03 ERROR:PostgreSQL database error: relation "lightrag_doc_chunks" does not exist
2025-02-18 23:01:03 INFO:Created table LIGHTRAG_DOC_CHUNKS in PostgreSQL database
2025-02-18 23:01:03 ERROR:PostgreSQL database error: relation "lightrag_vdb_entity" does not exist
2025-02-18 23:01:03 ERROR:Failed to check table LIGHTRAG_VDB_ENTITY in PostgreSQL database
2025-02-18 23:01:03 ERROR:PostgreSQL database error: relation "lightrag_vdb_entity" does not exist
2025-02-18 23:01:03 INFO:Created table LIGHTRAG_VDB_ENTITY in PostgreSQL database
2025-02-18 23:01:03 ERROR:PostgreSQL database error: relation "lightrag_vdb_relation" does not exist
2025-02-18 23:01:03 ERROR:Failed to check table LIGHTRAG_VDB_RELATION in PostgreSQL database
2025-02-18 23:01:03 ERROR:PostgreSQL database error: relation "lightrag_vdb_relation" does not exist
2025-02-18 23:01:03 INFO:Created table LIGHTRAG_VDB_RELATION in PostgreSQL database
2025-02-18 23:01:03 ERROR:PostgreSQL database error: relation "lightrag_llm_cache" does not exist
2025-02-18 23:01:03 ERROR:Failed to check table LIGHTRAG_LLM_CACHE in PostgreSQL database
2025-02-18 23:01:03 ERROR:PostgreSQL database error: relation "lightrag_llm_cache" does not exist
2025-02-18 23:01:03 INFO:Created table LIGHTRAG_LLM_CACHE in PostgreSQL database
2025-02-18 23:01:03 ERROR:PostgreSQL database error: relation "lightrag_doc_status" does not exist
2025-02-18 23:01:03 ERROR:Failed to check table LIGHTRAG_DOC_STATUS in PostgreSQL database
2025-02-18 23:01:03 ERROR:PostgreSQL database error: relation "lightrag_doc_status" does not exist
2025-02-18 23:01:03 INFO:Created table LIGHTRAG_DOC_STATUS in PostgreSQL database
2025-02-18 23:01:03 INFO:Finished checking all tables in PostgreSQL database
2025-02-18 23:01:03 INFO:Injected postgres_db to full_docs
2025-02-18 23:01:03 INFO:Injected postgres_db to text_chunks
2025-02-18 23:01:03 INFO:Injected postgres_db to chunk_entity_relation_graph
2025-02-18 23:01:03 INFO:Injected postgres_db to entities_vdb
2025-02-18 23:01:03 INFO:Injected postgres_db to relationships_vdb
2025-02-18 23:01:03 INFO:Injected postgres_db to chunks_vdb
2025-02-18 23:01:03 INFO:Injected postgres_db to doc_status
2025-02-18 23:01:03 INFO:Injected postgres_db to llm_response_cache
2025-02-18 23:01:03 INFO:     Application startup complete.
@YanSte
Copy link
Collaborator Author

YanSte commented Feb 18, 2025

@ArnoChenFx

@YanSte
Copy link
Collaborator Author

YanSte commented Feb 18, 2025

Here the log, my config was working before:

2025-02-19 00:17:51 INFO:     Started server process [1]
2025-02-19 00:17:51 INFO:     Waiting for application startup.
2025-02-19 00:17:51 INFO:Using the label default for PostgreSQL as identifier
2025-02-19 00:17:51 INFO:Connected to PostgreSQL database at postgres:5432/mydatabase
> Docker compose postgres

2025-02-19 00:17:51 ERROR:PostgreSQL database,
2025-02-19 00:17:51 sql:SELECT 1 FROM LIGHTRAG_DOC_FULL LIMIT 1,
2025-02-19 00:17:51 params:None,
2025-02-19 00:17:51 error:relation "lightrag_doc_full" does not exist
2025-02-19 00:17:51 ERROR:Failed to check table LIGHTRAG_DOC_FULL in PostgreSQL database
2025-02-19 00:17:51 ERROR:PostgreSQL database error: relation "lightrag_doc_full" does not exist
2025-02-19 00:17:51 INFO:Created table LIGHTRAG_DOC_FULL in PostgreSQL database
2025-02-19 00:17:51 ERROR:PostgreSQL database,
2025-02-19 00:17:51 sql:SELECT 1 FROM LIGHTRAG_DOC_CHUNKS LIMIT 1,
2025-02-19 00:17:51 params:None,
2025-02-19 00:17:51 error:relation "lightrag_doc_chunks" does not exist
2025-02-19 00:17:51 ERROR:Failed to check table LIGHTRAG_DOC_CHUNKS in PostgreSQL database
2025-02-19 00:17:51 ERROR:PostgreSQL database error: relation "lightrag_doc_chunks" does not exist
2025-02-19 00:17:51 ERROR:PostgreSQL database,
2025-02-19 00:17:51 sql:CREATE TABLE LIGHTRAG_DOC_CHUNKS (
2025-02-19 00:17:51                     id VARCHAR(255),
2025-02-19 00:17:51                     workspace VARCHAR(255),
2025-02-19 00:17:51                     full_doc_id VARCHAR(256),
2025-02-19 00:17:51                     chunk_order_index INTEGER,
2025-02-19 00:17:51                     tokens INTEGER,
2025-02-19 00:17:51                     content TEXT,
2025-02-19 00:17:51                     content_vector VECTOR,
2025-02-19 00:17:51                     create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
2025-02-19 00:17:51                     update_time TIMESTAMP,
2025-02-19 00:17:51                     CONSTRAINT LIGHTRAG_DOC_CHUNKS_PK PRIMARY KEY (workspace, id)
2025-02-19 00:17:51                     ),
2025-02-19 00:17:51 data:None,
2025-02-19 00:17:51 error:type "vector" does not exist
2025-02-19 00:17:51 ERROR:Failed to create table LIGHTRAG_DOC_CHUNKS in PostgreSQL database
2025-02-19 00:17:51 ERROR:PostgreSQL database error: type "vector" does not exist
2025-02-19 00:17:51 ERROR:PostgreSQL database,
2025-02-19 00:17:51 sql:SELECT 1 FROM LIGHTRAG_VDB_ENTITY LIMIT 1,
2025-02-19 00:17:51 params:None,
2025-02-19 00:17:51 error:relation "lightrag_vdb_entity" does not exist
2025-02-19 00:17:51 ERROR:Failed to check table LIGHTRAG_VDB_ENTITY in PostgreSQL database
2025-02-19 00:17:51 ERROR:PostgreSQL database error: relation "lightrag_vdb_entity" does not exist
2025-02-19 00:17:51 ERROR:PostgreSQL database,
2025-02-19 00:17:51 sql:CREATE TABLE LIGHTRAG_VDB_ENTITY (
2025-02-19 00:17:51                     id VARCHAR(255),
2025-02-19 00:17:51                     workspace VARCHAR(255),
2025-02-19 00:17:51                     entity_name VARCHAR(255),
2025-02-19 00:17:51                     content TEXT,
2025-02-19 00:17:51                     content_vector VECTOR,
2025-02-19 00:17:51                     create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
2025-02-19 00:17:51                     update_time TIMESTAMP,
2025-02-19 00:17:51                     CONSTRAINT LIGHTRAG_VDB_ENTITY_PK PRIMARY KEY (workspace, id)
2025-02-19 00:17:51                     ),
2025-02-19 00:17:51 data:None,
2025-02-19 00:17:51 error:type "vector" does not exist
2025-02-19 00:17:51 ERROR:Failed to create table LIGHTRAG_VDB_ENTITY in PostgreSQL database
2025-02-19 00:17:51 ERROR:PostgreSQL database error: type "vector" does not exist
2025-02-19 00:17:51 ERROR:PostgreSQL database,
2025-02-19 00:17:51 sql:SELECT 1 FROM LIGHTRAG_VDB_RELATION LIMIT 1,
2025-02-19 00:17:51 params:None,
2025-02-19 00:17:51 error:relation "lightrag_vdb_relation" does not exist
2025-02-19 00:17:51 ERROR:Failed to check table LIGHTRAG_VDB_RELATION in PostgreSQL database
2025-02-19 00:17:51 ERROR:PostgreSQL database error: relation "lightrag_vdb_relation" does not exist
2025-02-19 00:17:51 ERROR:PostgreSQL database,
2025-02-19 00:17:51 sql:CREATE TABLE LIGHTRAG_VDB_RELATION (
2025-02-19 00:17:51                     id VARCHAR(255),
2025-02-19 00:17:51                     workspace VARCHAR(255),
2025-02-19 00:17:51                     source_id VARCHAR(256),
2025-02-19 00:17:51                     target_id VARCHAR(256),
2025-02-19 00:17:51                     content TEXT,
2025-02-19 00:17:51                     content_vector VECTOR,
2025-02-19 00:17:51                     create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
2025-02-19 00:17:51                     update_time TIMESTAMP,
2025-02-19 00:17:51                     CONSTRAINT LIGHTRAG_VDB_RELATION_PK PRIMARY KEY (workspace, id)
2025-02-19 00:17:51                     ),
2025-02-19 00:17:51 data:None,
2025-02-19 00:17:51 error:type "vector" does not exist
2025-02-19 00:17:51 ERROR:Failed to create table LIGHTRAG_VDB_RELATION in PostgreSQL database
2025-02-19 00:17:51 ERROR:PostgreSQL database error: type "vector" does not exist
2025-02-19 00:17:51 ERROR:PostgreSQL database,
2025-02-19 00:17:51 sql:SELECT 1 FROM LIGHTRAG_LLM_CACHE LIMIT 1,
2025-02-19 00:17:51 params:None,
2025-02-19 00:17:51 error:relation "lightrag_llm_cache" does not exist
2025-02-19 00:17:51 ERROR:Failed to check table LIGHTRAG_LLM_CACHE in PostgreSQL database
2025-02-19 00:17:51 ERROR:PostgreSQL database error: relation "lightrag_llm_cache" does not exist
2025-02-19 00:17:51 INFO:Created table LIGHTRAG_LLM_CACHE in PostgreSQL database
2025-02-19 00:17:51 ERROR:PostgreSQL database,
2025-02-19 00:17:51 sql:SELECT 1 FROM LIGHTRAG_DOC_STATUS LIMIT 1,
2025-02-19 00:17:51 params:None,
2025-02-19 00:17:51 error:relation "lightrag_doc_status" does not exist
2025-02-19 00:17:51 ERROR:Failed to check table LIGHTRAG_DOC_STATUS in PostgreSQL database
2025-02-19 00:17:51 ERROR:PostgreSQL database error: relation "lightrag_doc_status" does not exist
2025-02-19 00:17:51 INFO:Created table LIGHTRAG_DOC_STATUS in PostgreSQL database
2025-02-19 00:17:51 INFO:Finished checking all tables in PostgreSQL database
2025-02-19 00:17:51 INFO:     Application startup complete.
2025-02-19 00:17:51 INFO:     Uvicorn running on http://0.0.0.0:9626 (Press CTRL+C to quit)

@ArnoChenFx
Copy link
Contributor

ArnoChenFx commented Feb 19, 2025

 async def check_tables(self):
        for k, v in TABLES.items():
            try:
                await self.query("SELECT 1 FROM {k} LIMIT 1".format(k=k))
            except Exception as e:
                logger.error(f"Failed to check table {k} in PostgreSQL database")
                logger.error(f"PostgreSQL database error: {e}")
                try:
                    await self.execute(v["ddl"]) <-------------------------------------- do create table
                    logger.info(f"Created table {k} in PostgreSQL database")
                except Exception as e:
                    logger.error(f"Failed to create table {k} in PostgreSQL database")
                    logger.error(f"PostgreSQL database error: {e}")

        logger.info("Finished checking all tables in PostgreSQL database")

It looks like this issue has existed since postgres_impl.py was first created.
It creates the table within an Exception and does not produce accurate logs.

The real error in your log is the following:

2025-02-19 00:17:51 error:type "vector" does not exist
2025-02-19 00:17:51 ERROR:Failed to create table LIGHTRAG_DOC_CHUNKS in PostgreSQL database
2025-02-19 00:17:51 ERROR:PostgreSQL database error: type "vector" does not exist

2025-02-19 00:17:51 error:type "vector" does not exist
2025-02-19 00:17:51 ERROR:Failed to create table LIGHTRAG_VDB_ENTITY in PostgreSQL database
2025-02-19 00:17:51 ERROR:PostgreSQL database error: type "vector" does not exist

2025-02-19 00:17:51 error:type "vector" does not exist
2025-02-19 00:17:51 ERROR:Failed to create table LIGHTRAG_VDB_RELATION in PostgreSQL database
2025-02-19 00:17:51 ERROR:PostgreSQL database error: type "vector" does not exist

This is because your PostgreSQL instance has not enabled the vector extension.

@mirzabaig14
Copy link

@YanSte you can do the following for installing the vector extension, I did this on my ubuntu:

sudo apt update
sudo apt install postgresql-server-dev-14 build-essential git

# Clone the repository
git clone --branch v0.5.1 https://github.com/pgvector/pgvector.git
cd pgvector

# Build and install
make
sudo make install

# Connect to PostgreSQL
sudo -u postgres psql -d <your db name>

# Create the extension
CREATE EXTENSION vector;

# Test with a simple vector
SELECT '[1,2,3]'::vector;

# Edit postgresql.conf
sudo nano /etc/postgresql/14/main/postgresql.conf

# Add or modify the line:
shared_preload_libraries = 'age,vector'

# Save and restart PostgreSQL
sudo systemctl restart postgresql

Hope this helps!

@YanSte YanSte added bug Something isn't working lightrag-server labels Feb 19, 2025
@YanSte YanSte self-assigned this Feb 19, 2025
@YanSte
Copy link
Collaborator Author

YanSte commented Feb 19, 2025

@mirzabaig14 Thanks I will have a look 🙏🏻

@YanSte YanSte added the docker label Feb 19, 2025
@YanSte
Copy link
Collaborator Author

YanSte commented Feb 19, 2025

Still getting some errors.

I have difficulty to solve this.

Insert a text

LightRAG

2025-02-19 11:47:46 HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
2025-02-19 11:47:46 ERROR:Failed to extract entities and relationships
2025-02-19 11:47:46 ERROR:Failed to process document doc-b45cffe084dd3d20d928bee85e7b0f21: {'message': 'Error executing graph query: SELECT * FROM cypher(\'chunk_entity_relation\', $$\n                     MATCH (n:Entity {node_id: "x535452494e47"})\n                     RETURN n\n                   $$) AS (n agtype)', 'wrapped': 'SELECT * FROM cypher(\'chunk_entity_relation\', $$\n                     MATCH (n:Entity {node_id: "x535452494e47"})\n                     RETURN n\n                   $$) AS (n agtype)', 'detail': 'function create_graph(unknown) does not exist\nHINT:  No function matches the given name and argument types. You might need to add explicit type casts.'}
2025-02-19 11:47:46 INFO:Inserting 1 vectors to chunks
2025-02-19 11:47:46 ERROR:PostgreSQL database,
2025-02-19 11:47:46 sql:SELECT * FROM cypher('chunk_entity_relation', $$
2025-02-19 11:47:46                      MATCH (n:Entity {node_id: "x4d414e59"})
2025-02-19 11:47:46                      RETURN n
2025-02-19 11:47:46                    $$) AS (n agtype),
2025-02-19 11:47:46 params:None,
2025-02-19 11:47:46 error:function create_graph(unknown) does not exist
2025-02-19 11:47:46 HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
2025-02-19 11:47:48 ERROR:PostgreSQL database,
2025-02-19 11:47:48 sql:SELECT * FROM cypher('chunk_entity_relation', $$
2025-02-19 11:47:48                      MATCH (n:Entity {node_id: "x535452494e47"})
2025-02-19 11:47:48                      RETURN n
2025-02-19 11:47:48                    $$) AS (n agtype),
2025-02-19 11:47:48 params:None,
2025-02-19 11:47:48 error:function create_graph(unknown) does not exist
2025-02-19 11:47:48 HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
2025-02-19 11:47:48 ERROR:Failed to extract entities and relationships
2025-02-19 11:47:48 ERROR:Failed to process document doc-f30f77bcc00281e63d6d3d268368e6e5: {'message': 'Error executing graph query: SELECT * FROM cypher(\'chunk_entity_relation\', $$\n                     MATCH (n:Entity {node_id: "x535452494e47"})\n                     RETURN n\n                   $$) AS (n agtype)', 'wrapped': 'SELECT * FROM cypher(\'chunk_entity_relation\', $$\n                     MATCH (n:Entity {node_id: "x535452494e47"})\n                     RETURN n\n                   $$) AS (n agtype)', 'detail': 'function create_graph(unknown) does not exist\nHINT:  No function matches the given name and argument types. You might need to add explicit type casts.'}
2025-02-19 11:47:48 INFO:Completed batch 1 of 1.

Posgres

2025-02-19 11:47:43 INFO:     xxx - "POST /documents/text HTTP/1.1" 200 OK
2025-02-19 11:47:43 INFO:No new unique documents were found.
2025-02-19 11:47:43 INFO:Number of batches to process: 1.
2025-02-19 11:47:43 INFO:Inserting 1 vectors to chunks
2025-02-19 11:47:46 ERROR:PostgreSQL database,
2025-02-19 11:47:46 sql:SELECT * FROM cypher('chunk_entity_relation', $$
2025-02-19 11:47:46                      MATCH (n:Entity {node_id: "x535452494e47"})
2025-02-19 11:47:46                      RETURN n
2025-02-19 11:47:46                    $$) AS (n agtype),
2025-02-19 11:47:46 params:None,
2025-02-19 11:47:46 error:function create_graph(unknown) does not exist
2025-02-19 11:47:46 HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
2025-02-19 11:47:46 ERROR:Failed to extract entities and relationships
2025-02-19 11:47:46 ERROR:Failed to process document doc-b45cffe084dd3d20d928bee85e7b0f21: {'message': 'Error executing graph query: SELECT * FROM cypher(\'chunk_entity_relation\', $$\n                     MATCH (n:Entity {node_id: "x535452494e47"})\n                     RETURN n\n                   $$) AS (n agtype)', 'wrapped': 'SELECT * FROM cypher(\'chunk_entity_relation\', $$\n                     MATCH (n:Entity {node_id: "x535452494e47"})\n                     RETURN n\n                   $$) AS (n agtype)', 'detail': 'function create_graph(unknown) does not exist\nHINT:  No function matches the given name and argument types. You might need to add explicit type casts.'}
2025-02-19 11:47:46 INFO:Inserting 1 vectors to chunks
2025-02-19 11:47:46 ERROR:PostgreSQL database,
2025-02-19 11:47:46 sql:SELECT * FROM cypher('chunk_entity_relation', $$
2025-02-19 11:47:46                      MATCH (n:Entity {node_id: "x4d414e59"})
2025-02-19 11:47:46                      RETURN n
2025-02-19 11:47:46                    $$) AS (n agtype),
2025-02-19 11:47:46 params:None,
2025-02-19 11:47:46 error:function create_graph(unknown) does not exist
2025-02-19 11:47:46 HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
2025-02-19 11:47:48 ERROR:PostgreSQL database,
2025-02-19 11:47:48 sql:SELECT * FROM cypher('chunk_entity_relation', $$
2025-02-19 11:47:48                      MATCH (n:Entity {node_id: "x535452494e47"})
2025-02-19 11:47:48                      RETURN n
2025-02-19 11:47:48                    $$) AS (n agtype),
2025-02-19 11:47:48 params:None,
2025-02-19 11:47:48 error:function create_graph(unknown) does not exist
2025-02-19 11:47:48 HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
2025-02-19 11:47:48 ERROR:Failed to extract entities and relationships
2025-02-19 11:47:48 ERROR:Failed to process document doc-f30f77bcc00281e63d6d3d268368e6e5: {'message': 'Error executing graph query: SELECT * FROM cypher(\'chunk_entity_relation\', $$\n                     MATCH (n:Entity {node_id: "x535452494e47"})\n                     RETURN n\n                   $$) AS (n agtype)', 'wrapped': 'SELECT * FROM cypher(\'chunk_entity_relation\', $$\n                     MATCH (n:Entity {node_id: "x535452494e47"})\n                     RETURN n\n                   $$) AS (n agtype)', 'detail': 'function create_graph(unknown) does not exist\nHINT:  No function matches the given name and argument types. You might need to add explicit type casts.'}
2025-02-19 11:47:48 INFO:Completed batch 1 of 1.

@YanSte
Copy link
Collaborator Author

YanSte commented Feb 19, 2025

Thanks all works will make an update for all developers.

@YanSte YanSte closed this as completed Feb 19, 2025
@mirzabaig14
Copy link

@YanSte so is the postgressql implementation working for you???

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working docker lightrag-server
Projects
None yet
Development

No branches or pull requests

3 participants