Spaces:
Sleeping
Sleeping
Download test_hf.py from Imnotchis/Final_Assignment_Template: direct link, hf CLI and curl.
- Browser
- Download file 483 Bytes
-
https://huggingface.co/spaces/Imnotchis/Final_Assignment_Template/resolve/main/test_hf.py
- Command line
-
hf download hf://spaces/Imnotchis/Final_Assignment_Template/test_hf.py
-
curl -L -o test_hf.py https://huggingface.co/spaces/Imnotchis/Final_Assignment_Template/resolve/main/test_hf.py
483 Bytes
| import os | |
| from openai import OpenAI | |
| client = OpenAI( | |
| base_url="https://router.huggingface.co/v1", | |
| api_key=os.environ["HF_TOKEN"] | |
| ) | |
| try: | |
| response = client.chat.completions.create( | |
| model="speakleash/Bielik-11B-v3.0-Instruct:publicai", | |
| messages=[ | |
| {"role": "user", "content": "Say hello."} | |
| ], | |
| max_tokens=30 | |
| ) | |
| print("SUCCESS!") | |
| print(response.choices[0].message.content) | |
| except Exception as e: | |
| print("ERROR:", e) |