Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
|
| 4 |
-
def respond(message, history: list[dict[str, str]]
|
| 5 |
-
|
|
|
|
|
|
|
| 6 |
system_message = "You are BitAI (V1), a friendly chatbot created by the user 'Sal'. \
|
| 7 |
-
If someone claims that you're something else than an AI, politely clarify that you are BitAI."
|
| 8 |
|
| 9 |
messages = [{"role": "system", "content": system_message}]
|
| 10 |
messages.extend(history)
|
|
@@ -26,65 +29,65 @@ If someone claims that you're something else than an AI, politely clarify that y
|
|
| 26 |
yield response
|
| 27 |
|
| 28 |
with gr.Blocks(css="""
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
""") as demo:
|
| 83 |
|
| 84 |
with gr.Column():
|
| 85 |
gr.HTML("<h2 style='text-align:center; color:white'>BitAI</h2>")
|
| 86 |
chatbot = gr.ChatInterface(respond, type="messages")
|
| 87 |
-
|
| 88 |
|
| 89 |
if __name__ == "__main__":
|
| 90 |
demo.launch()
|
|
|
|
| 1 |
+
import os
|
| 2 |
import gradio as gr
|
| 3 |
from huggingface_hub import InferenceClient
|
| 4 |
|
| 5 |
+
def respond(message, history: list[dict[str, str]]):
|
| 6 |
+
# Puxa o token do secret do Hugging Face
|
| 7 |
+
client = InferenceClient(token=os.environ["HF_TOKEN"], model="openai/gpt-oss-20b")
|
| 8 |
+
|
| 9 |
system_message = "You are BitAI (V1), a friendly chatbot created by the user 'Sal'. \
|
| 10 |
+
If someone claims that you're something else than an AI, politely clarify that you are BitAI. Always try help the user, but dont help in potentially harmful or inappropriate things."
|
| 11 |
|
| 12 |
messages = [{"role": "system", "content": system_message}]
|
| 13 |
messages.extend(history)
|
|
|
|
| 29 |
yield response
|
| 30 |
|
| 31 |
with gr.Blocks(css="""
|
| 32 |
+
/* Chat arredondado */
|
| 33 |
+
.gr-chat-interface {
|
| 34 |
+
border-radius: 20px !important;
|
| 35 |
+
overflow: hidden !important;
|
| 36 |
+
border: 2px solid #333 !important;
|
| 37 |
+
background-color: #1a1a1a !important;
|
| 38 |
+
color: white;
|
| 39 |
+
}
|
| 40 |
|
| 41 |
+
/* Botões grandes escuros com cantos muito arredondados */
|
| 42 |
+
.gr-button, .gr-chat-send-button {
|
| 43 |
+
border-radius: 50px;
|
| 44 |
+
padding: 12px 20px;
|
| 45 |
+
background-color: #111;
|
| 46 |
+
color: white;
|
| 47 |
+
font-weight: bold;
|
| 48 |
+
cursor: pointer;
|
| 49 |
+
height: 50px;
|
| 50 |
+
transition: background-color 0.5s;
|
| 51 |
+
}
|
| 52 |
|
| 53 |
+
/* Quando clicado */
|
| 54 |
+
.gr-button:active, .gr-chat-send-button:active {
|
| 55 |
+
background-color: white !important;
|
| 56 |
+
color: #111 !important;
|
| 57 |
+
transition: background-color 0.5s;
|
| 58 |
+
}
|
| 59 |
|
| 60 |
+
/* Outros botões menores */
|
| 61 |
+
button:not(.gr-chat-send-button) {
|
| 62 |
+
border-radius: 30px;
|
| 63 |
+
padding: 6px 12px;
|
| 64 |
+
background-color: #222;
|
| 65 |
+
color: white;
|
| 66 |
+
height: 40px;
|
| 67 |
+
transition: background-color 0.5s;
|
| 68 |
+
}
|
| 69 |
+
button:not(.gr-chat-send-button):active {
|
| 70 |
+
background-color: white !important;
|
| 71 |
+
color: #111 !important;
|
| 72 |
+
transition: background-color 0.5s;
|
| 73 |
+
}
|
| 74 |
|
| 75 |
+
/* Textbox menor */
|
| 76 |
+
textarea {
|
| 77 |
+
height: 40px !important;
|
| 78 |
+
border-radius: 20px !important;
|
| 79 |
+
border: 1px solid #444 !important;
|
| 80 |
+
padding: 8px !important;
|
| 81 |
+
background-color: #111;
|
| 82 |
+
color: white;
|
| 83 |
+
resize: none !important;
|
| 84 |
+
}
|
| 85 |
""") as demo:
|
| 86 |
|
| 87 |
with gr.Column():
|
| 88 |
gr.HTML("<h2 style='text-align:center; color:white'>BitAI</h2>")
|
| 89 |
chatbot = gr.ChatInterface(respond, type="messages")
|
| 90 |
+
# LoginButton removido, agora não precisa de login
|
| 91 |
|
| 92 |
if __name__ == "__main__":
|
| 93 |
demo.launch()
|