lmnr 0.5.2__py3-none-any.whl → 0.5.3__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.
Files changed (41) hide show
  1. lmnr/__init__.py +2 -2
  2. lmnr/cli.py +10 -8
  3. lmnr/{openllmetry_sdk → opentelemetry_lib}/__init__.py +3 -3
  4. lmnr/{openllmetry_sdk → opentelemetry_lib}/decorators/base.py +5 -5
  5. lmnr/{openllmetry_sdk → opentelemetry_lib}/instruments.py +1 -0
  6. lmnr/{openllmetry_sdk → opentelemetry_lib}/opentelemetry/instrumentation/google_genai/utils.py +1 -1
  7. lmnr/opentelemetry_lib/tracing/__init__.py +1 -0
  8. lmnr/{openllmetry_sdk → opentelemetry_lib}/tracing/context_manager.py +1 -1
  9. lmnr/{openllmetry_sdk → opentelemetry_lib}/tracing/tracing.py +23 -5
  10. lmnr/sdk/browser/browser_use_otel.py +20 -3
  11. lmnr/sdk/browser/patchright_otel.py +177 -0
  12. lmnr/sdk/browser/playwright_otel.py +16 -7
  13. lmnr/sdk/browser/pw_utils.py +118 -80
  14. lmnr/sdk/browser/rrweb/rrweb.umd.min.cjs +98 -0
  15. lmnr/sdk/client/asynchronous/resources/agent.py +19 -0
  16. lmnr/sdk/client/synchronous/resources/agent.py +20 -0
  17. lmnr/sdk/decorators.py +3 -3
  18. lmnr/sdk/eval_control.py +3 -2
  19. lmnr/sdk/evaluations.py +8 -14
  20. lmnr/sdk/laminar.py +8 -8
  21. lmnr/sdk/types.py +2 -0
  22. lmnr/version.py +1 -1
  23. {lmnr-0.5.2.dist-info → lmnr-0.5.3.dist-info}/METADATA +2 -2
  24. lmnr-0.5.3.dist-info/RECORD +55 -0
  25. {lmnr-0.5.2.dist-info → lmnr-0.5.3.dist-info}/WHEEL +1 -1
  26. lmnr/openllmetry_sdk/tracing/__init__.py +0 -1
  27. lmnr/sdk/browser/rrweb/rrweb.min.js +0 -18
  28. lmnr-0.5.2.dist-info/RECORD +0 -54
  29. /lmnr/{openllmetry_sdk → opentelemetry_lib}/.flake8 +0 -0
  30. /lmnr/{openllmetry_sdk → opentelemetry_lib}/config/__init__.py +0 -0
  31. /lmnr/{openllmetry_sdk → opentelemetry_lib}/decorators/__init__.py +0 -0
  32. /lmnr/{openllmetry_sdk → opentelemetry_lib}/opentelemetry/instrumentation/google_genai/__init__.py +0 -0
  33. /lmnr/{openllmetry_sdk → opentelemetry_lib}/opentelemetry/instrumentation/google_genai/config.py +0 -0
  34. /lmnr/{openllmetry_sdk → opentelemetry_lib}/tracing/attributes.py +0 -0
  35. /lmnr/{openllmetry_sdk → opentelemetry_lib}/tracing/content_allow_list.py +0 -0
  36. /lmnr/{openllmetry_sdk → opentelemetry_lib}/utils/__init__.py +0 -0
  37. /lmnr/{openllmetry_sdk → opentelemetry_lib}/utils/in_memory_span_exporter.py +0 -0
  38. /lmnr/{openllmetry_sdk → opentelemetry_lib}/utils/json_encoder.py +0 -0
  39. /lmnr/{openllmetry_sdk → opentelemetry_lib}/utils/package_check.py +0 -0
  40. {lmnr-0.5.2.dist-info → lmnr-0.5.3.dist-info}/LICENSE +0 -0
  41. {lmnr-0.5.2.dist-info → lmnr-0.5.3.dist-info}/entry_points.txt +0 -0
@@ -40,11 +40,13 @@ class AsyncAgent(BaseAsyncResource):
40
40
  return_screenshots: bool = False,
41
41
  return_agent_state: bool = False,
42
42
  return_storage_state: bool = False,
43
+ disable_give_control: bool = False,
43
44
  timeout: Optional[int] = None,
44
45
  cdp_url: Optional[str] = None,
45
46
  max_steps: Optional[int] = None,
46
47
  thinking_token_budget: Optional[int] = None,
47
48
  start_url: Optional[str] = None,
49
+ user_agent: Optional[str] = None,
48
50
  ) -> AsyncIterator[RunAgentResponseChunk]:
