Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
|
| 4 |
-
|
| 5 |
def respond(
|
| 6 |
message,
|
| 7 |
history: list[dict[str, str]],
|
|
@@ -11,6 +10,8 @@ def respond(
|
|
| 11 |
top_p,
|
| 12 |
hf_token: gr.OAuthToken,
|
| 13 |
):
|
|
|
|
|
|
|
| 14 |
|
| 15 |
client = InferenceClient(token=hf_token.token, model="deepseek-ai/DeepSeek-V3.2")
|
| 16 |
|
|
@@ -35,16 +36,13 @@ def respond(
|
|
| 35 |
response += token
|
| 36 |
yield response
|
| 37 |
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
custom_theme = gr.themes.Soft(
|
| 41 |
primary_hue="indigo",
|
| 42 |
secondary_hue="violet",
|
| 43 |
)
|
| 44 |
|
| 45 |
-
|
| 46 |
-
h1 { text-align: center; color: #4f46e5;
|
| 47 |
-
.description { text-align: center; color: #666; margin-bottom: 20px; }
|
| 48 |
"""
|
| 49 |
|
| 50 |
my_chatbot = gr.Chatbot(
|
|
@@ -54,10 +52,11 @@ my_chatbot = gr.Chatbot(
|
|
| 54 |
show_copy_button=True
|
| 55 |
)
|
| 56 |
|
| 57 |
-
|
| 58 |
respond,
|
| 59 |
chatbot=my_chatbot,
|
| 60 |
type="messages",
|
|
|
|
| 61 |
additional_inputs=[
|
| 62 |
gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
|
| 63 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
|
@@ -66,18 +65,14 @@ chat_interface = gr.ChatInterface(
|
|
| 66 |
],
|
| 67 |
)
|
| 68 |
|
| 69 |
-
with gr.Blocks(theme=
|
| 70 |
-
gr.Markdown("# ✨ Le Chatbot qu'il vous faut")
|
| 71 |
-
gr.Markdown("Une interface intelligente propulsée par DeepSeek AI.", elem_classes="description")
|
| 72 |
-
|
| 73 |
with gr.Row():
|
| 74 |
with gr.Column(scale=1, min_width=200):
|
| 75 |
-
gr.Markdown("###
|
| 76 |
-
gr.LoginButton(
|
| 77 |
-
|
| 78 |
-
|
| 79 |
with gr.Column(scale=4):
|
| 80 |
-
|
| 81 |
|
| 82 |
if __name__ == "__main__":
|
| 83 |
demo.launch(ssr_mode=False)
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
|
|
|
|
| 4 |
def respond(
|
| 5 |
message,
|
| 6 |
history: list[dict[str, str]],
|
|
|
|
| 10 |
top_p,
|
| 11 |
hf_token: gr.OAuthToken,
|
| 12 |
):
|
| 13 |
+
if hf_token is None:
|
| 14 |
+
raise gr.Error("Veuillez vous connecter via le bouton pour utiliser le chatbot.")
|
| 15 |
|
| 16 |
client = InferenceClient(token=hf_token.token, model="deepseek-ai/DeepSeek-V3.2")
|
| 17 |
|
|
|
|
| 36 |
response += token
|
| 37 |
yield response
|
| 38 |
|
| 39 |
+
theme = gr.themes.Soft(
|
|
|
|
|
|
|
| 40 |
primary_hue="indigo",
|
| 41 |
secondary_hue="violet",
|
| 42 |
)
|
| 43 |
|
| 44 |
+
css = """
|
| 45 |
+
h1 { text-align: center; color: #4f46e5; }
|
|
|
|
| 46 |
"""
|
| 47 |
|
| 48 |
my_chatbot = gr.Chatbot(
|
|
|
|
| 52 |
show_copy_button=True
|
| 53 |
)
|
| 54 |
|
| 55 |
+
chat = gr.ChatInterface(
|
| 56 |
respond,
|
| 57 |
chatbot=my_chatbot,
|
| 58 |
type="messages",
|
| 59 |
+
title="Le chatbot qu'il vous faut",
|
| 60 |
additional_inputs=[
|
| 61 |
gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
|
| 62 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
|
|
|
| 65 |
],
|
| 66 |
)
|
| 67 |
|
| 68 |
+
with gr.Blocks(theme=theme, css=css) as demo:
|
|
|
|
|
|
|
|
|
|
| 69 |
with gr.Row():
|
| 70 |
with gr.Column(scale=1, min_width=200):
|
| 71 |
+
gr.Markdown("### Authentification")
|
| 72 |
+
gr.LoginButton()
|
| 73 |
+
|
|
|
|
| 74 |
with gr.Column(scale=4):
|
| 75 |
+
chat.render()
|
| 76 |
|
| 77 |
if __name__ == "__main__":
|
| 78 |
demo.launch(ssr_mode=False)
|