Spaces:
Sleeping
Sleeping
Create test_hf.py
Browse files- test_hf.py +22 -0
test_hf.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from openai import OpenAI
|
| 3 |
+
|
| 4 |
+
client = OpenAI(
|
| 5 |
+
base_url="https://router.huggingface.co/v1",
|
| 6 |
+
api_key=os.environ["HF_TOKEN"]
|
| 7 |
+
)
|
| 8 |
+
|
| 9 |
+
try:
|
| 10 |
+
response = client.chat.completions.create(
|
| 11 |
+
model="speakleash/Bielik-11B-v3.0-Instruct:publicai",
|
| 12 |
+
messages=[
|
| 13 |
+
{"role": "user", "content": "Say hello."}
|
| 14 |
+
],
|
| 15 |
+
max_tokens=30
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
print("SUCCESS!")
|
| 19 |
+
print(response.choices[0].message.content)
|
| 20 |
+
|
| 21 |
+
except Exception as e:
|
| 22 |
+
print("ERROR:", e)
|