Spaces:
Running on Zero
Running on Zero
| """ | |
| Call the deployed ZeroGPU Space API from localhost. | |
| pip install gradio_client | |
| export HF_TOKEN=hf_xxx # your Pro token -> uses YOUR ZeroGPU quota | |
| python space_client.py | |
| """ | |
| import os | |
| from gradio_client import Client, handle_file | |
| SPACE = os.environ.get("SPACE_ID", "chabab/qwen-agentworld-35b-zerogpu") | |
| # Passing hf_token charges the call to your account's ZeroGPU quota (recommended; | |
| # anonymous calls share a much smaller pool and may be rejected). | |
| client = Client(SPACE, token=os.environ.get("HF_TOKEN")) | |
| # --- text only ------------------------------------------------------------- | |
| result = client.predict( | |
| message={"text": "Give me a one-sentence hello.", "files": []}, | |
| max_new_tokens=256, | |
| temperature=0.7, | |
| api_name="/chat", | |
| ) | |
| print("TEXT ->", result) | |
| # --- image + text ---------------------------------------------------------- | |
| # result = client.predict( | |
| # message={ | |
| # "text": "Describe this image.", | |
| # "files": [handle_file("https://gradio-builds.s3.amazonaws.com/demo-files/cheetah.jpg")], | |
| # }, | |
| # max_new_tokens=256, | |
| # temperature=0.7, | |
| # api_name="/chat", | |
| # ) | |
| # print("VISION ->", result) | |