49
51
  """Run Laminar index agent in streaming mode.
50
52
 
@@ -60,11 +62,13 @@ class AsyncAgent(BaseAsyncResource):
60
62
  return_screenshots (bool, optional): whether to return screenshots of the agent's states at every step. Default to False.
61
63
  return_agent_state (bool, optional): whether to return the agent's state in the final chunk. Default to False.
62
64
  return_storage_state (bool, optional): whether to return the storage state in the final chunk. Default to False.
65
+ disable_give_control (bool, optional): whether to NOT give the agent additional direction to give control to the user for tasks such as login. Default to False.
63
66
  timeout (Optional[int], optional): timeout seconds for the agent's response. Default to None.
64
67
  cdp_url (Optional[str], optional): Chrome DevTools Protocol URL of an existing browser session. Default to None.
65
68
  max_steps (Optional[int], optional): maximum number of steps the agent can take. If not set, the backend will use a default value (currently 100). Default to None.
66
69
  thinking_token_budget (Optional[int], optional): maximum number of tokens the underlying LLM can spend on thinking in each step, if supported by the model. Default to None.
67
70
  start_url (Optional[str], optional): the URL to start the agent on. Must be a valid URL - refer to https://playwright.dev/docs/api/class-page#page-goto. If not specified, the agent infers this from the prompt. Default to None.
71
+ user_agent (Optional[str], optional): the user to be sent to the browser. If not specified, Laminar uses the default user agent. Default to None.
68
72
 
69
73
  Returns:
70
74
  AsyncIterator[RunAgentResponseChunk]: a generator of response chunks
@@ -84,11 +88,13 @@ class AsyncAgent(BaseAsyncResource):
84
88
  return_screenshots: bool = False,
85
89
  return_agent_state: bool = False,
86
90
  return_storage_state: bool = False,
91
+ disable_give_control: bool = False,
87
92
  timeout: Optional[int] = None,
88
93
  cdp_url: Optional[str] = None,
89
94
  max_steps: Optional[int] = None,
90
95
  thinking_token_budget: Optional[int] = None,
91
96
  start_url: Optional[str] = None,
97
+ user_agent: Optional[str] = None,
92
98
  ) -> AgentOutput:
93
99
  """Run Laminar index agent.
94
100
 
@@ -103,11 +109,13 @@ class AsyncAgent(BaseAsyncResource):
103
109
  return_screenshots (bool, optional): whether to return screenshots of the agent's states at every step. Default to False.
104
110
  return_agent_state (bool, optional): whether to return the agent's state. Default to False.
105
111
  return_storage_state (bool, optional): whether to return the storage state. Default to False.
112
+ disable_give_control (bool, optional): whether to NOT give the agent additional direction to give control to the user for tasks such as login. Default to False.
106
113
  timeout (Optional[int], optional): timeout seconds for the agent's response. Default to None.
107
114
  cdp_url (Optional[str], optional): Chrome DevTools Protocol URL of an existing browser session. Default to None.
108
115
  max_steps (Optional[int], optional): maximum number of steps the agent can take. If not set, the backend will use a default value (currently 100). Default to None.
109
116
  thinking_token_budget (Optional[int], optional): maximum number of tokens the underlying LLM can spend on thinking in each step, if supported by the model. Default to None.
110
117
  start_url (Optional[str], optional): the URL to start the agent on. Must be a valid URL - refer to https://playwright.dev/docs/api/class-page#page-goto. If not specified, the agent infers this from the prompt. Default to None.
118
+ user_agent (Optional[str], optional): the user to be sent to the browser. If not specified, Laminar uses the default user agent. Default to None.
111
119
 
112
120
  Returns:
113
121
  AgentOutput: agent output
@@ -128,10 +136,12 @@ class AsyncAgent(BaseAsyncResource):
128
136
  return_screenshots: bool = False,
129
137
  return_agent_state: bool = False,
130
138
  return_storage_state: bool = False,
139
+ disable_give_control: bool = False,
131
140
  timeout: Optional[int] = None,
132
141
  max_steps: Optional[int] = None,
133
142
  thinking_token_budget: Optional[int] = None,
134
143
  start_url: Optional[str] = None,
144
+ user_agent: Optional[str] = None,
135
145
  ) -> AgentOutput:
136
146
  """Run Laminar index agent.
137
147
 
@@ -147,11 +157,14 @@ class AsyncAgent(BaseAsyncResource):
147
157
  return_screenshots (bool, optional): whether to return screenshots of the agent's states at every step. Default to False.
148
158
  return_agent_state (bool, optional): whether to return the agent's state. Default to False.
149
159
  return_storage_state (bool, optional): whether to return the storage state. Default to False.
160
+ disable_give_control (bool, optional): whether to NOT give the agent additional direction to give control to the user for tasks such as login. Default to False.
150
161
  timeout (Optional[int], optional): timeout seconds for the agent's response. Default to None.
151
162
  cdp_url (Optional[str], optional): Chrome DevTools Protocol URL of an existing browser session. Default to None.
152
163
  max_steps (Optional[int], optional): maximum number of steps the agent can take. If not set, the backend will use a default value (currently 100). Default to None.
153
164
  thinking_token_budget (Optional[int], optional): maximum number of tokens the underlying LLM can spend on thinking in each step, if supported by the model. Default to None.
154
165
  start_url (Optional[str], optional): the URL to start the agent on. Must be a valid URL - refer to https://playwright.dev/docs/api/class-page#page-goto. If not specified, the agent infers this from the prompt. Default to None.
166
+ user_agent (Optional[str], optional): the user to be sent to the browser. If not specified, Laminar uses the default user agent. Default to None.
167
+
155
168
  Returns:
156
169
  AgentOutput: agent output
157
170
  """
