Spaces:
Sleeping
Sleeping
Download python_client.py from kevalgajjar/base-chatbot: direct link, hf CLI and curl.
- Browser
- Download file 822 Bytes
-
https://huggingface.co/spaces/kevalgajjar/base-chatbot/resolve/main/python_client.py
- Command line
-
hf download hf://spaces/kevalgajjar/base-chatbot/python_client.py
-
curl -L -o python_client.py https://huggingface.co/spaces/kevalgajjar/base-chatbot/resolve/main/python_client.py
822 Bytes
| from gradio_client import Client | |
| import sys | |
| import json | |
| def call_space(space_url, message, image_base64, model): | |
| client = Client(space_url) | |
| result = client.predict( | |
| message=message, | |
| history=[], | |
| system_message="You are a helpful AI assistant.", | |
| max_tokens=400, | |
| temperature=0.6, | |
| top_p=0.9, | |
| model_selection=model, | |
| image=image_base64, | |
| hf_token="", | |
| api_name="/respond" | |
| ) | |
| return result | |
| if __name__ == "__main__": | |
| space_url = sys.argv[1] | |
| message = sys.argv[2] | |
| image_base64 = sys.argv[3] if len(sys.argv) > 3 else None | |
| model = sys.argv[4] if len(sys.argv) > 4 else "Qwen/Qwen2.5-7B-Instruct" | |
| result = call_space(space_url, message, image_base64, model) | |
| print(json.dumps({"analysis": result})) | |