simplai-sdk 0.1.0__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.
- billing/__init__.py +6 -0
- billing/api.py +55 -0
- billing/client.py +14 -0
- billing/schema.py +15 -0
- constants/__init__.py +90 -0
- core/__init__.py +53 -0
- core/agents/__init__.py +42 -0
- core/agents/execution/__init__.py +49 -0
- core/agents/execution/api.py +283 -0
- core/agents/execution/client.py +1139 -0
- core/agents/models.py +99 -0
- core/workflows/WORKFLOW_ARCHITECTURE.md +417 -0
- core/workflows/__init__.py +31 -0
- core/workflows/bulk/__init__.py +14 -0
- core/workflows/bulk/api.py +202 -0
- core/workflows/bulk/client.py +115 -0
- core/workflows/bulk/schema.py +58 -0
- core/workflows/models.py +49 -0
- core/workflows/scheduling/__init__.py +9 -0
- core/workflows/scheduling/api.py +179 -0
- core/workflows/scheduling/client.py +128 -0
- core/workflows/scheduling/schema.py +74 -0
- core/workflows/tool_execution/__init__.py +16 -0
- core/workflows/tool_execution/api.py +172 -0
- core/workflows/tool_execution/client.py +195 -0
- core/workflows/tool_execution/schema.py +40 -0
- exceptions/__init__.py +21 -0
- simplai_sdk/__init__.py +7 -0
- simplai_sdk/simplai.py +239 -0
- simplai_sdk-0.1.0.dist-info/METADATA +728 -0
- simplai_sdk-0.1.0.dist-info/RECORD +42 -0
- simplai_sdk-0.1.0.dist-info/WHEEL +5 -0
- simplai_sdk-0.1.0.dist-info/licenses/LICENSE +21 -0
- simplai_sdk-0.1.0.dist-info/top_level.txt +7 -0
- traces/__init__.py +1 -0
- traces/agents/__init__.py +55 -0
- traces/agents/api.py +350 -0
- traces/agents/client.py +697 -0
- traces/agents/models.py +249 -0
- traces/workflows/__init__.py +0 -0
- utils/__init__.py +0 -0
- utils/config.py +117 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
billing/__init__.py,sha256=MyTlI603pQk0PZ6lQawQU71Wcz-CZpPW_5X3qef0evQ,80
|
|
2
|
+
billing/api.py,sha256=eC2TEWFsQs_-J-M_1jz_Ks0r8hx1RJIYT5WtC_6vgPg,1534
|
|
3
|
+
billing/client.py,sha256=IUGiu6VDC2c0tjyJ19BLcxTwqoeUidMZBXmTkioQBQY,393
|
|
4
|
+
billing/schema.py,sha256=9oZUQOnAJCD4aLDATpP-YB982RPv70zxv8PeYLjuubU,515
|
|
5
|
+
constants/__init__.py,sha256=ZMjr4ruppIFAZoF8ufmFD3bXKTt3TC8wGGIH3FOhBIY,3266
|
|
6
|
+
core/__init__.py,sha256=tDi8hErxnY2cL_qMU1iGdInXRwbwS7V4iwc5KHWUlho,1125
|
|
7
|
+
core/agents/__init__.py,sha256=slYJzoWIckLXraVmjyT6mnUcJ_CFYNxYfn9xBNr5Kjk,1006
|
|
8
|
+
core/agents/models.py,sha256=oX0dkQXqB49304c4PrQ-oQp2_kw3ZNZW0XaHoKsvChs,2904
|
|
9
|
+
core/agents/execution/__init__.py,sha256=3H5kf-EhHVqkj4mCGcOnuCzO10FlhQ7PSJNnCQxSFxU,1235
|
|
10
|
+
core/agents/execution/api.py,sha256=y0zEVH0yV3FzCU2V3Ra6q62qy_jRV5C1IavPkw1jvKg,8946
|
|
11
|
+
core/agents/execution/client.py,sha256=srLLq8-I6TDX72FORrGxTw1v1sM8zaLqojt9Ni3Nf2U,51572
|
|
12
|
+
core/workflows/WORKFLOW_ARCHITECTURE.md,sha256=yq_K6r3fcAlE0RwHyrtNcQ-PZlGMtQQAZLtnavDzNPw,13987
|
|
13
|
+
core/workflows/__init__.py,sha256=QXBj6GNykRIdzmmeIEmzOvnvdcgbVOxcjgLxBCy5MX8,668
|
|
14
|
+
core/workflows/models.py,sha256=WMkgQHEvEkKTx5rGbgMWa_Ti9FHDWAKDcX_amEuJxK8,1248
|
|
15
|
+
core/workflows/bulk/__init__.py,sha256=H3XFE08_5K8Dl-XizeOAcDg3Fu1EM5OQ_uOzwrCyddg,337
|
|
16
|
+
core/workflows/bulk/api.py,sha256=gWiHMfTagbEF04t_L0_A7PtN2vse4kYa7L0g_OnysME,6146
|
|
17
|
+
core/workflows/bulk/client.py,sha256=e7gY83nO4L1v5rvOj5zWM2Z6c41u96Yeh53_mRgsm10,3034
|
|
18
|
+
core/workflows/bulk/schema.py,sha256=Snj-iCYTJcjdHoAXv4HWwDpza2KRGH2LgecHBVae8mI,2422
|
|
19
|
+
core/workflows/scheduling/__init__.py,sha256=GKt7x5ww1Nf98bZOdZ8V4XRo97CFep5sGqK70bVXkpQ,179
|
|
20
|
+
core/workflows/scheduling/api.py,sha256=M-EEPTdwiLCajW-lwWkdgn3xDHYpEFmPkB5XdQSvzto,5965
|
|
21
|
+
core/workflows/scheduling/client.py,sha256=Blbn1sS7eA97MUD8gvufvQ9uo2y0g8si784Erbterss,4085
|
|
22
|
+
core/workflows/scheduling/schema.py,sha256=7V4-uRxXX84d6eZUvDW3oSPg2er3YFDOlSWJRbK29e0,3355
|
|
23
|
+
core/workflows/tool_execution/__init__.py,sha256=Z59MhfZbHYvBtxGcQupXT5Pt5As6tn1kKwf2d7N5iLw,292
|
|
24
|
+
core/workflows/tool_execution/api.py,sha256=sgl5l87mDmaAZoye-ejR4usPb2_wI7LdM8OZVLqMIdg,5119
|
|
25
|
+
core/workflows/tool_execution/client.py,sha256=lFXXsVgz_VDxWfBQ42ZNo8UcTOV7RumML6szW6s_ewQ,5256
|
|
26
|
+
core/workflows/tool_execution/schema.py,sha256=To8uVGFNULcdupaCZbYnJTu4azAGTv0so75wuVdCKrI,1502
|
|
27
|
+
exceptions/__init__.py,sha256=bUAIwVmyYtHhPvHOpO7LAYRJrzhY9N_KMB3-AfZCUlU,522
|
|
28
|
+
simplai_sdk/__init__.py,sha256=vT8U1gQbTS4xXFyoVU767IMh9-5ZVqPaNjL5gF8YFKU,121
|
|
29
|
+
simplai_sdk/simplai.py,sha256=U-jf1E4ygd6fyKNx6lMqy79_F2Fh15dAzW4E-pFOISY,8116
|
|
30
|
+
simplai_sdk-0.1.0.dist-info/licenses/LICENSE,sha256=byn2pn7QZM4hs8uCv8VSaiZ1XTk5KrpNSWZ7hYc2EpY,1064
|
|
31
|
+
traces/__init__.py,sha256=Wn1H6KU_JXIGlj-O0NBkz9lykh3Axwj9UqJf7Sa5QMk,37
|
|
32
|
+
traces/agents/__init__.py,sha256=wzwdX5Bxkol_ikS6x2M5wyM_zEAzlbM0NP6dJI9LmTU,1087
|
|
33
|
+
traces/agents/api.py,sha256=Afv_blHayN1GwBxaSmcyTgugioyg62E9Fg67xsBNTeA,10730
|
|
34
|
+
traces/agents/client.py,sha256=BxZUOFk7OMGelsK8bRts6my2n4UchCI2bUIEhUXiEXA,24975
|
|
35
|
+
traces/agents/models.py,sha256=HVxHQJtixau-B0x0OwwUexnaJuOsKrAYkXRAtoPg0cs,8629
|
|
36
|
+
traces/workflows/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
37
|
+
utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
38
|
+
utils/config.py,sha256=uaEGZ3QfYOhKK34d5RBbuIVP18Lue2ZcLz-Hpuv_p_c,3354
|
|
39
|
+
simplai_sdk-0.1.0.dist-info/METADATA,sha256=5RVEFOafHbdkvTT3zDWoZ-YoFLwt_Syuc-Oxb2jLnS8,23617
|
|
40
|
+
simplai_sdk-0.1.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
41
|
+
simplai_sdk-0.1.0.dist-info/top_level.txt,sha256=CznxFBTncbDBZKLnqjDee5bfUXPKrrKXD4qVKq54SeA,59
|
|
42
|
+
simplai_sdk-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 SimplAI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
traces/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Traces module for SimplAI SDK."""
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"""Simplai Tracing APIs for agents.
|
|
2
|
+
|
|
3
|
+
This module provides APIs for fetching and analyzing traces from agent conversations.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from .api import (
|
|
7
|
+
fetch_traces,
|
|
8
|
+
get_trace_details,
|
|
9
|
+
fetch_trace_nodes,
|
|
10
|
+
get_aggregate_output,
|
|
11
|
+
get_trace_tree,
|
|
12
|
+
get_trace_node_details,
|
|
13
|
+
download_traces,
|
|
14
|
+
get_agent_metrics,
|
|
15
|
+
get_tool_metrics,
|
|
16
|
+
)
|
|
17
|
+
from .client import TraceClient
|
|
18
|
+
from .models import (
|
|
19
|
+
EvalMetrics,
|
|
20
|
+
FetchTraceFilters,
|
|
21
|
+
MetricsRequestDto,
|
|
22
|
+
PageableResponse,
|
|
23
|
+
RagTrace,
|
|
24
|
+
TraceData,
|
|
25
|
+
TraceError,
|
|
26
|
+
TraceFilters,
|
|
27
|
+
TraceNode,
|
|
28
|
+
ChildInfo,
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
__all__ = [
|
|
32
|
+
# API functions
|
|
33
|
+
"fetch_traces",
|
|
34
|
+
"get_trace_details",
|
|
35
|
+
"fetch_trace_nodes",
|
|
36
|
+
"get_aggregate_output",
|
|
37
|
+
"get_trace_tree",
|
|
38
|
+
"get_trace_node_details",
|
|
39
|
+
"download_traces",
|
|
40
|
+
"get_agent_metrics",
|
|
41
|
+
"get_tool_metrics",
|
|
42
|
+
# Client
|
|
43
|
+
"TraceClient",
|
|
44
|
+
# Models
|
|
45
|
+
"EvalMetrics",
|
|
46
|
+
"FetchTraceFilters",
|
|
47
|
+
"MetricsRequestDto",
|
|
48
|
+
"PageableResponse",
|
|
49
|
+
"RagTrace",
|
|
50
|
+
"TraceData",
|
|
51
|
+
"TraceError",
|
|
52
|
+
"TraceFilters",
|
|
53
|
+
"TraceNode",
|
|
54
|
+
"ChildInfo",
|
|
55
|
+
]
|
traces/agents/api.py
ADDED
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
from typing import Any, Dict, List, Optional, Union
|
|
5
|
+
|
|
6
|
+
from utils.config import get_api_key, get_base_url
|
|
7
|
+
|
|
8
|
+
from .client import TraceClient
|
|
9
|
+
from constants import DEFAULT_BASE_URL
|
|
10
|
+
from .models import (
|
|
11
|
+
FetchTraceFilters,
|
|
12
|
+
MetricsRequestDto,
|
|
13
|
+
PageableResponse,
|
|
14
|
+
RagTrace,
|
|
15
|
+
TraceError,
|
|
16
|
+
TraceFilters,
|
|
17
|
+
TraceNode,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def fetch_traces(
|
|
22
|
+
*,
|
|
23
|
+
api_key: Optional[str] = None,
|
|
24
|
+
filters: Optional[FetchTraceFilters] = None,
|
|
25
|
+
page: int = 0,
|
|
26
|
+
size: int = 20,
|
|
27
|
+
sort: str = "id",
|
|
28
|
+
direction: str = "DESC",
|
|
29
|
+
base_url: Optional[str] = None,
|
|
30
|
+
user_id: Optional[str] = None,
|
|
31
|
+
tenant_id: str = "1",
|
|
32
|
+
project_id: Optional[int] = None,
|
|
33
|
+
) -> PageableResponse:
|
|
34
|
+
"""Fetch paginated request-level traces (RAG traces).
|
|
35
|
+
|
|
36
|
+
Args:
|
|
37
|
+
api_key: PIM-SID API key.
|
|
38
|
+
filters: Optional filters for querying traces.
|
|
39
|
+
page: Page number (0-indexed).
|
|
40
|
+
size: Page size.
|
|
41
|
+
sort: Sort field.
|
|
42
|
+
direction: Sort direction (ASC or DESC).
|
|
43
|
+
base_url: Override the default base URL if needed.
|
|
44
|
+
user_id: Optional user ID for trace operations.
|
|
45
|
+
tenant_id: Tenant ID (defaults to "1").
|
|
46
|
+
project_id: Optional project ID.
|
|
47
|
+
|
|
48
|
+
Returns:
|
|
49
|
+
PageableResponse containing paginated RagTrace objects.
|
|
50
|
+
"""
|
|
51
|
+
client = TraceClient(
|
|
52
|
+
api_key=get_api_key(api_key),
|
|
53
|
+
base_url=get_base_url(base_url),
|
|
54
|
+
user_id=user_id,
|
|
55
|
+
tenant_id=tenant_id,
|
|
56
|
+
project_id=project_id,
|
|
57
|
+
)
|
|
58
|
+
return client.fetch_traces(filters=filters, page=page, size=size, sort=sort, direction=direction)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def get_trace_details(
|
|
62
|
+
*,
|
|
63
|
+
api_key: Optional[str] = None,
|
|
64
|
+
trace_id: Optional[str] = None,
|
|
65
|
+
request_id: Optional[str] = None,
|
|
66
|
+
base_url: Optional[str] = None,
|
|
67
|
+
user_id: Optional[str] = None,
|
|
68
|
+
tenant_id: str = "1",
|
|
69
|
+
project_id: Optional[int] = None,
|
|
70
|
+
) -> RagTrace:
|
|
71
|
+
"""Get details of a specific request-level trace.
|
|
72
|
+
|
|
73
|
+
Args:
|
|
74
|
+
api_key: PIM-SID API key.
|
|
75
|
+
trace_id: Trace ID (optional, but either trace_id or request_id required).
|
|
76
|
+
request_id: Request ID (optional, but either trace_id or request_id required).
|
|
77
|
+
base_url: Override the default base URL if needed.
|
|
78
|
+
user_id: Optional user ID for trace operations.
|
|
79
|
+
tenant_id: Tenant ID (defaults to "1").
|
|
80
|
+
project_id: Optional project ID.
|
|
81
|
+
|
|
82
|
+
Returns:
|
|
83
|
+
RagTrace object with full details.
|
|
84
|
+
"""
|
|
85
|
+
client = TraceClient(
|
|
86
|
+
api_key=get_api_key(api_key),
|
|
87
|
+
base_url=get_base_url(base_url),
|
|
88
|
+
user_id=user_id,
|
|
89
|
+
tenant_id=tenant_id,
|
|
90
|
+
project_id=project_id,
|
|
91
|
+
)
|
|
92
|
+
return client.get_trace_details(trace_id=trace_id, request_id=request_id)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def fetch_trace_nodes(
|
|
96
|
+
*,
|
|
97
|
+
api_key: Optional[str] = None,
|
|
98
|
+
filters: Optional[TraceFilters] = None,
|
|
99
|
+
page: int = 0,
|
|
100
|
+
size: int = 20,
|
|
101
|
+
sort: str = "id",
|
|
102
|
+
direction: str = "DESC",
|
|
103
|
+
base_url: Optional[str] = None,
|
|
104
|
+
user_id: Optional[str] = None,
|
|
105
|
+
tenant_id: str = "1",
|
|
106
|
+
project_id: Optional[int] = None,
|
|
107
|
+
) -> PageableResponse:
|
|
108
|
+
"""Fetch paginated tree-based trace nodes (root traces).
|
|
109
|
+
|
|
110
|
+
Args:
|
|
111
|
+
api_key: PIM-SID API key.
|
|
112
|
+
filters: Optional filters for querying traces.
|
|
113
|
+
page: Page number (0-indexed).
|
|
114
|
+
size: Page size.
|
|
115
|
+
sort: Sort field.
|
|
116
|
+
direction: Sort direction (ASC or DESC).
|
|
117
|
+
base_url: Override the default base URL if needed.
|
|
118
|
+
user_id: Optional user ID for trace operations.
|
|
119
|
+
tenant_id: Tenant ID (defaults to "1").
|
|
120
|
+
project_id: Optional project ID.
|
|
121
|
+
|
|
122
|
+
Returns:
|
|
123
|
+
PageableResponse containing paginated TraceNode objects.
|
|
124
|
+
"""
|
|
125
|
+
client = TraceClient(
|
|
126
|
+
api_key=get_api_key(api_key),
|
|
127
|
+
base_url=get_base_url(base_url),
|
|
128
|
+
user_id=user_id,
|
|
129
|
+
tenant_id=tenant_id,
|
|
130
|
+
project_id=project_id,
|
|
131
|
+
)
|
|
132
|
+
return client.fetch_trace_nodes(filters=filters, page=page, size=size, sort=sort, direction=direction)
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def get_aggregate_output(
|
|
136
|
+
*,
|
|
137
|
+
api_key: Optional[str] = None,
|
|
138
|
+
filters: Optional[TraceFilters] = None,
|
|
139
|
+
page: int = 0,
|
|
140
|
+
size: int = 20,
|
|
141
|
+
sort: str = "id",
|
|
142
|
+
direction: str = "DESC",
|
|
143
|
+
base_url: Optional[str] = None,
|
|
144
|
+
user_id: Optional[str] = None,
|
|
145
|
+
tenant_id: str = "1",
|
|
146
|
+
project_id: Optional[int] = None,
|
|
147
|
+
) -> Dict[str, Any]:
|
|
148
|
+
"""Get aggregate output traces (summary view).
|
|
149
|
+
|
|
150
|
+
Args:
|
|
151
|
+
api_key: PIM-SID API key.
|
|
152
|
+
filters: Optional filters for querying traces.
|
|
153
|
+
page: Page number (0-indexed).
|
|
154
|
+
size: Page size.
|
|
155
|
+
sort: Sort field.
|
|
156
|
+
direction: Sort direction (ASC or DESC).
|
|
157
|
+
base_url: Override the default base URL if needed.
|
|
158
|
+
user_id: Optional user ID for trace operations.
|
|
159
|
+
tenant_id: Tenant ID (defaults to "1").
|
|
160
|
+
project_id: Optional project ID.
|
|
161
|
+
|
|
162
|
+
Returns:
|
|
163
|
+
Dictionary containing aggregate trace data.
|
|
164
|
+
"""
|
|
165
|
+
client = TraceClient(
|
|
166
|
+
api_key=get_api_key(api_key),
|
|
167
|
+
base_url=get_base_url(base_url),
|
|
168
|
+
user_id=user_id,
|
|
169
|
+
tenant_id=tenant_id,
|
|
170
|
+
project_id=project_id,
|
|
171
|
+
)
|
|
172
|
+
return client.get_aggregate_output(filters=filters, page=page, size=size, sort=sort, direction=direction)
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def get_trace_tree(
|
|
176
|
+
*,
|
|
177
|
+
api_key: Optional[str] = None,
|
|
178
|
+
tree_id: str,
|
|
179
|
+
node_id: str,
|
|
180
|
+
max_depth: Optional[int] = None,
|
|
181
|
+
base_url: Optional[str] = None,
|
|
182
|
+
user_id: Optional[str] = None,
|
|
183
|
+
tenant_id: str = "1",
|
|
184
|
+
project_id: Optional[int] = None,
|
|
185
|
+
seller_id: Optional[str] = None,
|
|
186
|
+
client_id: Optional[str] = None,
|
|
187
|
+
seller_profile_id: Optional[str] = None,
|
|
188
|
+
raw_response: bool = False,
|
|
189
|
+
) -> Union[TraceNode, Dict[str, Any]]:
|
|
190
|
+
"""Get a trace sub-tree starting from a specific node.
|
|
191
|
+
|
|
192
|
+
Args:
|
|
193
|
+
api_key: PIM-SID API key.
|
|
194
|
+
tree_id: Tree ID of the trace.
|
|
195
|
+
node_id: Node ID to start the tree from.
|
|
196
|
+
max_depth: Maximum depth to traverse (optional).
|
|
197
|
+
base_url: Override the default base URL if needed.
|
|
198
|
+
user_id: Optional user ID for trace operations.
|
|
199
|
+
tenant_id: Tenant ID (defaults to "1").
|
|
200
|
+
project_id: Optional project ID.
|
|
201
|
+
seller_id: Optional seller ID.
|
|
202
|
+
client_id: Optional client ID.
|
|
203
|
+
seller_profile_id: Optional seller profile ID.
|
|
204
|
+
raw_response: If True, return raw JSON response instead of parsed TraceNode.
|
|
205
|
+
|
|
206
|
+
Returns:
|
|
207
|
+
TraceNode representing the root of the sub-tree, or raw JSON dict if raw_response=True.
|
|
208
|
+
"""
|
|
209
|
+
client = TraceClient(
|
|
210
|
+
api_key=get_api_key(api_key),
|
|
211
|
+
base_url=get_base_url(base_url),
|
|
212
|
+
user_id=user_id,
|
|
213
|
+
tenant_id=tenant_id,
|
|
214
|
+
project_id=project_id,
|
|
215
|
+
seller_id=seller_id,
|
|
216
|
+
client_id=client_id,
|
|
217
|
+
seller_profile_id=seller_profile_id,
|
|
218
|
+
)
|
|
219
|
+
return client.get_trace_tree(tree_id=tree_id, node_id=node_id, max_depth=max_depth, raw_response=raw_response)
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
def get_trace_node_details(
|
|
223
|
+
*,
|
|
224
|
+
api_key: Optional[str] = None,
|
|
225
|
+
tree_id: str,
|
|
226
|
+
node_id: str,
|
|
227
|
+
base_url: Optional[str] = None,
|
|
228
|
+
user_id: Optional[str] = None,
|
|
229
|
+
tenant_id: str = "1",
|
|
230
|
+
project_id: Optional[int] = None,
|
|
231
|
+
) -> TraceNode:
|
|
232
|
+
"""Get details of a specific trace node.
|
|
233
|
+
|
|
234
|
+
Args:
|
|
235
|
+
api_key: PIM-SID API key.
|
|
236
|
+
tree_id: Tree ID of the trace.
|
|
237
|
+
node_id: Node ID to get details for.
|
|
238
|
+
base_url: Override the default base URL if needed.
|
|
239
|
+
user_id: Optional user ID for trace operations.
|
|
240
|
+
tenant_id: Tenant ID (defaults to "1").
|
|
241
|
+
project_id: Optional project ID.
|
|
242
|
+
|
|
243
|
+
Returns:
|
|
244
|
+
TraceNode object with full details.
|
|
245
|
+
"""
|
|
246
|
+
client = TraceClient(
|
|
247
|
+
api_key=get_api_key(api_key),
|
|
248
|
+
base_url=get_base_url(base_url),
|
|
249
|
+
user_id=user_id,
|
|
250
|
+
tenant_id=tenant_id,
|
|
251
|
+
project_id=project_id,
|
|
252
|
+
)
|
|
253
|
+
return client.get_trace_node_details(tree_id=tree_id, node_id=node_id)
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
def download_traces(
|
|
257
|
+
*,
|
|
258
|
+
api_key: Optional[str] = None,
|
|
259
|
+
filters: Optional[TraceFilters] = None,
|
|
260
|
+
base_url: Optional[str] = None,
|
|
261
|
+
user_id: Optional[str] = None,
|
|
262
|
+
tenant_id: str = "1",
|
|
263
|
+
project_id: Optional[int] = None,
|
|
264
|
+
) -> bytes:
|
|
265
|
+
"""Download traces as CSV.
|
|
266
|
+
|
|
267
|
+
Args:
|
|
268
|
+
api_key: PIM-SID API key.
|
|
269
|
+
filters: Optional filters for querying traces.
|
|
270
|
+
base_url: Override the default base URL if needed.
|
|
271
|
+
user_id: Optional user ID for trace operations.
|
|
272
|
+
tenant_id: Tenant ID (defaults to "1").
|
|
273
|
+
project_id: Optional project ID.
|
|
274
|
+
|
|
275
|
+
Returns:
|
|
276
|
+
Bytes containing CSV file content.
|
|
277
|
+
"""
|
|
278
|
+
client = TraceClient(
|
|
279
|
+
api_key=get_api_key(api_key),
|
|
280
|
+
base_url=get_base_url(base_url),
|
|
281
|
+
user_id=user_id,
|
|
282
|
+
tenant_id=tenant_id,
|
|
283
|
+
project_id=project_id,
|
|
284
|
+
)
|
|
285
|
+
return client.download_traces(filters=filters)
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
def get_agent_metrics(
|
|
289
|
+
*,
|
|
290
|
+
api_key: Optional[str] = None,
|
|
291
|
+
metrics_request: Optional[MetricsRequestDto] = None,
|
|
292
|
+
base_url: Optional[str] = None,
|
|
293
|
+
user_id: Optional[str] = None,
|
|
294
|
+
tenant_id: str = "1",
|
|
295
|
+
project_id: Optional[int] = None,
|
|
296
|
+
) -> Dict[str, Any]:
|
|
297
|
+
"""Get agent-level metrics from traces.
|
|
298
|
+
|
|
299
|
+
Args:
|
|
300
|
+
api_key: PIM-SID API key.
|
|
301
|
+
metrics_request: Optional metrics request with filters.
|
|
302
|
+
base_url: Override the default base URL if needed.
|
|
303
|
+
user_id: Optional user ID for trace operations.
|
|
304
|
+
tenant_id: Tenant ID (defaults to "1").
|
|
305
|
+
project_id: Optional project ID.
|
|
306
|
+
|
|
307
|
+
Returns:
|
|
308
|
+
Dictionary containing aggregated agent metrics.
|
|
309
|
+
"""
|
|
310
|
+
client = TraceClient(
|
|
311
|
+
api_key=get_api_key(api_key),
|
|
312
|
+
base_url=get_base_url(base_url),
|
|
313
|
+
user_id=user_id,
|
|
314
|
+
tenant_id=tenant_id,
|
|
315
|
+
project_id=project_id,
|
|
316
|
+
)
|
|
317
|
+
return client.get_agent_metrics(metrics_request=metrics_request)
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
def get_tool_metrics(
|
|
321
|
+
*,
|
|
322
|
+
api_key: Optional[str] = None,
|
|
323
|
+
metrics_request: Optional[MetricsRequestDto] = None,
|
|
324
|
+
base_url: Optional[str] = None,
|
|
325
|
+
user_id: Optional[str] = None,
|
|
326
|
+
tenant_id: str = "1",
|
|
327
|
+
project_id: Optional[int] = None,
|
|
328
|
+
) -> Dict[str, Any]:
|
|
329
|
+
"""Get tool-level metrics from traces.
|
|
330
|
+
|
|
331
|
+
Args:
|
|
332
|
+
api_key: PIM-SID API key.
|
|
333
|
+
metrics_request: Optional metrics request with filters.
|
|
334
|
+
base_url: Override the default base URL if needed.
|
|
335
|
+
user_id: Optional user ID for trace operations.
|
|
336
|
+
tenant_id: Tenant ID (defaults to "1").
|
|
337
|
+
project_id: Optional project ID.
|
|
338
|
+
|
|
339
|
+
Returns:
|
|
340
|
+
Dictionary containing aggregated tool metrics.
|
|
341
|
+
"""
|
|
342
|
+
client = TraceClient(
|
|
343
|
+
api_key=get_api_key(api_key),
|
|
344
|
+
base_url=get_base_url(base_url),
|
|
345
|
+
user_id=user_id,
|
|
346
|
+
tenant_id=tenant_id,
|
|
347
|
+
project_id=project_id,
|
|
348
|
+
)
|
|
349
|
+
return client.get_tool_metrics(metrics_request=metrics_request)
|
|
350
|
+
|