Download llm.py from THED1/Ok2: direct link, hf CLI and curl.
- Browser
- Download file 441 Bytes
-
https://huggingface.co/spaces/THED1/Ok2/resolve/main/llm.py
- Command line
-
hf download hf://spaces/THED1/Ok2/llm.py
-
curl -L -o llm.py https://huggingface.co/spaces/THED1/Ok2/resolve/main/llm.py
441 Bytes
| import os | |
| import requests | |
| HF_TOKEN = os.environ["HF_TOKEN"] | |
| MODEL = os.getenv("HF_MODEL", "Qwen/Qwen3-8B") | |
| def chat(messages): | |
| r = requests.post( | |
| "https://router.huggingface.co/v1/chat/completions", | |
| headers={ | |
| "Authorization": f"Bearer {HF_TOKEN}" | |
| }, | |
| json={ | |
| "model": MODEL, | |
| "messages": messages | |
| } | |
| ) | |
| return r.json()["choices"][0]["message"]["content"] |