docstr: Override Agent.respond to set top_docs.
docstr_tok: ["Override","Agent.respond","to","set","top_docs","."]
code: def respond(
      self, text_or_message: Union[str, Message], **other_message_fields
  ) -> str:
      """
      Override Agent.respond to set top_docs.
      """
      if isinstance(text_or_message, str):
          observation = Message(
              text=text_or_message, **other_message_fields
          )
      else:
          observation = Message(
              **text_or_message, **other_message_fields
          )
          if "text" not in observation:
              raise RuntimeError(
                  "The agent needs a 'text' field in the message."
              )
  
      if "episode_done" not in observation:
          observation["episode_done"] = True
      agent = self.clone()
      agent.observe(observation)
      response = agent.act()
      self.top_docs = response["top_docs"]
      return response["text"]
  
file_path: ParlAI/projects/bb3/agents/search_agent.py
imports: from typing import Any, Dict, List, Optional, Union
  from parlai.agents.rag.retrieve_api import SearchEngineRetriever, SearchEngineRetrieverMock
  from parlai.agents.rag.retrievers import Document
  from parlai.core.agents import Agent
  from parlai.core.opt import Opt
  from parlai.core.params import ParlaiParser
  from parlai.core.message import Message
label_desc: Use image node_id 6 for calling the SearchAgent obj's underlying member method code with example usage: obj.respond(text_or_message) and returns: response