This is sample code
how can i give custom input to this python code
# Note that the docstring is how the agent knows how to call the function. It follows the Google Python Style Guide:
# https://google.github.io/styleguide/pyguide.html#383-functions-and-methods
from cognite.client import CogniteClient
from cognite.client.data_classes.data_modeling import NodeId
from cognite.client.data_classes.data_modeling.cdm.v1 import CogniteTimeSeries
client = CogniteClient()
# Retrieve latest data point by time series node id
def handle(time_series_id: NodeId):
"""
Retrieves the latest data point for a given time series.
Args:
time_series_id: The node id of the time series to retrieve the latest data point for.
Returns:
The latest data point for the given time series.
"""
datapoint = client.time_series.data.retrieve_latest(instance_id=time_series_id)
# Only json serializable data is supported, so we convert the created_data to a dict with .dump().
return datapoint.dump()
# This test function runs when you click the "Test code" button in the UI
def test():
time_series = client.data_modeling.instances.list(sources=CogniteTimeSeries.get_source(), limit=1)
time_series_node_id = time_series[0].as_id()
return handle(time_series_id=time_series_node_id)
Check the
documentation
Ask the
Community
Take a look
at
Academy
Cognite
Status
Page
Contact
Cognite Support