harp-dev commited on
Commit
06ad846
·
verified ·
1 Parent(s): 8e81a78

Spread the gradio_client token keyword rather than shadowing the client factory

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -11,6 +11,9 @@ from pyharp import *
11
  from gradio_client import Client, handle_file
12
 
13
 
 
 
 
14
  _BACKEND_SPACE = "facebook/MelodyFlow"
15
  _BACKEND_API_NAME = "/predict"
16
  _BACKEND_TOKEN_ENV = "HF_TOKEN"
@@ -29,7 +32,7 @@ def _backend_client():
29
  global _client
30
  if _client is None:
31
  _token = os.environ.get(_BACKEND_TOKEN_ENV) or None
32
- _client = _backend_client(_BACKEND_SPACE, _token)
33
  return _client
34
 
35
 
@@ -43,7 +46,7 @@ def _reset_client():
43
  def _make_conn(tok):
44
  tok = (tok or '').strip()
45
  if tok:
46
- return _backend_client(_BACKEND_SPACE, tok)
47
  return _backend_client()
48
 
49
 
 
11
  from gradio_client import Client, handle_file
12
 
13
 
14
+ _TOKEN_ARG = ("token" if "token" in inspect.signature(Client.__init__).parameters
15
+ else "hf_token")
16
+
17
  _BACKEND_SPACE = "facebook/MelodyFlow"
18
  _BACKEND_API_NAME = "/predict"
19
  _BACKEND_TOKEN_ENV = "HF_TOKEN"
 
32
  global _client
33
  if _client is None:
34
  _token = os.environ.get(_BACKEND_TOKEN_ENV) or None
35
+ _client = Client(_BACKEND_SPACE, **{_TOKEN_ARG: _token})
36
  return _client
37
 
38
 
 
46
  def _make_conn(tok):
47
  tok = (tok or '').strip()
48
  if tok:
49
+ return Client(_BACKEND_SPACE, **{_TOKEN_ARG: tok})
50
  return _backend_client()
51
 
52