lmnr 0.4.5__py3-none-any.whl → 0.4.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.
- lmnr/sdk/decorators.py +2 -7
- lmnr/sdk/laminar.py +79 -9
- lmnr/traceloop_sdk/.flake8 +12 -0
- lmnr/traceloop_sdk/.python-version +1 -0
- lmnr/traceloop_sdk/README.md +16 -0
- lmnr/traceloop_sdk/__init__.py +138 -0
- lmnr/traceloop_sdk/config/__init__.py +13 -0
- lmnr/traceloop_sdk/decorators/__init__.py +131 -0
- lmnr/traceloop_sdk/decorators/base.py +253 -0
- lmnr/traceloop_sdk/instruments.py +29 -0
- lmnr/traceloop_sdk/metrics/__init__.py +0 -0
- lmnr/traceloop_sdk/metrics/metrics.py +176 -0
- lmnr/traceloop_sdk/tests/__init__.py +1 -0
- lmnr/traceloop_sdk/tests/cassettes/test_association_properties/test_langchain_and_external_association_properties.yaml +101 -0
- lmnr/traceloop_sdk/tests/cassettes/test_association_properties/test_langchain_association_properties.yaml +99 -0
- lmnr/traceloop_sdk/tests/cassettes/test_manual/test_manual_report.yaml +98 -0
- lmnr/traceloop_sdk/tests/cassettes/test_manual/test_resource_attributes.yaml +98 -0
- lmnr/traceloop_sdk/tests/cassettes/test_privacy_no_prompts/test_simple_workflow.yaml +199 -0
- lmnr/traceloop_sdk/tests/cassettes/test_prompt_management/test_prompt_management.yaml +202 -0
- lmnr/traceloop_sdk/tests/cassettes/test_sdk_initialization/test_resource_attributes.yaml +199 -0
- lmnr/traceloop_sdk/tests/cassettes/test_tasks/test_task_io_serialization_with_langchain.yaml +96 -0
- lmnr/traceloop_sdk/tests/cassettes/test_workflows/test_simple_aworkflow.yaml +98 -0
- lmnr/traceloop_sdk/tests/cassettes/test_workflows/test_simple_workflow.yaml +199 -0
- lmnr/traceloop_sdk/tests/cassettes/test_workflows/test_streaming_workflow.yaml +167 -0
- lmnr/traceloop_sdk/tests/conftest.py +111 -0
- lmnr/traceloop_sdk/tests/test_association_properties.py +229 -0
- lmnr/traceloop_sdk/tests/test_manual.py +48 -0
- lmnr/traceloop_sdk/tests/test_nested_tasks.py +47 -0
- lmnr/traceloop_sdk/tests/test_privacy_no_prompts.py +50 -0
- lmnr/traceloop_sdk/tests/test_sdk_initialization.py +57 -0
- lmnr/traceloop_sdk/tests/test_tasks.py +32 -0
- lmnr/traceloop_sdk/tests/test_workflows.py +261 -0
- lmnr/traceloop_sdk/tracing/__init__.py +2 -0
- lmnr/traceloop_sdk/tracing/content_allow_list.py +24 -0
- lmnr/traceloop_sdk/tracing/context_manager.py +13 -0
- lmnr/traceloop_sdk/tracing/manual.py +57 -0
- lmnr/traceloop_sdk/tracing/tracing.py +1078 -0
- lmnr/traceloop_sdk/utils/__init__.py +26 -0
- lmnr/traceloop_sdk/utils/in_memory_span_exporter.py +61 -0
- lmnr/traceloop_sdk/utils/json_encoder.py +20 -0
- lmnr/traceloop_sdk/utils/package_check.py +8 -0
- lmnr/traceloop_sdk/version.py +1 -0
- {lmnr-0.4.5.dist-info → lmnr-0.4.7.dist-info}/METADATA +40 -3
- lmnr-0.4.7.dist-info/RECORD +53 -0
- lmnr-0.4.5.dist-info/RECORD +0 -13
- {lmnr-0.4.5.dist-info → lmnr-0.4.7.dist-info}/LICENSE +0 -0
- {lmnr-0.4.5.dist-info → lmnr-0.4.7.dist-info}/WHEEL +0 -0
- {lmnr-0.4.5.dist-info → lmnr-0.4.7.dist-info}/entry_points.txt +0 -0
lmnr/sdk/decorators.py
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
from
|
1
|
+
from lmnr.traceloop_sdk.decorators.base import (
|
2
2
|
entity_method,
|
3
3
|
aentity_method,
|
4
4
|
)
|
5
5
|
from opentelemetry.trace import INVALID_SPAN, get_current_span
|
6
|
-
from
|
6
|
+
from lmnr.traceloop_sdk import Traceloop
|
7
7
|
|
8
8
|
from typing import Callable, Optional, ParamSpec, TypeVar, cast
|
9
9
|
|
@@ -42,11 +42,6 @@ def observe(
|
|
42
42
|
"""
|
43
43
|
|
44
44
|
def decorator(func: Callable[P, R]) -> Callable[P, R]:
|
45
|
-
if not L.is_initialized():
|
46
|
-
raise Exception(
|
47
|
-
"Laminar is not initialized. Please "
|
48
|
-
+ "call Laminar.initialize() first."
|
49
|
-
)
|
50
45
|
current_span = get_current_span()
|
51
46
|
if current_span != INVALID_SPAN:
|
52
47
|
if session_id is not None:
|
lmnr/sdk/laminar.py
CHANGED
@@ -4,11 +4,16 @@ from opentelemetry.trace import (
|
|
4
4
|
get_current_span,
|
5
5
|
set_span_in_context,
|
6
6
|
Span,
|
7
|
+
SpanKind,
|
7
8
|
)
|
8
9
|
from opentelemetry.semconv_ai import SpanAttributes
|
9
10
|
from opentelemetry.util.types import AttributeValue
|
10
|
-
from
|
11
|
-
from
|
11
|
+
from opentelemetry.context.context import Context
|
12
|
+
from opentelemetry.util import types
|
13
|
+
from lmnr.traceloop_sdk import Traceloop
|
14
|
+
from lmnr.traceloop_sdk.tracing import get_tracer
|
15
|
+
from contextlib import contextmanager
|
16
|
+
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
|
12
17
|
|
13
18
|
from pydantic.alias_generators import to_snake
|
14
19
|
from typing import Any, Optional, Union
|
@@ -35,7 +40,7 @@ from .types import (
|
|
35
40
|
|
36
41
|
|
37
42
|
class Laminar:
|
38
|
-
__base_url: str = "https://api.lmnr.ai"
|
43
|
+
__base_url: str = "https://api.lmnr.ai:8443"
|
39
44
|
__project_api_key: Optional[str] = None
|
40
45
|
__env: dict[str, str] = {}
|
41
46
|
__initialized: bool = False
|
@@ -67,9 +72,9 @@ class Laminar:
|
|
67
72
|
base_url (Optional[str], optional): Url of Laminar endpoint,
|
68
73
|
or the customopen telemetry ingester.
|
69
74
|
If not specified, defaults to
|
70
|
-
https://api.lmnr.ai.
|
75
|
+
https://api.lmnr.ai:8443.
|
71
76
|
For locally hosted Laminar, default setting
|
72
|
-
must be http://localhost:
|
77
|
+
must be http://localhost:8001
|
73
78
|
Defaults to None.
|
74
79
|
|
75
80
|
Raises:
|
@@ -95,8 +100,10 @@ class Laminar:
|
|
95
100
|
cls.__initialized = True
|
96
101
|
cls._initialize_logger()
|
97
102
|
Traceloop.init(
|
98
|
-
|
99
|
-
|
103
|
+
exporter=OTLPSpanExporter(
|
104
|
+
endpoint=cls.__base_url,
|
105
|
+
headers={"authorization": f"Bearer {cls.__project_api_key}"},
|
106
|
+
),
|
100
107
|
)
|
101
108
|
|
102
109
|
@classmethod
|
@@ -247,7 +254,7 @@ class Laminar:
|
|
247
254
|
name: str,
|
248
255
|
evaluator: str,
|
249
256
|
data: dict[str, AttributeValue],
|
250
|
-
env: Optional[dict[str, str]] =
|
257
|
+
env: Optional[dict[str, str]] = None,
|
251
258
|
timestamp: Optional[Union[datetime.datetime, int]] = None,
|
252
259
|
):
|
253
260
|
"""Send an event for evaluation to the Laminar backend
|
@@ -284,6 +291,68 @@ class Laminar:
|
|
284
291
|
|
285
292
|
current_span.add_event(name, event)
|
286
293
|
|
294
|
+
@classmethod
|
295
|
+
@contextmanager
|
296
|
+
def start_as_current_span(
|
297
|
+
cls,
|
298
|
+
name: str,
|
299
|
+
input: Any = None,
|
300
|
+
context: Optional[Context] = None,
|
301
|
+
kind: SpanKind = SpanKind.INTERNAL,
|
302
|
+
attributes: types.Attributes = None,
|
303
|
+
links=None,
|
304
|
+
start_time: Optional[int] = None,
|
305
|
+
record_exception: bool = True,
|
306
|
+
set_status_on_exception: bool = True,
|
307
|
+
end_on_exit: bool = True,
|
308
|
+
):
|
309
|
+
"""Start a new span as the current span. Useful for manual instrumentation.
|
310
|
+
This is the preferred and more stable way to use manual instrumentation.
|
311
|
+
|
312
|
+
Usage example:
|
313
|
+
```python
|
314
|
+
with Laminar.start_as_current_span("my_span", input="my_input"):
|
315
|
+
await my_async_function()
|
316
|
+
```
|
317
|
+
|
318
|
+
Args:
|
319
|
+
name (str): name of the span
|
320
|
+
input (Any, optional): input to the span. Will be sent as an
|
321
|
+
attribute, so must be json serializable. Defaults to None.
|
322
|
+
context (Optional[Context], optional): context to start the span in.
|
323
|
+
Defaults to None.
|
324
|
+
kind (SpanKind, optional): kind of the span. Defaults to SpanKind.INTERNAL.
|
325
|
+
attributes (types.Attributes, optional): attributes to set on the span.
|
326
|
+
Defaults to None.
|
327
|
+
links ([type], optional): links to set on the span. Defaults to None.
|
328
|
+
start_time (Optional[int], optional): start time of the span.
|
329
|
+
Defaults to None.
|
330
|
+
record_exception (bool, optional): whether to record exceptions.
|
331
|
+
Defaults to True.
|
332
|
+
set_status_on_exception (bool, optional): whether to set status on exception.
|
333
|
+
Defaults to True.
|
334
|
+
end_on_exit (bool, optional): whether to end the span on exit.
|
335
|
+
Defaults to True.
|
336
|
+
"""
|
337
|
+
with get_tracer() as tracer:
|
338
|
+
with tracer.start_as_current_span(
|
339
|
+
name,
|
340
|
+
context=context,
|
341
|
+
kind=kind,
|
342
|
+
attributes=attributes,
|
343
|
+
links=links,
|
344
|
+
start_time=start_time,
|
345
|
+
record_exception=record_exception,
|
346
|
+
set_status_on_exception=set_status_on_exception,
|
347
|
+
end_on_exit=end_on_exit,
|
348
|
+
) as span:
|
349
|
+
if input is not None:
|
350
|
+
span.set_attribute(
|
351
|
+
SpanAttributes.TRACELOOP_ENTITY_INPUT,
|
352
|
+
json.dumps({"input": input}),
|
353
|
+
)
|
354
|
+
yield span
|
355
|
+
|
287
356
|
@classmethod
|
288
357
|
def start_span(
|
289
358
|
cls,
|
@@ -330,7 +399,7 @@ class Laminar:
|
|
330
399
|
"""
|
331
400
|
if output is not None:
|
332
401
|
span.set_attribute(
|
333
|
-
SpanAttributes.TRACELOOP_ENTITY_OUTPUT, json.dumps(
|
402
|
+
SpanAttributes.TRACELOOP_ENTITY_OUTPUT, json.dumps(output)
|
334
403
|
)
|
335
404
|
|
336
405
|
@classmethod
|
@@ -448,6 +517,7 @@ class Laminar:
|
|
448
517
|
|
449
518
|
@classmethod
|
450
519
|
def _headers(cls):
|
520
|
+
assert cls.__project_api_key is not None, "Project API key is not set"
|
451
521
|
return {
|
452
522
|
"Authorization": "Bearer " + cls.__project_api_key,
|
453
523
|
"Content-Type": "application/json",
|
@@ -0,0 +1 @@
|
|
1
|
+
3.9.5
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# traceloop-sdk
|
2
|
+
|
3
|
+
Traceloop’s Python SDK allows you to easily start monitoring and debugging your LLM execution. Tracing is done in a non-intrusive way, built on top of OpenTelemetry. You can choose to export the traces to Traceloop, or to your existing observability stack.
|
4
|
+
|
5
|
+
```python
|
6
|
+
Traceloop.init(app_name="joke_generation_service")
|
7
|
+
|
8
|
+
@workflow(name="joke_creation")
|
9
|
+
def create_joke():
|
10
|
+
completion = openai.ChatCompletion.create(
|
11
|
+
model="gpt-3.5-turbo",
|
12
|
+
messages=[{"role": "user", "content": "Tell me a joke about opentelemetry"}],
|
13
|
+
)
|
14
|
+
|
15
|
+
return completion.choices[0].message.content
|
16
|
+
```
|
@@ -0,0 +1,138 @@
|
|
1
|
+
import os
|
2
|
+
import sys
|
3
|
+
from pathlib import Path
|
4
|
+
|
5
|
+
from typing import Optional, Set
|
6
|
+
from colorama import Fore
|
7
|
+
from opentelemetry.sdk.trace import SpanProcessor
|
8
|
+
from opentelemetry.sdk.trace.export import SpanExporter
|
9
|
+
from opentelemetry.sdk.metrics.export import MetricExporter
|
10
|
+
from opentelemetry.sdk.resources import SERVICE_NAME
|
11
|
+
from opentelemetry.propagators.textmap import TextMapPropagator
|
12
|
+
from opentelemetry.util.re import parse_env_headers
|
13
|
+
|
14
|
+
from lmnr.traceloop_sdk.metrics.metrics import MetricsWrapper
|
15
|
+
from lmnr.traceloop_sdk.instruments import Instruments
|
16
|
+
from lmnr.traceloop_sdk.config import (
|
17
|
+
is_content_tracing_enabled,
|
18
|
+
is_tracing_enabled,
|
19
|
+
is_metrics_enabled,
|
20
|
+
)
|
21
|
+
from lmnr.traceloop_sdk.tracing.tracing import (
|
22
|
+
TracerWrapper,
|
23
|
+
set_association_properties,
|
24
|
+
set_external_prompt_tracing_context,
|
25
|
+
)
|
26
|
+
from typing import Dict
|
27
|
+
|
28
|
+
|
29
|
+
class Traceloop:
|
30
|
+
AUTO_CREATED_KEY_PATH = str(
|
31
|
+
Path.home() / ".cache" / "traceloop" / "auto_created_key"
|
32
|
+
)
|
33
|
+
AUTO_CREATED_URL = str(Path.home() / ".cache" / "traceloop" / "auto_created_url")
|
34
|
+
|
35
|
+
__tracer_wrapper: TracerWrapper
|
36
|
+
|
37
|
+
@staticmethod
|
38
|
+
def init(
|
39
|
+
app_name: Optional[str] = sys.argv[0],
|
40
|
+
api_endpoint: str = "https://api.lmnr.ai",
|
41
|
+
api_key: str = None,
|
42
|
+
headers: Dict[str, str] = {},
|
43
|
+
disable_batch=False,
|
44
|
+
exporter: SpanExporter = None,
|
45
|
+
metrics_exporter: MetricExporter = None,
|
46
|
+
metrics_headers: Dict[str, str] = None,
|
47
|
+
processor: SpanProcessor = None,
|
48
|
+
propagator: TextMapPropagator = None,
|
49
|
+
should_enrich_metrics: bool = True,
|
50
|
+
resource_attributes: dict = {},
|
51
|
+
instruments: Optional[Set[Instruments]] = None,
|
52
|
+
) -> None:
|
53
|
+
api_endpoint = os.getenv("TRACELOOP_BASE_URL") or api_endpoint
|
54
|
+
api_key = os.getenv("TRACELOOP_API_KEY") or api_key
|
55
|
+
|
56
|
+
if not is_tracing_enabled():
|
57
|
+
print(Fore.YELLOW + "Tracing is disabled" + Fore.RESET)
|
58
|
+
return
|
59
|
+
|
60
|
+
enable_content_tracing = is_content_tracing_enabled()
|
61
|
+
|
62
|
+
if exporter or processor:
|
63
|
+
print(Fore.GREEN + "Laminar exporting traces to a custom exporter")
|
64
|
+
|
65
|
+
headers = os.getenv("TRACELOOP_HEADERS") or headers
|
66
|
+
|
67
|
+
if isinstance(headers, str):
|
68
|
+
headers = parse_env_headers(headers)
|
69
|
+
|
70
|
+
if (
|
71
|
+
not exporter
|
72
|
+
and not processor
|
73
|
+
and api_endpoint == "https://api.lmnr.ai"
|
74
|
+
and not api_key
|
75
|
+
):
|
76
|
+
print(
|
77
|
+
Fore.RED
|
78
|
+
+ "Error: Missing API key,"
|
79
|
+
+ " go to project settings to create one"
|
80
|
+
)
|
81
|
+
print("Set the LMNR_PROJECT_API_KEY environment variable to the key")
|
82
|
+
print(Fore.RESET)
|
83
|
+
return
|
84
|
+
|
85
|
+
if not exporter and not processor and headers:
|
86
|
+
print(
|
87
|
+
Fore.GREEN
|
88
|
+
+ f"Laminar exporting traces to {api_endpoint}, authenticating with custom headers"
|
89
|
+
)
|
90
|
+
|
91
|
+
if api_key and not exporter and not processor and not headers:
|
92
|
+
print(
|
93
|
+
Fore.GREEN
|
94
|
+
+ f"Laminar exporting traces to {api_endpoint} authenticating with bearer token"
|
95
|
+
)
|
96
|
+
headers = {
|
97
|
+
"Authorization": f"Bearer {api_key}",
|
98
|
+
}
|
99
|
+
|
100
|
+
print(Fore.RESET)
|
101
|
+
|
102
|
+
# Tracer init
|
103
|
+
resource_attributes.update({SERVICE_NAME: app_name})
|
104
|
+
TracerWrapper.set_static_params(
|
105
|
+
resource_attributes, enable_content_tracing, api_endpoint, headers
|
106
|
+
)
|
107
|
+
Traceloop.__tracer_wrapper = TracerWrapper(
|
108
|
+
disable_batch=disable_batch,
|
109
|
+
processor=processor,
|
110
|
+
propagator=propagator,
|
111
|
+
exporter=exporter,
|
112
|
+
should_enrich_metrics=should_enrich_metrics,
|
113
|
+
instruments=instruments,
|
114
|
+
)
|
115
|
+
|
116
|
+
if not metrics_exporter and exporter:
|
117
|
+
return
|
118
|
+
|
119
|
+
metrics_endpoint = os.getenv("TRACELOOP_METRICS_ENDPOINT") or api_endpoint
|
120
|
+
metrics_headers = (
|
121
|
+
os.getenv("TRACELOOP_METRICS_HEADERS") or metrics_headers or headers
|
122
|
+
)
|
123
|
+
|
124
|
+
if not is_metrics_enabled() or not metrics_exporter and exporter:
|
125
|
+
print(Fore.YELLOW + "Metrics are disabled" + Fore.RESET)
|
126
|
+
return
|
127
|
+
|
128
|
+
MetricsWrapper.set_static_params(
|
129
|
+
resource_attributes, metrics_endpoint, metrics_headers
|
130
|
+
)
|
131
|
+
|
132
|
+
Traceloop.__metrics_wrapper = MetricsWrapper(exporter=metrics_exporter)
|
133
|
+
|
134
|
+
def set_association_properties(properties: dict) -> None:
|
135
|
+
set_association_properties(properties)
|
136
|
+
|
137
|
+
def set_prompt(template: str, variables: dict, version: int):
|
138
|
+
set_external_prompt_tracing_context(template, variables, version)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import os
|
2
|
+
|
3
|
+
|
4
|
+
def is_tracing_enabled() -> bool:
|
5
|
+
return (os.getenv("TRACELOOP_TRACING_ENABLED") or "true").lower() == "true"
|
6
|
+
|
7
|
+
|
8
|
+
def is_content_tracing_enabled() -> bool:
|
9
|
+
return (os.getenv("TRACELOOP_TRACE_CONTENT") or "true").lower() == "true"
|
10
|
+
|
11
|
+
|
12
|
+
def is_metrics_enabled() -> bool:
|
13
|
+
return (os.getenv("TRACELOOP_METRICS_ENABLED") or "true").lower() == "true"
|
@@ -0,0 +1,131 @@
|
|
1
|
+
from typing import Optional
|
2
|
+
|
3
|
+
from opentelemetry.semconv_ai import TraceloopSpanKindValues
|
4
|
+
|
5
|
+
from lmnr.traceloop_sdk.decorators.base import (
|
6
|
+
aentity_class,
|
7
|
+
aentity_method,
|
8
|
+
entity_class,
|
9
|
+
entity_method,
|
10
|
+
)
|
11
|
+
|
12
|
+
|
13
|
+
def task(
|
14
|
+
name: Optional[str] = None,
|
15
|
+
version: Optional[int] = None,
|
16
|
+
method_name: Optional[str] = None,
|
17
|
+
tlp_span_kind: Optional[TraceloopSpanKindValues] = TraceloopSpanKindValues.TASK,
|
18
|
+
):
|
19
|
+
if method_name is None:
|
20
|
+
return entity_method(name=name, version=version, tlp_span_kind=tlp_span_kind)
|
21
|
+
else:
|
22
|
+
return entity_class(
|
23
|
+
name=name,
|
24
|
+
version=version,
|
25
|
+
method_name=method_name,
|
26
|
+
tlp_span_kind=tlp_span_kind,
|
27
|
+
)
|
28
|
+
|
29
|
+
|
30
|
+
def workflow(
|
31
|
+
name: Optional[str] = None,
|
32
|
+
version: Optional[int] = None,
|
33
|
+
method_name: Optional[str] = None,
|
34
|
+
tlp_span_kind: Optional[TraceloopSpanKindValues] = TraceloopSpanKindValues.WORKFLOW,
|
35
|
+
):
|
36
|
+
if method_name is None:
|
37
|
+
return entity_method(name=name, version=version, tlp_span_kind=tlp_span_kind)
|
38
|
+
else:
|
39
|
+
return entity_class(
|
40
|
+
name=name,
|
41
|
+
version=version,
|
42
|
+
method_name=method_name,
|
43
|
+
tlp_span_kind=tlp_span_kind,
|
44
|
+
)
|
45
|
+
|
46
|
+
|
47
|
+
def agent(
|
48
|
+
name: Optional[str] = None,
|
49
|
+
version: Optional[int] = None,
|
50
|
+
method_name: Optional[str] = None,
|
51
|
+
):
|
52
|
+
return workflow(
|
53
|
+
name=name,
|
54
|
+
version=version,
|
55
|
+
method_name=method_name,
|
56
|
+
tlp_span_kind=TraceloopSpanKindValues.AGENT,
|
57
|
+
)
|
58
|
+
|
59
|
+
|
60
|
+
def tool(
|
61
|
+
name: Optional[str] = None,
|
62
|
+
version: Optional[int] = None,
|
63
|
+
method_name: Optional[str] = None,
|
64
|
+
):
|
65
|
+
return task(
|
66
|
+
name=name,
|
67
|
+
version=version,
|
68
|
+
method_name=method_name,
|
69
|
+
tlp_span_kind=TraceloopSpanKindValues.TOOL,
|
70
|
+
)
|
71
|
+
|
72
|
+
|
73
|
+
# Async Decorators
|
74
|
+
def atask(
|
75
|
+
name: Optional[str] = None,
|
76
|
+
version: Optional[int] = None,
|
77
|
+
method_name: Optional[str] = None,
|
78
|
+
tlp_span_kind: Optional[TraceloopSpanKindValues] = TraceloopSpanKindValues.TASK,
|
79
|
+
):
|
80
|
+
if method_name is None:
|
81
|
+
return aentity_method(name=name, version=version, tlp_span_kind=tlp_span_kind)
|
82
|
+
else:
|
83
|
+
return aentity_class(
|
84
|
+
name=name,
|
85
|
+
version=version,
|
86
|
+
method_name=method_name,
|
87
|
+
tlp_span_kind=tlp_span_kind,
|
88
|
+
)
|
89
|
+
|
90
|
+
|
91
|
+
def aworkflow(
|
92
|
+
name: Optional[str] = None,
|
93
|
+
version: Optional[int] = None,
|
94
|
+
method_name: Optional[str] = None,
|
95
|
+
tlp_span_kind: Optional[TraceloopSpanKindValues] = TraceloopSpanKindValues.WORKFLOW,
|
96
|
+
):
|
97
|
+
if method_name is None:
|
98
|
+
return aentity_method(name=name, version=version, tlp_span_kind=tlp_span_kind)
|
99
|
+
else:
|
100
|
+
return aentity_class(
|
101
|
+
name=name,
|
102
|
+
version=version,
|
103
|
+
method_name=method_name,
|
104
|
+
tlp_span_kind=tlp_span_kind,
|
105
|
+
)
|
106
|
+
|
107
|
+
|
108
|
+
def aagent(
|
109
|
+
name: Optional[str] = None,
|
110
|
+
version: Optional[int] = None,
|
111
|
+
method_name: Optional[str] = None,
|
112
|
+
):
|
113
|
+
return atask(
|
114
|
+
name=name,
|
115
|
+
version=version,
|
116
|
+
method_name=method_name,
|
117
|
+
tlp_span_kind=TraceloopSpanKindValues.AGENT,
|
118
|
+
)
|
119
|
+
|
120
|
+
|
121
|
+
def atool(
|
122
|
+
name: Optional[str] = None,
|
123
|
+
version: Optional[int] = None,
|
124
|
+
method_name: Optional[str] = None,
|
125
|
+
):
|
126
|
+
return atask(
|
127
|
+
name=name,
|
128
|
+
version=version,
|
129
|
+
method_name=method_name,
|
130
|
+
tlp_span_kind=TraceloopSpanKindValues.TOOL,
|
131
|
+
)
|