scale-gp-beta 0.1.0a15__py3-none-any.whl → 0.1.0a17__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.
@@ -4,13 +4,19 @@ from __future__ import annotations
4
4
 
5
5
  from typing import Dict, Union, Iterable
6
6
  from datetime import datetime
7
- from typing_extensions import Literal, overload
7
+ from typing_extensions import Literal
8
8
 
9
9
  import httpx
10
10
 
11
- from ..types import span_list_params, span_batch_params, span_create_params, span_update_params
11
+ from ..types import (
12
+ span_batch_params,
13
+ span_create_params,
14
+ span_search_params,
15
+ span_update_params,
16
+ span_upsert_batch_params,
17
+ )
12
18
  from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
13
- from .._utils import required_args, maybe_transform, async_maybe_transform
19
+ from .._utils import maybe_transform, async_maybe_transform
14
20
  from .._compat import cached_property
15
21
  from .._resource import SyncAPIResource, AsyncAPIResource
16
22
  from .._response import (
@@ -19,9 +25,11 @@ from .._response import (
19
25
  async_to_raw_response_wrapper,
20
26
  async_to_streamed_response_wrapper,
21
27
  )
22
- from ..pagination import SyncCursorPage, AsyncCursorPage, SyncAPIListPage, AsyncAPIListPage
23
28
  from ..types.span import Span
24
- from .._base_client import AsyncPaginator, make_request_options
29
+ from .._base_client import make_request_options
30
+ from ..types.span_batch_response import SpanBatchResponse
31
+ from ..types.span_search_response import SpanSearchResponse
32
+ from ..types.span_upsert_batch_response import SpanUpsertBatchResponse
25
33
 
26
34
  __all__ = ["SpansResource", "AsyncSpansResource"]
27
35
 
@@ -46,7 +54,6 @@ class SpansResource(SyncAPIResource):
46
54
  """
47
55
  return SpansResourceWithStreamingResponse(self)
48
56
 
49
- @overload
50
57
  def create(
51
58
  self,
52
59
  *,
@@ -54,7 +61,10 @@ class SpansResource(SyncAPIResource):
54
61
  start_timestamp: Union[str, datetime],
55
62
  trace_id: str,
56
63
  id: str | NotGiven = NOT_GIVEN,
64
+ application_interaction_id: str | NotGiven = NOT_GIVEN,
65
+ application_variant_id: str | NotGiven = NOT_GIVEN,
57
66
  end_timestamp: Union[str, datetime] | NotGiven = NOT_GIVEN,
67
+ group_id: str | NotGiven = NOT_GIVEN,
58
68
  input: Dict[str, object] | NotGiven = NOT_GIVEN,
59
69
  metadata: Dict[str, object] | NotGiven = NOT_GIVEN,
60
70
  output: Dict[str, object] | NotGiven = NOT_GIVEN,
@@ -104,77 +114,11 @@ class SpansResource(SyncAPIResource):
104
114
 
105
115
  id: The id of the span
106
116
 
107
- parent_id: Reference to a parent span_id
108
-
109
- extra_headers: Send extra headers
110
-
111
- extra_query: Add additional query parameters to the request
117
+ application_interaction_id: The optional application interaction ID this span belongs to
112
118
 
113
- extra_body: Add additional JSON properties to the request
119
+ application_variant_id: The optional application variant ID this span belongs to
114
120
 
115
- timeout: Override the client-level default timeout for this request, in seconds
116
- """
117
- ...
118
-
119
- @overload
120
- def create(
121
- self,
122
- *,
123
- application_interaction_id: str,
124
- application_variant_id: str,
125
- name: str,
126
- start_timestamp: Union[str, datetime],
127
- trace_id: str,
128
- id: str | NotGiven = NOT_GIVEN,
129
- end_timestamp: Union[str, datetime] | NotGiven = NOT_GIVEN,
130
- input: Dict[str, object] | NotGiven = NOT_GIVEN,
131
- metadata: Dict[str, object] | NotGiven = NOT_GIVEN,
132
- output: Dict[str, object] | NotGiven = NOT_GIVEN,
133
- parent_id: str | NotGiven = NOT_GIVEN,
134
- status: Literal["SUCCESS", "ERROR"] | NotGiven = NOT_GIVEN,
135
- type: Literal[
136
- "TEXT_INPUT",
137
- "TEXT_OUTPUT",
138
- "COMPLETION_INPUT",
139
- "COMPLETION",
140
- "KB_RETRIEVAL",
141
- "KB_INPUT",
142
- "RERANKING",
143
- "EXTERNAL_ENDPOINT",
144
- "PROMPT_ENGINEERING",
145
- "DOCUMENT_INPUT",
146
- "MAP_REDUCE",
147
- "DOCUMENT_SEARCH",
148
- "DOCUMENT_PROMPT",
149
- "CUSTOM",
150
- "INPUT_GUARDRAIL",
151
- "OUTPUT_GUARDRAIL",
152
- "CODE_EXECUTION",
153
- "DATA_MANIPULATION",
154
- "EVALUATION",
155
- "FILE_RETRIEVAL",
156
- "KB_ADD_CHUNK",
157
- "KB_MANAGEMENT",
158
- "TRACER",
159
- "AGENT_TRACER",
160
- "AGENT_WORKFLOW",
161
- "STANDALONE",
162
- ]
163
- | NotGiven = NOT_GIVEN,
164
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
165
- # The extra values given here take precedence over values defined on the client or passed to this method.
166
- extra_headers: Headers | None = None,
167
- extra_query: Query | None = None,
168
- extra_body: Body | None = None,
169
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
170
- ) -> Span:
171
- """
172
- Create Span
173
-
174
- Args:
175
- trace_id: id for grouping traces together, uuid is recommended
176
-
177
- id: The id of the span
121
+ group_id: Reference to a group_id
178
122
 
179
123
  parent_id: Reference to a parent span_id
180
124
 
@@ -186,63 +130,6 @@ class SpansResource(SyncAPIResource):
186
130
 
187
131
  timeout: Override the client-level default timeout for this request, in seconds
188
132
  """
189
- ...
190
-
191
- @required_args(
192
- ["name", "start_timestamp", "trace_id"],
193
- ["application_interaction_id", "application_variant_id", "name", "start_timestamp", "trace_id"],
194
- )
195
- def create(
196
- self,
197
- *,
198
- name: str,
199
- start_timestamp: Union[str, datetime],
200
- trace_id: str,
201
- id: str | NotGiven = NOT_GIVEN,
202
- end_timestamp: Union[str, datetime] | NotGiven = NOT_GIVEN,
203
- input: Dict[str, object] | NotGiven = NOT_GIVEN,
204
- metadata: Dict[str, object] | NotGiven = NOT_GIVEN,
205
- output: Dict[str, object] | NotGiven = NOT_GIVEN,
206
- parent_id: str | NotGiven = NOT_GIVEN,
207
- status: Literal["SUCCESS", "ERROR"] | NotGiven = NOT_GIVEN,
208
- type: Literal[
209
- "TEXT_INPUT",
210
- "TEXT_OUTPUT",
211
- "COMPLETION_INPUT",
212
- "COMPLETION",
213
- "KB_RETRIEVAL",
214
- "KB_INPUT",
215
- "RERANKING",
216
- "EXTERNAL_ENDPOINT",
217
- "PROMPT_ENGINEERING",
218
- "DOCUMENT_INPUT",
219
- "MAP_REDUCE",
220
- "DOCUMENT_SEARCH",
221
- "DOCUMENT_PROMPT",
222
- "CUSTOM",
223
- "INPUT_GUARDRAIL",
224
- "OUTPUT_GUARDRAIL",
225
- "CODE_EXECUTION",
226
- "DATA_MANIPULATION",
227
- "EVALUATION",
228
- "FILE_RETRIEVAL",
229
- "KB_ADD_CHUNK",
230
- "KB_MANAGEMENT",
231
- "TRACER",
232
- "AGENT_TRACER",
233
- "AGENT_WORKFLOW",
234
- "STANDALONE",
235
- ]
236
- | NotGiven = NOT_GIVEN,
237
- application_interaction_id: str | NotGiven = NOT_GIVEN,
238
- application_variant_id: str | NotGiven = NOT_GIVEN,
239
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
240
- # The extra values given here take precedence over values defined on the client or passed to this method.
241
- extra_headers: Headers | None = None,
242
- extra_query: Query | None = None,
243
- extra_body: Body | None = None,
244
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
245
- ) -> Span:
246
133
  return self._post(
247
134
  "/v5/spans",
248
135
  body=maybe_transform(
@@ -251,15 +138,16 @@ class SpansResource(SyncAPIResource):
251
138
  "start_timestamp": start_timestamp,
252
139
  "trace_id": trace_id,
253
140
  "id": id,
141
+ "application_interaction_id": application_interaction_id,
142
+ "application_variant_id": application_variant_id,
254
143
  "end_timestamp": end_timestamp,
144
+ "group_id": group_id,
255
145
  "input": input,
256
146
  "metadata": metadata,
257
147
  "output": output,
258
148
  "parent_id": parent_id,
259
149
  "status": status,
260
150
  "type": type,
261
- "application_interaction_id": application_interaction_id,
262
- "application_variant_id": application_variant_id,
263
151
  },
264
152
  span_create_params.SpanCreateParams,
265
153
  ),
@@ -350,31 +238,111 @@ class SpansResource(SyncAPIResource):
350
238
  cast_to=Span,
351
239
  )