@@ -170,11 +183,13 @@ class AsyncAgent(BaseAsyncResource):
170
183
  return_screenshots: bool = False,
171
184
  return_agent_state: bool = False,
172
185
  return_storage_state: bool = False,
186
+ disable_give_control: bool = False,
173
187
  timeout: Optional[int] = None,
174
188
  cdp_url: Optional[str] = None,
175
189
  max_steps: Optional[int] = None,
176
190
  thinking_token_budget: Optional[int] = None,
177
191
  start_url: Optional[str] = None,
192
+ user_agent: Optional[str] = None,
178
193
  ) -> Union[AgentOutput, Awaitable[AsyncIterator[RunAgentResponseChunk]]]:
179
194
  """Run Laminar index agent.
180
195
 
@@ -190,11 +205,13 @@ class AsyncAgent(BaseAsyncResource):
190
205
  return_screenshots (bool, optional): whether to return screenshots of the agent's states at every step. Default to False.
191
206
  return_agent_state (bool, optional): whether to return the agent's state. Default to False.
192
207
  return_storage_state (bool, optional): whether to return the storage state. Default to False.
208
+ disable_give_control (bool, optional): whether to NOT give the agent additional direction to give control to the user for tasks such as login. Default to False.
193
209
  timeout (Optional[int], optional): timeout seconds for the agent's response. Default to None.
194
210
  cdp_url (Optional[str], optional): Chrome DevTools Protocol URL of an existing browser session. Default to None.
195
211
  max_steps (Optional[int], optional): maximum number of steps the agent can take. If not set, the backend will use a default value (currently 100). Default to None.
196
212
  thinking_token_budget (Optional[int], optional): maximum number of tokens the underlying LLM can spend on thinking in each step, if supported by the model. Default to None.
197
213
  start_url (Optional[str], optional): the URL to start the agent on. Must be a valid URL - refer to https://playwright.dev/docs/api/class-page#page-goto. If not specified, the agent infers this from the prompt. Default to None.
214
+ user_agent (Optional[str], optional): the user to be sent to the browser. If not specified, Laminar uses the default user agent. Default to None.
198
215
 
199
216
  Returns:
200
217
  Union[AgentOutput, AsyncIterator[RunAgentResponseChunk]]: agent output or a generator of response chunks
@@ -228,6 +245,8 @@ class AsyncAgent(BaseAsyncResource):
228
245
  return_screenshots=return_screenshots,
229
246
  return_agent_state=return_agent_state,
230
247
  return_storage_state=return_storage_state,
248
+ disable_give_control=disable_give_control,
249
+ user_agent=user_agent,
231
250
  timeout=timeout,
232
251
  cdp_url=cdp_url,
233
252
  max_steps=max_steps,
@@ -32,11 +32,13 @@ class Agent(BaseResource):
32
32
  return_screenshots: bool = False,
33
33
  return_agent_state: bool = False,
34
34
  return_storage_state: bool = False,
35
+ disable_give_control: bool = False,
35
36
  timeout: Optional[int] = None,
36
37
  cdp_url: Optional[str] = None,
37
38
  max_steps: Optional[int] = None,
38
39
  thinking_token_budget: Optional[int] = None,
39
40
  start_url: Optional[str] = None,
41
+ user_agent: Optional[str] = None,
40
42
  ) -> Generator[RunAgentResponseChunk, None, None]:
41
43
  """Run Laminar index agent in streaming mode.
42
44
 
@@ -52,11 +54,13 @@ class Agent(BaseResource):
52
54
  return_screenshots (bool, optional): whether to return screenshots of the agent's states at every step. Default to False.
53
55
  return_agent_state (bool, optional): whether to return the agent's state. Default to False.
54
56
  return_storage_state (bool, optional): whether to return the storage state. Default to False.
57
+ disable_give_control (bool, optional): whether to NOT give the agent additional direction to give control to the user for tasks such as login. Default to False.
55
58
  timeout (Optional[int], optional): timeout seconds for the agent's response. Default to None.
56
59
  cdp_url (Optional[str], optional): Chrome DevTools Protocol URL of an existing browser session. Default to None.
57
60
  max_steps (Optional[int], optional): maximum number of steps the agent can take. If not set, the backend will use a default value (currently 100). Default to None.
58
61
  thinking_token_budget (Optional[int], optional): maximum number of tokens the underlying LLM can spend on thinking in each step, if supported by the model. Default to None.
59
62
  start_url (Optional[str], optional): the URL to start the agent on. Must be a valid URL - refer to https://playwright.dev/docs/api/class-page#page-goto. If not specified, the agent infers this from the prompt. Default to None.
63
+ user_agent (Optional[str], optional): the user to be sent to the browser. If not specified, Laminar uses the default user agent. Default to None.
60
64
  Returns:
61
65
  Generator[RunAgentResponseChunk, None, None]: a generator of response chunks
