class_docstr: Base class for all agents which contains the main API methods.
  
  Args:
      chat_prompt_template (`str`, *optional*):
          Pass along your own prompt if you want to override the default template for the `chat` method. Can be the
          actual prompt template or a repo ID (on the Hugging Face Hub). The prompt should be in a file named
          `chat_prompt_template.txt` in this repo in this case.
      run_prompt_template (`str`, *optional*):
          Pass along your own prompt if you want to override the default template for the `run` method. Can be the
          actual prompt template or a repo ID (on the Hugging Face Hub). The prompt should be in a file named
          `run_prompt_template.txt` in this repo in this case.
      additional_tools ([`Tool`], list of tools or dictionary with tool values, *optional*):
          Any additional tools to include on top of the default ones. If you pass along a tool with the same name as
          one of the default tools, that default tool will be overridden.
class_docstr_tok: ["Base","class","for","all","agents","which","contains","the","main","API","methods",".","Args",":","chat_prompt_template","(","`","str","`",",","*","optional","*",")",":","Pass","along","your","own","prompt","if","you","want","to","override","the","default","template","for","the","`","chat","`","method",".","Can","be","the","actual","prompt","template","or","a","repo","ID","(","on","the","Hugging","Face","Hub",")",".","The","prompt","should","be","in","a","file","named","`","chat_prompt_template.txt","`","in","this","repo","in","this","case",".","run_prompt_template","(","`","str","`",",","*","optional","*",")",":","Pass","along","your","own","prompt","if","you","want","to","override","the","default","template","for","the","`","run","`","method",".","Can","be","the","actual","prompt","template","or","a","repo","ID","(","on","the","Hugging","Face","Hub",")",".","The","prompt","should","be","in","a","file","named","`","run_prompt_template.txt","`","in","this","repo","in","this","case",".","additional_tools","(","[","`","Tool","`","]",",","list","of","tools","or","dictionary","with","tool","values",",","*","optional","*",")",":","Any","additional","tools","to","include","on","top","of","the","default","ones",".","If","you","pass","along","a","tool","with","the","same","name","as","one","of","the","default","tools",",","that","default","tool","will","be","overridden","."]
docstr: Sends a request to the agent.
  
  Args:
      task (`str`): The task to perform
      return_code (`bool`, *optional*, defaults to `False`):
          Whether to just return code and not evaluate it.
      remote (`bool`, *optional*, defaults to `False`):
          Whether or not to use remote tools (inference endpoints) instead of local ones.
      kwargs (additional keyword arguments, *optional*):
          Any keyword argument to send to the agent when evaluating the code.
  
  Example:
  
  ```py
  from transformers import HfAgent
  
  agent = HfAgent("https://api-inference.huggingface.co/models/bigcode/starcoder")
  agent.run("Draw me a picture of rivers and lakes")
  ```
docstr_tok: ["Sends","a","request","to","the","agent",".","Args",":","task","(","`","str","`",")",":","The","task","to","perform","return_code","(","`","bool","`",",","*","optional","*",",","defaults","to","`","False","`",")",":","Whether","to","just","return","code","and","not","evaluate","it",".","remote","(","`","bool","`",",","*","optional","*",",","defaults","to","`","False","`",")",":","Whether","or","not","to","use","remote","tools","(","inference","endpoints",")","instead","of","local","ones",".","kwargs","(","additional","keyword","arguments",",","*","optional","*",")",":","Any","keyword","argument","to","send","to","the","agent","when","evaluating","the","code",".","Example",":","``","`","py","from","transformers","import","HfAgent","agent","=","HfAgent","(","``","https",":","\/\/api-inference.huggingface.co\/models\/bigcode\/starcoder","''",")","agent.run","(","``","Draw","me","a","picture","of","rivers","and","lakes","''",")","``","`"]
code: def run(self, task, *, return_code=False, remote=False, **kwargs):
      """
      Sends a request to the agent.
  
      Args:
          task (`str`): The task to perform
          return_code (`bool`, *optional*, defaults to `False`):
              Whether to just return code and not evaluate it.
          remote (`bool`, *optional*, defaults to `False`):
              Whether or not to use remote tools (inference endpoints) instead of local ones.
          kwargs (additional keyword arguments, *optional*):
              Any keyword argument to send to the agent when evaluating the code.
  
      Example:
  
      ```py
      from transformers import HfAgent
  
      agent = HfAgent("https://api-inference.huggingface.co/models/bigcode/starcoder")
      agent.run("Draw me a picture of rivers and lakes")
      ```
      """
      prompt = self.format_prompt(task)
      result = self.generate_one(prompt, stop=["Task:"])
      explanation, code = clean_code_for_run(result)
  
      self.log(f"==Explanation from the agent==\n{explanation}")
  
      self.log(f"\n\n==Code generated by the agent==\n{code}")
      if not return_code:
          self.log("\n\n==Result==")
          self.cached_tools = resolve_tools(
              code,
              self.toolbox,
              remote=remote,
              cached_tools=self.cached_tools,
          )
          return evaluate(code, self.cached_tools, state=kwargs.copy())
      else:
          tool_code = get_tool_creation_code(
              code, self.toolbox, remote=remote
          )
          return f"{tool_code}\n{code}"
  
imports: import importlib.util
  import json
  import os
  import time
  from dataclasses import dataclass
  from typing import Dict
  import requests
  from huggingface_hub import HfFolder, hf_hub_download, list_spaces
  from ..models.auto import AutoTokenizer
  from ..utils import is_offline_mode, is_openai_available, is_torch_available, logging
  from .base import TASK_MAPPING, TOOL_CONFIG_FILE, Tool, load_tool, supports_remote
  from .prompts import CHAT_MESSAGE_PROMPT, download_prompt
  from .python_interpreter import evaluate
label_desc: Use image node_id 7 for calling the Agent obj's underlying member method code with example usage: obj.run(task) and returns: evaluate, tool_code, str, code