mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-17 21:25:46 +02:00
3b04ee4677
Bumps [langchain-core](https://github.com/langchain-ai/langchain) from 1.2.7 to 1.2.11. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/langchain-ai/langchain/releases">langchain-core's releases</a>.</em></p> <blockquote> <h2>langchain-core==1.2.11</h2> <p>Changes since langchain-core==1.2.10</p> <p>release(core): 1.2.11 (<a href="https://redirect.github.com/langchain-ai/langchain/issues/35144">#35144</a>) fix(openai): sanitize urls when counting tokens in images (<a href="https://redirect.github.com/langchain-ai/langchain/issues/35143">#35143</a>) chore(core): clean up docstring mismatch and redundant logic in langchain-core (<a href="https://redirect.github.com/langchain-ai/langchain/issues/35064">#35064</a>) fix(core): replace bare except with Exception in tracer (<a href="https://redirect.github.com/langchain-ai/langchain/issues/35138">#35138</a>)</p> <h2>langchain-core==1.2.10</h2> <p>Changes since langchain-core==1.2.9</p> <p>release(core): 1.2.10 (<a href="https://redirect.github.com/langchain-ai/langchain/issues/35136">#35136</a>) chore(deps): bump the langchain-deps group across 3 directories with 40 updates (<a href="https://redirect.github.com/langchain-ai/langchain/issues/35129">#35129</a>) chore(deps): bump the langchain-deps group across 3 directories with 11 updates (<a href="https://redirect.github.com/langchain-ai/langchain/issues/35121">#35121</a>) feat(core): add ContextOverflowError, raise in anthropic and openai (<a href="https://redirect.github.com/langchain-ai/langchain/issues/35099">#35099</a>) feat(model-profiles): add <code>text_inputs</code> and <code>text_outputs</code> (<a href="https://redirect.github.com/langchain-ai/langchain/issues/35084">#35084</a>) feat(core): count tokens from tool schemas in <code>count_tokens_approximately</code> (<a href="https://redirect.github.com/langchain-ai/langchain/issues/35098">#35098</a>) docs(core): add missing <code>name</code> docstring for <code>RunnableSerializable</code> (<a href="https://redirect.github.com/langchain-ai/langchain/issues/35088">#35088</a>)</p> <h2>langchain-core==1.2.9</h2> <p>Changes since langchain-core==1.2.8</p> <p>release(core): 1.2.9 (<a href="https://redirect.github.com/langchain-ai/langchain/issues/35025">#35025</a>) fix(core): adjust cap when scaling approximate token counts (<a href="https://redirect.github.com/langchain-ai/langchain/issues/35017">#35017</a>) revert: precompile hex color regex pattern at module level (<a href="https://redirect.github.com/langchain-ai/langchain/issues/35016">#35016</a>) chore: add <code>make type</code> target (<a href="https://redirect.github.com/langchain-ai/langchain/issues/35015">#35015</a>) revert: "chore: add typing target in <code>Makefile</code>" (<a href="https://redirect.github.com/langchain-ai/langchain/issues/35013">#35013</a>) chore: add typing target in <code>Makefile</code> (<a href="https://redirect.github.com/langchain-ai/langchain/issues/35012">#35012</a>) fix(core): apply cap when scaling approximate token counts (<a href="https://redirect.github.com/langchain-ai/langchain/issues/35005">#35005</a>) feat(core): allow scaling by reported usage when counting tokens approximately (<a href="https://redirect.github.com/langchain-ai/langchain/issues/34996">#34996</a>) test(core): increase <code>delta_time</code> for flaky test (<a href="https://redirect.github.com/langchain-ai/langchain/issues/34982">#34982</a>) chore: enrich <code>pyproject.toml</code> files (<a href="https://redirect.github.com/langchain-ai/langchain/issues/34980">#34980</a>)</p> <h2>langchain-core==1.2.8</h2> <p>Changes since langchain-core==1.2.7</p> <p>release(core): 1.2.8 (<a href="https://redirect.github.com/langchain-ai/langchain/issues/34975">#34975</a>) docs(core): add examples for <code>pretty_repr</code>, <code>pretty_print</code> (<a href="https://redirect.github.com/langchain-ai/langchain/issues/34968">#34968</a>) docs(core): use proper admonition for <code>get_buffer_string</code> (<a href="https://redirect.github.com/langchain-ai/langchain/issues/34967">#34967</a>) docs: add usage examples to core classes (<a href="https://redirect.github.com/langchain-ai/langchain/issues/34841">#34841</a>) chore(core): fix docstring format (<a href="https://redirect.github.com/langchain-ai/langchain/issues/34966">#34966</a>) chore(deps): bump the uv group across 20 directories with 3 updates (<a href="https://redirect.github.com/langchain-ai/langchain/issues/34941">#34941</a>) docs: add example to create_message function docstring (<a href="https://redirect.github.com/langchain-ai/langchain/issues/34851">#34851</a>) docs(core): clarify <a href="https://github.com/tool"><code>@tool</code></a> decorator argument and return type requirements (<a href="https://redirect.github.com/langchain-ai/langchain/issues/34860">#34860</a>) fix(core): fix nested mustache variable extraction and update docs (<a href="https://redirect.github.com/langchain-ai/langchain/issues/34872">#34872</a>) fix(core): allow base model annotations for empty model (<a href="https://redirect.github.com/langchain-ai/langchain/issues/34932">#34932</a>) chore: upgrade urllib3 to 2.6.3 (<a href="https://redirect.github.com/langchain-ai/langchain/issues/34940">#34940</a>) fix(core): prevent crash in ParrotFakeChatModel when messages list is empty (<a href="https://redirect.github.com/langchain-ai/langchain/issues/34943">#34943</a>) fix(core): google docstring parsing with no arguments/reserved arguments (<a href="https://redirect.github.com/langchain-ai/langchain/issues/34861">#34861</a>) test(core): add tests for approximate token counting with multimodal messages (<a href="https://redirect.github.com/langchain-ai/langchain/issues/34898">#34898</a>)</p> <!-- raw HTML omitted --> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/langchain-ai/langchain/commit/524e1dab5e7c8229bd78be3c13ab38ac93a6216b"><code>524e1da</code></a> release(core): 1.2.11 (<a href="https://redirect.github.com/langchain-ai/langchain/issues/35144">#35144</a>)</li> <li><a href="https://github.com/langchain-ai/langchain/commit/2b4b1dc29a833d4053deba4c2b77a3848c834565"><code>2b4b1dc</code></a> fix(openai): sanitize urls when counting tokens in images (<a href="https://redirect.github.com/langchain-ai/langchain/issues/35143">#35143</a>)</li> <li><a href="https://github.com/langchain-ai/langchain/commit/0493b276e0be31d4f48d9d0ba5fcbce7fdded38f"><code>0493b27</code></a> fix(anthropic): support effort="max" and remove beta headers (<a href="https://redirect.github.com/langchain-ai/langchain/issues/35141">#35141</a>)</li> <li><a href="https://github.com/langchain-ai/langchain/commit/a5f22e7cb18a05ed057028797a7d0d79cd509b0d"><code>a5f22e7</code></a> chore(core): clean up docstring mismatch and redundant logic in langchain-cor...</li> <li><a href="https://github.com/langchain-ai/langchain/commit/97ee14c179f703473a6ec6ee24179ea756a5698f"><code>97ee14c</code></a> fix(core): replace bare except with Exception in tracer (<a href="https://redirect.github.com/langchain-ai/langchain/issues/35138">#35138</a>)</li> <li><a href="https://github.com/langchain-ai/langchain/commit/990e8076e1d61a0c8ced4d83607685bd71e23687"><code>990e807</code></a> release(standard-tests): release 1.1.5 (<a href="https://redirect.github.com/langchain-ai/langchain/issues/35139">#35139</a>)</li> <li><a href="https://github.com/langchain-ai/langchain/commit/74dffca3d89effdb62da567d1ff6d160c9ad5354"><code>74dffca</code></a> release(langchain): 1.2.10 (<a href="https://redirect.github.com/langchain-ai/langchain/issues/35137">#35137</a>)</li> <li><a href="https://github.com/langchain-ai/langchain/commit/f41e0493336698e9a3e25e6e238786dfc8af91ba"><code>f41e049</code></a> release(core): 1.2.10 (<a href="https://redirect.github.com/langchain-ai/langchain/issues/35136">#35136</a>)</li> <li><a href="https://github.com/langchain-ai/langchain/commit/de05838fca46eb6c2f67064da3a59f5e84818e9a"><code>de05838</code></a> chore(deps): bump the langchain-deps group across 3 directories with 40 updat...</li> <li><a href="https://github.com/langchain-ai/langchain/commit/d6e86aa748ae173857732ee1f7114a06ff8f4231"><code>d6e86aa</code></a> chore(deps): bump the other-deps group across 3 directories with 12 updates (...</li> <li>Additional commits viewable in <a href="https://github.com/langchain-ai/langchain/compare/langchain-core==1.2.7...langchain-core==1.2.11">compare view</a></li> </ul> </details> <br /> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/langchain-ai/langgraph/network/alerts). </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
LangGraph Checkpoint Postgres
Implementation of LangGraph CheckpointSaver that uses Postgres.
Dependencies
By default langgraph-checkpoint-postgres installs psycopg (Psycopg 3) without any extras. However, you can choose a specific installation that best suits your needs here (for example, psycopg[binary]).
Usage
Important
When using Postgres checkpointers for the first time, make sure to call
.setup()method on them to create required tables. See example below.
Important
When manually creating Postgres connections and passing them to
PostgresSaverorAsyncPostgresSaver, make sure to includeautocommit=Trueandrow_factory=dict_row(from psycopg.rows import dict_row). See a full example in this how-to guide.Why these parameters are required:
autocommit=True: Required for the.setup()method to properly commit the checkpoint tables to the database. Without this, table creation may not be persisted.row_factory=dict_row: Required because the PostgresSaver implementation accesses database rows using dictionary-style syntax (e.g.,row["column_name"]). The defaulttuple_rowfactory returns tuples that only support index-based access (e.g.,row[0]), which will causeTypeErrorexceptions when the checkpointer tries to access columns by name.Example of incorrect usage:
# ❌ This will fail with TypeError during checkpointer operations with psycopg.connect(DB_URI) as conn: # Missing autocommit=True and row_factory=dict_row checkpointer = PostgresSaver(conn) checkpointer.setup() # May not persist tables properly # Any operation that reads from database will fail with: # TypeError: tuple indices must be integers or slices, not str
from langgraph.checkpoint.postgres import PostgresSaver
write_config = {"configurable": {"thread_id": "1", "checkpoint_ns": ""}}
read_config = {"configurable": {"thread_id": "1"}}
DB_URI = "postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable"
with PostgresSaver.from_conn_string(DB_URI) as checkpointer:
# call .setup() the first time you're using the checkpointer
checkpointer.setup()
checkpoint = {
"v": 4,
"ts": "2024-07-31T20:14:19.804150+00:00",
"id": "1ef4f797-8335-6428-8001-8a1503f9b875",
"channel_values": {
"my_key": "meow",
"node": "node"
},
"channel_versions": {
"__start__": 2,
"my_key": 3,
"start:node": 3,
"node": 3
},
"versions_seen": {
"__input__": {},
"__start__": {
"__start__": 1
},
"node": {
"start:node": 2
}
},
}
# store checkpoint
checkpointer.put(write_config, checkpoint, {}, {})
# load checkpoint
checkpointer.get(read_config)
# list checkpoints
list(checkpointer.list(read_config))
Async
from langgraph.checkpoint.postgres.aio import AsyncPostgresSaver
async with AsyncPostgresSaver.from_conn_string(DB_URI) as checkpointer:
checkpoint = {
"v": 4,
"ts": "2024-07-31T20:14:19.804150+00:00",
"id": "1ef4f797-8335-6428-8001-8a1503f9b875",
"channel_values": {
"my_key": "meow",
"node": "node"
},
"channel_versions": {
"__start__": 2,
"my_key": 3,
"start:node": 3,
"node": 3
},
"versions_seen": {
"__input__": {},
"__start__": {
"__start__": 1
},
"node": {
"start:node": 2
}
},
}
# store checkpoint
await checkpointer.aput(write_config, checkpoint, {}, {})
# load checkpoint
await checkpointer.aget(read_config)
# list checkpoints
[c async for c in checkpointer.alist(read_config)]