|
| 1 | +""" |
| 2 | +Create a new dashboard with llm_observability_stream list_stream widget |
| 3 | +""" |
| 4 | + |
| 5 | +from datadog_api_client import ApiClient, Configuration |
| 6 | +from datadog_api_client.v1.api.dashboards_api import DashboardsApi |
| 7 | +from datadog_api_client.v1.model.dashboard import Dashboard |
| 8 | +from datadog_api_client.v1.model.dashboard_layout_type import DashboardLayoutType |
| 9 | +from datadog_api_client.v1.model.list_stream_column import ListStreamColumn |
| 10 | +from datadog_api_client.v1.model.list_stream_column_width import ListStreamColumnWidth |
| 11 | +from datadog_api_client.v1.model.list_stream_query import ListStreamQuery |
| 12 | +from datadog_api_client.v1.model.list_stream_response_format import ListStreamResponseFormat |
| 13 | +from datadog_api_client.v1.model.list_stream_source import ListStreamSource |
| 14 | +from datadog_api_client.v1.model.list_stream_widget_definition import ListStreamWidgetDefinition |
| 15 | +from datadog_api_client.v1.model.list_stream_widget_definition_type import ListStreamWidgetDefinitionType |
| 16 | +from datadog_api_client.v1.model.list_stream_widget_request import ListStreamWidgetRequest |
| 17 | +from datadog_api_client.v1.model.widget import Widget |
| 18 | + |
| 19 | +body = Dashboard( |
| 20 | + layout_type=DashboardLayoutType.ORDERED, |
| 21 | + title="Example-Dashboard with list_stream widget", |
| 22 | + widgets=[ |
| 23 | + Widget( |
| 24 | + definition=ListStreamWidgetDefinition( |
| 25 | + type=ListStreamWidgetDefinitionType.LIST_STREAM, |
| 26 | + requests=[ |
| 27 | + ListStreamWidgetRequest( |
| 28 | + response_format=ListStreamResponseFormat.EVENT_LIST, |
| 29 | + query=ListStreamQuery( |
| 30 | + data_source=ListStreamSource.LLM_OBSERVABILITY_STREAM, |
| 31 | + query_string="@event_type:span @parent_id:undefined", |
| 32 | + indexes=[], |
| 33 | + ), |
| 34 | + columns=[ |
| 35 | + ListStreamColumn( |
| 36 | + field="@status", |
| 37 | + width=ListStreamColumnWidth.COMPACT, |
| 38 | + ), |
| 39 | + ListStreamColumn( |
| 40 | + field="@content.prompt", |
| 41 | + width=ListStreamColumnWidth.AUTO, |
| 42 | + ), |
| 43 | + ListStreamColumn( |
| 44 | + field="@content.response.content", |
| 45 | + width=ListStreamColumnWidth.AUTO, |
| 46 | + ), |
| 47 | + ListStreamColumn( |
| 48 | + field="timestamp", |
| 49 | + width=ListStreamColumnWidth.AUTO, |
| 50 | + ), |
| 51 | + ListStreamColumn( |
| 52 | + field="@ml_app", |
| 53 | + width=ListStreamColumnWidth.AUTO, |
| 54 | + ), |
| 55 | + ListStreamColumn( |
| 56 | + field="service", |
| 57 | + width=ListStreamColumnWidth.AUTO, |
| 58 | + ), |
| 59 | + ListStreamColumn( |
| 60 | + field="@meta.evaluations.quality", |
| 61 | + width=ListStreamColumnWidth.AUTO, |
| 62 | + ), |
| 63 | + ListStreamColumn( |
| 64 | + field="@meta.evaluations.security", |
| 65 | + width=ListStreamColumnWidth.AUTO, |
| 66 | + ), |
| 67 | + ListStreamColumn( |
| 68 | + field="@duration", |
| 69 | + width=ListStreamColumnWidth.AUTO, |
| 70 | + ), |
| 71 | + ], |
| 72 | + ), |
| 73 | + ], |
| 74 | + ), |
| 75 | + ), |
| 76 | + ], |
| 77 | +) |
| 78 | + |
| 79 | +configuration = Configuration() |
| 80 | +with ApiClient(configuration) as api_client: |
| 81 | + api_instance = DashboardsApi(api_client) |
| 82 | + response = api_instance.create_dashboard(body=body) |
| 83 | + |
| 84 | + print(response) |
0 commit comments