langgraph-api 0.4.15__py3-none-any.whl → 0.4.16__py3-none-any.whl

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/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.4.15"
1
+ __version__ = "0.4.16"
langgraph_api/api/a2a.py CHANGED
@@ -22,6 +22,7 @@ from starlette.responses import JSONResponse, Response
22
22
  from structlog import getLogger
23
23
  from typing_extensions import TypedDict
24
24
 
25
+ from langgraph_api import __version__
25
26
  from langgraph_api.metadata import USER_API_URL
26
27
  from langgraph_api.route import ApiRequest, ApiRoute
27
28
  from langgraph_api.utils.cache import LRUCache
@@ -96,28 +97,6 @@ def _client() -> LangGraphClient:
96
97
  return get_client(url=None)
97
98
 
98
99
 
99
- def _get_version() -> str:
100
- """Get langgraph-api version."""
101
- from langgraph_api import __version__
102
-
103
- return __version__
104
-
105
-
106
- def _generate_task_id() -> str:
107
- """Generate a unique task ID."""
108
- return str(uuid.uuid4())
109
-
110
-
111
- def _generate_context_id() -> str:
112
- """Generate a unique context ID."""
113
- return str(uuid.uuid4())
114
-
115
-
116
- def _generate_timestamp() -> str:
117
- """Generate ISO 8601 timestamp."""
118
- return datetime.now(UTC).isoformat()
119
-
120
-
121
100
  async def _get_assistant(
122
101
  client: LangGraphClient, assistant_id: str, headers: Headers | dict[str, Any] | None
123
102
  ) -> dict[str, Any]:
@@ -469,14 +448,14 @@ def _create_task_response(
469
448
  "text": f"Error executing assistant: {result['__error__']['error']}",
470
449
  }
471
450
  ],
472
- "messageId": _generate_task_id(),
451
+ "messageId": str(uuid.uuid4()),
473
452
  "taskId": task_id,
474
453
  "contextId": context_id,
475
454
  "kind": "message",
476
455
  },
477
456
  }
478
457
  else:
