code: def _build_chat_response(
      request: glm.GenerateMessageRequest,
      response: glm.GenerateMessageResponse,
      client: glm.DiscussServiceClient | glm.DiscussServiceAsyncClient,
  ) -> ChatResponse:
      request = type(request).to_dict(request)
      prompt = request.pop("prompt")
      request["examples"] = prompt["examples"]
      request["context"] = prompt["context"]
      request["messages"] = prompt["messages"]
  
      response = type(response).to_dict(response)
      response.pop("messages")
  
      response["filters"] = safety_types.convert_filters_to_enums(
          response["filters"]
      )
  
      if response["candidates"]:
          last = response["candidates"][0]
      else:
          last = None
      request["messages"].append(last)
      request.setdefault("temperature", None)
      request.setdefault("candidate_count", None)
  
      return ChatResponse(_client=client, **response, **request)
  
imports: from __future__ import annotations
  import dataclasses
  import sys
  import textwrap
  from typing import Iterable, List, Optional, Union
  import google.ai.generativelanguage
  from google.generativeai.client import get_default_discuss_client
  from google.generativeai.client import get_default_discuss_async_client
  from google.generativeai import string_utils
  from google.generativeai.types import discuss_types
  from google.generativeai.types import model_types
  from google.generativeai.types import safety_types
label_desc: Use image node_id 10 for calling a global function with example usage: _build_chat_response(request, response, client) and returns: ChatResponse