|
| 1 | +# Push events for an LLM Observability experiment returns "Accepted" response |
| 2 | + |
| 3 | +require "datadog_api_client" |
| 4 | +DatadogAPIClient.configure do |config| |
| 5 | + config.unstable_operations["v2.create_llm_obs_experiment_events".to_sym] = true |
| 6 | +end |
| 7 | +api_instance = DatadogAPIClient::V2::LLMObservabilityAPI.new |
| 8 | + |
| 9 | +body = DatadogAPIClient::V2::LLMObsExperimentEventsRequest.new({ |
| 10 | + data: DatadogAPIClient::V2::LLMObsExperimentEventsDataRequest.new({ |
| 11 | + attributes: DatadogAPIClient::V2::LLMObsExperimentEventsDataAttributesRequest.new({ |
| 12 | + metrics: [ |
| 13 | + DatadogAPIClient::V2::LLMObsExperimentMetric.new({ |
| 14 | + assessment: DatadogAPIClient::V2::LLMObsMetricAssessment::PASS, |
| 15 | + error: DatadogAPIClient::V2::LLMObsExperimentMetricError.new({}), |
| 16 | + label: "faithfulness", |
| 17 | + metric_type: DatadogAPIClient::V2::LLMObsMetricScoreType::SCORE, |
| 18 | + span_id: "span-7a1b2c3d", |
| 19 | + tags: [], |
| 20 | + timestamp_ms: 1705314600000, |
| 21 | + }), |
| 22 | + ], |
| 23 | + spans: [ |
| 24 | + DatadogAPIClient::V2::LLMObsExperimentSpan.new({ |
| 25 | + dataset_id: "9f64e5c7-dc5a-45c8-a17c-1b85f0bec97d", |
| 26 | + duration: 1500000000, |
| 27 | + meta: DatadogAPIClient::V2::LLMObsExperimentSpanMeta.new({ |
| 28 | + error: DatadogAPIClient::V2::LLMObsExperimentSpanError.new({ |
| 29 | + message: "Model response timed out", |
| 30 | + stack: 'Traceback (most recent call last):\n File "main.py", line 10, in <module>\n response = model.generate(input)\n File "model.py", line 45, in generate\n raise TimeoutError("Model response timed out")\nTimeoutError: Model response timed out', |
| 31 | + type: "TimeoutError", |
| 32 | + }), |
| 33 | + input: nil, |
| 34 | + output: nil, |
| 35 | + }), |
| 36 | + name: "llm_call", |
| 37 | + project_id: "a33671aa-24fd-4dcd-9b33-a8ec7dde7751", |
| 38 | + span_id: "span-7a1b2c3d", |
| 39 | + start_ns: 1705314600000000000, |
| 40 | + status: DatadogAPIClient::V2::LLMObsExperimentSpanStatus::OK, |
| 41 | + tags: [], |
| 42 | + trace_id: "abc123def456", |
| 43 | + }), |
| 44 | + ], |
| 45 | + }), |
| 46 | + type: DatadogAPIClient::V2::LLMObsEventType::EVENTS, |
| 47 | + }), |
| 48 | +}) |
| 49 | +p api_instance.create_llm_obs_experiment_events("experiment_id", body) |
0 commit comments