Skip to content

Commit a0a7757

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add display_block interaction type to LLM Obs annotation queues (#1594)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 6a2f35d commit a0a7757

22 files changed

Lines changed: 2005 additions & 410 deletions

.generator/schemas/v2/openapi.yaml

Lines changed: 350 additions & 68 deletions
Large diffs are not rendered by default.

examples/v2_llm-observability_CreateLLMObsAnnotationQueueInteractions.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,20 @@ use datadog_api_client::datadogV2::model::LLMObsAnnotationQueueInteractionsDataA
66
use datadog_api_client::datadogV2::model::LLMObsAnnotationQueueInteractionsDataRequest;
77
use datadog_api_client::datadogV2::model::LLMObsAnnotationQueueInteractionsRequest;
88
use datadog_api_client::datadogV2::model::LLMObsAnnotationQueueInteractionsType;
9-
use datadog_api_client::datadogV2::model::LLMObsInteractionType;
9+
use datadog_api_client::datadogV2::model::LLMObsTraceInteractionItem;
10+
use datadog_api_client::datadogV2::model::LLMObsTraceInteractionType;
1011

1112
#[tokio::main]
1213
async fn main() {
1314
let body = LLMObsAnnotationQueueInteractionsRequest::new(
1415
LLMObsAnnotationQueueInteractionsDataRequest::new(
1516
LLMObsAnnotationQueueInteractionsDataAttributesRequest::new(vec![
16-
LLMObsAnnotationQueueInteractionItem::new(
17-
"trace-abc-123".to_string(),
18-
LLMObsInteractionType::TRACE,
19-
),
17+
LLMObsAnnotationQueueInteractionItem::LLMObsTraceInteractionItem(Box::new(
18+
LLMObsTraceInteractionItem::new(
19+
"trace-abc-123".to_string(),
20+
LLMObsTraceInteractionType::TRACE,
21+
),
22+
)),
2023
]),
2124
LLMObsAnnotationQueueInteractionsType::INTERACTIONS,
2225
),
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Add a display_block interaction returns "Created" response
2+
use datadog_api_client::datadog;
3+
use datadog_api_client::datadogV2::api_llm_observability::LLMObservabilityAPI;
4+
use datadog_api_client::datadogV2::model::LLMObsAnnotationQueueInteractionItem;
5+
use datadog_api_client::datadogV2::model::LLMObsAnnotationQueueInteractionsDataAttributesRequest;
6+
use datadog_api_client::datadogV2::model::LLMObsAnnotationQueueInteractionsDataRequest;
7+
use datadog_api_client::datadogV2::model::LLMObsAnnotationQueueInteractionsRequest;
8+
use datadog_api_client::datadogV2::model::LLMObsAnnotationQueueInteractionsType;
9+
use datadog_api_client::datadogV2::model::LLMObsContentBlock;
10+
use datadog_api_client::datadogV2::model::LLMObsContentBlockType;
11+
use datadog_api_client::datadogV2::model::LLMObsDisplayBlockInteractionItem;
12+
use datadog_api_client::datadogV2::model::LLMObsDisplayBlockInteractionType;
13+
use serde_json::Value;
14+
15+
#[tokio::main]
16+
async fn main() {
17+
let body = LLMObsAnnotationQueueInteractionsRequest::new(
18+
LLMObsAnnotationQueueInteractionsDataRequest::new(
19+
LLMObsAnnotationQueueInteractionsDataAttributesRequest::new(vec![
20+
LLMObsAnnotationQueueInteractionItem::LLMObsDisplayBlockInteractionItem(Box::new(
21+
LLMObsDisplayBlockInteractionItem::new(
22+
vec![LLMObsContentBlock::new(LLMObsContentBlockType::MARKDOWN)
23+
.content(Value::from("## Triage Instructions"))],
24+
LLMObsDisplayBlockInteractionType::DISPLAY_BLOCK,
25+
),
26+
)),
27+
]),
28+
LLMObsAnnotationQueueInteractionsType::INTERACTIONS,
29+
),
30+
);
31+
let mut configuration = datadog::Configuration::new();
32+
configuration
33+
.set_unstable_operation_enabled("v2.CreateLLMObsAnnotationQueueInteractions", true);
34+
let api = LLMObservabilityAPI::with_config(configuration);
35+
let resp = api
36+
.create_llm_obs_annotation_queue_interactions("queue_id".to_string(), body)
37+
.await;
38+
if let Ok(value) = resp {
39+
println!("{:#?}", value);
40+
} else {
41+
println!("{:#?}", resp.unwrap_err());
42+
}
43+
}

src/datadogV2/api/api_llm_observability.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -689,8 +689,16 @@ impl LLMObservabilityAPI {
689689
}
690690
}
691691

692-
/// Add one or more interactions (traces or sessions) to an annotation queue.
693-
/// At least one interaction must be provided.
692+
/// Add one or more interactions to an annotation queue. At least one
693+
/// interaction must be provided. Each interaction has a `type`:
694+
///
695+
/// - `trace`, `experiment_trace`, `session`: `content_id` references the
696+
/// upstream entity; the server fetches the actual content.
697+
/// - `display_block`: omit `content_id` and provide the rendered content
698+
/// in `display_block`. The server generates `content_id` as a
699+
/// deterministic hash of the block list.
700+
///
701+
/// Items of different types can be mixed in a single request.
694702
pub async fn create_llm_obs_annotation_queue_interactions(
695703
&self,
696704
queue_id: String,
@@ -716,8 +724,16 @@ impl LLMObservabilityAPI {
716724
}
717725
}
718726

719-
/// Add one or more interactions (traces or sessions) to an annotation queue.
720-
/// At least one interaction must be provided.
727+
/// Add one or more interactions to an annotation queue. At least one
728+
/// interaction must be provided. Each interaction has a `type`:
729+
///
730+
/// - `trace`, `experiment_trace`, `session`: `content_id` references the
731+
/// upstream entity; the server fetches the actual content.
732+
/// - `display_block`: omit `content_id` and provide the rendered content
733+
/// in `display_block`. The server generates `content_id` as a
734+
/// deterministic hash of the block list.
735+
///
736+
/// Items of different types can be mixed in a single request.
721737
pub async fn create_llm_obs_annotation_queue_interactions_with_http_info(
722738
&self,
723739
queue_id: String,

src/datadogV2/model/mod.rs

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4730,12 +4730,28 @@ pub mod model_llm_obs_annotated_interactions_data_response;
47304730
pub use self::model_llm_obs_annotated_interactions_data_response::LLMObsAnnotatedInteractionsDataResponse;
47314731
pub mod model_llm_obs_annotated_interactions_data_attributes_response;
47324732
pub use self::model_llm_obs_annotated_interactions_data_attributes_response::LLMObsAnnotatedInteractionsDataAttributesResponse;
4733-
pub mod model_llm_obs_annotated_interaction_item;
4734-
pub use self::model_llm_obs_annotated_interaction_item::LLMObsAnnotatedInteractionItem;
4733+
pub mod model_llm_obs_trace_annotated_interaction_item;
4734+
pub use self::model_llm_obs_trace_annotated_interaction_item::LLMObsTraceAnnotatedInteractionItem;
47354735
pub mod model_llm_obs_annotation_item;
47364736
pub use self::model_llm_obs_annotation_item::LLMObsAnnotationItem;
4737-
pub mod model_llm_obs_interaction_type;
4738-
pub use self::model_llm_obs_interaction_type::LLMObsInteractionType;
4737+
pub mod model_llm_obs_trace_interaction_type;
4738+
pub use self::model_llm_obs_trace_interaction_type::LLMObsTraceInteractionType;
4739+
pub mod model_llm_obs_display_block_annotated_interaction_item;
4740+
pub use self::model_llm_obs_display_block_annotated_interaction_item::LLMObsDisplayBlockAnnotatedInteractionItem;
4741+
pub mod model_llm_obs_content_block;
4742+
pub use self::model_llm_obs_content_block::LLMObsContentBlock;
4743+
pub mod model_llm_obs_content_block_llm_obs_trace_interaction_type;
4744+
pub use self::model_llm_obs_content_block_llm_obs_trace_interaction_type::LLMObsContentBlockLLMObsTraceInteractionType;
4745+
pub mod model_llm_obs_content_block_header_level;
4746+
pub use self::model_llm_obs_content_block_header_level::LLMObsContentBlockHeaderLevel;
4747+
pub mod model_llm_obs_content_block_time_frame;
4748+
pub use self::model_llm_obs_content_block_time_frame::LLMObsContentBlockTimeFrame;
4749+
pub mod model_llm_obs_content_block_type;
4750+
pub use self::model_llm_obs_content_block_type::LLMObsContentBlockType;
4751+
pub mod model_llm_obs_display_block_interaction_type;
4752+
pub use self::model_llm_obs_display_block_interaction_type::LLMObsDisplayBlockInteractionType;
4753+
pub mod model_llm_obs_annotated_interaction_item;
4754+
pub use self::model_llm_obs_annotated_interaction_item::LLMObsAnnotatedInteractionItem;
47394755
pub mod model_llm_obs_annotated_interactions_type;
47404756
pub use self::model_llm_obs_annotated_interactions_type::LLMObsAnnotatedInteractionsType;
47414757
pub mod model_llm_obs_annotation_queue_interactions_request;
@@ -4744,6 +4760,10 @@ pub mod model_llm_obs_annotation_queue_interactions_data_request;
47444760
pub use self::model_llm_obs_annotation_queue_interactions_data_request::LLMObsAnnotationQueueInteractionsDataRequest;
47454761
pub mod model_llm_obs_annotation_queue_interactions_data_attributes_request;
47464762
pub use self::model_llm_obs_annotation_queue_interactions_data_attributes_request::LLMObsAnnotationQueueInteractionsDataAttributesRequest;
4763+
pub mod model_llm_obs_trace_interaction_item;
4764+
pub use self::model_llm_obs_trace_interaction_item::LLMObsTraceInteractionItem;
4765+
pub mod model_llm_obs_display_block_interaction_item;
4766+
pub use self::model_llm_obs_display_block_interaction_item::LLMObsDisplayBlockInteractionItem;
47474767
pub mod model_llm_obs_annotation_queue_interaction_item;
47484768
pub use self::model_llm_obs_annotation_queue_interaction_item::LLMObsAnnotationQueueInteractionItem;
47494769
pub mod model_llm_obs_annotation_queue_interactions_type;
@@ -4754,6 +4774,10 @@ pub mod model_llm_obs_annotation_queue_interactions_data_response;
47544774
pub use self::model_llm_obs_annotation_queue_interactions_data_response::LLMObsAnnotationQueueInteractionsDataResponse;
47554775
pub mod model_llm_obs_annotation_queue_interactions_data_attributes_response;
47564776
pub use self::model_llm_obs_annotation_queue_interactions_data_attributes_response::LLMObsAnnotationQueueInteractionsDataAttributesResponse;
4777+
pub mod model_llm_obs_trace_interaction_response_item;
4778+
pub use self::model_llm_obs_trace_interaction_response_item::LLMObsTraceInteractionResponseItem;
4779+
pub mod model_llm_obs_display_block_interaction_response_item;
4780+
pub use self::model_llm_obs_display_block_interaction_response_item::LLMObsDisplayBlockInteractionResponseItem;
47574781
pub mod model_llm_obs_annotation_queue_interaction_response_item;
47584782
pub use self::model_llm_obs_annotation_queue_interaction_response_item::LLMObsAnnotationQueueInteractionResponseItem;
47594783
pub mod model_llm_obs_delete_annotation_queue_interactions_request;
Lines changed: 28 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,138 +1,49 @@
11
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
22
// This product includes software developed at Datadog (https://www.datadoghq.com/).
33
// Copyright 2019-Present Datadog, Inc.
4-
use serde::de::{Error, MapAccess, Visitor};
54
use serde::{Deserialize, Deserializer, Serialize};
6-
use serde_with::skip_serializing_none;
7-
use std::fmt::{self, Formatter};
85

96
/// An interaction with its associated annotations.
107
#[non_exhaustive]
11-
#[skip_serializing_none]
128
#[derive(Clone, Debug, PartialEq, Serialize)]
13-
pub struct LLMObsAnnotatedInteractionItem {
14-
/// List of annotations for this interaction.
15-
#[serde(rename = "annotations")]
16-
pub annotations: Vec<crate::datadogV2::model::LLMObsAnnotationItem>,
17-
/// Identifier of the content (trace ID or session ID) for this interaction.
18-
#[serde(rename = "content_id")]
19-
pub content_id: String,
20-
/// Unique identifier of the interaction.
21-
#[serde(rename = "id")]
22-
pub id: String,
23-
/// Type of interaction in an annotation queue.
24-
#[serde(rename = "type")]
25-
pub type_: crate::datadogV2::model::LLMObsInteractionType,
26-
#[serde(flatten)]
27-
pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
28-
#[serde(skip)]
29-
#[serde(default)]
30-
pub(crate) _unparsed: bool,
31-
}
32-
33-
impl LLMObsAnnotatedInteractionItem {
34-
pub fn new(
35-
annotations: Vec<crate::datadogV2::model::LLMObsAnnotationItem>,
36-
content_id: String,
37-
id: String,
38-
type_: crate::datadogV2::model::LLMObsInteractionType,
39-
) -> LLMObsAnnotatedInteractionItem {
40-
LLMObsAnnotatedInteractionItem {
41-
annotations,
42-
content_id,
43-
id,
44-
type_,
45-
additional_properties: std::collections::BTreeMap::new(),
46-
_unparsed: false,
47-
}
48-
}
49-
50-
pub fn additional_properties(
51-
mut self,
52-
value: std::collections::BTreeMap<String, serde_json::Value>,
53-
) -> Self {
54-
self.additional_properties = value;
55-
self
56-
}
9+
#[serde(untagged)]
10+
pub enum LLMObsAnnotatedInteractionItem {
11+
LLMObsTraceAnnotatedInteractionItem(
12+
Box<crate::datadogV2::model::LLMObsTraceAnnotatedInteractionItem>,
13+
),
14+
LLMObsDisplayBlockAnnotatedInteractionItem(
15+
Box<crate::datadogV2::model::LLMObsDisplayBlockAnnotatedInteractionItem>,
16+
),
17+
UnparsedObject(crate::datadog::UnparsedObject),
5718
}
5819

5920
impl<'de> Deserialize<'de> for LLMObsAnnotatedInteractionItem {
6021
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
6122
where
6223
D: Deserializer<'de>,
6324
{
64-
struct LLMObsAnnotatedInteractionItemVisitor;
65-
impl<'a> Visitor<'a> for LLMObsAnnotatedInteractionItemVisitor {
66-
type Value = LLMObsAnnotatedInteractionItem;
67-
68-
fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result {
69-
f.write_str("a mapping")
25+
let value: serde_json::Value = Deserialize::deserialize(deserializer)?;
26+
if let Ok(_v) = serde_json::from_value::<
27+
Box<crate::datadogV2::model::LLMObsTraceAnnotatedInteractionItem>,
28+
>(value.clone())
29+
{
30+
if !_v._unparsed {
31+
return Ok(LLMObsAnnotatedInteractionItem::LLMObsTraceAnnotatedInteractionItem(_v));
7032
}
71-
72-
fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
73-
where
74-
M: MapAccess<'a>,
75-
{
76-
let mut annotations: Option<Vec<crate::datadogV2::model::LLMObsAnnotationItem>> =
77-
None;
78-
let mut content_id: Option<String> = None;
79-
let mut id: Option<String> = None;
80-
let mut type_: Option<crate::datadogV2::model::LLMObsInteractionType> = None;
81-
let mut additional_properties: std::collections::BTreeMap<
82-
String,
83-
serde_json::Value,
84-
> = std::collections::BTreeMap::new();
85-
let mut _unparsed = false;
86-
87-
while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
88-
match k.as_str() {
89-
"annotations" => {
90-
annotations =
91-
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
92-
}
93-
"content_id" => {
94-
content_id = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
95-
}
96-
"id" => {
97-
id = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
98-
}
99-
"type" => {
100-
type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
101-
if let Some(ref _type_) = type_ {
102-
match _type_ {
103-
crate::datadogV2::model::LLMObsInteractionType::UnparsedObject(_type_) => {
104-
_unparsed = true;
105-
},
106-
_ => {}
107-
}
108-
}
109-
}
110-
&_ => {
111-
if let Ok(value) = serde_json::from_value(v.clone()) {
112-
additional_properties.insert(k, value);
113-
}
114-
}
115-
}
116-
}
117-
let annotations =
118-
annotations.ok_or_else(|| M::Error::missing_field("annotations"))?;
119-
let content_id = content_id.ok_or_else(|| M::Error::missing_field("content_id"))?;
120-
let id = id.ok_or_else(|| M::Error::missing_field("id"))?;
121-
let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?;
122-
123-
let content = LLMObsAnnotatedInteractionItem {
124-
annotations,
125-
content_id,
126-
id,
127-
type_,
128-
additional_properties,
129-
_unparsed,
130-
};
131-
132-
Ok(content)
33+
}
34+
if let Ok(_v) = serde_json::from_value::<
35+
Box<crate::datadogV2::model::LLMObsDisplayBlockAnnotatedInteractionItem>,
36+
>(value.clone())
37+
{
38+
if !_v._unparsed {
39+
return Ok(
40+
LLMObsAnnotatedInteractionItem::LLMObsDisplayBlockAnnotatedInteractionItem(_v),
41+
);
13342
}
13443
}
13544

136-
deserializer.deserialize_any(LLMObsAnnotatedInteractionItemVisitor)
45+
return Ok(LLMObsAnnotatedInteractionItem::UnparsedObject(
46+
crate::datadog::UnparsedObject { value },
47+
));
13748
}
13849
}

0 commit comments

Comments
 (0)