langgraph-sdk 0.2.6__tar.gz → 0.2.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langgraph-sdk
3
- Version: 0.2.6
3
+ Version: 0.2.7
4
4
  Summary: SDK for interacting with LangGraph API
5
5
  Project-URL: Repository, https://www.github.com/langchain-ai/langgraph
6
6
  License-Expression: MIT
@@ -1,6 +1,6 @@
1
1
  from langgraph_sdk.auth import Auth
2
2
  from langgraph_sdk.client import get_client, get_sync_client
3
3
 
4
- __version__ = "0.2.6"
4
+ __version__ = "0.2.7"
5
5
 
6
6
  __all__ = ["Auth", "get_client", "get_sync_client"]
@@ -157,27 +157,38 @@ def get_client(
157
157
  headers: Mapping[str, str] | None = None,
158
158
  timeout: TimeoutTypes | None = None,
159
159
  ) -> LangGraphClient:
160
- """Get a LangGraphClient instance.
160
+ """Create and configure a LangGraphClient.
161
+
162
+ The client provides programmatic access to a LangGraph Platform deployment. It supports
163
+ both remote servers and local in-process connections (when running inside a LangGraph server).
161
164
 
162
165
  Args:
163
- url: The URL of the LangGraph API.
164
- api_key: The API key. If not provided, it will be read from the environment.
165
- Precedence:
166
- 1. explicit argument
167
- 2. LANGGRAPH_API_KEY
168
- 3. LANGSMITH_API_KEY
169
- 4. LANGCHAIN_API_KEY
170
- headers: Optional custom headers
171
- timeout: Optional timeout configuration for the HTTP client.
172
- Accepts an httpx.Timeout instance, a float (seconds), or a tuple of timeouts.
173
- Tuple format is (connect, read, write, pool)
174
- If not provided, defaults to connect=5s, read=300s, write=300s, and pool=5s.
166
+ url:
167
+ Base URL of the LangGraph API.
168
+ – If `None`, the client first attempts an in-process connection via ASGI transport.
169
+ If that fails, it falls back to `http://localhost:8123`.
170
+ api_key:
171
+ API key for authentication. If omitted, the client reads from environment
172
+ variables in the following order:
173
+ 1. Function argument
174
+ 2. `LANGGRAPH_API_KEY`
175
+ 3. `LANGSMITH_API_KEY`
176
+ 4. `LANGCHAIN_API_KEY`
177
+ headers:
178
+ Additional HTTP headers to include in requests. Merged with authentication headers.
179
+ timeout:
180
+ HTTP timeout configuration. May be:
181
+ – `httpx.Timeout` instance
182
+ – float (total seconds)
183
+ – tuple `(connect, read, write, pool)` in seconds
184
+ Defaults: connect=5, read=300, write=300, pool=5.
175
185
 
176
186
  Returns:
177
- LangGraphClient: The top-level client for accessing AssistantsClient,
178
- ThreadsClient, RunsClient, and CronClient.
187
+ LangGraphClient:
188
+ A top-level client exposing sub-clients for assistants, threads,
189
+ runs, and cron operations.
179
190
 
180
- ???+ example "Example"
191
+ ???+ example "Connect to a remote server:"
181
192
 
182
193
  ```python
183
194
  from langgraph_sdk import get_client
@@ -188,6 +199,21 @@ def get_client(
188
199
  # example usage: client.<model>.<method_name>()
189
200
  assistants = await client.assistants.get(assistant_id="some_uuid")
190
201
  ```
202
+
203
+ ???+ example "Connect in-process to a running LangGraph server:"
204
+
205
+ ```python
206
+ from langgraph_sdk import get_client
207
+
208
+ client = get_client(url=None)
209
+
210
+ async def my_node(...):
211
+ subagent_result = await client.runs.wait(
212
+ thread_id=None,
213
+ assistant_id="agent",
214
+ input={"messages": [{"role": "user", "content": "Foo"}]},
215
+ )
216
+ ```
191
217
  """
192
218
 
193
219
  transport: httpx.AsyncBaseTransport | None = None
@@ -457,6 +483,8 @@ class HttpClient:
457
483
  sse = decoder.decode(line=line.rstrip(b"\n"))
458
484
  if sse is not None:
459
485
  yield sse
486
+ if sse := decoder.decode(b""):
487
+ yield sse
460
488
 
461
489
 
462
490
  async def _aencode_json(json: Any) -> tuple[dict[str, str], bytes | None]:
@@ -3647,6 +3675,8 @@ class SyncHttpClient:
3647
3675
  sse = decoder.decode(line.rstrip(b"\n"))
3648
3676
  if sse is not None:
3649
3677
  yield sse
3678
+ if sse := decoder.decode(b""):
3679
+ yield sse
3650
3680
 
3651
3681
 
3652
3682
  def _encode_json(json: Any) -> tuple[dict[str, str], bytes]: