lmnr 0.2.5__py3-none-any.whl → 0.2.6__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.
@@ -0,0 +1,26 @@
1
+ from dataclasses import dataclass
2
+ from typing import Optional
3
+ import uuid
4
+
5
+ from lmnr.cli.parser.nodes import Handle, HandleType, NodeFunctions
6
+ from lmnr.types import NodeInput
7
+
8
+
9
+ @dataclass
10
+ class InputNode(NodeFunctions):
11
+ id: uuid.UUID
12
+ name: str
13
+ outputs: list[Handle]
14
+ input: Optional[NodeInput]
15
+ input_type: HandleType
16
+
17
+ def handles_mapping(
18
+ self, output_handle_id_to_node_name: dict[str, str]
19
+ ) -> list[tuple[str, str]]:
20
+ return []
21
+
22
+ def node_type(self) -> str:
23
+ return "Input"
24
+
25
+ def config(self) -> dict:
26
+ return {}
@@ -0,0 +1,51 @@
1
+ from dataclasses import dataclass
2
+ from typing import Optional
3
+ import uuid
4
+
5
+ from lmnr.cli.parser.nodes import Handle, NodeFunctions
6
+ from lmnr.cli.parser.utils import map_handles
7
+
8
+
9
+ @dataclass
10
+ class LLMNode(NodeFunctions):
11
+ id: uuid.UUID
12
+ name: str
13
+ inputs: list[Handle]
14
+ dynamic_inputs: list[Handle]
15
+ outputs: list[Handle]
16
+ inputs_mappings: dict[uuid.UUID, uuid.UUID]
17
+ prompt: str
18
+ model: str
19
+ model_params: Optional[str]
20
+ stream: bool
21
+ structured_output_enabled: bool
22
+ structured_output_max_retries: int
23
+ structured_output_schema: Optional[str]
24
+ structured_output_schema_target: Optional[str]
25
+
26
+ def handles_mapping(
27
+ self, output_handle_id_to_node_name: dict[str, str]
28
+ ) -> list[tuple[str, str]]:
29
+ combined_inputs = self.inputs + self.dynamic_inputs
30
+ return map_handles(
31
+ combined_inputs, self.inputs_mappings, output_handle_id_to_node_name
32
+ )
33
+
34
+ def node_type(self) -> str:
35
+ return "LLM"
36
+
37
+ def config(self) -> dict:
38
+ # For easier access in the template separate the provider and model here
39
+ provider, model = self.model.split(":", maxsplit=1)
40
+
41
+ return {
42
+ "prompt": self.prompt,
43
+ "provider": provider,
44
+ "model": model,
45
+ "model_params": self.model_params,
46
+ "stream": self.stream,
47
+ "structured_output_enabled": self.structured_output_enabled,
48
+ "structured_output_max_retries": self.structured_output_max_retries,
49
+ "structured_output_schema": self.structured_output_schema,
50
+ "structured_output_schema_target": self.structured_output_schema_target,
51
+ }
@@ -0,0 +1,27 @@
1
+ from dataclasses import dataclass
2
+ import uuid
3
+
4
+ from lmnr.cli.parser.nodes import Handle, NodeFunctions
5
+ from lmnr.cli.parser.utils import map_handles
6
+
7
+
8
+ @dataclass
9
+ class OutputNode(NodeFunctions):
10
+ id: uuid.UUID
11
+ name: str
12
+ inputs: list[Handle]
13
+ outputs: list[Handle]
14
+ inputs_mappings: dict[uuid.UUID, uuid.UUID]
15
+
16
+ def handles_mapping(
17
+ self, output_handle_id_to_node_name: dict[str, str]
18
+ ) -> list[tuple[str, str]]:
19
+ return map_handles(
20
+ self.inputs, self.inputs_mappings, output_handle_id_to_node_name
21
+ )
22
+
23
+ def node_type(self) -> str:
24
+ return "Output"
25
+
26
+ def config(self) -> dict:
27
+ return {}
@@ -0,0 +1,81 @@
1
+ from dataclasses import dataclass
2
+ from datetime import datetime
3
+
4
+ import uuid
5
+
6
+ from lmnr.cli.parser.nodes import Handle, NodeFunctions
7
+ from lmnr.cli.parser.utils import map_handles
8
+
9
+
10
+ @dataclass
11
+ class FileMetadata:
12
+ id: uuid.UUID
13
+ created_at: datetime
14
+ project_id: uuid.UUID
15
+ filename: str
16
+
17
+
18
+ @dataclass
19
+ class Dataset:
20
+ id: uuid.UUID
21
+ created_at: datetime
22
+ project_id: uuid.UUID
23
+ name: str
24
+
25
+
26
+ @dataclass
27
+ class SemanticSearchDatasource:
28
+ type: str
29
+ id: uuid.UUID
30
+ # TODO: Paste other fields here, use Union[FileMetadata, Dataset]
31
+
32
+ @classmethod
33
+ def from_dict(cls, datasource_dict: dict) -> "SemanticSearchDatasource":
34
+ if datasource_dict["type"] == "File":
35
+ return cls(
36
+ type="File",
37
+ id=uuid.UUID(datasource_dict["id"]),
38
+ )
39
+ elif datasource_dict["type"] == "Dataset":
40
+ return cls(
41
+ type="Dataset",
42
+ id=uuid.UUID(datasource_dict["id"]),
43
+ )
44
+ else:
45
+ raise ValueError(
46
+ f"Invalid SemanticSearchDatasource type: {datasource_dict['type']}"
47
+ )
48
+
49
+
50
+ @dataclass
51
+ class SemanticSearchNode(NodeFunctions):
52
+ id: uuid.UUID
53
+ name: str
54
+ inputs: list[Handle]
55
+ outputs: list[Handle]
56
+ inputs_mappings: dict[uuid.UUID, uuid.UUID]
57
+ limit: int
58
+ threshold: float
59
+ template: str
60
+ datasources: list[SemanticSearchDatasource]
61
+
62
+ def handles_mapping(
63
+ self, output_handle_id_to_node_name: dict[str, str]
64
+ ) -> list[tuple[str, str]]:
65
+ return map_handles(
66
+ self.inputs, self.inputs_mappings, output_handle_id_to_node_name
67
+ )
68
+
69
+ def node_type(self) -> str:
70
+ return "SemanticSearch"
71
+
72
+ def config(self) -> dict:
73
+ return {
74
+ "limit": self.limit,
75
+ "threshold": self.threshold,
76
+ "template": self.template,
77
+ "datasource_ids": [str(datasource.id) for datasource in self.datasources],
78
+ "datasource_ids_list": str(
79
+ [str(datasource.id) for datasource in self.datasources]
80
+ ),
81
+ }
@@ -1,8 +1,14 @@
1
- from dataclasses import dataclass
2
- from typing import Any, Optional, Union
1
+ from typing import Any, Union
3
2
  import uuid
4
- from lmnr.cli.parser.nodes import Handle, HandleType, NodeFunctions
5
- from lmnr.cli.parser.utils import map_handles
3
+
4
+ from lmnr.cli.parser.nodes import Handle
5
+ from lmnr.cli.parser.nodes.input import InputNode
6
+ from lmnr.cli.parser.nodes.llm import LLMNode
7
+ from lmnr.cli.parser.nodes.output import OutputNode
8
+ from lmnr.cli.parser.nodes.semantic_search import (
9
+ SemanticSearchDatasource,
10
+ SemanticSearchNode,
11
+ )
6
12
  from lmnr.types import NodeInput, ChatMessage
7
13
 
8
14
 
@@ -15,97 +21,7 @@ def node_input_from_json(json_val: Any) -> NodeInput:
15
21
  raise ValueError(f"Invalid NodeInput value: {json_val}")
16
22
 
17
23
 
18
- # TODO: Convert to Pydantic
19
- @dataclass
20
- class InputNode(NodeFunctions):
21
- id: uuid.UUID
22
- name: str
23
- outputs: list[Handle]
24
- input: Optional[NodeInput]
25
- input_type: HandleType
26
-
27
- def handles_mapping(
28
- self, output_handle_id_to_node_name: dict[str, str]
29
- ) -> list[tuple[str, str]]:
30
- return []
31
-
32
- def node_type(self) -> str:
33
- return "Input"
34
-
35
- def config(self) -> dict:
36
- return {}
37
-
38
-
39
- # TODO: Convert to Pydantic
40
- @dataclass
41
- class LLMNode(NodeFunctions):
42
- id: uuid.UUID
43
- name: str
44
- inputs: list[Handle]
45
- dynamic_inputs: list[Handle]
46
- outputs: list[Handle]
47
- inputs_mappings: dict[uuid.UUID, uuid.UUID]
48
- prompt: str
49
- model: str
50
- model_params: Optional[str]
51
- stream: bool
52
- structured_output_enabled: bool
53
- structured_output_max_retries: int
54
- structured_output_schema: Optional[str]
55
- structured_output_schema_target: Optional[str]
56
-
57
- def handles_mapping(
58
- self, output_handle_id_to_node_name: dict[str, str]
59
- ) -> list[tuple[str, str]]:
60
- combined_inputs = self.inputs + self.dynamic_inputs
61
- return map_handles(
62
- combined_inputs, self.inputs_mappings, output_handle_id_to_node_name
63
- )
64
-
65
- def node_type(self) -> str:
66
- return "LLM"
67
-
68
- def config(self) -> dict:
69
- # For easier access in the template separate the provider and model here
70
- provider, model = self.model.split(":", maxsplit=1)
71
-
72
- return {
73
- "prompt": self.prompt,
74
- "provider": provider,
75
- "model": model,
76
- "model_params": self.model_params,
77
- "stream": self.stream,
78
- "structured_output_enabled": self.structured_output_enabled,
79
- "structured_output_max_retries": self.structured_output_max_retries,
80
- "structured_output_schema": self.structured_output_schema,
81
- "structured_output_schema_target": self.structured_output_schema_target,
82
- }
83
-
84
-
85
- # TODO: Convert to Pydantic
86
- @dataclass
87
- class OutputNode(NodeFunctions):
88
- id: uuid.UUID
89
- name: str
90
- inputs: list[Handle]
91
- outputs: list[Handle]
92
- inputs_mappings: dict[uuid.UUID, uuid.UUID]
93
-
94
- def handles_mapping(
95
- self, output_handle_id_to_node_name: dict[str, str]
96
- ) -> list[tuple[str, str]]:
97
- return map_handles(
98
- self.inputs, self.inputs_mappings, output_handle_id_to_node_name
99
- )
100
-
101
- def node_type(self) -> str:
102
- return "Output"
103
-
104
- def config(self) -> dict:
105
- return {}
106
-
107
-
108
- Node = Union[InputNode, OutputNode, LLMNode]
24
+ Node = Union[InputNode, OutputNode, LLMNode, SemanticSearchNode]
109
25
 
110
26
 
111
27
  def node_from_dict(node_dict: dict) -> Node:
@@ -153,5 +69,23 @@ def node_from_dict(node_dict: dict) -> Node:
153
69
  structured_output_schema=None,
154
70
  structured_output_schema_target=None,
155
71
  )
72
+ elif node_dict["type"] == "SemanticSearch":
73
+ return SemanticSearchNode(
74
+ id=uuid.UUID(node_dict["id"]),
75
+ name=node_dict["name"],
76
+ inputs=[Handle.from_dict(handle) for handle in node_dict["inputs"]],
77
+ outputs=[Handle.from_dict(handle) for handle in node_dict["outputs"]],
78
+ inputs_mappings={
79
+ uuid.UUID(k): uuid.UUID(v)
80
+ for k, v in node_dict["inputsMappings"].items()
81
+ },
82
+ limit=node_dict["limit"],
83
+ threshold=node_dict["threshold"],
84
+ template=node_dict["template"],
85
+ datasources=[
86
+ SemanticSearchDatasource.from_dict(ds)
87
+ for ds in node_dict["datasources"]
88
+ ],
89
+ )
156
90
  else:
157
91
  raise ValueError(f"Node type {node_dict['type']} not supported")
@@ -9,7 +9,8 @@ import queue
9
9
  from .task import Task
10
10
  from .action import NodeRunError, RunOutput
11
11
  from .state import State
12
- from lmnr_engine.types import Message, NodeInput
12
+ from lmnr.types import NodeInput
13
+ from lmnr_engine.types import Message
13
14
 
14
15
 
15
16
  logger = logging.getLogger(__name__)
@@ -132,6 +132,42 @@ def {{task.function_name}}({{ task.handle_args }}, _env: dict[str, str]) -> RunO
132
132
  return RunOutput(status="Success", output=completion_message)
133
133
 
134
134
 
135
+ {% elif task.node_type == "SemanticSearch" %}
136
+ def {{task.function_name}}(query: NodeInput, _env: dict[str, str]) -> RunOutput:
137
+ {% set datasources_length=task.config.datasource_ids|length %}
138
+ {% if datasources_length == 0 %}
139
+ raise NodeRunError("No datasources provided")
140
+ {% endif %}
141
+
142
+ headers = {
143
+ "Authorization": f"Bearer {_env['LMNR_PROJECT_API_KEY']}",
144
+ }
145
+ data = {
146
+ "query": query,
147
+ "limit": {{ task.config.limit }},
148
+ "threshold": {{ task.config.threshold }},
149
+ "datasourceIds": {{ task.config.datasource_ids_list }},
150
+ }
151
+ query_res = requests.post("https://api.lmnr.ai/v2/semantic-search", headers=headers, json=data)
152
+ if query_res.status_code != 200:
153
+ raise NodeRunError(f"Vector search request failed: {query_res.text}")
154
+
155
+ results = query_res.json()
156
+
157
+ def render_query_res_point(template: str, point: dict, relevance_index: int) -> str:
158
+ data = point["data"]
159
+ data["relevance_index"] = relevance_index
160
+ res = template
161
+ for key, value in data.items():
162
+ res = res.replace("{{'{{'}}" + key + "{{'}}'}}", str(value))
163
+ return res
164
+
165
+ rendered_res_points = [render_query_res_point("""{{task.config.template}}""", res_point, index + 1) for (index, res_point) in enumerate(results)]
166
+ output = "\n".join(rendered_res_points)
167
+
168
+ return RunOutput(status="Success", output=output)
169
+
170
+
135
171
  {% elif task.node_type == "Output" %}
136
172
  def {{task.function_name}}(output: NodeInput, _env: dict[str, str]) -> RunOutput:
137
173
  return RunOutput(status="Success", output=output)
lmnr/sdk/endpoint.py CHANGED
@@ -4,7 +4,7 @@ import pydantic
4
4
  import requests
5
5
  from lmnr.types import (
6
6
  EndpointRunError, EndpointRunResponse, NodeInput, EndpointRunRequest,
7
- ToolCall, SDKError
7
+ ToolCallError, ToolCallRequest, ToolCallResponse, SDKError
8
8
  )
9
9
  from typing import Callable, Optional
10
10
  from websockets.sync.client import connect
@@ -126,31 +126,52 @@ class Laminar:
126
126
  }
127
127
  ) as websocket:
128
128
  websocket.send(request.model_dump_json())
129
+ req_id = None
129
130
 
130
131
  while True:
131
132
  message = websocket.recv()
132
133
  try:
133
- tool_call = ToolCall.model_validate_json(message)
134
+ tool_call = ToolCallRequest.model_validate_json(message)
135
+ req_id = tool_call.req_id
134
136
  matching_tools = [
135
137
  tool for tool in tools
136
- if tool.__name__ == tool_call.function.name
138
+ if tool.__name__ == tool_call.toolCall.function.name
137
139
  ]
138
140
  if not matching_tools:
139
141
  raise SDKError(
140
- f'Tool {tool_call.function.name} not found.'
142
+ f'Tool {tool_call.toolCall.function.name} not found.'
141
143
  ' Registered tools: '
142
144
  f'{", ".join([tool.__name__ for tool in tools])}'
143
145
  )
144
146
  tool = matching_tools[0]
145
- if tool.__name__ == tool_call.function.name:
146
147
  # default the arguments to an empty dictionary
148
+ if tool.__name__ == tool_call.toolCall.function.name:
147
149
  arguments = {}
148
150
  try:
149
- arguments = json.loads(tool_call.function.arguments)
151
+ arguments = json.loads(tool_call.toolCall.function.arguments)
150
152
  except:
151
153
  pass
152
- response = tool(**arguments)
153
- websocket.send(json.dumps(response))
154
+ try:
155
+ response = tool(**arguments)
156
+ except Exception as e:
157
+ error_message = 'Error occurred while running tool' +\
158
+ f'{tool.__name__}: {e}'
159
+ e = ToolCallError(error=error_message, reqId=req_id)
160
+ websocket.send(e.model_dump_json())
161
+ formatted_response = None
162
+ try:
163
+ formatted_response = ToolCallResponse(
164
+ reqId=tool_call.reqId,
165
+ response=response
166
+ )
167
+ except pydantic.ValidationError as e:
168
+ formatted_response = ToolCallResponse(
169
+ reqId=tool_call.reqId,
170
+ response=str(response)
171
+ )
172
+ websocket.send(
173
+ formatted_response.model_dump_json()
174
+ )
154
175
  except pydantic.ValidationError as e:
155
176
  message_json = json.loads(message)
156
177
  keys = list(message_json.keys())
@@ -161,6 +182,5 @@ class Laminar:
161
182
  result = EndpointRunResponse.model_validate(message_json)
162
183
  websocket.close()
163
184
  return result
164
- except Exception:
165
- websocket.close()
166
- raise SDKError('Error communicating to backend through websocket')
185
+ except Exception as e:
186
+ raise SDKError(f'Error communicating to backend through websocket {e}')
@@ -1,13 +1,21 @@
1
1
  from typing import Callable, Optional
2
2
  from websockets.sync.client import connect
3
+ import pydantic
3
4
  import websockets
4
- from lmnr.types import DeregisterDebuggerRequest, NodeInput, RegisterDebuggerRequest, SDKError, ToolCall, ToolCallError
5
+ from lmnr.types import (
6
+ DeregisterDebuggerRequest, NodeInput, RegisterDebuggerRequest,
7
+ SDKError, ToolCallError, ToolCallRequest, ToolCallResponse
8
+ )
5
9
  import uuid
6
10
  import json
7
11
  from threading import Thread
8
12
 
9
13
  class RemoteDebugger:
10
- def __init__(self, project_api_key: str, tools: list[Callable[..., NodeInput]] = []):
14
+ def __init__(
15
+ self,
16
+ project_api_key: str,
17
+ tools: list[Callable[..., NodeInput]] = []
18
+ ):
11
19
  self.project_api_key = project_api_key
12
20
  self.url = 'wss://api.lmnr.ai/v2/endpoint/ws'
13
21
  self.tools = tools
@@ -25,7 +33,8 @@ class RemoteDebugger:
25
33
  self.stop_flag = True
26
34
  self.thread.join()
27
35
  self.session = None
28
- # python allows running threads only once, so we need to create a new thread
36
+ # python allows running threads only once, so we need to create
37
+ # a new thread
29
38
  # in case the user wants to start the debugger again
30
39
  self.thread = Thread(target=self._run)
31
40
 
@@ -41,10 +50,13 @@ class RemoteDebugger:
41
50
  }
42
51
  ) as websocket:
43
52
  websocket.send(request.model_dump_json())
44
- print(self._format_session_id())
53
+ print(self._format_session_id_and_registerd_functions())
54
+ req_id = None
55
+
45
56
  while not self.stop_flag:
46
57
  try:
47
- # blocks the thread until a message is received or a timeout (3 seconds) occurs
58
+ # blocks the thread until a message
59
+ # is received or a timeout (3 seconds) occurs
48
60
  message = websocket.recv(3)
49
61
  except TimeoutError:
50
62
  continue
@@ -52,45 +64,76 @@ class RemoteDebugger:
52
64
  print("Connection closed. Please restart the debugger.")
53
65
  return
54
66
  try:
55
- tool_call = ToolCall.model_validate_json(message)
67
+ tool_call = ToolCallRequest.model_validate_json(message)
68
+ req_id = tool_call.reqId
56
69
  except:
57
70
  raise SDKError(f'Invalid message received:\n{message}')
58
71
  matching_tools = [
59
72
  tool for tool in self.tools
60
- if tool.__name__ == tool_call.function.name
73
+ if tool.__name__ == tool_call.toolCall.function.name
61
74
  ]
62
75
  if not matching_tools:
63
- error_message = f'Tool {tool_call.function.name} not found.' +\
64
- f' Registered tools: {", ".join([tool.__name__ for tool in self.tools])}'
65
- e = ToolCallError(error=error_message)
76
+ error_message = \
77
+ f'Tool {tool_call.toolCall.function.name} not found' +\
78
+ '. Registered tools: ' +\
79
+ {", ".join([tool.__name__ for tool in self.tools])}
80
+ e = ToolCallError(error=error_message, reqId=req_id)
66
81
  websocket.send(e.model_dump_json())
67
82
  continue
68
83
  tool = matching_tools[0]
69
- if tool.__name__ == tool_call.function.name:
84
+ if tool.__name__ == tool_call.toolCall.function.name:
70
85
  # default the arguments to an empty dictionary
71
86
  arguments = {}
72
87
  try:
73
- arguments = json.loads(tool_call.function.arguments)
88
+ arguments = json.loads(
89
+ tool_call.toolCall.function.arguments)
74
90
  except:
75
91
  pass
76
92
  try:
77
- response = tool(**arguments) # of type NodeInput
78
- websocket.send(json.dumps(response))
93
+ response = tool(**arguments)
79
94
  except Exception as e:
80
- error_message = f'Error occurred while running tool {tool.__name__}: {e}'
81
- e = ToolCallError(error=error_message)
95
+ error_message = 'Error occurred while running tool' +\
96
+ f'{tool.__name__}: {e}'
97
+ e = ToolCallError(error=error_message, reqId=req_id)
82
98
  websocket.send(e.model_dump_json())
