|
| 1 | +// Create or update annotations returns "OK — annotations created or updated. Per-item errors are |
| 2 | +// listed in `errors`." |
| 3 | +// response |
| 4 | + |
| 5 | +import com.datadog.api.client.ApiClient; |
| 6 | +import com.datadog.api.client.ApiException; |
| 7 | +import com.datadog.api.client.v2.api.LlmObservabilityApi; |
| 8 | +import com.datadog.api.client.v2.model.LLMObsAnnotationLabelValue; |
| 9 | +import com.datadog.api.client.v2.model.LLMObsAnnotationLabelValueValue; |
| 10 | +import com.datadog.api.client.v2.model.LLMObsAnnotationsDataAttributesRequest; |
| 11 | +import com.datadog.api.client.v2.model.LLMObsAnnotationsDataRequest; |
| 12 | +import com.datadog.api.client.v2.model.LLMObsAnnotationsRequest; |
| 13 | +import com.datadog.api.client.v2.model.LLMObsAnnotationsResponse; |
| 14 | +import com.datadog.api.client.v2.model.LLMObsAnnotationsType; |
| 15 | +import com.datadog.api.client.v2.model.LLMObsUpsertAnnotationItem; |
| 16 | +import java.util.Arrays; |
| 17 | +import java.util.Collections; |
| 18 | + |
| 19 | +public class Example { |
| 20 | + public static void main(String[] args) { |
| 21 | + ApiClient defaultClient = ApiClient.getDefaultApiClient(); |
| 22 | + defaultClient.setUnstableOperationEnabled("v2.upsertLLMObsAnnotations", true); |
| 23 | + LlmObservabilityApi apiInstance = new LlmObservabilityApi(defaultClient); |
| 24 | + |
| 25 | + LLMObsAnnotationsRequest body = |
| 26 | + new LLMObsAnnotationsRequest() |
| 27 | + .data( |
| 28 | + new LLMObsAnnotationsDataRequest() |
| 29 | + .attributes( |
| 30 | + new LLMObsAnnotationsDataAttributesRequest() |
| 31 | + .annotations( |
| 32 | + Collections.singletonList( |
| 33 | + new LLMObsUpsertAnnotationItem() |
| 34 | + .interactionId("00000000-0000-0000-0000-000000000001") |
| 35 | + .labelValues( |
| 36 | + Arrays.asList( |
| 37 | + new LLMObsAnnotationLabelValue() |
| 38 | + .labelSchemaId("abc-123") |
| 39 | + .value( |
| 40 | + new LLMObsAnnotationLabelValueValue( |
| 41 | + "good")), |
| 42 | + new LLMObsAnnotationLabelValue() |
| 43 | + .labelSchemaId("ef56gh78") |
| 44 | + .value( |
| 45 | + new LLMObsAnnotationLabelValueValue( |
| 46 | + "positive"))))))) |
| 47 | + .type(LLMObsAnnotationsType.ANNOTATIONS)); |
| 48 | + |
| 49 | + try { |
| 50 | + LLMObsAnnotationsResponse result = |
| 51 | + apiInstance.upsertLLMObsAnnotations("00000000-0000-0000-0000-000000000001", body); |
| 52 | + System.out.println(result); |
| 53 | + } catch (ApiException e) { |
| 54 | + System.err.println("Exception when calling LlmObservabilityApi#upsertLLMObsAnnotations"); |
| 55 | + System.err.println("Status code: " + e.getCode()); |
| 56 | + System.err.println("Reason: " + e.getResponseBody()); |
| 57 | + System.err.println("Response headers: " + e.getResponseHeaders()); |
| 58 | + e.printStackTrace(); |
| 59 | + } |
| 60 | + } |
| 61 | +} |
0 commit comments