langchain-trigger-server 0.1.2__tar.gz → 0.1.3__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 langchain-trigger-server might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langchain-trigger-server
3
- Version: 0.1.2
3
+ Version: 0.1.3
4
4
  Summary: Generic event-driven triggers framework
5
5
  Project-URL: Homepage, https://github.com/langchain-ai/open-agent-platform
6
6
  Project-URL: Repository, https://github.com/langchain-ai/open-agent-platform
@@ -18,6 +18,7 @@ Classifier: Programming Language :: Python :: 3.12
18
18
  Requires-Python: >=3.9
19
19
  Requires-Dist: fastapi>=0.100.0
20
20
  Requires-Dist: httpx>=0.24.0
21
+ Requires-Dist: langgraph-sdk>=0.2.6
21
22
  Requires-Dist: pydantic>=2.0.0
22
23
  Requires-Dist: python-jose[cryptography]>=3.3.0
23
24
  Requires-Dist: python-multipart>=0.0.6
@@ -9,6 +9,7 @@ from typing import Any, Callable, Dict, List, Optional
9
9
  import httpx
10
10
 
11
11
  from fastapi import FastAPI, HTTPException, Request, Depends
12
+ from langgraph_sdk import get_client
12
13
  from starlette.middleware.base import BaseHTTPMiddleware
13
14
  from starlette.responses import Response
14
15
 
@@ -92,6 +93,9 @@ class TriggerServer:
92
93
 
93
94
  self.langgraph_api_url = self.langgraph_api_url.rstrip("/")
94
95
 
96
+ # Initialize LangGraph SDK client
97
+ self.langgraph_client = get_client(url=self.langgraph_api_url)
98
+
95
99
  self.langchain_auth_client = None
96
100
  try:
97
101
  from langchain_auth import Client
@@ -555,48 +559,35 @@ class TriggerServer:
555
559
  user_id: str,
556
560
  input_data: Dict[str, Any],
557
561
  ) -> Dict[str, Any]:
558
- """Invoke LangGraph agent directly."""
559
- # Build headers using the custom function
560
- headers = await self.langgraph_headers_builder(
561
- user_id=user_id,
562
- api_key=self.langgraph_api_key,
563
- agent_id=agent_id
564
- )
565
-
566
- payload = {
567
- "input": input_data,
568
- "assistant_id": agent_id,
569
- "metadata": {
570
- "triggered_by": "langchain-triggers",
571
- "user_id": user_id,
572
- },
573
- }
574
-
575
- # Let LangGraph create a new thread automatically
576
- url = f"{self.langgraph_api_url}/runs"
577
-
562
+ """Invoke LangGraph agent using the SDK."""
578
563
  logger.info(f"Invoking LangGraph agent {agent_id} for user {user_id}")
579
564
 
580
- async with httpx.AsyncClient() as client:
581
- try:
582
- response = await client.post(
583
- url,
584
- json=payload,
585
- headers=headers,
586
- timeout=30.0,
587
- )
588
- response.raise_for_status()
589
-
590
- result = response.json()
591
- logger.info(f"Successfully invoked agent {agent_id}")
592
- return result
593
-
594
- except httpx.HTTPStatusError as e:
595
- logger.error(f"HTTP error invoking agent: {e.response.status_code} - {e.response.text}")
596
- raise
597
- except Exception as e:
598
- logger.error(f"Error invoking agent {agent_id}: {e}")
599
- raise
565
+ try:
566
+ # Build headers using the custom function
567
+ headers = await self.langgraph_headers_builder(
568
+ user_id=user_id,
569
+ api_key=self.langgraph_api_key,
570
+ agent_id=agent_id
571
+ )
572
+
573
+ # Create a background run using the SDK
574
+ run = await self.langgraph_client.runs.create(
575
+ thread_id=None, # Let LangGraph create a new thread
576
+ assistant_id=agent_id,
577
+ input=input_data,
578
+ metadata={
579
+ "triggered_by": "langchain-triggers",
580
+ "user_id": user_id,
581
+ },
582
+ headers=headers,
583
+ )
584
+
585
+ logger.info(f"Successfully invoked agent {agent_id}, run_id: {run['run_id']}")
586
+ return run
587
+
588
+ except Exception as e:
589
+ logger.error(f"Error invoking agent {agent_id}: {e}")
590
+ raise
600
591
 
601
592
  async def _get_authenticated_user(self, trigger: TriggerTemplate, user_id: str) -> UserAuthInfo:
602
593
  """Get authenticated user with OAuth tokens for the trigger's required providers."""
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "langchain-trigger-server"
7
- version = "0.1.2"
7
+ version = "0.1.3"
8
8
  description = "Generic event-driven triggers framework"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -30,6 +30,7 @@ dependencies = [
30
30
  "httpx>=0.24.0",
31
31
  "python-multipart>=0.0.6",
32
32
  "python-jose[cryptography]>=3.3.0",
33
+ "langgraph-sdk>=0.2.6",
33
34
  ]
34
35
 
35
36
  [project.optional-dependencies]