Download test_chat.py from harvesthealth/gemma-inference: direct link, hf CLI and curl.
- Browser
- Download file 389 Bytes
-
https://huggingface.co/spaces/harvesthealth/gemma-inference/resolve/main/test_chat.py
- Command line
-
hf download hf://spaces/harvesthealth/gemma-inference/test_chat.py
-
curl -L -o test_chat.py https://huggingface.co/spaces/harvesthealth/gemma-inference/resolve/main/test_chat.py
389 Bytes
| import requests | |
| import json | |
| url = "https://harvesthealth-gemma-inference.hf.space/v1/chat/completions" | |
| payload = { | |
| "model": "google/gemma-2b-it", | |
| "messages": [ | |
| {"role": "user", "content": "Hello, how are you?"} | |
| ] | |
| } | |
| headers = { | |
| "Content-Type": "application/json" | |
| } | |
| response = requests.post(url, headers=headers, data=json.dumps(payload)) | |
| print(response.json()) | |