langgraph-api 0.2.78__tar.gz → 0.2.83__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.
Potentially problematic release.
This version of langgraph-api might be problematic. Click here for more details.
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/PKG-INFO +1 -1
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/benchmark/README.md +12 -2
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/benchmark/burst.js +13 -6
- langgraph_api-0.2.83/langgraph_api/__init__.py +1 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/api/__init__.py +13 -1
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/cli.py +1 -1
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/config.py +1 -1
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/js/remote.py +24 -2
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/metadata.py +72 -21
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/serde.py +13 -7
- langgraph_api-0.2.78/langgraph_api/__init__.py +0 -1
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/.gitignore +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/LICENSE +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/Makefile +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/README.md +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/benchmark/.gitignore +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/benchmark/Makefile +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/benchmark/weather.js +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/constraints.txt +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/forbidden.txt +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/healthcheck.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/api/assistants.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/api/mcp.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/api/meta.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/api/openapi.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/api/runs.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/api/store.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/api/threads.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/api/ui.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/asgi_transport.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/asyncio.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/auth/__init__.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/auth/custom.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/auth/langsmith/__init__.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/auth/langsmith/backend.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/auth/langsmith/client.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/auth/middleware.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/auth/noop.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/auth/studio_user.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/command.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/cron_scheduler.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/errors.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/graph.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/http.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/http_metrics.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/js/.gitignore +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/js/.prettierrc +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/js/__init__.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/js/base.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/js/build.mts +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/js/client.http.mts +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/js/client.mts +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/js/errors.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/js/global.d.ts +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/js/package.json +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/js/schema.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/js/src/graph.mts +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/js/src/load.hooks.mjs +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/js/src/preload.mjs +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/js/src/utils/files.mts +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/js/src/utils/importMap.mts +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/js/src/utils/pythonSchemas.mts +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/js/src/utils/serde.mts +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/js/sse.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/js/tsconfig.json +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/js/ui.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/js/yarn.lock +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/logging.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/middleware/__init__.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/middleware/http_logger.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/middleware/private_network.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/middleware/request_id.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/models/__init__.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/models/run.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/patch.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/queue_entrypoint.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/route.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/schema.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/server.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/sse.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/state.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/store.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/stream.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/thread_ttl.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/tunneling/cloudflare.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/utils/__init__.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/utils/config.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/utils/future.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/utils.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/validation.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/webhook.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_api/worker.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_license/__init__.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_license/validation.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_runtime/__init__.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_runtime/checkpoint.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_runtime/database.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_runtime/lifespan.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_runtime/metrics.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_runtime/ops.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_runtime/queue.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_runtime/retry.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/langgraph_runtime/store.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/logging.json +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/openapi.json +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/pyproject.toml +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/scripts/create_license.py +0 -0
- {langgraph_api-0.2.78 → langgraph_api-0.2.83}/uv.lock +0 -0
|
@@ -6,7 +6,14 @@ K6 is a modern load testing tool that allows you to test the performance and rel
|
|
|
6
6
|
|
|
7
7
|
### Available Tests
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
We use a local benchmark agent that has a MODE that can be any of the following:
|
|
10
|
+
- `single` - Run a single node
|
|
11
|
+
- `parallel` - Run EXPAND nodes in parallel
|
|
12
|
+
- `sequential` - Run EXPAND nodes in sequence
|
|
13
|
+
|
|
14
|
+
By default, MODE is `single` and EXPAND is 50.
|
|
15
|
+
|
|
16
|
+
1. Burst - Kick off a burst of /run/wait requests. Default BURST_SIZE is 100.
|
|
10
17
|
|
|
11
18
|
## Running Tests Locally
|
|
12
19
|
|
|
@@ -19,12 +26,15 @@ K6 is a modern load testing tool that allows you to test the performance and rel
|
|
|
19
26
|
### Basic Usage
|
|
20
27
|
|
|
21
28
|
```bash
|
|
22
|
-
# Run burst test with default burst size
|
|
29
|
+
# Run burst test with default burst size
|
|
23
30
|
make benchmark-burst
|
|
24
31
|
|
|
25
32
|
# Run burst test with custom burst size
|
|
26
33
|
BURST_SIZE=500 make benchmark-burst
|
|
27
34
|
|
|
35
|
+
# Run burst test with a different mode and expand size
|
|
36
|
+
MODE='parallel' EXPAND=100 make benchmark-burst
|
|
37
|
+
|
|
28
38
|
# Run burst test against a deployment
|
|
29
39
|
BASE_URL=https://jdr-debug-31ac2c83eef557309f21c1e98d822025.us.langgraph.app make benchmark-burst
|
|
30
40
|
|
|
@@ -15,7 +15,9 @@ const burstSuccessRate = new Rate('burst_success_rate');
|
|
|
15
15
|
|
|
16
16
|
// URL of your LangGraph server
|
|
17
17
|
const BASE_URL = __ENV.BASE_URL || 'http://localhost:9123';
|
|
18
|
-
const BURST_SIZE = parseInt(__ENV.BURST_SIZE || '
|
|
18
|
+
const BURST_SIZE = parseInt(__ENV.BURST_SIZE || '100');
|
|
19
|
+
const MODE = __ENV.MODE || 'single';
|
|
20
|
+
const EXPAND = parseInt(__ENV.EXPAND || '50');
|
|
19
21
|
|
|
20
22
|
// Burst testing configuration
|
|
21
23
|
export let options = {
|
|
@@ -28,7 +30,7 @@ export let options = {
|
|
|
28
30
|
},
|
|
29
31
|
},
|
|
30
32
|
thresholds: {
|
|
31
|
-
'run_duration': ['p(95)<
|
|
33
|
+
'run_duration': ['p(95)<2000'],
|
|
32
34
|
'burst_success_rate': ['rate>0.99'],
|
|
33
35
|
},
|
|
34
36
|
};
|
|
@@ -50,8 +52,10 @@ export default function() {
|
|
|
50
52
|
// Create a payload with the LangGraph agent configuration
|
|
51
53
|
const payload = JSON.stringify({
|
|
52
54
|
assistant_id: "benchmark",
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
input: {mode: MODE, expand: EXPAND},
|
|
56
|
+
config: {
|
|
57
|
+
recursion_limit: EXPAND + 2,
|
|
58
|
+
}
|
|
55
59
|
});
|
|
56
60
|
|
|
57
61
|
// Make a single request to the wait endpoint
|
|
@@ -60,15 +64,18 @@ export default function() {
|
|
|
60
64
|
timeout: '35s'
|
|
61
65
|
});
|
|
62
66
|
|
|
67
|
+
// Don't include verification in the duration of the request
|
|
68
|
+
const duration = new Date().getTime() - startTime;
|
|
69
|
+
|
|
63
70
|
// Check the response
|
|
71
|
+
const expected_length = MODE === 'single' ? 1 : EXPAND + 1;
|
|
64
72
|
const success = check(response, {
|
|
65
73
|
'Run completed successfully': (r) => r.status === 200,
|
|
66
|
-
'Response contains
|
|
74
|
+
'Response contains expected number of messages': (r) => JSON.parse(r.body).messages.length === expected_length,
|
|
67
75
|
});
|
|
68
76
|
|
|
69
77
|
if (success) {
|
|
70
78
|
// Record success metrics
|
|
71
|
-
const duration = new Date().getTime() - startTime;
|
|
72
79
|
runDuration.add(duration);
|
|
73
80
|
successfulRuns.add(1);
|
|
74
81
|
burstSuccessRate.add(1); // 1 = success
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.2.83"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import asyncio
|
|
2
|
+
import functools
|
|
2
3
|
import importlib
|
|
3
4
|
import importlib.util
|
|
4
5
|
import os
|
|
@@ -27,7 +28,11 @@ from langgraph_runtime.database import connect, healthcheck
|
|
|
27
28
|
logger = structlog.stdlib.get_logger(__name__)
|
|
28
29
|
|
|
29
30
|
|
|
30
|
-
async def ok(request: Request):
|
|
31
|
+
async def ok(request: Request, *, disabled: bool = False):
|
|
32
|
+
if disabled:
|
|
33
|
+
# We still expose an /ok endpoint even if disable_meta is set so that
|
|
34
|
+
# the operator knows the server started up.
|
|
35
|
+
return JSONResponse({"ok": True})
|
|
31
36
|
check_db = int(request.query_params.get("check_db", "0")) # must be "0" or "1"
|
|
32
37
|
if check_db:
|
|
33
38
|
await healthcheck()
|
|
@@ -126,6 +131,13 @@ if HTTP_CONFIG:
|
|
|
126
131
|
user_router = load_custom_app(router_import)
|
|
127
132
|
if not HTTP_CONFIG.get("disable_meta"):
|
|
128
133
|
routes.extend(meta_routes)
|
|
134
|
+
else:
|
|
135
|
+
# Otherwise the deployment will never be considered healthy
|
|
136
|
+
routes.append(
|
|
137
|
+
Route(
|
|
138
|
+
"/ok", functools.partial(ok, disabled=True), methods=["GET"], name="ok"
|
|
139
|
+
)
|
|
140
|
+
)
|
|
129
141
|
if protected_routes:
|
|
130
142
|
routes.append(
|
|
131
143
|
Mount(
|
|
@@ -346,7 +346,7 @@ def run_server(
|
|
|
346
346
|
- 📚 API Docs: \033[36m{local_url}/docs\033[0m
|
|
347
347
|
|
|
348
348
|
This in-memory server is designed for development and testing.
|
|
349
|
-
For production use, please use LangGraph
|
|
349
|
+
For production use, please use LangGraph Platform.
|
|
350
350
|
|
|
351
351
|
"""
|
|
352
352
|
logger.info(welcome)
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import asyncio
|
|
2
|
+
import json
|
|
2
3
|
import logging
|
|
3
4
|
import os
|
|
5
|
+
import re
|
|
4
6
|
import shutil
|
|
5
7
|
import ssl
|
|
6
8
|
from collections import deque
|
|
@@ -452,6 +454,26 @@ async def run_js_http_process(paths_str: str, http_config: dict, watch: bool = F
|
|
|
452
454
|
attempt += 1
|
|
453
455
|
|
|
454
456
|
|
|
457
|
+
_BAD_SURROGATE_RE = re.compile(r"\\u[dD][89a-fA-F][0-9a-fA-F]{2}")
|
|
458
|
+
_BAD_ESCAPE_RE = re.compile(r"\\(?![\"\\/bfnrtu])")
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
def _safe_json_loads(data: bytes):
|
|
462
|
+
"""Attempt *orjson.loads* first; if it fails, repair common escape issues.
|
|
463
|
+
|
|
464
|
+
For a time, we had a bug in our surrogate cleanup in serde.py, which
|
|
465
|
+
allowed sequences containing a stray backslash to be stored which would
|
|
466
|
+
then fail upon loading. This function attempts to repair those sequences.
|
|
467
|
+
"""
|
|
468
|
+
try:
|
|
469
|
+
return orjson.loads(data)
|
|
470
|
+
except orjson.JSONDecodeError:
|
|
471
|
+
txt = data.decode("utf-8", "replace")
|
|
472
|
+
txt = _BAD_ESCAPE_RE.sub(r"\\\\", txt)
|
|
473
|
+
txt = _BAD_SURROGATE_RE.sub("", txt)
|
|
474
|
+
return json.loads(txt)
|
|
475
|
+
|
|
476
|
+
|
|
455
477
|
class PassthroughSerialiser(SerializerProtocol):
|
|
456
478
|
def dumps(self, obj: Any) -> bytes:
|
|
457
479
|
return json_dumpb(obj)
|
|
@@ -460,13 +482,13 @@ class PassthroughSerialiser(SerializerProtocol):
|
|
|
460
482
|
return "json", json_dumpb(obj)
|
|
461
483
|
|
|
462
484
|
def loads(self, data: bytes) -> Any:
|
|
463
|
-
return
|
|
485
|
+
return _safe_json_loads(data)
|
|
464
486
|
|
|
465
487
|
def loads_typed(self, data: tuple[str, bytes]) -> Any:
|
|
466
488
|
type, payload = data
|
|
467
489
|
if type != "json":
|
|
468
490
|
raise ValueError(f"Unsupported type {type}")
|
|
469
|
-
return
|
|
491
|
+
return _safe_json_loads(payload)
|
|
470
492
|
|
|
471
493
|
|
|
472
494
|
def _get_passthrough_checkpointer():
|
|
@@ -55,13 +55,15 @@ RUN_COUNTER = 0
|
|
|
55
55
|
NODE_COUNTER = 0
|
|
56
56
|
FROM_TIMESTAMP = datetime.now(UTC).isoformat()
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
58
|
+
# Beacon endpoint for license key submissions
|
|
59
|
+
BEACON_ENDPOINT = "https://api.smith.langchain.com/v1/metadata/submit"
|
|
60
|
+
|
|
61
|
+
# LangChain auth endpoint for API key submissions
|
|
62
|
+
LANGCHAIN_METADATA_ENDPOINT = None
|
|
63
|
+
if LANGSMITH_AUTH_ENDPOINT:
|
|
64
|
+
LANGCHAIN_METADATA_ENDPOINT = (
|
|
65
|
+
LANGSMITH_AUTH_ENDPOINT.rstrip("/") + "/v1/metadata/submit"
|
|
66
|
+
)
|
|
65
67
|
|
|
66
68
|
|
|
67
69
|
def incr_runs(*, incr: int = 1) -> None:
|
|
@@ -82,8 +84,10 @@ async def metadata_loop() -> None:
|
|
|
82
84
|
if not LANGGRAPH_CLOUD_LICENSE_KEY and not LANGSMITH_API_KEY:
|
|
83
85
|
return
|
|
84
86
|
|
|
85
|
-
if
|
|
86
|
-
|
|
87
|
+
if (
|
|
88
|
+
LANGGRAPH_CLOUD_LICENSE_KEY
|
|
89
|
+
and not LANGGRAPH_CLOUD_LICENSE_KEY.startswith("lcl_")
|
|
90
|
+
and not LANGSMITH_API_KEY
|
|
87
91
|
):
|
|
88
92
|
logger.info("Running in air-gapped mode, skipping metadata loop")
|
|
89
93
|
return
|
|
@@ -102,9 +106,7 @@ async def metadata_loop() -> None:
|
|
|
102
106
|
NODE_COUNTER = 0
|
|
103
107
|
FROM_TIMESTAMP = to_timestamp
|
|
104
108
|
|
|
105
|
-
|
|
106
|
-
"license_key": LANGGRAPH_CLOUD_LICENSE_KEY,
|
|
107
|
-
"api_key": LANGSMITH_API_KEY,
|
|
109
|
+
base_payload = {
|
|
108
110
|
"from_timestamp": from_timestamp,
|
|
109
111
|
"to_timestamp": to_timestamp,
|
|
110
112
|
"tags": {
|
|
@@ -130,17 +132,66 @@ async def metadata_loop() -> None:
|
|
|
130
132
|
},
|
|
131
133
|
"logs": [],
|
|
132
134
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
135
|
+
|
|
136
|
+
# Track successful submissions
|
|
137
|
+
submissions_attempted = []
|
|
138
|
+
submissions_failed = []
|
|
139
|
+
|
|
140
|
+
# 1. Send to beacon endpoint if license key starts with lcl_
|
|
141
|
+
if LANGGRAPH_CLOUD_LICENSE_KEY and LANGGRAPH_CLOUD_LICENSE_KEY.startswith(
|
|
142
|
+
"lcl_"
|
|
143
|
+
):
|
|
144
|
+
beacon_payload = {
|
|
145
|
+
**base_payload,
|
|
146
|
+
"license_key": LANGGRAPH_CLOUD_LICENSE_KEY,
|
|
147
|
+
}
|
|
148
|
+
submissions_attempted.append("beacon")
|
|
149
|
+
try:
|
|
150
|
+
await http_request(
|
|
151
|
+
"POST",
|
|
152
|
+
BEACON_ENDPOINT,
|
|
153
|
+
body=orjson.dumps(beacon_payload),
|
|
154
|
+
headers={"Content-Type": "application/json"},
|
|
155
|
+
)
|
|
156
|
+
await logger.ainfo("Successfully submitted metadata to beacon endpoint")
|
|
157
|
+
except Exception as e:
|
|
158
|
+
submissions_failed.append("beacon")
|
|
159
|
+
await logger.awarning(
|
|
160
|
+
"Beacon metadata submission failed.", error=str(e)
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
# 2. Send to langchain auth endpoint if API key is set
|
|
164
|
+
if LANGSMITH_API_KEY and LANGCHAIN_METADATA_ENDPOINT:
|
|
165
|
+
langchain_payload = {
|
|
166
|
+
**base_payload,
|
|
167
|
+
"api_key": LANGSMITH_API_KEY,
|
|
168
|
+
}
|
|
169
|
+
submissions_attempted.append("langchain")
|
|
170
|
+
try:
|
|
171
|
+
await http_request(
|
|
172
|
+
"POST",
|
|
173
|
+
LANGCHAIN_METADATA_ENDPOINT,
|
|
174
|
+
body=orjson.dumps(langchain_payload),
|
|
175
|
+
headers={"Content-Type": "application/json"},
|
|
176
|
+
)
|
|
177
|
+
logger.info("Successfully submitted metadata to LangSmith instance")
|
|
178
|
+
except Exception as e:
|
|
179
|
+
submissions_failed.append("langchain")
|
|
180
|
+
await logger.awarning(
|
|
181
|
+
"LangChain metadata submission failed.", error=str(e)
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
if submissions_attempted and len(submissions_failed) == len(
|
|
185
|
+
submissions_attempted
|
|
186
|
+
):
|
|
141
187
|
# retry on next iteration
|
|
142
188
|
incr_runs(incr=runs)
|
|
143
189
|
incr_nodes("", incr=nodes)
|
|
144
190
|
FROM_TIMESTAMP = from_timestamp
|
|
145
|
-
await logger.
|
|
191
|
+
await logger.awarning(
|
|
192
|
+
"All metadata submissions failed, will retry",
|
|
193
|
+
attempted=submissions_attempted,
|
|
194
|
+
failed=submissions_failed,
|
|
195
|
+
)
|
|
196
|
+
|
|
146
197
|
await asyncio.sleep(INTERVAL)
|
|
@@ -123,16 +123,18 @@ def _sanitise(o: Any) -> Any:
|
|
|
123
123
|
|
|
124
124
|
def json_dumpb(obj) -> bytes:
|
|
125
125
|
try:
|
|
126
|
-
|
|
127
|
-
rb"\u0000", b""
|
|
128
|
-
) # null unicode char not allowed in json
|
|
126
|
+
dumped = orjson.dumps(obj, default=default, option=_option)
|
|
129
127
|
except TypeError as e:
|
|
130
128
|
if "surrogates not allowed" not in str(e):
|
|
131
129
|
raise
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
130
|
+
dumped = orjson.dumps(_sanitise(obj), default=default, option=_option)
|
|
131
|
+
return (
|
|
132
|
+
# Unfortunately simply doing ``.replace(rb"\\u0000", b"")`` on
|
|
133
|
+
# the dumped bytes can leave an **orphaned back-slash** (e.g. ``\\q``)
|
|
134
|
+
# which makes the resulting JSON invalid. The fix is to delete the *double*
|
|
135
|
+
# back-slash form **first**, then (optionally) the single-escapes.
|
|
136
|
+
dumped.replace(rb"\\u0000", b"").replace(rb"\u0000", b"")
|
|
137
|
+
)
|
|
136
138
|
|
|
137
139
|
|
|
138
140
|
def json_loads(content: bytes | Fragment | dict) -> Any:
|
|
@@ -154,6 +156,10 @@ class Serializer(JsonPlusSerializer):
|
|
|
154
156
|
except TypeError:
|
|
155
157
|
return "pickle", cloudpickle.dumps(obj)
|
|
156
158
|
|
|
159
|
+
def dumps(self, obj: Any) -> bytes:
|
|
160
|
+
# See comment above (in json_dumpb)
|
|
161
|
+
return super().dumps(obj).replace(rb"\\u0000", b"").replace(rb"\u0000", b"")
|
|
162
|
+
|
|
157
163
|
def loads_typed(self, data: tuple[str, bytes]) -> Any:
|
|
158
164
|
if data[0] == "pickle":
|
|
159
165
|
try:
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.2.78"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|