Spaces:
Running
Running
Commit
·
271596a
1
Parent(s):
a07ee33
fix: do not throw an error at the end of the message
Browse files- .gitignore +1 -0
- app.py +6 -2
.gitignore
CHANGED
@@ -1 +1,2 @@
|
|
1 |
venv
|
|
|
|
1 |
venv
|
2 |
+
.env
|
app.py
CHANGED
@@ -1,6 +1,9 @@
|
|
1 |
import gradio as gr
|
2 |
from huggingface_hub import InferenceClient
|
3 |
import os
|
|
|
|
|
|
|
4 |
|
5 |
token = os.environ.get("HF_TOKEN")
|
6 |
|
@@ -12,7 +15,6 @@ client = InferenceClient(
|
|
12 |
token=token
|
13 |
)
|
14 |
|
15 |
-
|
16 |
def respond(
|
17 |
message,
|
18 |
history: list[tuple[str, str]],
|
@@ -42,7 +44,9 @@ def respond(
|
|
42 |
):
|
43 |
token = message.choices[0].delta.content
|
44 |
|
45 |
-
|
|
|
|
|
46 |
yield response
|
47 |
|
48 |
"""
|
|
|
1 |
import gradio as gr
|
2 |
from huggingface_hub import InferenceClient
|
3 |
import os
|
4 |
+
from dotenv import load_dotenv
|
5 |
+
|
6 |
+
load_dotenv()
|
7 |
|
8 |
token = os.environ.get("HF_TOKEN")
|
9 |
|
|
|
15 |
token=token
|
16 |
)
|
17 |
|
|
|
18 |
def respond(
|
19 |
message,
|
20 |
history: list[tuple[str, str]],
|
|
|
44 |
):
|
45 |
token = message.choices[0].delta.content
|
46 |
|
47 |
+
if token:
|
48 |
+
response += token
|
49 |
+
|
50 |
yield response
|
51 |
|
52 |
"""
|