Spaces:
Sleeping
Sleeping
suka
Browse files
app.py
CHANGED
@@ -1,15 +1,13 @@
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
from huggingface_hub import InferenceClient
|
4 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
5 |
|
6 |
-
#
|
7 |
-
|
|
|
|
|
8 |
|
9 |
-
# Инициализация клиента
|
10 |
-
client = InferenceClient("sambanovasystems/SambaLingo-Russian-Chat", token=HF_TOKEN)
|
11 |
|
12 |
-
# Функция для ответа на сообщения
|
13 |
def respond(
|
14 |
message,
|
15 |
history: list[tuple[str, str]],
|
@@ -41,7 +39,7 @@ def respond(
|
|
41 |
response += token
|
42 |
yield response
|
43 |
|
44 |
-
|
45 |
demo = gr.ChatInterface(
|
46 |
respond,
|
47 |
additional_inputs=[
|
@@ -58,5 +56,6 @@ demo = gr.ChatInterface(
|
|
58 |
],
|
59 |
)
|
60 |
|
|
|
61 |
if __name__ == "__main__":
|
62 |
demo.launch()
|
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
from huggingface_hub import InferenceClient
|
|
|
4 |
|
5 |
+
# Получаем токен из секрета
|
6 |
+
hf_token = os.environ.get("HUGGINGFACE_TOKEN")
|
7 |
+
|
8 |
+
client = InferenceClient("sambanovasystems/SambaLingo-Russian-Chat", token=hf_token)
|
9 |
|
|
|
|
|
10 |
|
|
|
11 |
def respond(
|
12 |
message,
|
13 |
history: list[tuple[str, str]],
|
|
|
39 |
response += token
|
40 |
yield response
|
41 |
|
42 |
+
|
43 |
demo = gr.ChatInterface(
|
44 |
respond,
|
45 |
additional_inputs=[
|
|
|
56 |
],
|
57 |
)
|
58 |
|
59 |
+
|
60 |
if __name__ == "__main__":
|
61 |
demo.launch()
|