Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import spaces
|
2 |
import gradio as gr
|
3 |
from huggingface_hub import InferenceClient
|
@@ -5,8 +6,9 @@ from huggingface_hub import InferenceClient
|
|
5 |
"""
|
6 |
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
|
7 |
"""
|
8 |
-
|
9 |
-
|
|
|
10 |
|
11 |
@spaces.GPU(duration=60)
|
12 |
def respond(
|
@@ -29,7 +31,7 @@ def respond(
|
|
29 |
|
30 |
response = ""
|
31 |
|
32 |
-
for message in client.chat_completion(
|
33 |
messages,
|
34 |
max_tokens=max_tokens,
|
35 |
stream=True,
|
|
|
1 |
+
import os
|
2 |
import spaces
|
3 |
import gradio as gr
|
4 |
from huggingface_hub import InferenceClient
|
|
|
6 |
"""
|
7 |
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
|
8 |
"""
|
9 |
+
HF_TOKEN = os.getenv("HF_TOKEN")
|
10 |
+
|
11 |
+
client = InferenceClient(model_name, api_key=HF_TOKEN)
|
12 |
|
13 |
@spaces.GPU(duration=60)
|
14 |
def respond(
|
|
|
31 |
|
32 |
response = ""
|
33 |
|
34 |
+
for message in client.chat_completion.create(
|
35 |
messages,
|
36 |
max_tokens=max_tokens,
|
37 |
stream=True,
|