62
66
  """
@@ -74,12 +78,14 @@ class Agent(BaseResource):
74
78
  storage_state: Optional[str] = None,
75
79
  return_screenshots: bool = False,
76
80
  return_agent_state: bool = False,
81
+ disable_give_control: bool = False,
77
82
  return_storage_state: bool = False,
78
83
  timeout: Optional[int] = None,
79
84
  cdp_url: Optional[str] = None,
80
85
  max_steps: Optional[int] = None,
81
86
  thinking_token_budget: Optional[int] = None,
82
87
  start_url: Optional[str] = None,
88
+ user_agent: Optional[str] = None,
83
89
  ) -> AgentOutput:
84
90
  """Run Laminar index agent.
85
91
 
@@ -94,11 +100,14 @@ class Agent(BaseResource):
94
100
  return_screenshots (bool, optional): whether to return screenshots of the agent's states at every step. Default to False.
95
101
  return_agent_state (bool, optional): whether to return the agent's state. Default to False.
96
102
  return_storage_state (bool, optional): whether to return the storage state. Default to False.
103
+ disable_give_control (bool, optional): whether to NOT give the agent additional direction to give control to the user for tasks such as login. Default to False.
97
104
  timeout (Optional[int], optional): timeout seconds for the agent's response. Default to None.
98
105
  cdp_url (Optional[str], optional): Chrome DevTools Protocol URL of an existing browser session. Default to None.
99
106
  max_steps (Optional[int], optional): maximum number of steps the agent can take. If not set, the backend will use a default value (currently 100). Default to None.
100
107
  thinking_token_budget (Optional[int], optional): maximum number of tokens the underlying LLM can spend on thinking in each step, if supported by the model. Default to None.
101
108
  start_url (Optional[str], optional): the URL to start the agent on. Must be a valid URL - refer to https://playwright.dev/docs/api/class-page#page-goto. If not specified, the agent infers this from the prompt. Default to None.
109
+ user_agent (Optional[str], optional): the user to be sent to the browser. If not specified, Laminar uses the default user agent. Default to None.
110
+
102
111
  Returns:
103
112
  AgentOutput: agent output
104
113
  """
@@ -118,11 +127,13 @@ class Agent(BaseResource):
118
127
  return_screenshots: bool = False,
119
128
  return_agent_state: bool = False,
120
129
  return_storage_state: bool = False,
130
+ disable_give_control: bool = False,
121
131
  timeout: Optional[int] = None,
122
132
  cdp_url: Optional[str] = None,
123
133
  max_steps: Optional[int] = None,
124
134
  thinking_token_budget: Optional[int] = None,
125
135
  start_url: Optional[str] = None,
136
+ user_agent: Optional[str] = None,
126
137
  ) -> AgentOutput:
127
138
  """Run Laminar index agent.
128
139
 
@@ -138,11 +149,14 @@ class Agent(BaseResource):
138
149
  return_screenshots (bool, optional): whether to return screenshots of the agent's states at every step. Default to False.
139
150
  return_agent_state (bool, optional): whether to return the agent's state. Default to False.
140
151
  return_storage_state (bool, optional): whether to return the storage state. Default to False.
152
+ disable_give_control (bool, optional): whether to NOT give the agent additional direction to give control to the user for tasks such as login. Default to False.
141
153
  timeout (Optional[int], optional): timeout seconds for the agent's response. Default to None.
142
154
  cdp_url (Optional[str], optional): Chrome DevTools Protocol URL of an existing browser session. Default to None.
143
155
  max_steps (Optional[int], optional): maximum number of steps the agent can take. If not set, the backend will use a default value (currently 100). Default to None.
144
156
  thinking_token_budget (Optional[int], optional): maximum number of tokens the underlying LLM can spend on thinking in each step, if supported by the model. Default to None.
145
157
  start_url (Optional[str], optional): the URL to start the agent on. Must be a valid URL - refer to https://playwright.dev/docs/api/class-page#page-goto. If not specified, the agent infers this from the prompt. Default to None.
158
+ user_agent (Optional[str], optional): the user to be sent to the browser. If not specified, Laminar uses the default user agent. Default to None.
159
+
146
160
  Returns:
147
161
  AgentOutput: agent output
148
162
  """
@@ -161,11 +175,13 @@ class Agent(BaseResource):
161
175
  return_screenshots: bool = False,
162
176
  return_agent_state: bool = False,
163
177
  return_storage_state: bool = False,
178
+ disable_give_control: bool = False,
164
179
  timeout: Optional[int] = None,
165
180
  cdp_url: Optional[str] = None,
166
181
  max_steps: Optional[int] = None,
167
182
  thinking_token_budget: Optional[int] = None,
168
183
  start_url: Optional[str] = None,
184
+ user_agent: Optional[str] = None,
169
185
  ) -> Union[AgentOutput, Generator[RunAgentResponseChunk, None, None]]:
170
186
  """Run Laminar index agent.
171
187
 
@@ -181,11 +197,13 @@ class Agent(BaseResource):
181
197
  return_screenshots (bool, optional): whether to return screenshots of the agent's states at every step. Default to False.