352
240
 
353
- def list(
241
+ def batch(
242
+ self,
243
+ *,
244
+ items: Iterable[span_batch_params.Item],
245
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
246
+ # The extra values given here take precedence over values defined on the client or passed to this method.
247
+ extra_headers: Headers | None = None,
248
+ extra_query: Query | None = None,
249
+ extra_body: Body | None = None,
250
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
251
+ ) -> SpanBatchResponse:
252
+ """
253
+ Create Spans in Batch
254
+
255
+ Args:
256
+ extra_headers: Send extra headers
257
+
258
+ extra_query: Add additional query parameters to the request
259
+
260
+ extra_body: Add additional JSON properties to the request
261
+
262
+ timeout: Override the client-level default timeout for this request, in seconds
263
+ """
264
+ return self._post(
265
+ "/v5/spans/batch",
266
+ body=maybe_transform({"items": items}, span_batch_params.SpanBatchParams),
267
+ options=make_request_options(
268
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
269
+ ),
270
+ cast_to=SpanBatchResponse,
271
+ )
272
+
273
+ def search(
354
274
  self,
355
275
  *,
356
276
  ending_before: str | NotGiven = NOT_GIVEN,
357
- from_ts: int | NotGiven = NOT_GIVEN,
277
+ from_ts: Union[str, datetime] | NotGiven = NOT_GIVEN,
358
278
  limit: int | NotGiven = NOT_GIVEN,
359
- parents_only: bool | NotGiven = NOT_GIVEN,
360
279
  sort_order: Literal["asc", "desc"] | NotGiven = NOT_GIVEN,
361
280
  starting_after: str | NotGiven = NOT_GIVEN,
362
- to_ts: int | NotGiven = NOT_GIVEN,
281
+ to_ts: Union[str, datetime] | NotGiven = NOT_GIVEN,
282
+ extra_metadata: Dict[str, object] | NotGiven = NOT_GIVEN,
283
+ group_id: str | NotGiven = NOT_GIVEN,
284
+ name: str | NotGiven = NOT_GIVEN,
285
+ parents_only: bool | NotGiven = NOT_GIVEN,
286
+ span_id: str | NotGiven = NOT_GIVEN,
287
+ status: Literal["SUCCESS", "ERROR"] | NotGiven = NOT_GIVEN,
363
288
  trace_id: str | NotGiven = NOT_GIVEN,
289
+ type: Literal[
290
+ "TEXT_INPUT",
291
+ "TEXT_OUTPUT",
292
+ "COMPLETION_INPUT",
293
+ "COMPLETION",
294
+ "KB_RETRIEVAL",
295
+ "KB_INPUT",
296
+ "RERANKING",
297
+ "EXTERNAL_ENDPOINT",
298
+ "PROMPT_ENGINEERING",
299
+ "DOCUMENT_INPUT",
300
+ "MAP_REDUCE",
301
+ "DOCUMENT_SEARCH",
302
+ "DOCUMENT_PROMPT",
303
+ "CUSTOM",
304
+ "INPUT_GUARDRAIL",
305
+ "OUTPUT_GUARDRAIL",
306
+ "CODE_EXECUTION",
307
+ "DATA_MANIPULATION",
308
+ "EVALUATION",
309
+ "FILE_RETRIEVAL",
310
+ "KB_ADD_CHUNK",
311
+ "KB_MANAGEMENT",
312
+ "TRACER",
313
+ "AGENT_TRACER",
314
+ "AGENT_WORKFLOW",
315
+ "STANDALONE",
316
+ ]
317
+ | NotGiven = NOT_GIVEN,
364
318
  # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
365
319
  # The extra values given here take precedence over values defined on the client or passed to this method.
366
320
  extra_headers: Headers | None = None,
367
321
  extra_query: Query | None = None,
368
322
  extra_body: Body | None = None,
369
323
  timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
370
- ) -> SyncCursorPage[Span]:
324
+ ) -> SpanSearchResponse:
371
325
  """
372
- List Spans
326
+ Search and list spans
373
327
 
374
328
  Args:
375
- from_ts: The starting (oldest) timestamp window in seconds.
329
+ from_ts: The starting (oldest) timestamp in ISO format.
376
330
 
377
- to_ts: The ending (most recent) timestamp in seconds.
331
+ to_ts: The ending (most recent) timestamp in ISO format.
332
+
333
+ extra_metadata: Filter on custom metadata key-value pairs
334
+
335
+ group_id: Filter by group ID
336
+
337
+ name: Filter by trace/span name
338
+
339
+ parents_only: Only fetch spans that are the top-level (ie. have no parent_id)
340
+
341
+ span_id: Filter by span ID
342
+
343
+ status: Filter on span status
344
+
345
+ trace_id: Which trace_id to filter on
378
346
 
379
347
  extra_headers: Send extra headers
380
348
 
@@ -384,9 +352,21 @@ class SpansResource(SyncAPIResource):
384
352
 
385
353
  timeout: Override the client-level default timeout for this request, in seconds
386
354
  """
387
- return self._get_api_list(
388
- "/v5/spans",
389
- page=SyncCursorPage[Span],
355
+ return self._post(
356
+ "/v5/spans/search",
357
+ body=maybe_transform(
358
+ {
359
+ "extra_metadata": extra_metadata,
360
+ "group_id": group_id,
361
+ "name": name,
362
+ "parents_only": parents_only,
363
+ "span_id": span_id,
364
+ "status": status,
365
+ "trace_id": trace_id,
366
+ "type": type,
367
+ },
368
+ span_search_params.SpanSearchParams,
369
+ ),
390
370
  options=make_request_options(
391
371
  extra_headers=extra_headers,
392
372
  extra_query=extra_query,
@@ -397,31 +377,29 @@ class SpansResource(SyncAPIResource):
397
377
  "ending_before": ending_before,
398
378
  "from_ts": from_ts,
399
379
  "limit": limit,
400
- "parents_only": parents_only,
401
380
  "sort_order": sort_order,
402
381
  "starting_after": starting_after,
403
382
  "to_ts": to_ts,
404
- "trace_id": trace_id,
405
383
  },
406
- span_list_params.SpanListParams,
384
+ span_search_params.SpanSearchParams,
407
385
  ),
408
386
  ),
409
- model=Span,
387
+ cast_to=SpanSearchResponse,
410
388
  )
411
389
 
412
- def batch(
390
+ def upsert_batch(
413
391
  self,
414
392
  *,
415
- items: Iterable[span_batch_params.Item],
393
+ items: Iterable[span_upsert_batch_params.Item],
416
394
  # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
417
395
  # The extra values given here take precedence over values defined on the client or passed to this method.
418
396
  extra_headers: Headers | None = None,
419
397
  extra_query: Query | None = None,
420
398
  extra_body: Body | None = None,
421
399
  timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
422
- ) -> SyncAPIListPage[Span]:
400
+ ) -> SpanUpsertBatchResponse:
423
401
  """
424
- Create Spans in Batch
402
+ Upsert Spans in Batch
425
403
 
426
404
  Args:
427
405
  extra_headers: Send extra headers
@@ -432,15 +410,13 @@ class SpansResource(SyncAPIResource):
432
410
 
433
411
  timeout: Override the client-level default timeout for this request, in seconds
434
412
  """
435
- return self._get_api_list(
413
+ return self._put(
436
414
  "/v5/spans/batch",
437
- page=SyncAPIListPage[Span],
438
- body=maybe_transform({"items": items}, span_batch_params.SpanBatchParams),
415
+ body=maybe_transform({"items": items}, span_upsert_batch_params.SpanUpsertBatchParams),
439
416
  options=make_request_options(
440
417
  extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
441
418
  ),
442
- model=Span,
443
- method="post",
419
+ cast_to=SpanUpsertBatchResponse,
444
420
  )
445
421
 
446
422
 
@@ -464,7 +440,6 @@ class AsyncSpansResource(AsyncAPIResource):
464
440
  """
465
441
  return AsyncSpansResourceWithStreamingResponse(self)
466
442
 
467
- @overload
468
443
  async def create(
469
444
  self,
470
445
  *,
@@ -472,7 +447,10 @@ class AsyncSpansResource(AsyncAPIResource):
472
447
  start_timestamp: Union[str, datetime],
473
448
  trace_id: str,
474
449
  id: str | NotGiven = NOT_GIVEN,
450
+ application_interaction_id: str | NotGiven = NOT_GIVEN,
451
+ application_variant_id: str | NotGiven = NOT_GIVEN,
475
452
  end_timestamp: Union[str, datetime] | NotGiven = NOT_GIVEN,
453
+ group_id: str | NotGiven = NOT_GIVEN,
476
454
  input: Dict[str, object] | NotGiven = NOT_GIVEN,
477
455
  metadata: Dict[str, object] | NotGiven = NOT_GIVEN,
478
456
  output: Dict[str, object] | NotGiven = NOT_GIVEN,
@@ -522,77 +500,11 @@ class AsyncSpansResource(AsyncAPIResource):
522
500
 
523
501
  id: The id of the span
524
502
 
525
- parent_id: Reference to a parent span_id
526
-
527
- extra_headers: Send extra headers
528
-
529
- extra_query: Add additional query parameters to the request
503
+ application_interaction_id: The optional application interaction ID this span belongs to
530
504
 
531
- extra_body: Add additional JSON properties to the request
505
+ application_variant_id: The optional application variant ID this span belongs to
532
506
 
533
- timeout: Override the client-level default timeout for this request, in seconds
534
- """
535
- ...
536
-
537
- @overload
538
- async def create(
539
- self,
540
- *,
541
- application_interaction_id: str,
542
- application_variant_id: str,
543
- name: str,
544
- start_timestamp: Union[str, datetime],
545
- trace_id: str,
546
- id: str | NotGiven = NOT_GIVEN,
547
- end_timestamp: Union[str, datetime] | NotGiven = NOT_GIVEN,
548
- input: Dict[str, object] | NotGiven = NOT_GIVEN,
549
- metadata: Dict[str, object] | NotGiven = NOT_GIVEN,
550
- output: Dict[str, object] | NotGiven = NOT_GIVEN,
551
- parent_id: str | NotGiven = NOT_GIVEN,
552
- status: Literal["SUCCESS", "ERROR"] | NotGiven = NOT_GIVEN,
553
- type: Literal[
554
- "TEXT_INPUT",
555
- "TEXT_OUTPUT",
556
- "COMPLETION_INPUT",
557
- "COMPLETION",
558
- "KB_RETRIEVAL",
559
- "KB_INPUT",
560
- "RERANKING",
561
- "EXTERNAL_ENDPOINT",
562
- "PROMPT_ENGINEERING",
563
- "DOCUMENT_INPUT",
564
- "MAP_REDUCE",
565
- "DOCUMENT_SEARCH",
566
- "DOCUMENT_PROMPT",
567
- "CUSTOM",
568
- "INPUT_GUARDRAIL",
569
- "OUTPUT_GUARDRAIL",
570
- "CODE_EXECUTION",
571
- "DATA_MANIPULATION",
572
- "EVALUATION",
573
- "FILE_RETRIEVAL",
574
- "KB_ADD_CHUNK",
575
- "KB_MANAGEMENT",
576
- "TRACER",
577
- "AGENT_TRACER",
578
- "AGENT_WORKFLOW",
579
- "STANDALONE",
580
- ]
581
- | NotGiven = NOT_GIVEN,
582
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
583
- # The extra values given here take precedence over values defined on the client or passed to this method.
584
- extra_headers: Headers | None = None,
585
- extra_query: Query | None = None,
586
- extra_body: Body | None = None,
587
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
588
- ) -> Span:
589
- """
590
- Create Span
591
-
592
- Args:
593
- trace_id: id for grouping traces together, uuid is recommended
594
-
595
- id: The id of the span
507
+ group_id: Reference to a group_id
596
508
 
597
509
  parent_id: Reference to a parent span_id
598
510
 
@@ -604,63 +516,6 @@ class AsyncSpansResource(AsyncAPIResource):
604
516
 
605
517
  timeout: Override the client-level default timeout for this request, in seconds
606
518
  """
607
- ...
608
-
609
- @required_args(
610
- ["name", "start_timestamp", "trace_id"],
611
- ["application_interaction_id", "application_variant_id", "name", "start_timestamp", "trace_id"],
612
- )
613
- async def create(
614
- self,
615
- *,
616
- name: str,
617
- start_timestamp: Union[str, datetime],
618
- trace_id: str,
619
- id: str | NotGiven = NOT_GIVEN,
620
- end_timestamp: Union[str, datetime] | NotGiven = NOT_GIVEN,
621
- input: Dict[str, object] | NotGiven = NOT_GIVEN,
622
- metadata: Dict[str, object] | NotGiven = NOT_GIVEN,
623
- output: Dict[str, object] | NotGiven = NOT_GIVEN,
624
- parent_id: str | NotGiven = NOT_GIVEN,
625
- status: Literal["SUCCESS", "ERROR"] | NotGiven = NOT_GIVEN,
626
- type: Literal[
627
- "TEXT_INPUT",
628
- "TEXT_OUTPUT",
629
- "COMPLETION_INPUT",
630
- "COMPLETION",
631
- "KB_RETRIEVAL",
632
- "KB_INPUT",
633
- "RERANKING",
634
- "EXTERNAL_ENDPOINT",
635
- "PROMPT_ENGINEERING",
636
- "DOCUMENT_INPUT",
637
- "MAP_REDUCE",
638
- "DOCUMENT_SEARCH",
639
- "DOCUMENT_PROMPT",
640
- "CUSTOM",
641
- "INPUT_GUARDRAIL",
642
- "OUTPUT_GUARDRAIL",
643
- "CODE_EXECUTION",
644
- "DATA_MANIPULATION",
645
- "EVALUATION",
646
- "FILE_RETRIEVAL",
647
- "KB_ADD_CHUNK",
648
- "KB_MANAGEMENT",
649
- "TRACER",
650
- "AGENT_TRACER",
651
- "AGENT_WORKFLOW",
652
- "STANDALONE",
653
- ]
654
- | NotGiven = NOT_GIVEN,
655
- application_interaction_id: str | NotGiven = NOT_GIVEN,
656
- application_variant_id: str | NotGiven = NOT_GIVEN,
657
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
658
- # The extra values given here take precedence over values defined on the client or passed to this method.
659
- extra_headers: Headers | None = None,
660
- extra_query: Query | None = None,
661
- extra_body: Body | None = None,
662
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
663
- ) -> Span:
664
519
  return await self._post(
665
520
  "/v5/spans",
666
521
  body=await async_maybe_transform(
@@ -669,15 +524,16 @@ class AsyncSpansResource(AsyncAPIResource):
669
524
  "start_timestamp": start_timestamp,
670
525
  "trace_id": trace_id,
671
526
  "id": id,
527
+ "application_interaction_id": application_interaction_id,
528
+ "application_variant_id": application_variant_id,
672
529
  "end_timestamp": end_timestamp,
530
+ "group_id": group_id,
673
531
  "input": input,
674
532
  "metadata": metadata,
675
533
  "output": output,
676
534
  "parent_id": parent_id,
677
535
  "status": status,
678
536
  "type": type,
679
- "application_interaction_id": application_interaction_id,
680
- "application_variant_id": application_variant_id,
681
537
  },
682
538
  span_create_params.SpanCreateParams,
683
539
  ),
@@ -768,31 +624,111 @@ class AsyncSpansResource(AsyncAPIResource):
768
624
  cast_to=Span,
769
625
  )
770
626
 
771
- def list(
627
+ async def batch(
628
+ self,
629
+ *,
630
+ items: Iterable[span_batch_params.Item],
631
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
632
+ # The extra values given here take precedence over values defined on the client or passed to this method.
633
+ extra_headers: Headers | None = None,
634
+ extra_query: Query | None = None,
635
+ extra_body: Body | None = None,
636
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
637
+ ) -> SpanBatchResponse:
638
+ """
639
+ Create Spans in Batch
640
+
641
+ Args:
642
+ extra_headers: Send extra headers
643
+
644
+ extra_query: Add additional query parameters to the request
645
+
646
+ extra_body: Add additional JSON properties to the request
647
+
648
+ timeout: Override the client-level default timeout for this request, in seconds
649
+ """
650
+ return await self._post(
651
+ "/v5/spans/batch",
652
+ body=await async_maybe_transform({"items": items}, span_batch_params.SpanBatchParams),
653
+ options=make_request_options(
654
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
655
+ ),
656
+ cast_to=SpanBatchResponse,
657
+ )
658
+
659
+ async def search(
772
660
  self,
773
661
  *,
774
662
  ending_before: str | NotGiven = NOT_GIVEN,
775
- from_ts: int | NotGiven = NOT_GIVEN,
663
+ from_ts: Union[str, datetime] | NotGiven = NOT_GIVEN,
776
664
  limit: int | NotGiven = NOT_GIVEN,
777
- parents_only: bool | NotGiven = NOT_GIVEN,
778
665
  sort_order: Literal["asc", "desc"] | NotGiven = NOT_GIVEN,
779
666
  starting_after: str | NotGiven = NOT_GIVEN,
780
- to_ts: int | NotGiven = NOT_GIVEN,
667
+ to_ts: Union[str, datetime] | NotGiven = NOT_GIVEN,
668
+ extra_metadata: Dict[str, object] | NotGiven = NOT_GIVEN,
669
+ group_id: str | NotGiven = NOT_GIVEN,
670
+ name: str | NotGiven = NOT_GIVEN,
671
+ parents_only: bool | NotGiven = NOT_GIVEN,
672
+ span_id: str | NotGiven = NOT_GIVEN,
673
+ status: Literal["SUCCESS", "ERROR"] | NotGiven = NOT_GIVEN,
781
674
  trace_id: str | NotGiven = NOT_GIVEN,
675
+ type: Literal[
676
+ "TEXT_INPUT",
677
+ "TEXT_OUTPUT",
678
+ "COMPLETION_INPUT",
679
+ "COMPLETION",
680
+ "KB_RETRIEVAL",
681
+ "KB_INPUT",
682
+ "RERANKING",
683
+ "EXTERNAL_ENDPOINT",
684
+ "PROMPT_ENGINEERING",
685
+ "DOCUMENT_INPUT",
686
+ "MAP_REDUCE",
687
+ "DOCUMENT_SEARCH",
688
+ "DOCUMENT_PROMPT",
689
+ "CUSTOM",
690
+ "INPUT_GUARDRAIL",
691
+ "OUTPUT_GUARDRAIL",
692
+ "CODE_EXECUTION",
693
+ "DATA_MANIPULATION",
694
+ "EVALUATION",
695
+ "FILE_RETRIEVAL",
696
+ "KB_ADD_CHUNK",
697
+ "KB_MANAGEMENT",
698
+ "TRACER",
699
+ "AGENT_TRACER",
700
+ "AGENT_WORKFLOW",
701
+ "STANDALONE",
702
+ ]
703
+ | NotGiven = NOT_GIVEN,
782
704
  # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
783
705
  # The extra values given here take precedence over values defined on the client or passed to this method.
784
706
  extra_headers: Headers | None = None,
785
707
  extra_query: Query | None = None,
786
708
  extra_body: Body | None = None,
787
709
  timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
788
- ) -> AsyncPaginator[Span, AsyncCursorPage[Span]]:
710
+ ) -> SpanSearchResponse:
789
711
  """
790
- List Spans
712
+ Search and list spans
791
713
 
792
714
  Args:
793
- from_ts: The starting (oldest) timestamp window in seconds.
715
+ from_ts: The starting (oldest) timestamp in ISO format.
716
+
717
+ to_ts: The ending (most recent) timestamp in ISO format.
718
+
719
+ extra_metadata: Filter on custom metadata key-value pairs
794
720
 
795
- to_ts: The ending (most recent) timestamp in seconds.
721
+ group_id: Filter by group ID
722
+
723
+ name: Filter by trace/span name
724
+
725
+ parents_only: Only fetch spans that are the top-level (ie. have no parent_id)
726
+
727
+ span_id: Filter by span ID
728
+
729
+ status: Filter on span status
730
+
731
+ trace_id: Which trace_id to filter on
796
732
 
797
733
  extra_headers: Send extra headers
798
734
 
@@ -802,44 +738,54 @@ class AsyncSpansResource(AsyncAPIResource):
802
738
 
803
739
  timeout: Override the client-level default timeout for this request, in seconds
804
740
  """
805
- return self._get_api_list(
806
- "/v5/spans",
807
- page=AsyncCursorPage[Span],
741
+ return await self._post(
742
+ "/v5/spans/search",
743
+ body=await async_maybe_transform(
744
+ {
745
+ "extra_metadata": extra_metadata,
746
+ "group_id": group_id,
747
+ "name": name,
748
+ "parents_only": parents_only,
749
+ "span_id": span_id,
750
+ "status": status,
751
+ "trace_id": trace_id,
752
+ "type": type,
753
+ },
754
+ span_search_params.SpanSearchParams,
755
+ ),
808
756
  options=make_request_options(
809
757
  extra_headers=extra_headers,
810
758
  extra_query=extra_query,
811
759
  extra_body=extra_body,
812
760
  timeout=timeout,
813
- query=maybe_transform(
761
+ query=await async_maybe_transform(
814
762
  {
815
763
  "ending_before": ending_before,
816
764
  "from_ts": from_ts,
817
765
  "limit": limit,
818
- "parents_only": parents_only,
819
766
  "sort_order": sort_order,
820
767
  "starting_after": starting_after,
821
768
  "to_ts": to_ts,
822
- "trace_id": trace_id,
823
769
  },
824
- span_list_params.SpanListParams,
770
+ span_search_params.SpanSearchParams,
825
771
  ),
826
772
  ),
827
- model=Span,
773
+ cast_to=SpanSearchResponse,
828
774
  )
829
775
 
830
- def batch(
776
+ async def upsert_batch(
831
777
  self,
832
778
  *,
833
- items: Iterable[span_batch_params.Item],
779
+ items: Iterable[span_upsert_batch_params.Item],
834
780
  # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
835
781
  # The extra values given here take precedence over values defined on the client or passed to this method.
836
782
  extra_headers: Headers | None = None,
837
783
  extra_query: Query | None = None,
838
784
  extra_body: Body | None = None,
839
785
  timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
840
- ) -> AsyncPaginator[Span, AsyncAPIListPage[Span]]:
786
+ ) -> SpanUpsertBatchResponse:
841
787
  """
842
- Create Spans in Batch
788
+ Upsert Spans in Batch
843
789
 
844
790
  Args:
845
791
  extra_headers: Send extra headers
@@ -850,15 +796,13 @@ class AsyncSpansResource(AsyncAPIResource):
850
796
 
851
797
  timeout: Override the client-level default timeout for this request, in seconds
852
798
  """
853
- return self._get_api_list(
799
+ return await self._put(
854
800
  "/v5/spans/batch",
855
- page=AsyncAPIListPage[Span],
856
- body=maybe_transform({"items": items}, span_batch_params.SpanBatchParams),
801
+ body=await async_maybe_transform({"items": items}, span_upsert_batch_params.SpanUpsertBatchParams),
857
802
  options=make_request_options(
858
803
  extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
859
804
  ),
860
- model=Span,
861
- method="post",
805
+ cast_to=SpanUpsertBatchResponse,
862
806
  )
863
807
 
864
808
 
@@ -875,12 +819,15 @@ class SpansResourceWithRawResponse:
875
819
  self.update = to_raw_response_wrapper(
876
820
  spans.update,
877
821
  )
878
- self.list = to_raw_response_wrapper(
879
- spans.list,
880
- )
881
822
  self.batch = to_raw_response_wrapper(
882
823
  spans.batch,
883
824
  )
825
+ self.search = to_raw_response_wrapper(
826
+ spans.search,
827
+ )
828
+ self.upsert_batch = to_raw_response_wrapper(
829
+ spans.upsert_batch,
830
+ )
884
831
 
885
832
 
886
833
  class AsyncSpansResourceWithRawResponse:
@@ -896,12 +843,15 @@ class AsyncSpansResourceWithRawResponse:
896
843
  self.update = async_to_raw_response_wrapper(
897
844
  spans.update,
898
845
  )
899
- self.list = async_to_raw_response_wrapper(
900
- spans.list,
901
- )
902
846
  self.batch = async_to_raw_response_wrapper(
903
847
  spans.batch,
904
848
  )
849
+ self.search = async_to_raw_response_wrapper(
850
+ spans.search,
851
+ )
852
+ self.upsert_batch = async_to_raw_response_wrapper(
853
+ spans.upsert_batch,
854
+ )
905
855
 
906
856
 
907
857
  class SpansResourceWithStreamingResponse:
@@ -917,12 +867,15 @@ class SpansResourceWithStreamingResponse:
917
867
  self.update = to_streamed_response_wrapper(
918
868
  spans.update,
919
869
  )
920
- self.list = to_streamed_response_wrapper(
921
- spans.list,
922
- )
923
870
  self.batch = to_streamed_response_wrapper(
924
871
  spans.batch,
925
872
  )
873
+ self.search = to_streamed_response_wrapper(
874
+ spans.search,
875
+ )
876
+ self.upsert_batch = to_streamed_response_wrapper(
877
+ spans.upsert_batch,
878
+ )
926
879
 
927
880
 
928
881
  class AsyncSpansResourceWithStreamingResponse:
@@ -938,9 +891,12 @@ class AsyncSpansResourceWithStreamingResponse:
938
891
  self.update = async_to_streamed_response_wrapper(
939
892
  spans.update,
940
893
  )
941
- self.list = async_to_streamed_response_wrapper(
942
- spans.list,
943
- )
944
894
  self.batch = async_to_streamed_response_wrapper(
945
895
  spans.batch,
946
896
  )
897
+ self.search = async_to_streamed_response_wrapper(
898
+ spans.search,
899
+ )
900
+ self.upsert_batch = async_to_streamed_response_wrapper(
901
+ spans.upsert_batch,
902
+ )