class_docstr: Parent class of gradio client
  To handle automatically refreshing client if detect gradio server changed
class_docstr_tok: ["Parent","class","of","gradio","client","To","handle","automatically","refreshing","client","if","detect","gradio","server","changed"]
docstr: Parameters:
      src: Either the name of the Hugging Face Space to load, (e.g. "abidlabs/whisper-large-v2") or the full URL (including "http" or "https") of the hosted Gradio app to load (e.g. "http://mydomain.com/app" or "https://bec81a83-5b5c-471e.gradio.live/").
      hf_token: The Hugging Face token to use to access private Spaces. Automatically fetched if you are logged in via the Hugging Face Hub CLI. Obtain from: https://huggingface.co/settings/token
      max_workers: The maximum number of thread workers that can be used to make requests to the remote Gradio app simultaneously.
      serialize: Whether the client should serialize the inputs and deserialize the outputs of the remote API. If set to False, the client will pass the inputs and outputs as-is, without serializing/deserializing them. E.g. you if you set this to False, you'd submit an image in base64 format instead of a filepath, and you'd get back an image in base64 format from the remote API instead of a filepath.
      output_dir: The directory to save files that are downloaded from the remote API. If None, reads from the GRADIO_TEMP_DIR environment variable. Defaults to a temporary directory on your machine.
      verbose: Whether the client should print statements to the console.
  
      h2ogpt_key: h2oGPT key to gain access to the server
      persist: whether to persist the state, so repeated calls are aware of the prior user session
               This allows the scratch MyData to be reused, etc.
               This also maintains the chat_conversation history
      check_hash: whether to check git hash for consistency between server and client to ensure API always up to date
      check_model_name: whether to check the model name here (adds delays), or just let server fail (fater)
