import dataiku


def do(payload, config, plugin_config, inputs):

    connection_name = config.get("nvidia_nim_connection", "")

    client = dataiku.api_client()
    conn = client.get_connection(connection_name)
    model_list = conn.get_info().get_params().get('availableDeployments')

    choices = []
    for model in model_list:
        model_id=f"nvidia-nim:{connection_name}:{model.get('id')}"
        choices.append({
                "label": model.get("displayName", "Unknown Model"),
                "value": model_id
            })

    return {"choices": choices}