Skip to content

Commit

Permalink
Merge pull request #1562 from h2oai/restore_425_no_heartbeat
Browse files Browse the repository at this point in the history
Restore gradio 4.26.0 but no heartbeat
  • Loading branch information
pseudotensor authored Apr 15, 2024
2 parents 60c2ae3 + 4071071 commit 7551750
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
13 changes: 11 additions & 2 deletions gradio_utils/grclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ class GradioClient(Client):
To handle automatically refreshing client if detect gradio server changed
"""

def reset_session(self) -> None:
self.session_hash = str(uuid.uuid4())
if hasattr(self, 'include_heartbeat'):
self._refresh_heartbeat.set()

def __init__(
self,
src: str,
Expand All @@ -127,6 +132,7 @@ def __init__(
persist: bool = False,
check_hash: bool = True,
check_model_name: bool = False,
include_heartbeat: bool = False,
):
"""
Parameters:
Expand Down Expand Up @@ -154,6 +160,7 @@ def __init__(
persist=persist,
check_hash=check_hash,
check_model_name=check_model_name,
include_heartbeat=include_heartbeat,
)
if is_gradio_client_version7plus:
# 4.18.0:
Expand Down Expand Up @@ -200,6 +207,7 @@ def __init__(
self.persist = persist
self.check_hash = check_hash
self.check_model_name = check_model_name
self.include_heartbeat = include_heartbeat

self.chat_conversation = [] # internal for persist=True
self.server_hash = None # internal
Expand Down Expand Up @@ -268,7 +276,7 @@ def setup(self):
self.sse_url = urllib.parse.urljoin(
self.src, utils.SSE_URL_V0 if self.protocol == "sse" else utils.SSE_URL
)
if hasattr(utils, 'HEARTBEAT_URL'):
if hasattr(utils, 'HEARTBEAT_URL') and self.include_heartbeat:
self.heartbeat_url = urllib.parse.urljoin(self.src, utils.HEARTBEAT_URL)
else:
self.heartbeat_url = None
Expand All @@ -290,7 +298,7 @@ def setup(self):

# Disable telemetry by setting the env variable HF_HUB_DISABLE_TELEMETRY=1
# threading.Thread(target=self._telemetry_thread, daemon=True).start()
if is_gradio_client_version7plus and hasattr(utils, 'HEARTBEAT_URL'):
if is_gradio_client_version7plus and hasattr(utils, 'HEARTBEAT_URL') and self.include_heartbeat:
self._refresh_heartbeat = threading.Event()
self._kill_heartbeat = threading.Event()

Expand Down Expand Up @@ -405,6 +413,7 @@ def refresh_client(self):
kwargs.pop("persist", None)
kwargs.pop("check_hash", None)
kwargs.pop("check_model_name", None)
kwargs.pop("include_heartbeat", None)
ntrials = 3
client = None
for trial in range(0, ntrials):
Expand Down
4 changes: 2 additions & 2 deletions reqs_optional/reqs_constraints.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ensure doesn't drift, e.g. Issue #1348
torch==2.2.1
gradio==4.20.1
gradio_client==0.11.0
gradio==4.26.0
gradio_client==0.16.1
transformers==4.39.2
6 changes: 4 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ sentencepiece==0.2.0

# gradio @ https://h2o-release.s3.amazonaws.com/h2ogpt/gradio-4.25.0-py3-none-any.whl
# gradio_client @ https://h2o-release.s3.amazonaws.com/h2ogpt/gradio_client-0.15.0-py3-none-any.whl
gradio @ https://h2o-release.s3.amazonaws.com/h2ogpt/gradio-4.20.1-py3-none-any.whl
gradio_client==0.11.0
#gradio @ https://h2o-release.s3.amazonaws.com/h2ogpt/gradio-4.20.1-py3-none-any.whl
#gradio_client==0.11.0
gradio @ https://h2o-release.s3.amazonaws.com/h2ogpt/gradio-4.26.0-py3-none-any.whl
gradio_client @ https://h2o-release.s3.amazonaws.com/h2ogpt/gradio_client-0.15.1-py3-none-any.whl

sse_starlette==1.8.2
# consrained by tokenizers etc.:
Expand Down
2 changes: 2 additions & 0 deletions src/gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -3875,6 +3875,8 @@ def evaluate(
else:
# just 1 item and make list
langchain_agents = [langchain_agents]
if langchain_agents is None:
langchain_agents = []
chat_conversation = str_to_list(chat_conversation)
text_context_list = str_to_list(text_context_list)

Expand Down
2 changes: 1 addition & 1 deletion src/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "8770d92b80c7a9d23ef0895842eb8885a9bec282"
__version__ = "37a55ed20dca04af454aca2a0eb1739ce798c354"

0 comments on commit 7551750

Please sign in to comment.