479
- artifact_id = _generate_task_id()
458
+ artifact_id = str(uuid.uuid4())
480
459
  artifacts = [
481
460
  {
482
461
  "artifactId": artifact_id,
@@ -493,7 +472,7 @@ def _create_task_response(
493
472
 
494
473
  base_task["status"] = {
495
474
  "state": "completed",
496
- "timestamp": _generate_timestamp(),
475
+ "timestamp": datetime.now(UTC).isoformat(),
497
476
  }
498
477
  base_task["artifacts"] = artifacts
499
478
 
@@ -749,18 +728,17 @@ async def handle_message_send(
749
728
  }
750
729
 
751
730
  context_id = message.get("contextId")
752
- thread_id = context_id if context_id else None
753
731
 
754
732
  try:
755
- # Creating + joining separately so we can get the run id
756
733
  run = await client.runs.create(
757
- thread_id=thread_id,
734
+ thread_id=context_id,
758
735
  assistant_id=assistant_id,
759
736
  input=input_content,
737
+ if_not_exists="create",
760
738
  headers=request.headers,
761
739
  )
762
740
  except Exception as e:
763
- error_response = _map_runs_create_error_to_rpc(e, assistant_id, thread_id)
741
+ error_response = _map_runs_create_error_to_rpc(e, assistant_id, context_id)
764
742
  if error_response.get("error", {}).get("code") == ERROR_CODE_INTERNAL_ERROR:
765
743
  raise
766
744
  return error_response
@@ -772,7 +750,7 @@ async def handle_message_send(
772
750
  )
773
751
 
774
752
  task_id = run["run_id"]
775
- context_id = thread_id or _generate_context_id()
753
+ context_id = run["thread_id"]
776
754
 
777
755
  return _create_task_response(
778
756
  task_id=task_id,
@@ -884,7 +862,7 @@ async def handle_tasks_get(
884
862
  task_response["status"]["message"] = {
885
863
  "role": "agent",
886
864
  "parts": [{"kind": "text", "text": "Task completed successfully"}],
887
- "messageId": _generate_task_id(),
865
+ "messageId": str(uuid.uuid4()),
888
866
  "taskId": task_id,
889
867
  }
890
868
  elif a2a_state == "failed":
@@ -893,7 +871,7 @@ async def handle_tasks_get(
893
871
  "parts": [
894
872
  {"kind": "text", "text": f"Task failed with status: {lg_status}"}
895
873
  ],
896
- "messageId": _generate_task_id(),
874
+ "messageId": str(uuid.uuid4()),
897
875
  "taskId": task_id,
898
876
  }
899
877
 
@@ -1021,7 +999,7 @@ async def generate_agent_card(request: ApiRequest, assistant_id: str) -> dict[st
1021
999
  "defaultInputModes": ["application/json", "text/plain"],
1022
1000
  "defaultOutputModes": ["application/json", "text/plain"],
1023
1001
  "skills": skills,
1024
- "version": _get_version(),
1002
+ "version": __version__,
1025
1003
  }
1026
1004
 
1027
1005
 
langgraph_api/asyncio.py CHANGED
@@ -115,11 +115,16 @@ def create_task(
115
115
 
116
116
 
117
117
  def run_coroutine_threadsafe(
118
- coro: Coroutine[Any, Any, T], ignore_exceptions: tuple[type[Exception], ...] = ()
118
+ coro: Coroutine[Any, Any, T],
119
+ ignore_exceptions: tuple[type[Exception], ...] = (),
120
+ *,
121
+ loop: asyncio.AbstractEventLoop | None = None,
119
122
  ) -> concurrent.futures.Future[T] | concurrent.futures.Future[None]:
120
- if _MAIN_LOOP is None:
123
+ if loop is None:
124
+ loop = _MAIN_LOOP
125
+ if loop is None:
121
126
  raise RuntimeError("No event loop set")
122
- future = asyncio.run_coroutine_threadsafe(coro, _MAIN_LOOP)
127
+ future = asyncio.run_coroutine_threadsafe(coro, loop)
123
128
  future.add_done_callback(partial(_create_task_done_callback, ignore_exceptions))
124
129
  return future
125
130
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langgraph-api
3
- Version: 0.4.15
3
+ Version: 0.4.16
4
4
  Author-email: Nuno Campos <nuno@langchain.dev>, Will Fu-Hinthorn <will@langchain.dev>
5
5
  License: Elastic-2.0
6
6
  License-File: LICENSE
@@ -1,6 +1,6 @@
1
- langgraph_api/__init__.py,sha256=yHOqz5A9VYGVIjRAkE5ZWR9IpLeDo8sygF-I11UMLv0,23
1
+ langgraph_api/__init__.py,sha256=Qgm7I6hoEastyorRf_J_YW-gsesKcI737L731iY3jes,23
2
2
  langgraph_api/asgi_transport.py,sha256=XtiLOu4WWsd-xizagBLzT5xUkxc9ZG9YqwvETBPjBFE,5161
3
- langgraph_api/asyncio.py,sha256=DN2kyEYFBePzBW1Sa6hDUuQuUEp7M5LAMsH3_6r1Mjc,9762
3
+ langgraph_api/asyncio.py,sha256=FEEkLm_N-15cbElo4vQ309MkDKBZuRqAYV8VJ1DocNw,9860
4
4
  langgraph_api/cli.py,sha256=-ruIeKi1imvS6GriOfRDZY-waV4SbWiJ0BEFAciPVYI,16330
5
5
  langgraph_api/command.py,sha256=Q9XDRhnkCX7jyqW52_Rf2PPYKxjr-Z9BUHazI1HcmB8,817
6
6
  langgraph_api/config.py,sha256=r9mmbyZlhBuJLpnTkaOLcNH6ufFNqm_2eCiuOmhqRl0,12241
@@ -29,7 +29,7 @@ langgraph_api/validation.py,sha256=86jftgOsMa7tkeshBw6imYe7zyUXPoVuf5Voh6dFiR8,5
29
29
  langgraph_api/webhook.py,sha256=SvSM1rdnNtiH4q3JQYmAqJUk2Sable5xAcwOLuRhtlo,1723
30
30
  langgraph_api/worker.py,sha256=FQRw3kL9ynDv_LNgY_OjjPZQBuAvSQpsW6nECnABvDg,15354
31
31
  langgraph_api/api/__init__.py,sha256=raFkYH50tsO-KjRmDbGVoHCuxuH58u1lrZbr-MlITIY,6262
32
- langgraph_api/api/a2a.py,sha256=4J2rEYDz_ZkBrrggfkyqnkytCs3lAfpPD3fMkRdLt9A,35149
32
+ langgraph_api/api/a2a.py,sha256=ChqlhgTq5fzWt0jbbEl8ec9rf-cvAP19Yge7OFv8-6E,34629
33
33
  langgraph_api/api/assistants.py,sha256=JFaBYp9BAXGaJ0yfy1SG_Mr-3xjeWSkdCHtmXpiAqP4,17290
34
34
  langgraph_api/api/mcp.py,sha256=qe10ZRMN3f-Hli-9TI8nbQyWvMeBb72YB1PZVbyqBQw,14418
35
35
  langgraph_api/api/meta.py,sha256=Qyj6r5czkVJ81tpD6liFY7tlrmFDsiSfBr-4X8HJpRc,4834
@@ -98,8 +98,8 @@ langgraph_runtime/store.py,sha256=7mowndlsIroGHv3NpTSOZDJR0lCuaYMBoTnTrewjslw,11
98
98
  LICENSE,sha256=ZPwVR73Biwm3sK6vR54djCrhaRiM4cAD2zvOQZV8Xis,3859
99
99
  logging.json,sha256=3RNjSADZmDq38eHePMm1CbP6qZ71AmpBtLwCmKU9Zgo,379
100
100
  openapi.json,sha256=21wu-NxdxyTQwZctNcEfRkLMnSBi0QhGAfwq5kg8XNU,172618
101
- langgraph_api-0.4.15.dist-info/METADATA,sha256=uZGBb958Te_UK7sx6LB5b026kXWCMt2KrR2aosN7u3M,3893
102
- langgraph_api-0.4.15.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
103
- langgraph_api-0.4.15.dist-info/entry_points.txt,sha256=hGedv8n7cgi41PypMfinwS_HfCwA7xJIfS0jAp8htV8,78
104
- langgraph_api-0.4.15.dist-info/licenses/LICENSE,sha256=ZPwVR73Biwm3sK6vR54djCrhaRiM4cAD2zvOQZV8Xis,3859
105
- langgraph_api-0.4.15.dist-info/RECORD,,
101
+ langgraph_api-0.4.16.dist-info/METADATA,sha256=kvxtObVWl9I5JefxVXy9SET3EF03Zf9w-rITM-UIWRc,3893
102
+ langgraph_api-0.4.16.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
103
+ langgraph_api-0.4.16.dist-info/entry_points.txt,sha256=hGedv8n7cgi41PypMfinwS_HfCwA7xJIfS0jAp8htV8,78
104
+ langgraph_api-0.4.16.dist-info/licenses/LICENSE,sha256=ZPwVR73Biwm3sK6vR54djCrhaRiM4cAD2zvOQZV8Xis,3859
105
+ langgraph_api-0.4.16.dist-info/RECORD,,