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

Undefined table 'checkpoints' when using Postgres #2062

Open
5 tasks done
vignesh-spericorn opened this issue Oct 9, 2024 · 3 comments
Open
5 tasks done

Undefined table 'checkpoints' when using Postgres #2062

vignesh-spericorn opened this issue Oct 9, 2024 · 3 comments

Comments

@vignesh-spericorn
Copy link

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangGraph/LangChain documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangGraph/LangChain rather than my code.
  • I am sure this is better as an issue rather than a GitHub discussion, since this is a LangGraph bug and not a design question.

Example Code

from langgraph.checkpoint.postgres import PostgresSaver
from psycopg import Connection

DB_URI = "postgresql://postgres:postgres@localhost:5432/llama_db?sslmode=disable"
connection_kwargs = {
    "autocommit": True,
    "prepare_threshold": 0,
}

with Connection.connect(DB_URI, **connection_kwargs) as conn:
    checkpointer = PostgresSaver(conn)
    # NOTE: you need to call .setup() the first time you're using your checkpointer
    checkpointer.setup()
    # Finally, we compile it!
    app = workflow.compile(checkpointer=checkpointer)

    config = {"configurable": {"thread_id": "1"}}

    while True:
        user_input=input("User: ")
        if user_input.lower() in ["quit","q"]:
            print("Good Bye")
            break

        for event in app.stream({'messages': user_input}, config, stream_mode='updates'):
            for value in event.values():
                pass

            print_update(event)
            
        print("Assistant:",value["messages"][0].content)

Error Message and Stack Trace (if applicable)

psycopg.errors.UndefinedTable: relation "checkpoints" does not exist
LINE 34: from checkpoints WHERE thread_id = $1 AND checkpoint_ns = $2...

Description

I was trying this example to create a custom chatbot with memory that is managed according to my logic instead of 6 messages. When i try to use Postgres instead of MemorySaver() I get the above error message that 'checkpoints' table doesn't exist.

System Info

Ubuntu 20.04
Python 3.11.10
langgraph==0.2.34
langgraph-checkpoint==2.0.1
langgraph-checkpoint-postgres==2.0.1

@vbarda
Copy link
Collaborator

vbarda commented Oct 9, 2024

@vignesh-spericorn were there any errors from running checkpointer.setup()? the error you're seeing seems to indicate that .setup() didn't properly run

@vignesh-spericorn
Copy link
Author

@vbarda i didn't get any errors i checked the Postgres DB it had the following tables
checkpoint_blobs
checkpoint_writes
checkpoint_migrations

but checkpoints table is not present

@vbarda
Copy link
Collaborator

vbarda commented Oct 10, 2024

@vignesh-spericorn hmm, could you try deleting all checkpoint-related tables you mentioned and then re-running .setup()?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants