diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml
index 39623cac69e..b0ee5756e15 100644
--- a/.generator/schemas/v2/openapi.yaml
+++ b/.generator/schemas/v2/openapi.yaml
@@ -39902,33 +39902,19 @@ components:
type: object
LLMObsAnnotatedInteractionItem:
description: An interaction with its associated annotations.
- properties:
- annotations:
- description: List of annotations for this interaction.
- items:
- $ref: "#/components/schemas/LLMObsAnnotationItem"
- type: array
- content_id:
- description: Identifier of the content (trace ID or session ID) for this interaction.
- example: "trace-abc-123"
- type: string
- id:
- description: Unique identifier of the interaction.
- example: "interaction-456"
- type: string
- type:
- $ref: "#/components/schemas/LLMObsInteractionType"
- required:
- - id
- - type
- - content_id
- - annotations
- type: object
+ oneOf:
+ - $ref: "#/components/schemas/LLMObsTraceAnnotatedInteractionItem"
+ - $ref: "#/components/schemas/LLMObsDisplayBlockAnnotatedInteractionItem"
LLMObsAnnotatedInteractionsDataAttributesResponse:
description: Attributes containing the list of annotated interactions.
properties:
annotated_interactions:
description: List of interactions with their annotations.
+ example:
+ - annotations: []
+ content_id: trace-abc-123
+ id: "interaction-456"
+ type: trace
items:
$ref: "#/components/schemas/LLMObsAnnotatedInteractionItem"
type: array
@@ -40110,45 +40096,22 @@ components:
type: object
LLMObsAnnotationQueueInteractionItem:
description: A single interaction to add to an annotation queue.
- properties:
- content_id:
- description: Identifier of the content (trace ID or session ID) for this interaction.
- example: "trace-abc-123"
- type: string
- type:
- $ref: "#/components/schemas/LLMObsInteractionType"
- required:
- - type
- - content_id
- type: object
+ oneOf:
+ - $ref: "#/components/schemas/LLMObsTraceInteractionItem"
+ - $ref: "#/components/schemas/LLMObsDisplayBlockInteractionItem"
LLMObsAnnotationQueueInteractionResponseItem:
description: A single interaction result.
- properties:
- already_existed:
- description: Whether this interaction already existed in the queue.
- example: false
- type: boolean
- content_id:
- description: Identifier of the content (trace ID or session ID) for this interaction.
- example: "trace-abc-123"
- type: string
- id:
- description: Unique identifier of the interaction.
- example: "00000000-0000-0000-0000-000000000000"
- type: string
- type:
- $ref: "#/components/schemas/LLMObsInteractionType"
- required:
- - id
- - type
- - content_id
- - already_existed
- type: object
+ oneOf:
+ - $ref: "#/components/schemas/LLMObsTraceInteractionResponseItem"
+ - $ref: "#/components/schemas/LLMObsDisplayBlockInteractionResponseItem"
LLMObsAnnotationQueueInteractionsDataAttributesRequest:
description: Attributes for adding interactions to an annotation queue.
properties:
interactions:
description: List of interactions to add to the queue. Must contain at least one item.
+ example:
+ - content_id: trace-abc-123
+ type: trace
items:
$ref: "#/components/schemas/LLMObsAnnotationQueueInteractionItem"
minItems: 1
@@ -40161,6 +40124,11 @@ components:
properties:
interactions:
description: List of interactions that were processed.
+ example:
+ - already_existed: false
+ content_id: trace-abc-123
+ id: "00000000-0000-0000-0000-000000000000"
+ type: trace
items:
$ref: "#/components/schemas/LLMObsAnnotationQueueInteractionResponseItem"
type: array
@@ -40356,6 +40324,144 @@ components:
required:
- label_schemas
type: object
+ LLMObsContentBlock:
+ description: |-
+ A single content block rendered inside a `display_block` interaction.
+ `type` discriminates which other fields are meaningful:
+
+ - `markdown` / `text`: `content` must be a string.
+ - `header`: `content` must be a string; `level`, when set, must be one of `sm`, `md`, `lg`, `xl`.
+ - `json`: `content` must be a well-formed JSON value (object, array, or scalar).
+ - `image`: `url` is required.
+ - `widget`: `tileDef` is required (any well-formed JSON; the frontend owns the renderable schema).
+ - `llmobs_trace`: `traceId` is required; `interactionType`, when set, must be `trace` or `experiment_trace`.
+
+ `height`, when set, must be positive.
+ properties:
+ alt:
+ description: Alternative text for an `image` block.
+ example: "Example image"
+ type: string
+ content:
+ description: |-
+ Block payload. A string for `markdown`, `header`, and `text`; an
+ arbitrary JSON value (object, array, or scalar) for `json`. Omitted
+ for `image`, `widget`, and `llmobs_trace`.
+ example: "## Triage Instructions"
+ height:
+ description: Optional rendered height. Must be positive when set.
+ example: 240
+ format: int64
+ type: integer
+ interactionType:
+ $ref: "#/components/schemas/LLMObsContentBlockLLMObsTraceInteractionType"
+ label:
+ description: Optional label rendered alongside the block.
+ example: "Triage Instructions"
+ type: string
+ level:
+ $ref: "#/components/schemas/LLMObsContentBlockHeaderLevel"
+ tileDef:
+ description: |-
+ Tile definition for a `widget` block. Required for `widget`. The
+ schema is owned by the frontend renderer.
+ example:
+ requests:
+ - queries:
+ - data_source: metrics
+ name: q
+ query: "avg:system.cpu.user{*}"
+ response_format: timeseries
+ type: line
+ viz: timeseries
+ timeFrame:
+ $ref: "#/components/schemas/LLMObsContentBlockTimeFrame"
+ traceId:
+ description: Trace identifier. Required for `llmobs_trace` blocks.
+ example: "69fcc2bb0000000003113989d83069ba"
+ type: string
+ type:
+ $ref: "#/components/schemas/LLMObsContentBlockType"
+ url:
+ description: URL of the image. Required for `image` blocks.
+ example: "https://example.com/image.png"
+ type: string
+ required:
+ - type
+ type: object
+ LLMObsContentBlockHeaderLevel:
+ description: Visual size for a `header` block.
+ enum:
+ - sm
+ - md
+ - lg
+ - xl
+ example: md
+ type: string
+ x-enum-varnames:
+ - SM
+ - MD
+ - LG
+ - XL
+ LLMObsContentBlockLLMObsTraceInteractionType:
+ description: |-
+ Upstream interaction type referenced by an `llmobs_trace` block.
+ Restricted to `trace` or `experiment_trace`.
+ enum:
+ - trace
+ - experiment_trace
+ example: trace
+ type: string
+ x-enum-varnames:
+ - TRACE
+ - EXPERIMENT_TRACE
+ LLMObsContentBlockTimeFrame:
+ description: Unix-millis time range used by chart blocks.
+ properties:
+ end:
+ description: End of the range, in Unix milliseconds.
+ example: 1705315800000
+ format: int64
+ type: integer
+ start:
+ description: Start of the range, in Unix milliseconds.
+ example: 1705312200000
+ format: int64
+ type: integer
+ required:
+ - start
+ - end
+ type: object
+ LLMObsContentBlockType:
+ description: |-
+ Discriminator for a single `display_block` content block. Adding a
+ variant requires coordinated changes in the frontend renderer.
+ enum:
+ - markdown
+ - header
+ - text
+ - json
+ - image
+ - widget
+ - llmobs_trace
+ example: markdown
+ type: string
+ x-enum-varnames:
+ - MARKDOWN
+ - HEADER
+ - TEXT
+ - JSON
+ - IMAGE
+ - WIDGET
+ - LLMOBS_TRACE
+ LLMObsContentBlocks:
+ description: |-
+ List of content blocks that make up a `display_block` interaction.
+ Must contain at least one block.
+ items:
+ $ref: "#/components/schemas/LLMObsContentBlock"
+ minItems: 1
+ type: array
LLMObsCursorMeta:
description: Pagination cursor metadata.
properties:
@@ -41266,6 +41372,81 @@ components:
required:
- data
type: object
+ LLMObsDisplayBlockAnnotatedInteractionItem:
+ description: A display_block interaction with its associated annotations.
+ properties:
+ annotations:
+ description: List of annotations for this interaction.
+ items:
+ $ref: "#/components/schemas/LLMObsAnnotationItem"
+ type: array
+ content_id:
+ description: Server-generated deterministic identifier derived from the block list.
+ example: "9a87f3e2b1d4c5a6f8b3e2d1c4a7b5f6e3d2a1c4b7e5f8a3d6c2e1b4a7d5f8c2"
+ type: string
+ display_block:
+ $ref: "#/components/schemas/LLMObsContentBlocks"
+ id:
+ description: Unique identifier of the interaction.
+ example: "interaction-456"
+ type: string
+ type:
+ $ref: "#/components/schemas/LLMObsDisplayBlockInteractionType"
+ required:
+ - id
+ - type
+ - content_id
+ - annotations
+ - display_block
+ type: object
+ LLMObsDisplayBlockInteractionItem:
+ description: |-
+ An interaction whose rendered content is supplied directly as a list
+ of display blocks. The server generates `content_id` deterministically
+ from the block list.
+ properties:
+ display_block:
+ $ref: "#/components/schemas/LLMObsContentBlocks"
+ type:
+ $ref: "#/components/schemas/LLMObsDisplayBlockInteractionType"
+ required:
+ - type
+ - display_block
+ type: object
+ LLMObsDisplayBlockInteractionResponseItem:
+ description: A display_block interaction result.
+ properties:
+ already_existed:
+ description: Whether this interaction already existed in the queue.
+ example: false
+ type: boolean
+ content_id:
+ description: Server-generated deterministic identifier derived from the block list.
+ example: "9a87f3e2b1d4c5a6f8b3e2d1c4a7b5f6e3d2a1c4b7e5f8a3d6c2e1b4a7d5f8c2"
+ type: string
+ display_block:
+ $ref: "#/components/schemas/LLMObsContentBlocks"
+ id:
+ description: Unique identifier of the interaction.
+ example: "00000000-0000-0000-0000-000000000000"
+ type: string
+ type:
+ $ref: "#/components/schemas/LLMObsDisplayBlockInteractionType"
+ required:
+ - id
+ - type
+ - content_id
+ - already_existed
+ - display_block
+ type: object
+ LLMObsDisplayBlockInteractionType:
+ description: Type discriminator for a `display_block` interaction.
+ enum:
+ - display_block
+ example: display_block
+ type: string
+ x-enum-varnames:
+ - DISPLAY_BLOCK
LLMObsEventType:
description: Resource type for LLM Observability experiment events.
enum:
@@ -41643,18 +41824,6 @@ components:
required:
- data
type: object
- LLMObsInteractionType:
- description: Type of interaction in an annotation queue.
- enum:
- - trace
- - experiment_trace
- - session
- example: trace
- type: string
- x-enum-varnames:
- - TRACE
- - EXPERIMENT_TRACE
- - SESSION
LLMObsLabelSchema:
description: Schema definition for a single label in an annotation queue.
properties:
@@ -41896,6 +42065,78 @@ components:
type: string
x-enum-varnames:
- RECORDS
+ LLMObsTraceAnnotatedInteractionItem:
+ description: A trace, experiment trace, or session interaction with its associated annotations.
+ properties:
+ annotations:
+ description: List of annotations for this interaction.
+ items:
+ $ref: "#/components/schemas/LLMObsAnnotationItem"
+ type: array
+ content_id:
+ description: Upstream entity identifier supplied by the caller.
+ example: "trace-abc-123"
+ type: string
+ id:
+ description: Unique identifier of the interaction.
+ example: "interaction-456"
+ type: string
+ type:
+ $ref: "#/components/schemas/LLMObsTraceInteractionType"
+ required:
+ - id
+ - type
+ - content_id
+ - annotations
+ type: object
+ LLMObsTraceInteractionItem:
+ description: An interaction that references an upstream trace, experiment trace, or session.
+ properties:
+ content_id:
+ description: Upstream entity identifier (trace, experiment trace, or session ID).
+ example: "trace-abc-123"
+ type: string
+ type:
+ $ref: "#/components/schemas/LLMObsTraceInteractionType"
+ required:
+ - type
+ - content_id
+ type: object
+ LLMObsTraceInteractionResponseItem:
+ description: A trace, experiment trace, or session interaction result.
+ properties:
+ already_existed:
+ description: Whether this interaction already existed in the queue.
+ example: false
+ type: boolean
+ content_id:
+ description: Upstream entity identifier supplied by the caller.
+ example: "trace-abc-123"
+ type: string
+ id:
+ description: Unique identifier of the interaction.
+ example: "00000000-0000-0000-0000-000000000000"
+ type: string
+ type:
+ $ref: "#/components/schemas/LLMObsTraceInteractionType"
+ required:
+ - id
+ - type
+ - content_id
+ - already_existed
+ type: object
+ LLMObsTraceInteractionType:
+ description: Type of an upstream-entity interaction.
+ enum:
+ - trace
+ - experiment_trace
+ - session
+ example: trace
+ type: string
+ x-enum-varnames:
+ - TRACE
+ - EXPERIMENT_TRACE
+ - SESSION
Language:
description: Programming language
enum:
@@ -113835,8 +114076,16 @@ paths:
/api/v2/llm-obs/v1/annotation-queues/{queue_id}/interactions:
post:
description: |-
- Add one or more interactions (traces or sessions) to an annotation queue.
- At least one interaction must be provided.
+ Add one or more interactions to an annotation queue. At least one
+ interaction must be provided. Each interaction has a `type`:
+
+ - `trace`, `experiment_trace`, `session`: `content_id` references the
+ upstream entity; the server fetches the actual content.
+ - `display_block`: omit `content_id` and provide the rendered content
+ in `display_block`. The server generates `content_id` as a
+ deterministic hash of the block list.
+
+ Items of different types can be mixed in a single request.
operationId: CreateLLMObsAnnotationQueueInteractions
parameters:
- $ref: "#/components/parameters/LLMObsAnnotationQueueIDPathParameter"
@@ -113852,6 +114101,24 @@ paths:
- content_id: trace-abc-123
type: trace
type: interactions
+ display_block:
+ summary: Add a display_block interaction
+ value:
+ data:
+ attributes:
+ interactions:
+ - display_block:
+ - content: "## Triage Instructions"
+ type: markdown
+ - content: "Inputs"
+ level: md
+ type: header
+ - content:
+ experiment_id: abc-123
+ label: "Experiments"
+ type: json
+ type: display_block
+ type: interactions
schema:
$ref: "#/components/schemas/LLMObsAnnotationQueueInteractionsRequest"
description: Add interactions payload.
@@ -113872,6 +114139,21 @@ paths:
type: trace
id: 00000000-0000-0000-0000-000000000001
type: interactions
+ display_block:
+ summary: display_block response
+ value:
+ data:
+ attributes:
+ interactions:
+ - already_existed: false
+ content_id: 9a87f3e2b1d4c5a6f8b3e2d1c4a7b5f6e3d2a1c4b7e5f8a3d6c2e1b4a7d5f8c2
+ display_block:
+ - content: "## Triage Instructions"
+ type: markdown
+ id: 00000000-0000-0000-0000-000000000000
+ type: display_block
+ id: 00000000-0000-0000-0000-000000000001
+ type: interactions
schema:
$ref: "#/components/schemas/LLMObsAnnotationQueueInteractionsResponse"
description: Created
diff --git a/examples/v2/llm-observability/CreateLLMObsAnnotationQueueInteractions.java b/examples/v2/llm-observability/CreateLLMObsAnnotationQueueInteractions.java
index 47e40bd6ad9..400656c4915 100644
--- a/examples/v2/llm-observability/CreateLLMObsAnnotationQueueInteractions.java
+++ b/examples/v2/llm-observability/CreateLLMObsAnnotationQueueInteractions.java
@@ -9,7 +9,8 @@
import com.datadog.api.client.v2.model.LLMObsAnnotationQueueInteractionsRequest;
import com.datadog.api.client.v2.model.LLMObsAnnotationQueueInteractionsResponse;
import com.datadog.api.client.v2.model.LLMObsAnnotationQueueInteractionsType;
-import com.datadog.api.client.v2.model.LLMObsInteractionType;
+import com.datadog.api.client.v2.model.LLMObsTraceInteractionItem;
+import com.datadog.api.client.v2.model.LLMObsTraceInteractionType;
import java.util.Collections;
public class Example {
@@ -26,9 +27,10 @@ public static void main(String[] args) {
new LLMObsAnnotationQueueInteractionsDataAttributesRequest()
.interactions(
Collections.singletonList(
- new LLMObsAnnotationQueueInteractionItem()
- .contentId("trace-abc-123")
- .type(LLMObsInteractionType.TRACE))))
+ new LLMObsAnnotationQueueInteractionItem(
+ new LLMObsTraceInteractionItem()
+ .contentId("trace-abc-123")
+ .type(LLMObsTraceInteractionType.TRACE)))))
.type(LLMObsAnnotationQueueInteractionsType.INTERACTIONS));
try {
diff --git a/examples/v2/llm-observability/CreateLLMObsAnnotationQueueInteractions_2021594537.java b/examples/v2/llm-observability/CreateLLMObsAnnotationQueueInteractions_2021594537.java
new file mode 100644
index 00000000000..88745c70b28
--- /dev/null
+++ b/examples/v2/llm-observability/CreateLLMObsAnnotationQueueInteractions_2021594537.java
@@ -0,0 +1,56 @@
+// Add a display_block interaction returns "Created" response
+
+import com.datadog.api.client.ApiClient;
+import com.datadog.api.client.ApiException;
+import com.datadog.api.client.v2.api.LlmObservabilityApi;
+import com.datadog.api.client.v2.model.LLMObsAnnotationQueueInteractionItem;
+import com.datadog.api.client.v2.model.LLMObsAnnotationQueueInteractionsDataAttributesRequest;
+import com.datadog.api.client.v2.model.LLMObsAnnotationQueueInteractionsDataRequest;
+import com.datadog.api.client.v2.model.LLMObsAnnotationQueueInteractionsRequest;
+import com.datadog.api.client.v2.model.LLMObsAnnotationQueueInteractionsResponse;
+import com.datadog.api.client.v2.model.LLMObsAnnotationQueueInteractionsType;
+import com.datadog.api.client.v2.model.LLMObsContentBlock;
+import com.datadog.api.client.v2.model.LLMObsContentBlockType;
+import com.datadog.api.client.v2.model.LLMObsDisplayBlockInteractionItem;
+import com.datadog.api.client.v2.model.LLMObsDisplayBlockInteractionType;
+import java.util.Collections;
+
+public class Example {
+ public static void main(String[] args) {
+ ApiClient defaultClient = ApiClient.getDefaultApiClient();
+ defaultClient.setUnstableOperationEnabled("v2.createLLMObsAnnotationQueueInteractions", true);
+ LlmObservabilityApi apiInstance = new LlmObservabilityApi(defaultClient);
+
+ LLMObsAnnotationQueueInteractionsRequest body =
+ new LLMObsAnnotationQueueInteractionsRequest()
+ .data(
+ new LLMObsAnnotationQueueInteractionsDataRequest()
+ .attributes(
+ new LLMObsAnnotationQueueInteractionsDataAttributesRequest()
+ .interactions(
+ Collections.singletonList(
+ new LLMObsAnnotationQueueInteractionItem(
+ new LLMObsDisplayBlockInteractionItem()
+ .type(LLMObsDisplayBlockInteractionType.DISPLAY_BLOCK)
+ .displayBlock(
+ Collections.singletonList(
+ new LLMObsContentBlock()
+ .type(LLMObsContentBlockType.MARKDOWN)
+ .content("## Triage Instructions")))))))
+ .type(LLMObsAnnotationQueueInteractionsType.INTERACTIONS));
+
+ try {
+ LLMObsAnnotationQueueInteractionsResponse result =
+ apiInstance.createLLMObsAnnotationQueueInteractions(
+ "00000000-0000-0000-0000-000000000001", body);
+ System.out.println(result);
+ } catch (ApiException e) {
+ System.err.println(
+ "Exception when calling LlmObservabilityApi#createLLMObsAnnotationQueueInteractions");
+ System.err.println("Status code: " + e.getCode());
+ System.err.println("Reason: " + e.getResponseBody());
+ System.err.println("Response headers: " + e.getResponseHeaders());
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/src/main/java/com/datadog/api/client/v2/api/LlmObservabilityApi.java b/src/main/java/com/datadog/api/client/v2/api/LlmObservabilityApi.java
index 011ce54a62b..bae5f4b4864 100644
--- a/src/main/java/com/datadog/api/client/v2/api/LlmObservabilityApi.java
+++ b/src/main/java/com/datadog/api/client/v2/api/LlmObservabilityApi.java
@@ -269,8 +269,18 @@ public LLMObsAnnotationQueueInteractionsResponse createLLMObsAnnotationQueueInte
}
/**
- * Add one or more interactions (traces or sessions) to an annotation queue. At least one
- * interaction must be provided.
+ * Add one or more interactions to an annotation queue. At least one interaction must be provided.
+ * Each interaction has a type:
+ *
+ *
+ * trace, experiment_trace, session: content_id
+ * references the upstream entity; the server fetches the actual content.
+ * display_block: omit content_id and provide the rendered content
+ * in display_block. The server generates content_id as a
+ * deterministic hash of the block list.
+ *
+ *
+ * Items of different types can be mixed in a single request.
*
* @param queueId The ID of the LLM Observability annotation queue. (required)
* @param body Add interactions payload. (required)
diff --git a/src/main/java/com/datadog/api/client/v2/model/LLMObsAnnotatedInteractionItem.java b/src/main/java/com/datadog/api/client/v2/model/LLMObsAnnotatedInteractionItem.java
index 00665914307..3b88978fe1e 100644
--- a/src/main/java/com/datadog/api/client/v2/model/LLMObsAnnotatedInteractionItem.java
+++ b/src/main/java/com/datadog/api/client/v2/model/LLMObsAnnotatedInteractionItem.java
@@ -6,243 +6,302 @@
package com.datadog.api.client.v2.model;
-import com.fasterxml.jackson.annotation.JsonAnyGetter;
-import com.fasterxml.jackson.annotation.JsonAnySetter;
-import com.fasterxml.jackson.annotation.JsonCreator;
+import com.datadog.api.client.AbstractOpenApiSchema;
+import com.datadog.api.client.JSON;
+import com.datadog.api.client.UnparsedObject;
import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonPropertyOrder;
-import java.util.ArrayList;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.MapperFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
+import com.fasterxml.jackson.databind.ser.std.StdSerializer;
+import jakarta.ws.rs.core.GenericType;
+import java.io.IOException;
+import java.util.Collections;
import java.util.HashMap;
-import java.util.List;
+import java.util.HashSet;
import java.util.Map;
-import java.util.Objects;
-
-/** An interaction with its associated annotations. */
-@JsonPropertyOrder({
- LLMObsAnnotatedInteractionItem.JSON_PROPERTY_ANNOTATIONS,
- LLMObsAnnotatedInteractionItem.JSON_PROPERTY_CONTENT_ID,
- LLMObsAnnotatedInteractionItem.JSON_PROPERTY_ID,
- LLMObsAnnotatedInteractionItem.JSON_PROPERTY_TYPE
-})
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
@jakarta.annotation.Generated(
value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator")
-public class LLMObsAnnotatedInteractionItem {
+@JsonDeserialize(
+ using = LLMObsAnnotatedInteractionItem.LLMObsAnnotatedInteractionItemDeserializer.class)
+@JsonSerialize(
+ using = LLMObsAnnotatedInteractionItem.LLMObsAnnotatedInteractionItemSerializer.class)
+public class LLMObsAnnotatedInteractionItem extends AbstractOpenApiSchema {
+ private static final Logger log =
+ Logger.getLogger(LLMObsAnnotatedInteractionItem.class.getName());
+
@JsonIgnore public boolean unparsed = false;
- public static final String JSON_PROPERTY_ANNOTATIONS = "annotations";
- private List annotations = new ArrayList<>();
-
- public static final String JSON_PROPERTY_CONTENT_ID = "content_id";
- private String contentId;
-
- public static final String JSON_PROPERTY_ID = "id";
- private String id;
-
- public static final String JSON_PROPERTY_TYPE = "type";
- private LLMObsInteractionType type;
-
- public LLMObsAnnotatedInteractionItem() {}
-
- @JsonCreator
- public LLMObsAnnotatedInteractionItem(
- @JsonProperty(required = true, value = JSON_PROPERTY_ANNOTATIONS)
- List annotations,
- @JsonProperty(required = true, value = JSON_PROPERTY_CONTENT_ID) String contentId,
- @JsonProperty(required = true, value = JSON_PROPERTY_ID) String id,
- @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) LLMObsInteractionType type) {
- this.annotations = annotations;
- this.contentId = contentId;
- this.id = id;
- this.type = type;
- this.unparsed |= !type.isValid();
- }
- public LLMObsAnnotatedInteractionItem annotations(List annotations) {
- this.annotations = annotations;
- for (LLMObsAnnotationItem item : annotations) {
- this.unparsed |= item.unparsed;
+ public static class LLMObsAnnotatedInteractionItemSerializer
+ extends StdSerializer {
+ public LLMObsAnnotatedInteractionItemSerializer(Class t) {
+ super(t);
}
- return this;
- }
- public LLMObsAnnotatedInteractionItem addAnnotationsItem(LLMObsAnnotationItem annotationsItem) {
- this.annotations.add(annotationsItem);
- this.unparsed |= annotationsItem.unparsed;
- return this;
- }
+ public LLMObsAnnotatedInteractionItemSerializer() {
+ this(null);
+ }
- /**
- * List of annotations for this interaction.
- *
- * @return annotations
- */
- @JsonProperty(JSON_PROPERTY_ANNOTATIONS)
- @JsonInclude(value = JsonInclude.Include.ALWAYS)
- public List getAnnotations() {
- return annotations;
+ @Override
+ public void serialize(
+ LLMObsAnnotatedInteractionItem value, JsonGenerator jgen, SerializerProvider provider)
+ throws IOException, JsonProcessingException {
+ jgen.writeObject(value.getActualInstance());
+ }
}
- public void setAnnotations(List annotations) {
- this.annotations = annotations;
- }
+ public static class LLMObsAnnotatedInteractionItemDeserializer
+ extends StdDeserializer {
+ public LLMObsAnnotatedInteractionItemDeserializer() {
+ this(LLMObsAnnotatedInteractionItem.class);
+ }
- public LLMObsAnnotatedInteractionItem contentId(String contentId) {
- this.contentId = contentId;
- return this;
- }
+ public LLMObsAnnotatedInteractionItemDeserializer(Class> vc) {
+ super(vc);
+ }
- /**
- * Identifier of the content (trace ID or session ID) for this interaction.
- *
- * @return contentId
- */
- @JsonProperty(JSON_PROPERTY_CONTENT_ID)
- @JsonInclude(value = JsonInclude.Include.ALWAYS)
- public String getContentId() {
- return contentId;
- }
+ @Override
+ public LLMObsAnnotatedInteractionItem deserialize(JsonParser jp, DeserializationContext ctxt)
+ throws IOException, JsonProcessingException {
+ JsonNode tree = jp.readValueAsTree();
+ Object deserialized = null;
+ Object tmp = null;
+ boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS);
+ int match = 0;
+ JsonToken token = tree.traverse(jp.getCodec()).nextToken();
+ // deserialize LLMObsTraceAnnotatedInteractionItem
+ try {
+ boolean attemptParsing = true;
+ // ensure that we respect type coercion as set on the client ObjectMapper
+ if (LLMObsTraceAnnotatedInteractionItem.class.equals(Integer.class)
+ || LLMObsTraceAnnotatedInteractionItem.class.equals(Long.class)
+ || LLMObsTraceAnnotatedInteractionItem.class.equals(Float.class)
+ || LLMObsTraceAnnotatedInteractionItem.class.equals(Double.class)
+ || LLMObsTraceAnnotatedInteractionItem.class.equals(Boolean.class)
+ || LLMObsTraceAnnotatedInteractionItem.class.equals(String.class)) {
+ attemptParsing = typeCoercion;
+ if (!attemptParsing) {
+ attemptParsing |=
+ ((LLMObsTraceAnnotatedInteractionItem.class.equals(Integer.class)
+ || LLMObsTraceAnnotatedInteractionItem.class.equals(Long.class))
+ && token == JsonToken.VALUE_NUMBER_INT);
+ attemptParsing |=
+ ((LLMObsTraceAnnotatedInteractionItem.class.equals(Float.class)
+ || LLMObsTraceAnnotatedInteractionItem.class.equals(Double.class))
+ && (token == JsonToken.VALUE_NUMBER_FLOAT
+ || token == JsonToken.VALUE_NUMBER_INT));
+ attemptParsing |=
+ (LLMObsTraceAnnotatedInteractionItem.class.equals(Boolean.class)
+ && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
+ attemptParsing |=
+ (LLMObsTraceAnnotatedInteractionItem.class.equals(String.class)
+ && token == JsonToken.VALUE_STRING);
+ }
+ }
+ if (attemptParsing) {
+ tmp = tree.traverse(jp.getCodec()).readValueAs(LLMObsTraceAnnotatedInteractionItem.class);
+ // TODO: there is no validation against JSON schema constraints
+ // (min, max, enum, pattern...), this does not perform a strict JSON
+ // validation, which means the 'match' count may be higher than it should be.
+ if (!((LLMObsTraceAnnotatedInteractionItem) tmp).unparsed) {
+ deserialized = tmp;
+ match++;
+ }
+ log.log(Level.FINER, "Input data matches schema 'LLMObsTraceAnnotatedInteractionItem'");
+ }
+ } catch (Exception e) {
+ // deserialization failed, continue
+ log.log(
+ Level.FINER,
+ "Input data does not match schema 'LLMObsTraceAnnotatedInteractionItem'",
+ e);
+ }
- public void setContentId(String contentId) {
- this.contentId = contentId;
- }
+ // deserialize LLMObsDisplayBlockAnnotatedInteractionItem
+ try {
+ boolean attemptParsing = true;
+ // ensure that we respect type coercion as set on the client ObjectMapper
+ if (LLMObsDisplayBlockAnnotatedInteractionItem.class.equals(Integer.class)
+ || LLMObsDisplayBlockAnnotatedInteractionItem.class.equals(Long.class)
+ || LLMObsDisplayBlockAnnotatedInteractionItem.class.equals(Float.class)
+ || LLMObsDisplayBlockAnnotatedInteractionItem.class.equals(Double.class)
+ || LLMObsDisplayBlockAnnotatedInteractionItem.class.equals(Boolean.class)
+ || LLMObsDisplayBlockAnnotatedInteractionItem.class.equals(String.class)) {
+ attemptParsing = typeCoercion;
+ if (!attemptParsing) {
+ attemptParsing |=
+ ((LLMObsDisplayBlockAnnotatedInteractionItem.class.equals(Integer.class)
+ || LLMObsDisplayBlockAnnotatedInteractionItem.class.equals(Long.class))
+ && token == JsonToken.VALUE_NUMBER_INT);
+ attemptParsing |=
+ ((LLMObsDisplayBlockAnnotatedInteractionItem.class.equals(Float.class)
+ || LLMObsDisplayBlockAnnotatedInteractionItem.class.equals(Double.class))
+ && (token == JsonToken.VALUE_NUMBER_FLOAT
+ || token == JsonToken.VALUE_NUMBER_INT));
+ attemptParsing |=
+ (LLMObsDisplayBlockAnnotatedInteractionItem.class.equals(Boolean.class)
+ && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
+ attemptParsing |=
+ (LLMObsDisplayBlockAnnotatedInteractionItem.class.equals(String.class)
+ && token == JsonToken.VALUE_STRING);
+ }
+ }
+ if (attemptParsing) {
+ tmp =
+ tree.traverse(jp.getCodec())
+ .readValueAs(LLMObsDisplayBlockAnnotatedInteractionItem.class);
+ // TODO: there is no validation against JSON schema constraints
+ // (min, max, enum, pattern...), this does not perform a strict JSON
+ // validation, which means the 'match' count may be higher than it should be.
+ if (!((LLMObsDisplayBlockAnnotatedInteractionItem) tmp).unparsed) {
+ deserialized = tmp;
+ match++;
+ }
+ log.log(
+ Level.FINER,
+ "Input data matches schema 'LLMObsDisplayBlockAnnotatedInteractionItem'");
+ }
+ } catch (Exception e) {
+ // deserialization failed, continue
+ log.log(
+ Level.FINER,
+ "Input data does not match schema 'LLMObsDisplayBlockAnnotatedInteractionItem'",
+ e);
+ }
- public LLMObsAnnotatedInteractionItem id(String id) {
- this.id = id;
- return this;
- }
+ LLMObsAnnotatedInteractionItem ret = new LLMObsAnnotatedInteractionItem();
+ if (match == 1) {
+ ret.setActualInstance(deserialized);
+ } else {
+ Map res =
+ new ObjectMapper()
+ .readValue(
+ tree.traverse(jp.getCodec()).readValueAsTree().toString(),
+ new TypeReference