langchain-trigger-server 0.2.6rc8__py3-none-any.whl → 0.2.7__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 langchain-trigger-server might be problematic. Click here for more details.

@@ -3,22 +3,24 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import inspect
6
- from typing import Any, Dict, List, Type, get_type_hints
6
+ from typing import Any, get_type_hints
7
+
7
8
  from langchain_auth.client import Client
8
- from .core import TriggerHandlerResult, TriggerRegistrationResult
9
9
  from pydantic import BaseModel
10
10
 
11
+ from .core import TriggerHandlerResult, TriggerRegistrationResult
12
+
13
+
11
14
  class TriggerTemplate:
12
15
  """A trigger template with registration handler and main handler."""
13
-
16
+
14
17
  def __init__(
15
18
  self,
16
19
  id: str,
17
20
  provider: str,
18
21
  name: str,
19
22
  description: str,
20
- registration_model: Type[BaseModel],
21
-
23
+ registration_model: type[BaseModel],
22
24
  registration_handler,
23
25
  trigger_handler,
24
26
  ):
@@ -31,41 +33,66 @@ class TriggerTemplate:
31
33
  self.trigger_handler = trigger_handler
32
34
 
33
35
  self._validate_handler_signatures()
34
-
36
+
35
37
  def _validate_handler_signatures(self):
36
38
  """Validate that all handler functions have the correct signatures."""
37
39
  # Expected: async def handler(user_id: str, auth_client: Client, registration: RegistrationModel) -> TriggerRegistrationResult
38
- self._validate_handler("registration_handler", self.registration_handler, [str, Client, self.registration_model], TriggerRegistrationResult)
39
-
40
+ self._validate_handler(
41
+ "registration_handler",
42
+ self.registration_handler,
43
+ [str, Client, self.registration_model],
44
+ TriggerRegistrationResult,
45
+ )
46
+
40
47
  # Expected: async def handler(payload: Dict[str, Any], query_params: Dict[str, str], database, auth_client: Client) -> TriggerHandlerResult
41
- self._validate_handler("trigger_handler", self.trigger_handler, [Dict[str, Any], Dict[str, str], Any, Client], TriggerHandlerResult)
42
-
43
-
44
- def _validate_handler(self, handler_name: str, handler_func, expected_types: List[Type], expected_return_type: Type = None):
48
+ self._validate_handler(
49
+ "trigger_handler",
50
+ self.trigger_handler,
51
+ [dict[str, Any], dict[str, str], Any, Client],
52
+ TriggerHandlerResult,
53
+ )
54
+
55
+ def _validate_handler(
56
+ self,
57
+ handler_name: str,
58
+ handler_func,
59
+ expected_types: list[type],
60
+ expected_return_type: type = None,
61
+ ):
45
62
  """Common validation logic for all handler functions."""
46
63
  if not inspect.iscoroutinefunction(handler_func):
47
64
  raise TypeError(f"{handler_name} for trigger '{self.id}' must be async")
48
-
65
+
49
66
  sig = inspect.signature(handler_func)
50
67
  params = list(sig.parameters.values())
51
68
  expected_param_count = len(expected_types)
52
-
69
+
53
70
  if len(params) != expected_param_count:
54
- raise TypeError(f"{handler_name} for trigger '{self.id}' must have {expected_param_count} parameters, got {len(params)}")
55
-
71
+ raise TypeError(
72
+ f"{handler_name} for trigger '{self.id}' must have {expected_param_count} parameters, got {len(params)}"
73
+ )
74
+
56
75
  hints = get_type_hints(handler_func)
57
76
  param_names = list(sig.parameters.keys())
58
-
77
+
59
78
  # Check each parameter type if type hints are available
60
79
  for i, expected_type in enumerate(expected_types):
61
80
  if param_names[i] in hints and hints[param_names[i]] != expected_type:
62
- expected_name = getattr(expected_type, '__name__', str(expected_type))
63
- raise TypeError(f"{handler_name} for trigger '{self.id}': param {i+1} should be {expected_name}")
64
-
81
+ expected_name = getattr(expected_type, "__name__", str(expected_type))
82
+ raise TypeError(
83
+ f"{handler_name} for trigger '{self.id}': param {i + 1} should be {expected_name}"
84
+ )
85
+
65
86
  # Check return type if expected and available
66
- if expected_return_type and 'return' in hints:
67
- actual_return_type = hints['return']
87
+ if expected_return_type and "return" in hints:
88
+ actual_return_type = hints["return"]
68
89
  if actual_return_type != expected_return_type:
69
- expected_name = getattr(expected_return_type, '__name__', str(expected_return_type))
70
- actual_name = getattr(actual_return_type, '__name__', str(actual_return_type))
71
- raise TypeError(f"{handler_name} for trigger '{self.id}': return type should be {expected_name}, got {actual_name}")
90
+ expected_name = getattr(
91
+ expected_return_type, "__name__", str(expected_return_type)
92
+ )
93
+ actual_name = getattr(
94
+ actual_return_type, "__name__", str(actual_return_type)
95
+ )
96
+ raise TypeError(
97
+ f"{handler_name} for trigger '{self.id}': return type should be {expected_name}, got {actual_name}"
98
+ )
@@ -4,4 +4,4 @@ from .cron_trigger import cron_trigger
4
4
 