182
198
  return_agent_state (bool, optional): whether to return the agent's state. Default to False.
183
199
  return_storage_state (bool, optional): whether to return the storage state. Default to False.
200
+ disable_give_control (bool, optional): whether to NOT give the agent additional direction to give control to the user for tasks such as login. Default to False.
184
201
  timeout (Optional[int], optional): timeout seconds for the agent's response. Default to None.
185
202
  cdp_url (Optional[str], optional): Chrome DevTools Protocol URL of an existing browser session. Default to None.
186
203
  max_steps (Optional[int], optional): maximum number of steps the agent can take. If not set, the backend will use a default value (currently 100). Default to None.
187
204
  thinking_token_budget (Optional[int], optional): maximum number of tokens the underlying LLM can spend on thinking in each step, if supported by the model. Default to None.
188
205
  start_url (Optional[str], optional): the URL to start the agent on. Must be a valid URL - refer to https://playwright.dev/docs/api/class-page#page-goto. If not specified, the agent infers this from the prompt. Default to None.
206
+ user_agent (Optional[str], optional): the user to be sent to the browser. If not specified, Laminar uses the default user agent. Default to None.
189
207
 
190
208
  Returns:
191
209
  Union[AgentOutput, Generator[RunAgentResponseChunk, None, None]]: agent output or a generator of response chunks
@@ -224,6 +242,8 @@ class Agent(BaseResource):
224
242
  max_steps=max_steps,
225
243
  thinking_token_budget=thinking_token_budget,
226
244
  start_url=start_url,
245
+ disable_give_control=disable_give_control,
246
+ user_agent=user_agent,
227
247
  )
228
248
 
229
249
  # For streaming case, use a generator function
