|
| 1 | +// Create a new LLM Observability prompt version returns "OK" response |
| 2 | +use datadog_api_client::datadog; |
| 3 | +use datadog_api_client::datadogV2::api_llm_observability::LLMObservabilityAPI; |
| 4 | +use datadog_api_client::datadogV2::model::LLMObsCreatePromptVersionData; |
| 5 | +use datadog_api_client::datadogV2::model::LLMObsCreatePromptVersionDataAttributes; |
| 6 | +use datadog_api_client::datadogV2::model::LLMObsCreatePromptVersionRequest; |
| 7 | +use datadog_api_client::datadogV2::model::LLMObsPromptTemplate; |
| 8 | +use datadog_api_client::datadogV2::model::LLMObsPromptVersionType; |
| 9 | + |
| 10 | +#[tokio::main] |
| 11 | +async fn main() { |
| 12 | + // there is a valid "prompt" in the system |
| 13 | + let prompt_data_attributes_prompt_id = |
| 14 | + std::env::var("PROMPT_DATA_ATTRIBUTES_PROMPT_ID").unwrap(); |
| 15 | + let body = |
| 16 | + LLMObsCreatePromptVersionRequest::new( |
| 17 | + LLMObsCreatePromptVersionData::new( |
| 18 | + LLMObsCreatePromptVersionDataAttributes::new( |
| 19 | + LLMObsPromptTemplate::LLMObsPromptTextTemplate( |
| 20 | + "You are a concise customer support assistant for {{company_name}}. Answer {{customer_name}}'s question: {{question}}".to_string(), |
| 21 | + ), |
| 22 | + ), |
| 23 | + LLMObsPromptVersionType::PROMPT_TEMPLATE_VERSIONS, |
| 24 | + ), |
| 25 | + ); |
| 26 | + let mut configuration = datadog::Configuration::new(); |
| 27 | + configuration.set_unstable_operation_enabled("v2.CreateLLMObsPromptVersion", true); |
| 28 | + let api = LLMObservabilityAPI::with_config(configuration); |
| 29 | + let resp = api |
| 30 | + .create_llm_obs_prompt_version(prompt_data_attributes_prompt_id.clone(), body) |
| 31 | + .await; |
| 32 | + if let Ok(value) = resp { |
| 33 | + println!("{:#?}", value); |
| 34 | + } else { |
| 35 | + println!("{:#?}", resp.unwrap_err()); |
| 36 | + } |
| 37 | +} |
0 commit comments