vellum-ai 0.14.55__py3-none-any.whl → 0.14.56__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.
@@ -18,7 +18,7 @@ class BaseClientWrapper:
18
18
  headers: typing.Dict[str, str] = {
19
19
  "X-Fern-Language": "Python",
20
20
  "X-Fern-SDK-Name": "vellum-ai",
21
- "X-Fern-SDK-Version": "0.14.55",
21
+ "X-Fern-SDK-Version": "0.14.56",
22
22
  }
23
23
  headers["X-API-KEY"] = self.api_key
24
24
  return headers
@@ -57,26 +57,32 @@ def create_tool_router_node(
57
57
  functions: List[Callable[..., Any]],
58
58
  prompt_inputs: Optional[EntityInputsInterface],
59
59
  ) -> Type[ToolRouterNode]:
60
- Ports = type("Ports", (), {})
61
- for function in functions:
62
- function_name = function.__name__
63
-
64
- # Avoid using lambda to capture function_name
65
- # lambda will capture the function_name by reference,
66
- # and if the function_name is changed, the port_condition will also change.
67
- def create_port_condition(fn_name):
68
- return LazyReference(
69
- lambda: (
70
- node.Outputs.results[0]["type"].equals("FUNCTION_CALL")
71
- & node.Outputs.results[0]["value"]["name"].equals(fn_name)
60
+ if functions and len(functions) > 0:
61
+ # If we have functions, create dynamic ports for each function
62
+ Ports = type("Ports", (), {})
63
+ for function in functions:
64
+ function_name = function.__name__
65
+
66
+ # Avoid using lambda to capture function_name
67
+ # lambda will capture the function_name by reference,
68
+ # and if the function_name is changed, the port_condition will also change.
69
+ def create_port_condition(fn_name):
70
+ return LazyReference(
71
+ lambda: (
72
+ node.Outputs.results[0]["type"].equals("FUNCTION_CALL")
73
+ & node.Outputs.results[0]["value"]["name"].equals(fn_name)
74
+ )
72
75
  )
73
- )
74
76
 
75
- port_condition = create_port_condition(function_name)
76
- port = Port.on_if(port_condition)
77
- setattr(Ports, function_name, port)
77
+ port_condition = create_port_condition(function_name)
78
+ port = Port.on_if(port_condition)
79
+ setattr(Ports, function_name, port)
78
80
 
79
- setattr(Ports, "default", Port.on_else())
81
+ # Add the else port for when no function conditions match
82
+ setattr(Ports, "default", Port.on_else())
83
+ else:
84
+ # If no functions exist, create a simple Ports class with just a default port
85
+ Ports = type("Ports", (), {"default": Port(default=True)})
80
86
 
81
87
  # Add a chat history block to blocks
82
88
  blocks.append(
@@ -1,6 +1,7 @@
1
1
  from dataclasses import asdict, is_dataclass
2
2
  from datetime import datetime
3
3
  import enum
4
+ import inspect
4
5
  from json import JSONEncoder
5
6
  from queue import Queue
6
7
  from uuid import UUID
@@ -59,7 +60,13 @@ class DefaultStateEncoder(JSONEncoder):
59
60
  return str(obj)
60
61
 
61
62
  if callable(obj):
62
- return compile_function_definition(obj)
63
+ function_definition = compile_function_definition(obj)
64
+ try:
65
+ source_code = inspect.getsource(obj)
66
+ except Exception:
67
+ source_code = f"<source code not available for {obj.__name__}>"
68
+
69
+ return {"definition": function_definition, "src": source_code}
63
70
 
64
71
  if obj.__class__ in self.encoders:
65
72
  return self.encoders[obj.__class__](obj)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vellum-ai
3
- Version: 0.14.55
3
+ Version: 0.14.56
4
4
  Summary:
5
5
  License: MIT
6
6
  Requires-Python: >=3.9,<4.0
@@ -89,7 +89,7 @@ vellum_ee/workflows/display/tests/workflow_serialization/test_basic_search_node_
89
89
  vellum_ee/workflows/display/tests/workflow_serialization/test_basic_subworkflow_deployment_serialization.py,sha256=KkYZc_bZuq1lmDcvUz3QxIqJLpQPCZioD1FHUNsMJY8,11211
90
90
  vellum_ee/workflows/display/tests/workflow_serialization/test_basic_templating_node_serialization.py,sha256=aZaqRDrkO3ytcmdM2eKJqHSt60MF070NMj6M2vgzOKc,7711
91
91
  vellum_ee/workflows/display/tests/workflow_serialization/test_basic_terminal_node_serialization.py,sha256=r748dpS13HtwY7t_KQFExFssxRy0xI2d-wxmhiUHRe0,3850
92
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_tool_calling_node_serialization.py,sha256=Lws9-tWRsbtiS_WqRrO03BLMMRe5_6reXX_XfkkHkJs,7478
92
+ vellum_ee/workflows/display/tests/workflow_serialization/test_basic_tool_calling_node_serialization.py,sha256=kEhaRJmwg5rewuGYi4FjJB9D7xEiaO9gvQi5zQfuBic,7888
93
93
  vellum_ee/workflows/display/tests/workflow_serialization/test_basic_try_node_serialization.py,sha256=EL5kfakuoEcwD85dGjhMta-J-PpCHRSDoc80SdbBrQk,2769
94
94
  vellum_ee/workflows/display/tests/workflow_serialization/test_complex_terminal_node_serialization.py,sha256=RmFUDx8dYdfsOE2CGLvdXqNNRtLLpVzXDN8dqZyMcZ8,5822
95
95
  vellum_ee/workflows/display/types.py,sha256=i4T7ElU5b5h-nA1i3scmEhO1BqmNDc4eJDHavATD88w,2821
@@ -133,7 +133,7 @@ vellum/client/README.md,sha256=qmaVIP42MnxAu8jV7u-CsgVFfs3-pHQODrXdZdFxtaw,4749
133
133
  vellum/client/__init__.py,sha256=AYopGv2ZRVn3zsU8_km6KOvEHDbXiTPCVuYVI7bWvdA,120166
134
134
  vellum/client/core/__init__.py,sha256=SQ85PF84B9MuKnBwHNHWemSGuy-g_515gFYNFhvEE0I,1438
135
135
  vellum/client/core/api_error.py,sha256=RE8LELok2QCjABadECTvtDp7qejA1VmINCh6TbqPwSE,426
136
- vellum/client/core/client_wrapper.py,sha256=GMn5XtiuHqXf7vTEZMBtzd-oj9clWCurZASqSMpcAcI,1869
136
+ vellum/client/core/client_wrapper.py,sha256=M88FTiEEacH6N8wlBA4RkxOXM_ha2OYXYDPzIWnOOXk,1869
137
137
  vellum/client/core/datetime_utils.py,sha256=nBys2IsYrhPdszxGKCNRPSOCwa-5DWOHG95FB8G9PKo,1047
138
138
  vellum/client/core/file.py,sha256=d4NNbX8XvXP32z8KpK2Xovv33nFfruIrpz0QWxlgpZk,2663
139
139
  vellum/client/core/http_client.py,sha256=Z77OIxIbL4OAB2IDqjRq_sYa5yNYAWfmdhdCSSvh6Y4,19552
@@ -1645,7 +1645,7 @@ vellum/workflows/nodes/experimental/openai_chat_completion_node/node.py,sha256=c
1645
1645
  vellum/workflows/nodes/experimental/tool_calling_node/__init__.py,sha256=S7OzT3I4cyOU5Beoz87nPwCejCMP2FsHBFL8OcVmxJ4,118
1646
1646
  vellum/workflows/nodes/experimental/tool_calling_node/node.py,sha256=Vxa0hs_tK1zdU-ux5j1XtwQkTph8crdd56wrMfAqWUY,4849
1647
1647
  vellum/workflows/nodes/experimental/tool_calling_node/tests/test_tool_calling_node.py,sha256=sxG26mOwt4N36RLoPJ-ngginPqC5qFzD_kGj9izdCFI,1833
1648
- vellum/workflows/nodes/experimental/tool_calling_node/utils.py,sha256=mIQpAxLT2IF4SNQvUpRsX-t0jODxQ3Xvb_LEF7bRMF8,5214
1648
+ vellum/workflows/nodes/experimental/tool_calling_node/utils.py,sha256=JAxPP0DNNSxQlaC0pFHVs3B2WlY5Xf8MFzKLPmhlZYQ,5623
1649
1649
  vellum/workflows/nodes/mocks.py,sha256=a1FjWEIocseMfjzM-i8DNozpUsaW0IONRpZmXBoWlyc,10455
1650
1650
  vellum/workflows/nodes/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1651
1651
  vellum/workflows/nodes/tests/test_mocks.py,sha256=mfPvrs75PKcsNsbJLQAN6PDFoVqs9TmQxpdyFKDdO60,7837
@@ -1678,7 +1678,7 @@ vellum/workflows/sandbox.py,sha256=GVJzVjMuYzOBnSrboB0_6MMRZWBluAyQ2o7syeaeBd0,2
1678
1678
  vellum/workflows/state/__init__.py,sha256=yUUdR-_Vl7UiixNDYQZ-GEM_kJI9dnOia75TtuNEsnE,60
1679
1679
  vellum/workflows/state/base.py,sha256=-0b-nNBEXvGVau4c1BUwmCsXfo5wZD5VjLb8-eqi0Y8,21502
1680
1680
  vellum/workflows/state/context.py,sha256=KOAI1wEGn8dGmhmAemJaf4SZbitP3jpIBcwKfznQaRE,3076
1681
- vellum/workflows/state/encoder.py,sha256=z7Mk6jQC-92wCj6XTK7VEnJ8px_lU8qy0BINqwGDN4I,2063
1681
+ vellum/workflows/state/encoder.py,sha256=_z9V34I9-_ie5TSxJNjJYc_DMmE6f1Q4VtGE08Uo7Yo,2349
1682
1682
  vellum/workflows/state/store.py,sha256=uVe-oN73KwGV6M6YLhwZMMUQhzTQomsVfVnb8V91gVo,1147
1683
1683
  vellum/workflows/state/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1684
1684
  vellum/workflows/state/tests/test_state.py,sha256=YOiC9qZAzkdiqb7nRarNWeDwxo7xHv3y3czlHl81ezg,6741
@@ -1711,8 +1711,8 @@ vellum/workflows/workflows/event_filters.py,sha256=GSxIgwrX26a1Smfd-6yss2abGCnad
1711
1711
  vellum/workflows/workflows/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1712
1712
  vellum/workflows/workflows/tests/test_base_workflow.py,sha256=8P5YIsNMO78_CR1NNK6wkEdkMB4b3Q_Ni1qxh78OnHo,20481
1713
1713
  vellum/workflows/workflows/tests/test_context.py,sha256=VJBUcyWVtMa_lE5KxdhgMu0WYNYnUQUDvTF7qm89hJ0,2333
1714
- vellum_ai-0.14.55.dist-info/LICENSE,sha256=hOypcdt481qGNISA784bnAGWAE6tyIf9gc2E78mYC3E,1574
1715
- vellum_ai-0.14.55.dist-info/METADATA,sha256=ApsBqWl_U1jFrSqdnv2Rksz_onftgT0T2yu6KxfOpPc,5484
1716
- vellum_ai-0.14.55.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
1717
- vellum_ai-0.14.55.dist-info/entry_points.txt,sha256=HCH4yc_V3J_nDv3qJzZ_nYS8llCHZViCDP1ejgCc5Ak,42
1718
- vellum_ai-0.14.55.dist-info/RECORD,,
1714
+ vellum_ai-0.14.56.dist-info/LICENSE,sha256=hOypcdt481qGNISA784bnAGWAE6tyIf9gc2E78mYC3E,1574
1715
+ vellum_ai-0.14.56.dist-info/METADATA,sha256=NyxQYI0fSWAKolY31nX0fymQDu35425SCSXs1GJVZRI,5484
1716
+ vellum_ai-0.14.56.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
1717
+ vellum_ai-0.14.56.dist-info/entry_points.txt,sha256=HCH4yc_V3J_nDv3qJzZ_nYS8llCHZViCDP1ejgCc5Ak,42
1718
+ vellum_ai-0.14.56.dist-info/RECORD,,
@@ -130,17 +130,20 @@ def test_serialize_workflow():
130
130
  "type": "JSON",
131
131
  "value": [
132
132
  {
133
- "state": None,
134
- "cache_config": None,
135
- "name": "get_current_weather",
136
- "description": None,
137
- "parameters": {
138
- "type": "object",
139
- "properties": {"location": {"type": "string"}, "unit": {"type": "string"}},
140
- "required": ["location", "unit"],
133
+ "definition": {
134
+ "state": None,
135
+ "cache_config": None,
136
+ "name": "get_current_weather",
137
+ "description": None,
138
+ "parameters": {
139
+ "type": "object",
140
+ "properties": {"location": {"type": "string"}, "unit": {"type": "string"}},
141
+ "required": ["location", "unit"],
142
+ },
143
+ "forced": None,
144
+ "strict": None,
141
145
  },
142
- "forced": None,
143
- "strict": None,
146
+ "src": 'def get_current_weather(location: str, unit: str) -> str:\n """\n Get the current weather in a given location.\n """\n return f"The current weather in {location} is sunny with a temperature of 70 degrees {unit}."\n', # noqa: E501
144
147
  }
145
148
  ],
146
149
  },