docstr_tok: ["Parameters",":","src",":","Either","the","name","of","the","Hugging","Face","Space","to","load",",","(","e.g",".","``","abidlabs\/whisper-large-v2","''",")","or","the","full","URL","(","including","``","http","''","or","``","https","''",")","of","the","hosted","Gradio","app","to","load","(","e.g",".","``","http",":","\/\/mydomain.com\/app","''","or","``","https",":","\/\/bec81a83-5b5c-471e.gradio.live\/","''",")",".","hf_token",":","The","Hugging","Face","token","to","use","to","access","private","Spaces",".","Automatically","fetched","if","you","are","logged","in","via","the","Hugging","Face","Hub","CLI",".","Obtain","from",":","https",":","\/\/huggingface.co\/settings\/token","max_workers",":","The","maximum","number","of","thread","workers","that","can","be","used","to","make","requests","to","the","remote","Gradio","app","simultaneously",".","serialize",":","Whether","the","client","should","serialize","the","inputs","and","deserialize","the","outputs","of","the","remote","API",".","If","set","to","False",",","the","client","will","pass","the","inputs","and","outputs","as-is",",","without","serializing\/deserializing","them",".","E.g",".","you","if","you","set","this","to","False",",","you","'d","submit","an","image","in","base64","format","instead","of","a","filepath",",","and","you","'d","get","back","an","image","in","base64","format","from","the","remote","API","instead","of","a","filepath",".","output_dir",":","The","directory","to","save","files","that","are","downloaded","from","the","remote","API",".","If","None",",","reads","from","the","GRADIO_TEMP_DIR","environment","variable",".","Defaults","to","a","temporary","directory","on","your","machine",".","verbose",":","Whether","the","client","should","print","statements","to","the","console",".","h2ogpt_key",":","h2oGPT","key","to","gain","access","to","the","server","persist",":","whether","to","persist","the","state",",","so","repeated","calls","are","aware","of","the","prior","user","session","This","allows","the","scratch","MyData","to","be","reused",",","etc",".","This","also","maintains","the","chat_conversation","history","check_hash",":","whether","to","check","git","hash","for","consistency","between","server","and","client","to","ensure","API","always","up","to","date","check_model_name",":","whether","to","check","the","model","name","here","(","adds","delays",")",",","or","just","let","server","fail","(","fater",")"]
code: def __init__(
      self,
      src: str,
      hf_token: str | None = None,
      max_workers: int = 40,
      serialize: bool = None,
      output_dir: str | Path | None = DEFAULT_TEMP_DIR,
      verbose: bool = False,
      auth: tuple[str, str] | None = None,
      h2ogpt_key: str = None,
      persist: bool = False,
      check_hash: bool = True,
      check_model_name: bool = False,
  ):
      """
      Parameters:
          src: Either the name of the Hugging Face Space to load, (e.g. "abidlabs/whisper-large-v2") or the full URL (including "http" or "https") of the hosted Gradio app to load (e.g. "http://mydomain.com/app" or "https://bec81a83-5b5c-471e.gradio.live/").
          hf_token: The Hugging Face token to use to access private Spaces. Automatically fetched if you are logged in via the Hugging Face Hub CLI. Obtain from: https://huggingface.co/settings/token
          max_workers: The maximum number of thread workers that can be used to make requests to the remote Gradio app simultaneously.
          serialize: Whether the client should serialize the inputs and deserialize the outputs of the remote API. If set to False, the client will pass the inputs and outputs as-is, without serializing/deserializing them. E.g. you if you set this to False, you'd submit an image in base64 format instead of a filepath, and you'd get back an image in base64 format from the remote API instead of a filepath.
          output_dir: The directory to save files that are downloaded from the remote API. If None, reads from the GRADIO_TEMP_DIR environment variable. Defaults to a temporary directory on your machine.
          verbose: Whether the client should print statements to the console.
  
          h2ogpt_key: h2oGPT key to gain access to the server
          persist: whether to persist the state, so repeated calls are aware of the prior user session
                   This allows the scratch MyData to be reused, etc.
                   This also maintains the chat_conversation history
          check_hash: whether to check git hash for consistency between server and client to ensure API always up to date
          check_model_name: whether to check the model name here (adds delays), or just let server fail (fater)
      """
      if serialize is None:
          # else converts inputs arbitrarily and outputs mutate
          # False keeps as-is and is normal for h2oGPT
          serialize = False
      self.args = tuple([src])
      self.kwargs = dict(
          hf_token=hf_token,
          max_workers=max_workers,
          serialize=serialize,
          output_dir=output_dir,
          verbose=verbose,
          h2ogpt_key=h2ogpt_key,
          persist=persist,
          check_hash=check_hash,
          check_model_name=check_model_name,
      )
      if is_gradio_client_version7:
          self.kwargs.update(dict(auth=auth))
  
      self.verbose = verbose
      self.hf_token = hf_token
      self.serialize = serialize
      self.space_id = None
      self.cookies: dict[str, str] = {}
      if is_gradio_client_version7:
          self.output_dir = (
              str(output_dir)
              if isinstance(output_dir, Path)
              else output_dir
          )
      else:
          self.output_dir = output_dir
      self.max_workers = max_workers
      self.src = src
      self.auth = auth
      self.config = None
      self.h2ogpt_key = h2ogpt_key
      self.persist = persist
      self.check_hash = check_hash
      self.check_model_name = check_model_name
  
      self.chat_conversation = []  # internal for persist=True
      self.server_hash = None
  
imports: from __future__ import annotations
  import difflib
  import traceback
  import concurrent.futures
  import os
  import concurrent.futures
  import time
  import urllib.parse
  import uuid
  from concurrent.futures import Future
  from datetime import timedelta
  from enum import Enum
  from pathlib import Path
  from typing import Callable, Generator, Any, Union, List
  import ast
  from packaging import version
  from huggingface_hub import SpaceStage
  from huggingface_hub.utils import build_hf_headers
  from gradio_client import utils
  from importlib.metadata import distribution, PackageNotFoundError
  from gradio_client.client import Job, DEFAULT_TEMP_DIR, Endpoint
  from gradio_client import Client
label_desc: Use image node_id 1 to create a new GradioClient object from inherited base classes: Client with example: obj = GradioClient(src, hf_token, max_workers, serialize, output_dir, verbose, auth, h2ogpt_key, persist, check_hash, check_model_name)