5
5
  __all__ = [
6
6
  "cron_trigger",
7
- ]
7
+ ]
@@ -2,15 +2,15 @@
2
2
 
3
3
  import logging
4
4
  from datetime import datetime
5
- from typing import Dict, Any
5
+ from typing import Any
6
6
 
7
7
  from croniter import croniter
8
8
  from langchain_auth.client import Client
9
9
  from pydantic import Field
10
10
 
11
11
  from langchain_triggers.core import (
12
- TriggerRegistrationModel,
13
12
  TriggerHandlerResult,
13
+ TriggerRegistrationModel,
14
14
  TriggerRegistrationResult,
15
15
  )
16
16
  from langchain_triggers.decorators import TriggerTemplate
@@ -47,9 +47,9 @@ async def cron_registration_handler(
47
47
  response_body={
48
48
  "success": False,
49
49
  "error": "invalid_cron_pattern",
50
- "message": f"Invalid cron pattern: '{cron_pattern}'"
50
+ "message": f"Invalid cron pattern: '{cron_pattern}'",
51
51
  },
52
- status_code=400
52
+ status_code=400,
53
53
  )
54
54
  except Exception as e:
55
55
  return TriggerRegistrationResult(
@@ -57,9 +57,9 @@ async def cron_registration_handler(
57
57
  response_body={
58
58
  "success": False,
59
59
  "error": "cron_validation_failed",
60
- "message": f"Failed to validate cron pattern: {str(e)}"
60
+ "message": f"Failed to validate cron pattern: {str(e)}",
61
61
  },
62
- status_code=400
62
+ status_code=400,
63
63
  )
64
64
 
65
65
  logger.info(f"Successfully validated cron pattern: {cron_pattern}")
@@ -68,14 +68,14 @@ async def cron_registration_handler(
68
68
  "cron_pattern": cron_pattern,
69
69
  "timezone": "UTC",
70
70
  "created_at": datetime.utcnow().isoformat(),
71
- "validated": True
71
+ "validated": True,
72
72
  }
73
73
  )
74
74
 
75
75
 
76
76
  async def cron_trigger_handler(
77
- payload: Dict[str, Any],
78
- query_params: Dict[str, str],
77
+ payload: dict[str, Any],
78
+ query_params: dict[str, str],
79
79
  database,
80
80
  auth_client: Client,
81
81
  ) -> TriggerHandlerResult:
@@ -85,8 +85,8 @@ async def cron_trigger_handler(
85
85
  invoke_agent=False,
86
86
  response_body={
87
87
  "success": False,
88
- "message": "Cron triggers are executed by scheduler, not HTTP requests"
89
- }
88
+ "message": "Cron triggers are executed by scheduler, not HTTP requests",
89
+ },
90
90
  )
91
91
 
92
92
 
@@ -1,15 +0,0 @@
1
- langchain_triggers/__init__.py,sha256=qepit9_-RXpSQYPl5aaLA9Q90PwoyMgO69Dx9RkWvPQ,514
2
- langchain_triggers/app.py,sha256=0YL9F2vhgcZhcDORbPJk3jux9naDB-IAE2GXqocK1pc,33524
3
- langchain_triggers/core.py,sha256=VAH7KS_1qbNAzzqNLJ4JNUvig1iLhk2iCpxhY0L_mws,3385
4
- langchain_triggers/cron_manager.py,sha256=9OmBmxcWZT5HpHEYfmmaKaA4A-wjcj7gvARDsMVW_Lk,10143
5
- langchain_triggers/decorators.py,sha256=W78zXd8KiY1C3E-y8Zthmzem-Fn31h5v4DIRHxEDukA,3446
6
- langchain_triggers/auth/__init__.py,sha256=7Olu4vnpY9SUYzxbPgXydjh7H8sK52aE0tCzRtANAgo,350
7
- langchain_triggers/auth/slack_hmac.py,sha256=L8Jwv9SF9oYzTE4YXE1SEtHniAuygCEB6SvgQtx2uzU,3072
8
- langchain_triggers/database/__init__.py,sha256=3NkCRCDITN2kxggRl9zBsYD7TJUYG2-5NEQf5paqfiA,538
9
- langchain_triggers/database/interface.py,sha256=j7flXSMJbUCjnEPLt8hXO2_KePjt9lYlcJoNb3YOPmo,4530
10
- langchain_triggers/database/supabase.py,sha256=4b6B75E7YUknTURGqhzq2BaJ5Uc0mv2H_-6U3A04bCY,16673
11
- langchain_triggers/triggers/__init__.py,sha256=xK0BD6A4vXjC-avM_RtqGgnP4AVtBvW-SNvJOPjBTrE,145
12
- langchain_triggers/triggers/cron_trigger.py,sha256=klGQlCn54otTvL6tkEGwvwUk_AXwnI71W3WycfVNtAc,3173
13
- langchain_trigger_server-0.2.6rc8.dist-info/METADATA,sha256=x908ZCwCXa-2On5lkplEFTljgQzOyys0FEv2S-LCZqE,1484
14
- langchain_trigger_server-0.2.6rc8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
15
- langchain_trigger_server-0.2.6rc8.dist-info/RECORD,,