lmnr/sdk/decorators.py CHANGED
@@ -1,4 +1,4 @@
1
- from lmnr.openllmetry_sdk.decorators.base import (
1
+ from lmnr.opentelemetry_lib.decorators.base import (
2
2
  entity_method,
3
3
  aentity_method,
4
4
  )
@@ -7,8 +7,8 @@ from opentelemetry.trace import INVALID_SPAN, get_current_span
7
7
  from typing import Callable, Literal, Optional, TypeVar, Union, cast
8
8
  from typing_extensions import ParamSpec
9
9
 
10
- from lmnr.openllmetry_sdk.tracing.attributes import SESSION_ID
11
- from lmnr.openllmetry_sdk.tracing.tracing import update_association_properties
10
+ from lmnr.opentelemetry_lib.tracing.attributes import SESSION_ID
11
+ from lmnr.opentelemetry_lib.tracing.tracing import update_association_properties
12
12
 
13
13
  from .utils import is_async
14
14
 
lmnr/sdk/eval_control.py CHANGED
@@ -1,4 +1,5 @@
1
1
  from contextvars import ContextVar
2
2
 
3
- PREPARE_ONLY = ContextVar("__lmnr_prepare_only", default=False)
4
- EVALUATION_INSTANCE = ContextVar("__lmnr_evaluation_instance", default=None)
3
+
4
+ PREPARE_ONLY: ContextVar[bool] = ContextVar("__lmnr_prepare_only", default=False)
5
+ EVALUATION_INSTANCE = ContextVar("__lmnr_evaluation_instance")
lmnr/sdk/evaluations.py CHANGED
@@ -5,8 +5,8 @@ import dotenv
5
5
  from tqdm import tqdm
6
6
  from typing import Any, Awaitable, Optional, Set, Union
7
7
 
8
- from lmnr.openllmetry_sdk.instruments import Instruments
9
- from lmnr.openllmetry_sdk.tracing.attributes import SPAN_TYPE
8
+ from lmnr.opentelemetry_lib.instruments import Instruments
9
+ from lmnr.opentelemetry_lib.tracing.attributes import SPAN_TYPE
10
10
 
11
11
  from lmnr.sdk.client.asynchronous.async_client import AsyncLaminarClient
12
12
  from lmnr.sdk.client.synchronous.sync_client import LaminarClient
@@ -176,7 +176,6 @@ class Evaluation:
176
176
 
177
177
  base_url = base_url or from_env("LMNR_BASE_URL") or "https://api.lmnr.ai"
178
178
 
179
- self.is_finished = False
180
179
  self.reporter = EvaluationReporter(base_url)
181
180
  if isinstance(data, list):
182
181
  self.data = [
@@ -196,12 +195,7 @@ class Evaluation:
196
195
  self.upload_tasks = []
197
196
  self.base_http_url = f"{base_url}:{http_port or 443}"
198
197
 
199
- api_key = project_api_key
200
- if not api_key:
201
- dotenv_path = dotenv.find_dotenv(usecwd=True)
202
- api_key = dotenv.get_key(
203
- dotenv_path=dotenv_path, key_to_get="LMNR_PROJECT_API_KEY"
204
- )
198
+ api_key = project_api_key or from_env("LMNR_PROJECT_API_KEY")
205
199
  if not api_key:
206
200
  raise ValueError(
207
201
  "Please initialize the Laminar object with"
@@ -225,8 +219,6 @@ class Evaluation:
225
219
  )
226
220
 
227
221
  async def run(self) -> Awaitable[None]:
228
- if self.is_finished:
229
- raise Exception("Evaluation is already finished")
230
222
  return await self._run()
231
223
 
232
224
  async def _run(self) -> None:
@@ -253,17 +245,19 @@ class Evaluation:
253
245
  self._logger.debug("All upload tasks completed")
254
246
  except Exception as e:
255
247
  self.reporter.stopWithError(e)
256
- self.is_finished = True
257
248
  await self._shutdown()
258
249
  return
259
250
 
260
251
  average_scores = get_average_scores(result_datapoints)
261
252
  self.reporter.stop(average_scores, evaluation.projectId, evaluation.id)
262
- self.is_finished = True
263
253
  await self._shutdown()
264
254
 
265
255
  async def _shutdown(self):
266
- L.shutdown()
256
+ # We use flush() instead of shutdown() because multiple evaluations
257
+ # can be run sequentially in the same process. `shutdown()` would
258
+ # close the OTLP exporter and we wouldn't be able to export traces in
259
+ # the next evaluation.
260
+ L.flush()
267
261
  await self.client.close()
268
262
  if isinstance(self.data, LaminarDataset) and self.data.client:
269
263
  self.data.client.close()
lmnr/sdk/laminar.py CHANGED
@@ -1,15 +1,15 @@
1
1
  from contextlib import contextmanager
2
2
  from contextvars import Context
3
- from lmnr.openllmetry_sdk import TracerManager
4
- from lmnr.openllmetry_sdk.instruments import Instruments
5
- from lmnr.openllmetry_sdk.tracing import get_tracer
6
- from lmnr.openllmetry_sdk.tracing.attributes import (
3
+ from lmnr.opentelemetry_lib import TracerManager
4
+ from lmnr.opentelemetry_lib.instruments import Instruments
5
+ from lmnr.opentelemetry_lib.tracing import get_tracer
6
+ from lmnr.opentelemetry_lib.tracing.attributes import (
7
7
  ASSOCIATION_PROPERTIES,
8
8
  Attributes,
9
9
  SPAN_TYPE,
10
10
  )
11
- from lmnr.openllmetry_sdk.config import MAX_MANUAL_SPAN_PAYLOAD_SIZE
12
- from lmnr.openllmetry_sdk.decorators.base import json_dumps
11
+ from lmnr.opentelemetry_lib.config import MAX_MANUAL_SPAN_PAYLOAD_SIZE
12
+ from lmnr.opentelemetry_lib.decorators.base import json_dumps
13
13
  from opentelemetry import context as context_api, trace
14
14
  from opentelemetry.context import attach, detach
15
15
  from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import (
@@ -28,13 +28,13 @@ import os
28
28
  import re
29
29
  import uuid
30
30
 
31
- from lmnr.openllmetry_sdk.tracing.attributes import (
31
+ from lmnr.opentelemetry_lib.tracing.attributes import (
32
32
  SESSION_ID,
33
33
  SPAN_INPUT,
34
34
  SPAN_OUTPUT,
35
35
  TRACE_TYPE,
36
36
  )
37
- from lmnr.openllmetry_sdk.tracing.tracing import (
37
+ from lmnr.opentelemetry_lib.tracing.tracing import (
38
38
  get_association_properties,
39
39
  remove_association_properties,
40
40
  set_association_properties,
lmnr/sdk/types.py CHANGED
@@ -249,6 +249,8 @@ class RunAgentRequest(pydantic.BaseModel):
249
249
  max_steps: Optional[int] = pydantic.Field(default=None)
250
250
  thinking_token_budget: Optional[int] = pydantic.Field(default=None)
251
251
  start_url: Optional[str] = pydantic.Field(default=None)
252
+ disable_give_control: bool = pydantic.Field(default=False)
253
+ user_agent: Optional[str] = pydantic.Field(default=None)
252
254
 
253
255
 
254
256
  class ActionResult(pydantic.BaseModel):
lmnr/version.py CHANGED
@@ -3,7 +3,7 @@ import httpx
3
3
  from packaging import version
4
4
 
5
5
 
6
- __version__ = "0.5.2"
6
+ __version__ = "0.5.3"
7
7
  PYTHON_VERSION = f"{sys.version_info.major}.{sys.version_info.minor}"
8
8
 
9
9
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: lmnr
3
- Version: 0.5.2
3
+ Version: 0.5.3
4
4
  Summary: Python SDK for Laminar
5
5
  License: Apache-2.0
6
6
  Author: lmnr.ai
@@ -222,7 +222,7 @@ def handle_user_request(topic: str):
222
222
  Laminar allows you to automatically instrument majority of the most popular LLM, Vector DB, database, requests, and other libraries.
223
223
 
224
224
  If you want to automatically instrument a default set of libraries, then simply do NOT pass `instruments` argument to `.initialize()`.
225
- See the full list of available instrumentations in the [enum](https://github.com/lmnr-ai/lmnr-python/blob/main/src/lmnr/openllmetry_sdk/instruments.py).
225
+ See the full list of available instrumentations in the [enum](https://github.com/lmnr-ai/lmnr-python/blob/main/src/lmnr/opentelemetry_lib/instruments.py).
226
226
 
227
227
  If you want to automatically instrument only specific LLM, Vector DB, or other
228
228
  calls with OpenTelemetry-compatible instrumentation, then pass the appropriate instruments to `.initialize()`.
@@ -0,0 +1,55 @@
1
+ lmnr/__init__.py,sha256=XS83LtneFT8Sa0_04LxrcLnwTJbP0QjU1uq8G1yQrbU,1024
2
+ lmnr/cli.py,sha256=e_Jgcwn3Q-hgR6VLLar2ccWLAhJb8yB4cwoIdg5vwDs,3013
3
+ lmnr/opentelemetry_lib/.flake8,sha256=bCxuDlGx3YQ55QHKPiGJkncHanh9qGjQJUujcFa3lAU,150
4
+ lmnr/opentelemetry_lib/__init__.py,sha256=QsuzIbwzeH1qXvdvqLuqLjw_TQrUrXw2orbhxak1zok,2538
5
+ lmnr/opentelemetry_lib/config/__init__.py,sha256=5aGdIdo1LffBkNwIBUbqzN6OUCMCrURU4b0rf5LBSI0,300
6
+ lmnr/opentelemetry_lib/decorators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ lmnr/opentelemetry_lib/decorators/base.py,sha256=uJU0vX4NqNF48iEUeMPZ8zWpZg3nbxCMzK-hSxVsqQI,7440
8
+ lmnr/opentelemetry_lib/instruments.py,sha256=q8CHY2rmfkJ1psNvyPR2pr27ZqTOGNgliNuiUoWB7nU,1162
9
+ lmnr/opentelemetry_lib/opentelemetry/instrumentation/google_genai/__init__.py,sha256=jrvHu8aq2EBGZI3ypucUltR4-v8HqTKnqGtWXF5Qbb8,15339
10
+ lmnr/opentelemetry_lib/opentelemetry/instrumentation/google_genai/config.py,sha256=FeQOcC3RNq-yOd8KZ_VoBuZgDl6tnkxx6I2MKVH1GMI,256
11
+ lmnr/opentelemetry_lib/opentelemetry/instrumentation/google_genai/utils.py,sha256=P0fOmGi_0nv3cMFcdWblRuTsDRCZnvdM8GQ3zJT0qbM,6229
12
+ lmnr/opentelemetry_lib/tracing/__init__.py,sha256=wsjDg8GFn9NRbfZ4_JiB_lfiiLTd9iA8OugV57-mYcs,70
13
+ lmnr/opentelemetry_lib/tracing/attributes.py,sha256=BEMMGrX_7kPu4PNCV7Bz1uaclY4DNhlaLT0bWwFQnRE,1366
14
+ lmnr/opentelemetry_lib/tracing/content_allow_list.py,sha256=3feztm6PBWNelc8pAZUcQyEGyeSpNiVKjOaDk65l2ps,846
15
+ lmnr/opentelemetry_lib/tracing/context_manager.py,sha256=kGCUrNU6BleNOQ2i-LKxktG5GQV3kjsyh6smxRsM16s,308
16
+ lmnr/opentelemetry_lib/tracing/tracing.py,sha256=tp4SCcbwg4LXGjVyCkt6ccCwBytedhZ0GNxLEYjsSy0,37486
17
+ lmnr/opentelemetry_lib/utils/__init__.py,sha256=pNhf0G3vTd5ccoc03i1MXDbricSaiqCbi1DLWhSekK8,604
18
+ lmnr/opentelemetry_lib/utils/in_memory_span_exporter.py,sha256=H_4TRaThMO1H6vUQ0OpQvzJk_fZH0OOsRAM1iZQXsR8,2112
19
+ lmnr/opentelemetry_lib/utils/json_encoder.py,sha256=dK6b_axr70IYL7Vv-bu4wntvDDuyntoqsHaddqX7P58,463
20
+ lmnr/opentelemetry_lib/utils/package_check.py,sha256=_-Fu9Zbp9tOyy27_-Rul7tDc8JaXYR2FmqF8SWOXSCc,244
21
+ lmnr/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
+ lmnr/sdk/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
+ lmnr/sdk/browser/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
+ lmnr/sdk/browser/browser_use_otel.py,sha256=lwkHT8bQ11HKdeZjAoI5JrW4Shxrq7g1X6xmcUEK4EM,4524
25
+ lmnr/sdk/browser/patchright_otel.py,sha256=O7n1dB_Mw-_L70zi0zqpnFFiKuTPEEpO7ry1ia6IXWQ,5454
26
+ lmnr/sdk/browser/playwright_otel.py,sha256=dPmdZo9MeSkPGNG8lUCP9JV1G7pW8MXLWT6xoFVOVUA,12672
27
+ lmnr/sdk/browser/pw_utils.py,sha256=xg7Qd-Ejn50B8DOa9ruLELDmKN_eyn0RVv0QRNp-rHw,10199
28
+ lmnr/sdk/browser/rrweb/rrweb.umd.min.cjs,sha256=Ly2jiwC7hTEtgiXzBpoJNSE1Vkzu0lZPZS8brjusAW0,260896
29
+ lmnr/sdk/browser/utils.py,sha256=xPpMRP2y9aJIsdIDNg2wN4PSa_4w0LSsra-GIMx9VXc,2366
30
+ lmnr/sdk/client/asynchronous/async_client.py,sha256=NuGla1gGlyYLxyIQ6LSKG-b5eYGNIQA5HXAOzGQR5BU,4036
31
+ lmnr/sdk/client/asynchronous/resources/__init__.py,sha256=WL2ehX1LfxG3n7bsxzTRO8grM0YtMGb_r7DLMjkmm1Y,298
32
+ lmnr/sdk/client/asynchronous/resources/agent.py,sha256=bpoNyRowogJRpstzchdt-Dlc1Frjh4MRVNO3RhPsiN0,18163
33
+ lmnr/sdk/client/asynchronous/resources/base.py,sha256=aJ43Q1rltg23IQaI4eeaZKckxVTgDUbCJrChhQCUEoE,986
34
+ lmnr/sdk/client/asynchronous/resources/browser_events.py,sha256=T-DUbbAfMQ2VqiVfgVplxuTaJZuoNcC1O6RCxdfw7UQ,1163
35
+ lmnr/sdk/client/asynchronous/resources/evals.py,sha256=bm3ATwqLozUoW2Ed6psmdjmeJ7joBaQHSv6mBeA_cws,2187
36
+ lmnr/sdk/client/synchronous/resources/__init__.py,sha256=Sk0_5Y1UkqwUhJKRct9R3JAnHk6sPe8lDokpYVqehdY,250
37
+ lmnr/sdk/client/synchronous/resources/agent.py,sha256=YMpXbyH7uKKhgeV-IWaZFJMjYfOU3XqrDoYxoebkaJ4,18043
38
+ lmnr/sdk/client/synchronous/resources/base.py,sha256=ne1ZZ10UmNkMrECVvClcEJfcFJlSGvaXOC8K6mZTPdY,971
39
+ lmnr/sdk/client/synchronous/resources/browser_events.py,sha256=9rFYWZesXQomnFgbZ590tGFMTaNj0OAzT9RcFwD8q_Y,1135
40
+ lmnr/sdk/client/synchronous/resources/evals.py,sha256=sMMAai7_IW842z_J0W9OpthDhGQPCkTVJZamIkKq0wk,3496
41
+ lmnr/sdk/client/synchronous/sync_client.py,sha256=-sSMbUvgDLt98tT-nDyE_xfTohcGdn00lAmul1713Wo,4396
42
+ lmnr/sdk/datasets.py,sha256=jl5Wj5nEI9pww4Jwn4XKF8h0gXBU4TOIrhqNjTJsHZQ,1709
43
+ lmnr/sdk/decorators.py,sha256=8SRIvx53psMEIsU4QrdlAj2_nYrYvLUQtHuICbo1Sys,3331
44
+ lmnr/sdk/eval_control.py,sha256=qMiAI6FnHdIwKX8-W1nDhEcS5Cjm5lYRoIN7x4J-AVI,182
45
+ lmnr/sdk/evaluations.py,sha256=DNupsFQuY4fiFtg-iRmAyk59CiFgaIE62sWHiGJEH7g,20450
46
+ lmnr/sdk/laminar.py,sha256=8571DiQsMWXdT0BKJrKCDhoVzk1wxJ_HXdqOST038o0,27996
47
+ lmnr/sdk/log.py,sha256=nt_YMmPw1IRbGy0b7q4rTtP4Yo3pQfNxqJPXK3nDSNQ,2213
48
+ lmnr/sdk/types.py,sha256=QOIZ18ELzts5AG1Tx-_twHI43_PHoB4X8JYynTH0MCA,12287
49
+ lmnr/sdk/utils.py,sha256=_8t_KGnSJUIOfwAsNDEcI3YP2PuQdht2Pg2Rq7yaI08,3912
50
+ lmnr/version.py,sha256=S5lDEgXfAEPHUdUirfHaQvB6Fnz5RLgf_ECDTnPfNgU,1321
51
+ lmnr-0.5.3.dist-info/LICENSE,sha256=67b_wJHVV1CBaWkrKFWU1wyqTPSdzH77Ls-59631COg,10411
52
+ lmnr-0.5.3.dist-info/METADATA,sha256=g7YX_kYFp7oAE30CVA_fmyes_v-LcYDhZK-7XshH2no,14959
53
+ lmnr-0.5.3.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
54
+ lmnr-0.5.3.dist-info/entry_points.txt,sha256=K1jE20ww4jzHNZLnsfWBvU3YKDGBgbOiYG5Y7ivQcq4,37
55
+ lmnr-0.5.3.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.1.2
2
+ Generator: poetry-core 2.1.3
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1 +0,0 @@
1
- from lmnr.openllmetry_sdk.tracing.context_manager import get_tracer