|
| 1 | +// Create or update annotations returns "OK — annotations created or updated. |
| 2 | +// Per-item errors are listed in `errors`." response |
| 3 | +use datadog_api_client::datadog; |
| 4 | +use datadog_api_client::datadogV2::api_llm_observability::LLMObservabilityAPI; |
| 5 | +use datadog_api_client::datadogV2::model::LLMObsAnnotationLabelValue; |
| 6 | +use datadog_api_client::datadogV2::model::LLMObsAnnotationLabelValueValue; |
| 7 | +use datadog_api_client::datadogV2::model::LLMObsAnnotationsDataAttributesRequest; |
| 8 | +use datadog_api_client::datadogV2::model::LLMObsAnnotationsDataRequest; |
| 9 | +use datadog_api_client::datadogV2::model::LLMObsAnnotationsRequest; |
| 10 | +use datadog_api_client::datadogV2::model::LLMObsAnnotationsType; |
| 11 | +use datadog_api_client::datadogV2::model::LLMObsUpsertAnnotationItem; |
| 12 | + |
| 13 | +#[tokio::main] |
| 14 | +async fn main() { |
| 15 | + let body = LLMObsAnnotationsRequest::new(LLMObsAnnotationsDataRequest::new( |
| 16 | + LLMObsAnnotationsDataAttributesRequest::new(vec![LLMObsUpsertAnnotationItem::new( |
| 17 | + "00000000-0000-0000-0000-000000000001".to_string(), |
| 18 | + vec![ |
| 19 | + LLMObsAnnotationLabelValue::new( |
| 20 | + "abc-123".to_string(), |
| 21 | + LLMObsAnnotationLabelValueValue::AnyValueString("good".to_string()), |
| 22 | + ), |
| 23 | + LLMObsAnnotationLabelValue::new( |
| 24 | + "ef56gh78".to_string(), |
| 25 | + LLMObsAnnotationLabelValueValue::AnyValueString("positive".to_string()), |
| 26 | + ), |
| 27 | + ], |
| 28 | + )]), |
| 29 | + LLMObsAnnotationsType::ANNOTATIONS, |
| 30 | + )); |
| 31 | + let mut configuration = datadog::Configuration::new(); |
| 32 | + configuration.set_unstable_operation_enabled("v2.UpsertLLMObsAnnotations", true); |
| 33 | + let api = LLMObservabilityAPI::with_config(configuration); |
| 34 | + let resp = api |
| 35 | + .upsert_llm_obs_annotations("queue_id".to_string(), body) |
| 36 | + .await; |
| 37 | + if let Ok(value) = resp { |
| 38 | + println!("{:#?}", value); |
| 39 | + } else { |
| 40 | + println!("{:#?}", resp.unwrap_err()); |
| 41 | + } |
| 42 | +} |
0 commit comments