Skip to content

Commit

Permalink
Add langgraph.json snippet to concept doc (#2630)
Browse files Browse the repository at this point in the history
  • Loading branch information
hinthornw authored Dec 4, 2024
1 parent 8db6a78 commit e5e659c
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 3 deletions.
17 changes: 16 additions & 1 deletion docs/docs/concepts/persistence.md
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,22 @@ for update in graph.stream(
print(update)
```

When we use the LangGraph API, either locally (e.g., in LangGraph Studio) or with LangGraph Cloud, the base store is available to use by default and does not need to be specified during graph compilation. For cloud deployments, semantic search is automatically configured based on your `langgraph.json` settings. See the [deployment guide](../deployment/semantic_search.md) for more details.
When we use the LangGraph Platform, either locally (e.g., in LangGraph Studio) or with LangGraph Cloud, the base store is available to use by default and does not need to be specified during graph compilation. To enable semantic search, however, you **do** need to configure the indexing settings in your `langgraph.json` file. For example:

```json
{
...
"store": {
"index": {
"embed": "openai:text-embeddings-3-small",
"dims": 1536,
"fields": ["$"]
}
}
}
```

See the [deployment guide](../deployment/semantic_search.md) for more details and configuration options.

## Checkpointer libraries

Expand Down
5 changes: 5 additions & 0 deletions libs/checkpoint-postgres/langgraph/store/postgres/aio.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ class AsyncPostgresStore(AsyncBatchedBaseStore, BasePostgresStore[_ainternal.Con
1. Call `setup()` before first use to create necessary tables and indexes
2. Have the pgvector extension available to use vector search
3. Use Python 3.10+ for async functionality
Note:
Semantic search is disabled by default. You can enable it by providing an `index` configuration
when creating the store. Without this configuration, all `index` arguments passed to
`put` or `aput`will have no effect.
"""

__slots__ = (
Expand Down
6 changes: 5 additions & 1 deletion libs/checkpoint-postgres/langgraph/store/postgres/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,11 @@ class PostgresStore(BaseStore, BasePostgresStore[_pg_internal.Conn]):
# Search by similarity
results = store.search(("docs",), query="python programming")
```
Note:
Semantic search is disabled by default. You can enable it by providing an `index` configuration
when creating the store. Without this configuration, all `index` arguments passed to
`put` or `aput`will have no effect.
Warning:
Make sure to call `setup()` before first use to create necessary tables and indexes.
Expand Down
15 changes: 14 additions & 1 deletion libs/checkpoint/langgraph/store/base/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,11 @@ class InvalidNamespaceError(ValueError):


class IndexConfig(TypedDict, total=False):
"""Configuration for indexing documents for semantic search in the store."""
"""Configuration for indexing documents for semantic search in the store.
If not provided to the store, the store will not support vector search.
In that case, all `index` arguments to put() and `aput()` operations will be ignored.
"""

dims: int
"""Number of dimensions in the embedding vectors.
Expand Down Expand Up @@ -595,6 +599,15 @@ class BaseStore(ABC):
Stores enable persistence and memory that can be shared across threads,
scoped to user IDs, assistant IDs, or other arbitrary namespaces.
Some implementations may support semantic search capabilities through
an optional `index` configuration.
Note:
Semantic search capabilities vary by implementation and are typically
disabled by default. Stores that support this feature can be configured
by providing an `index` configuration at creation time. Without this
configuration, semantic search is disabled and any `index` arguments
to storage operations will have no effect.
"""

__slots__ = ("__weakref__",)
Expand Down
5 changes: 5 additions & 0 deletions libs/checkpoint/langgraph/store/memory/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ class InMemoryStore(BaseStore):
# Search by similarity
results = store.search(("docs",), query="python programming")
Note:
Semantic search is disabled by default. You can enable it by providing an `index` configuration
when creating the store. Without this configuration, all `index` arguments passed to
`put` or `aput`will have no effect.
Warning:
This store keeps all data in memory. Data is lost when the process exits.
For persistence, use a database-backed store like PostgresStore.
Expand Down

0 comments on commit e5e659c

Please sign in to comment.