Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,22 @@
|
|
1 |
import gradio as gr
|
2 |
from huggingface_hub import InferenceClient
|
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
"""
|
5 |
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
6 |
"""
|
|
|
1 |
import gradio as gr
|
2 |
from huggingface_hub import InferenceClient
|
3 |
|
4 |
+
import os
|
5 |
+
from huggingface_hub import InferenceClient
|
6 |
+
|
7 |
+
# Read token from Space secrets
|
8 |
+
hf_token = os.getenv("HF_TOKEN")
|
9 |
+
|
10 |
+
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta", token=hf_token)
|
11 |
+
|
12 |
+
response = client.chat.completions.create(
|
13 |
+
model="HuggingFaceH4/zephyr-7b-beta",
|
14 |
+
messages=[{"role": "user", "content": "Hello from Space!"}],
|
15 |
+
max_tokens=200,
|
16 |
+
)
|
17 |
+
print(response.choices[0].message)
|
18 |
+
|
19 |
+
|
20 |
"""
|
21 |
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
22 |
"""
|