Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from huggingface_hub import InferenceClient
|
2 |
+
api_key=os.getenv("HF_TOKEN")
|
3 |
+
client = InferenceClient(api_key=api_key)
|
4 |
+
|
5 |
+
messages = [
|
6 |
+
{ "role": "user", "content": "Tell me a story" }
|
7 |
+
]
|
8 |
+
|
9 |
+
stream = client.chat.completions.create(
|
10 |
+
model="HuggingFaceH4/zephyr-7b-beta",
|
11 |
+
messages=messages,
|
12 |
+
temperature=0.5,
|
13 |
+
max_tokens=2048,
|
14 |
+
top_p=0.7,
|
15 |
+
stream=True
|
16 |
+
)
|
17 |
+
|
18 |
+
for chunk in stream:
|
19 |
+
print(chunk.choices[0].delta.content)
|