83
- websocket.send(DeregisterDebuggerRequest(debuggerSessionId=self.session, deregister=True).model_dump_json())
99
+ formatted_response = None
100
+ try:
101
+ formatted_response = ToolCallResponse(
102
+ reqId=tool_call.reqId,
103
+ response=response
104
+ )
105
+ except pydantic.ValidationError as e:
106
+ formatted_response = ToolCallResponse(
107
+ reqId=tool_call.reqId,
108
+ response=str(response)
109
+ )
110
+ websocket.send(
111
+ formatted_response.model_dump_json()
112
+ )
113
+ websocket.send(
114
+ DeregisterDebuggerRequest(
115
+ debuggerSessionId=self.session,
116
+ deregister=True
117
+ ).model_dump_json()
118
+ )
84
119
 
85
120
  def _generate_session_id(self) -> str:
86
121
  return uuid.uuid4().urn[9:]
87
122
 
88
- def _format_session_id(self) -> str:
123
+ def _format_session_id_and_registerd_functions(self) -> str:
124
+ registered_functions = \
125
+ ',\n'.join(['- ' + tool.__name__ for tool in self.tools])
89
126
  return \
90
127
  f"""
91
128
  ========================================
92
129
  Debugger Session ID:
93
130
  {self.session}
131
+ ========================================
132
+
133
+ Registered functions:
134
+ {registered_functions}
135
+
94
136
  ========================================
95
137
  """
138
+
96
139
 
lmnr/types.py CHANGED
@@ -1,13 +1,16 @@
1
-
2
1
  import requests
3
2
  import pydantic
3
+ import uuid
4
4
  from typing import Union, Optional
5
5
 
6
+
6
7
  class ChatMessage(pydantic.BaseModel):
7
8
  role: str
8
9
  content: str
9
10
 
10
- NodeInput = Union[str, list[ChatMessage]] # TypeAlias
11
+
12
+ NodeInput = Union[str, list[ChatMessage]] # TypeAlias
13
+
11
14
 
12
15
  class EndpointRunRequest(pydantic.BaseModel):
13
16
  inputs: dict[str, NodeInput]
@@ -15,10 +18,12 @@ class EndpointRunRequest(pydantic.BaseModel):
15
18
  env: dict[str, str] = pydantic.Field(default_factory=dict)
16
19
  metadata: dict[str, str] = pydantic.Field(default_factory=dict)
17
20
 
21
+
18
22
  class EndpointRunResponse(pydantic.BaseModel):
19
23
  outputs: dict[str, dict[str, NodeInput]]
20
24
  run_id: str
21
25
 
26
+
22
27
  class EndpointRunError(Exception):
23
28
  error_code: str
24
29
  error_message: str
@@ -26,39 +31,57 @@ class EndpointRunError(Exception):
26
31
  def __init__(self, response: requests.Response):
27
32
  try:
28
33
  resp_json = response.json()
29
- self.error_code = resp_json['error_code']
30
- self.error_message = resp_json['error_message']
34
+ self.error_code = resp_json["error_code"]
35
+ self.error_message = resp_json["error_message"]
31
36
  super().__init__(self.error_message)
32
- except:
37
+ except Exception:
33
38
  super().__init__(response.text)
34
-
39
+
35
40
  def __str__(self) -> str:
36
41
  try:
37
- return str({'error_code': self.error_code, 'error_message': self.error_message})
38
- except:
42
+ return str(
43
+ {"error_code": self.error_code, "error_message": self.error_message}
44
+ )
45
+ except Exception:
39
46
  return super().__str__()
40
-
47
+
48
+
41
49
  class SDKError(Exception):
42
50
  def __init__(self, error_message: str):
43
51
  super().__init__(error_message)
44
52
 
53
+
45
54
  class ToolCallRequest(pydantic.BaseModel):
46
55
  name: str
47
56
  arguments: str
48
57
 
58
+
49
59
  class ToolCall(pydantic.BaseModel):
50
60
  id: Optional[str]
51
61
  type: Optional[str]
52
62
  function: ToolCallRequest
53
63
 
54
- ToolCallResponse = NodeInput
64
+
65
+ # TODO: allow snake_case and manually convert to camelCase
66
+ class ToolCallRequest(pydantic.BaseModel):
67
+ reqId: uuid.UUID
68
+ toolCall: ToolCall
69
+
70
+
71
+ class ToolCallResponse(pydantic.BaseModel):
72
+ reqId: uuid.UUID
73
+ response: NodeInput
74
+
75
+
55
76
  class ToolCallError(pydantic.BaseModel):
77
+ reqId: uuid.UUID
56
78
  error: str
57
79
 
58
- # TODO: allow snake_case and manually convert to camelCase
80
+
59
81
  class RegisterDebuggerRequest(pydantic.BaseModel):
60
82
  debuggerSessionId: str
