lmnr 0.4.12b1__tar.gz → 0.4.12b3__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.
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/PKG-INFO +1 -1
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/pyproject.toml +2 -2
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/sdk/evaluations.py +43 -18
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/sdk/laminar.py +1 -1
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/sdk/types.py +2 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/LICENSE +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/README.md +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/__init__.py +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/cli.py +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/sdk/__init__.py +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/sdk/decorators.py +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/sdk/log.py +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/sdk/utils.py +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/traceloop_sdk/.flake8 +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/traceloop_sdk/.python-version +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/traceloop_sdk/__init__.py +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/traceloop_sdk/config/__init__.py +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/traceloop_sdk/decorators/__init__.py +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/traceloop_sdk/decorators/base.py +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/traceloop_sdk/instruments.py +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/traceloop_sdk/metrics/__init__.py +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/traceloop_sdk/metrics/metrics.py +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/traceloop_sdk/tests/__init__.py +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/traceloop_sdk/tests/cassettes/test_association_properties/test_langchain_and_external_association_properties.yaml +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/traceloop_sdk/tests/cassettes/test_association_properties/test_langchain_association_properties.yaml +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/traceloop_sdk/tests/cassettes/test_manual/test_manual_report.yaml +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/traceloop_sdk/tests/cassettes/test_manual/test_resource_attributes.yaml +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/traceloop_sdk/tests/cassettes/test_privacy_no_prompts/test_simple_workflow.yaml +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/traceloop_sdk/tests/cassettes/test_prompt_management/test_prompt_management.yaml +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/traceloop_sdk/tests/cassettes/test_sdk_initialization/test_resource_attributes.yaml +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/traceloop_sdk/tests/cassettes/test_tasks/test_task_io_serialization_with_langchain.yaml +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/traceloop_sdk/tests/cassettes/test_workflows/test_simple_aworkflow.yaml +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/traceloop_sdk/tests/cassettes/test_workflows/test_simple_workflow.yaml +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/traceloop_sdk/tests/cassettes/test_workflows/test_streaming_workflow.yaml +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/traceloop_sdk/tests/conftest.py +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/traceloop_sdk/tests/test_association_properties.py +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/traceloop_sdk/tests/test_manual.py +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/traceloop_sdk/tests/test_nested_tasks.py +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/traceloop_sdk/tests/test_privacy_no_prompts.py +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/traceloop_sdk/tests/test_sdk_initialization.py +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/traceloop_sdk/tests/test_tasks.py +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/traceloop_sdk/tests/test_workflows.py +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/traceloop_sdk/tracing/__init__.py +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/traceloop_sdk/tracing/content_allow_list.py +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/traceloop_sdk/tracing/context_manager.py +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/traceloop_sdk/tracing/manual.py +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/traceloop_sdk/tracing/tracing.py +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/traceloop_sdk/utils/__init__.py +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/traceloop_sdk/utils/in_memory_span_exporter.py +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/traceloop_sdk/utils/json_encoder.py +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/traceloop_sdk/utils/package_check.py +0 -0
- {lmnr-0.4.12b1 → lmnr-0.4.12b3}/src/lmnr/traceloop_sdk/version.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
[project]
|
2
2
|
name = "lmnr"
|
3
|
-
version = "0.4.
|
3
|
+
version = "0.4.12b3"
|
4
4
|
description = "Python SDK for Laminar AI"
|
5
5
|
authors = [
|
6
6
|
{ name = "lmnr.ai", email = "founders@lmnr.ai" }
|
@@ -11,7 +11,7 @@ license = "Apache-2.0"
|
|
11
11
|
|
12
12
|
[tool.poetry]
|
13
13
|
name = "lmnr"
|
14
|
-
version = "0.4.
|
14
|
+
version = "0.4.12b3"
|
15
15
|
description = "Python SDK for Laminar AI"
|
16
16
|
authors = ["lmnr.ai"]
|
17
17
|
readme = "README.md"
|
@@ -7,7 +7,7 @@ from typing import Any, Awaitable, Optional, Union
|
|
7
7
|
from tqdm import tqdm
|
8
8
|
|
9
9
|
from .laminar import Laminar as L
|
10
|
-
from .types import CreateEvaluationResponse, Datapoint, EvaluationResultDatapoint, Numeric
|
10
|
+
from .types import CreateEvaluationResponse, Datapoint, EvaluationResultDatapoint, Numeric, NumericTypes
|
11
11
|
from .utils import is_async
|
12
12
|
|
13
13
|
DEFAULT_BATCH_SIZE = 5
|
@@ -76,10 +76,10 @@ class EvaluationDataset(ABC):
|
|
76
76
|
class Evaluation:
|
77
77
|
def __init__(
|
78
78
|
self,
|
79
|
-
name: str,
|
80
79
|
data: Union[EvaluationDataset, list[Union[Datapoint, dict]]],
|
81
80
|
executor: Any,
|
82
81
|
evaluators: list[Any],
|
82
|
+
name: Optional[str] = None,
|
83
83
|
batch_size: int = DEFAULT_BATCH_SIZE,
|
84
84
|
project_api_key: Optional[str] = None,
|
85
85
|
base_url: Optional[str] = None,
|
@@ -89,7 +89,6 @@ class Evaluation:
|
|
89
89
|
Initializes an instance of the Evaluations class.
|
90
90
|
|
91
91
|
Parameters:
|
92
|
-
name (str): The name of the evaluation.
|
93
92
|
data (Union[List[Union[EvaluationDatapoint, dict]], EvaluationDataset]): List of data points to evaluate or an evaluation dataset.
|
94
93
|
`data` is the input to the executor function,
|
95
94
|
`target` is the input to the evaluator function.
|
@@ -104,6 +103,8 @@ class Evaluation:
|
|
104
103
|
evaluator function. If the function is anonymous, it will be
|
105
104
|
named `evaluator_${index}`, where index is the index of the
|
106
105
|
evaluator function in the list starting from 1.
|
106
|
+
name (Optional[str], optional): The name of the evaluation.
|
107
|
+
It will be auto-generated if not provided.
|
107
108
|
batch_size (int, optional): The batch size for evaluation.
|
108
109
|
Defaults to DEFAULT_BATCH_SIZE.
|
109
110
|
project_api_key (Optional[str], optional): The project API key.
|
@@ -240,7 +241,7 @@ class Evaluation:
|
|
240
241
|
)
|
241
242
|
|
242
243
|
# If evaluator returns a single number, use evaluator name as key
|
243
|
-
if isinstance(value,
|
244
|
+
if isinstance(value, NumericTypes):
|
244
245
|
scores[evaluator_name] = value
|
245
246
|
else:
|
246
247
|
scores.update(value)
|
@@ -254,33 +255,57 @@ class Evaluation:
|
|
254
255
|
|
255
256
|
|
256
257
|
def evaluate(
|
257
|
-
name: str,
|
258
258
|
data: Union[EvaluationDataset, list[Union[Datapoint, dict]]],
|
259
259
|
executor: Any,
|
260
260
|
evaluators: list[Any],
|
261
|
+
name: Optional[str] = None,
|
261
262
|
batch_size: int = DEFAULT_BATCH_SIZE,
|
262
263
|
project_api_key: Optional[str] = None,
|
263
264
|
base_url: Optional[str] = None,
|
264
265
|
http_port: Optional[int] = None,
|
265
266
|
) -> Optional[Awaitable[None]]:
|
266
267
|
"""
|
267
|
-
|
268
|
-
|
269
|
-
If `_set_global_evaluation` is `True`, sets the global evaluation to be run in another part of the program.
|
270
|
-
|
271
|
-
Otherwise, if there is no event loop, runs the evaluation in the current thread until completion.
|
268
|
+
If added to the file which is called through lmnr eval command, then simply registers the evaluation.
|
269
|
+
Otherwise, if there is no event loop, creates it and runs the evaluation until completion.
|
272
270
|
If there is an event loop, schedules the evaluation as a task in the event loop and returns an awaitable handle.
|
271
|
+
|
272
|
+
Parameters:
|
273
|
+
data (Union[List[Union[EvaluationDatapoint, dict]], EvaluationDataset]): List of data points to evaluate or an evaluation dataset.
|
274
|
+
`data` is the input to the executor function,
|
275
|
+
`target` is the input to the evaluator function.
|
276
|
+
executor (Callable[..., Any]): The executor function.
|
277
|
+
Takes the data point + any additional arguments
|
278
|
+
and returns the output to evaluate.
|
279
|
+
evaluators (List[Callable[..., Any]]): List of evaluator functions.
|
280
|
+
Each evaluator function takes the output of the executor _and_
|
281
|
+
the target data, and returns a score. The score can be a
|
282
|
+
single number or a record of string keys and number values.
|
283
|
+
If the score is a single number, it will be named after the
|
284
|
+
evaluator function. If the function is anonymous, it will be
|
285
|
+
named `evaluator_${index}`, where index is the index of the
|
286
|
+
evaluator function in the list starting from 1.
|
287
|
+
name (Optional[str], optional): The name of the evaluation.
|
288
|
+
It will be auto-generated if not provided.
|
289
|
+
batch_size (int, optional): The batch size for evaluation.
|
290
|
+
Defaults to DEFAULT_BATCH_SIZE.
|
291
|
+
project_api_key (Optional[str], optional): The project API key.
|
292
|
+
Defaults to an empty string.
|
293
|
+
base_url (Optional[str], optional): The base URL for the Laminar API.
|
294
|
+
Useful if self-hosted elsewhere.
|
295
|
+
Defaults to "https://api.lmnr.ai".
|
296
|
+
http_port (Optional[int], optional): The port for the Laminar API HTTP service.
|
297
|
+
Defaults to 443.
|
273
298
|
"""
|
274
299
|
|
275
300
|
evaluation = Evaluation(
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
batch_size,
|
281
|
-
project_api_key,
|
282
|
-
base_url,
|
283
|
-
http_port,
|
301
|
+
data=data,
|
302
|
+
executor=executor,
|
303
|
+
evaluators=evaluators,
|
304
|
+
name=name,
|
305
|
+
batch_size=batch_size,
|
306
|
+
project_api_key=project_api_key,
|
307
|
+
base_url=base_url,
|
308
|
+
http_port=http_port,
|
284
309
|
)
|
285
310
|
|
286
311
|
global _evaluation
|
@@ -410,7 +410,7 @@ class Laminar:
|
|
410
410
|
set_association_properties(props)
|
411
411
|
|
412
412
|
@classmethod
|
413
|
-
def create_evaluation(cls, name: str) -> CreateEvaluationResponse:
|
413
|
+
def create_evaluation(cls, name: Optional[str]) -> CreateEvaluationResponse:
|
414
414
|
response = requests.post(
|
415
415
|
cls.__base_http_url + "/v1/evaluations",
|
416
416
|
data=json.dumps({"name": name}),
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|