61
83
 
84
+
62
85
  class DeregisterDebuggerRequest(pydantic.BaseModel):
63
86
  debuggerSessionId: str
64
87
  deregister: bool
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lmnr
3
- Version: 0.2.5
3
+ Version: 0.2.6
4
4
  Summary: Python SDK for Laminar AI
5
5
  License: Apache-2.0
6
6
  Author: lmnr.ai
@@ -17,11 +17,12 @@ Requires-Dist: cookiecutter (>=2.6.0,<3.0.0)
17
17
  Requires-Dist: pydantic (>=2.7.4,<3.0.0)
18
18
  Requires-Dist: python-dotenv (>=1.0.1,<2.0.0)
19
19
  Requires-Dist: requests (>=2.32.3,<3.0.0)
20
- Requires-Dist: urllib3 (==1.26.6)
21
20
  Requires-Dist: websockets (>=12.0,<13.0)
22
21
  Description-Content-Type: text/markdown
23
22
 
24
- # Python SDK for Laminar AI
23
+ # Laminar AI
24
+
25
+ This reipo provides core for code generation, Laminar CLI, and Laminar SDK.
25
26
 
26
27
  ## Quickstart
27
28
  ```sh
@@ -139,14 +140,6 @@ Set up `DEBUGGER_SESSION_ID` environment variable in your pipeline.
139
140
 
140
141
  You can run as many sessions as you need, experimenting with your flows.
141
142
 
142
- #### 5. Stop the debugger
143
-
144
- In order to stop the session, do
145
-
146
- ```python
147
- debugger.stop()
148
- ```
149
-
150
143
  ## CLI for code generation
151
144
 
152
145
  ### Basic usage
@@ -5,24 +5,28 @@ lmnr/cli/cli.py,sha256=pzr5LUILi7TcaJIkC-CzmT7RG7-HWApQmUpgK9bc7mI,2847
5
5
  lmnr/cli/cookiecutter.json,sha256=PeiMMzCPzDhsapqYoAceYGPI5lOUNimvFzh5KeQv5QE,359
6
6
  lmnr/cli/parser/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
7
  lmnr/cli/parser/nodes/__init__.py,sha256=BNbbfn0WwbFDA6TNhLOaT_Ji69rCL5voUibqMD7Knng,1163
8
- lmnr/cli/parser/nodes/types.py,sha256=fqw_0-szpcZ8G3bADjgG97gCng2DRIkL72nLV11gTP4,5081
8
+ lmnr/cli/parser/nodes/input.py,sha256=Xwktcih7Mezqv4cEejfPkpG8uJxDsbqRytBvKmlJDYE,578
9
+ lmnr/cli/parser/nodes/llm.py,sha256=iQWYFnQi5PcQD9WJpTSHbSzClM6s0wBOoEqyN5c4yQo,1674
10
+ lmnr/cli/parser/nodes/output.py,sha256=1XBppSscxM01kfZhE9oOh2GgdCVzyPVe2RAxLI5HmUc,665
11
+ lmnr/cli/parser/nodes/semantic_search.py,sha256=o_XCR7BShAq8VGeKjPTwL6MxLdB07XHSd5CE71sFFiY,2105
12
+ lmnr/cli/parser/nodes/types.py,sha256=c7jNaR7YlZUkxB9OosAkFH4o6ZPga0Bec1WtOxq9fGs,3505
9
13
  lmnr/cli/parser/parser.py,sha256=UtuupKj2Dh-47HVcYU4PI2s4Erh1gTjKiuGCcc-nkbM,2163
10
14
  lmnr/cli/parser/utils.py,sha256=wVaqHVOR9VXl8Og9nkVyCVgHIcgbtYGkDOEGPtmjZ8g,715
11
15
  lmnr/cli/{{cookiecutter.lmnr_pipelines_dir_name}}/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
16
  lmnr/cli/{{cookiecutter.lmnr_pipelines_dir_name}}/engine/__init__.py,sha256=pLVZqvDnNf9foGR-HXnX2F7WC2TWmyCTNcUctG8SXAI,27
13
17
  lmnr/cli/{{cookiecutter.lmnr_pipelines_dir_name}}/engine/action.py,sha256=mZMQwwPV5LtSfwdwQ7HefI3ttvwuokp4mhVI_Xn1Zck,274
14
- lmnr/cli/{{cookiecutter.lmnr_pipelines_dir_name}}/engine/engine.py,sha256=8DPh3zLhs4oDepuT5g6Z8mxuy2561v8P7Dhd4hUOn6g,8375
18
+ lmnr/cli/{{cookiecutter.lmnr_pipelines_dir_name}}/engine/engine.py,sha256=TKmgfXbs_BiuMpzHuPuSfq1mX3UEnQFnpKgU2NsYkB4,8397
15
19
  lmnr/cli/{{cookiecutter.lmnr_pipelines_dir_name}}/engine/state.py,sha256=wTx7jAv7b63-8k34cYfQp_DJxhCCOYT_qRHkmnZfnc0,1686
16
20
  lmnr/cli/{{cookiecutter.lmnr_pipelines_dir_name}}/engine/task.py,sha256=ware5VIrZvluHH3mpH6h7G0YDk5L0buSQ7s09za4Fro,1200
17
21
  lmnr/cli/{{cookiecutter.lmnr_pipelines_dir_name}}/pipelines/{{cookiecutter.pipeline_dir_name}}/__init__.py,sha256=bsfbNUBYtKv37qzc_GLhSAzBam2lnowP_dlr8pubhcg,80
18
- lmnr/cli/{{cookiecutter.lmnr_pipelines_dir_name}}/pipelines/{{cookiecutter.pipeline_dir_name}}/nodes/functions.py,sha256=2fLTN6PbhlSPEcrHBSSJESmg__UNMk4Ivs5mz0LqnG8,5169
22
+ lmnr/cli/{{cookiecutter.lmnr_pipelines_dir_name}}/pipelines/{{cookiecutter.pipeline_dir_name}}/nodes/functions.py,sha256=HwK6gKngZi1AhEyu9BVtE5IfD4NScRCdFLXV8uiBD34,6578
19
23
  lmnr/cli/{{cookiecutter.lmnr_pipelines_dir_name}}/pipelines/{{cookiecutter.pipeline_dir_name}}/{{cookiecutter.pipeline_dir_name}}.py,sha256=WG-ZMofPpGXCx5jdWVry3_XBzcKjqn8ZycFSiWEOBPg,2858
20
24
  lmnr/cli/{{cookiecutter.lmnr_pipelines_dir_name}}/types.py,sha256=iWuflMV7TiaBPs6-B-BlrovvWpZgHGGHK0v8rSqER7A,997
21
- lmnr/sdk/endpoint.py,sha256=tT6-w-mwbh4BAwnj5G0pCVE_Sz8EUzZmpBtacm_T2pE,6359
22
- lmnr/sdk/remote_debugger.py,sha256=pNSmmk-KAAOUygKQAeTB1DbB3vvlpHL8JLwPBpBhBwA,3892
23
- lmnr/types.py,sha256=Y41GGiCVemBUCTKedCwDhxjdsoO8uENr3LRwfdp9MI0,1771
24
- lmnr-0.2.5.dist-info/LICENSE,sha256=67b_wJHVV1CBaWkrKFWU1wyqTPSdzH77Ls-59631COg,10411
25
- lmnr-0.2.5.dist-info/METADATA,sha256=BgYsaYsxprvRZ5-RxZk8DQdSTKmF51hOvU27hg_0wn4,5492
26
- lmnr-0.2.5.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
27
- lmnr-0.2.5.dist-info/entry_points.txt,sha256=Qg7ZRax4k-rcQsZ26XRYQ8YFSBiyY2PNxYfq4a6PYXI,41
28
- lmnr-0.2.5.dist-info/RECORD,,
25
+ lmnr/sdk/endpoint.py,sha256=0HjcxMUcJz-klFZO2f5xtTaoLjcaEb8vrJ_YldTWUc8,7467
26
+ lmnr/sdk/remote_debugger.py,sha256=vCpMz7y3uboOi81qEwr8z3fhQ2H1y2YtJAxXVtb6uCA,5141
27
+ lmnr/types.py,sha256=IcoKNL1KJ-GIeunrt5fYuB_XhsBrtYZ9d1ShFJqrsUc,2004
28
+ lmnr-0.2.6.dist-info/LICENSE,sha256=67b_wJHVV1CBaWkrKFWU1wyqTPSdzH77Ls-59631COg,10411
29
+ lmnr-0.2.6.dist-info/METADATA,sha256=wipVETWwLYjuhdrOpkgUA7iE-kpj5lGph4X7zE0tLvQ,5428
30
+ lmnr-0.2.6.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
31
+ lmnr-0.2.6.dist-info/entry_points.txt,sha256=Qg7ZRax4k-rcQsZ26XRYQ8YFSBiyY2PNxYfq4a6PYXI,41
32
+ lmnr-0.2.6.dist-info/RECORD,,
File without changes
File without changes