Salt40404 commited on
Commit
c3a9a59
·
verified ·
1 Parent(s): 834c421

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +56 -53
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]], hf_token: gr.OAuthToken):
5
- client = InferenceClient(token=hf_token.token, model="openai/gpt-oss-20b")
 
 
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
- /* Chat arredondado */
30
- .gr-chat-interface {
31
- border-radius: 20px !important;
32
- overflow: hidden !important;
33
- border: 2px solid #333 !important;
34
- background-color: #1a1a1a !important;
35
- color: white;
36
- }
37
 
38
- /* Botões grandes escuros com cantos muito arredondados */
39
- .gr-button, .gr-chat-send-button {
40
- border-radius: 50px;
41
- padding: 12px 20px;
42
- background-color: #111;
43
- color: white;
44
- font-weight: bold;
45
- cursor: pointer;
46
- height: 50px;
47
- transition: background-color 0.5s; /* transição suave de volta */
48
- }
49
 
50
- /* Quando clicado */
51
- .gr-button:active, .gr-chat-send-button:active {
52
- background-color: white !important; /* branco instantâneo */
53
- color: #111 !important;
54
- transition: background-color 0.5s; /* volta suave */
55
- }
56
 
57
- /* Outros botões menores */
58
- button:not(.gr-chat-send-button) {
59
- border-radius: 30px;
60
- padding: 6px 12px;
61
- background-color: #222;
62
- color: white;
63
- height: 40px;
64
- transition: background-color 0.5s;
65
- }
66
- button:not(.gr-chat-send-button):active {
67
- background-color: white !important;
68
- color: #111 !important;
69
- transition: background-color 0.5s;
70
- }
71
 
72
- /* Textbox menor */
73
- textarea {
74
- height: 40px !important;
75
- border-radius: 20px !important;
76
- border: 1px solid #444 !important;
77
- padding: 8px !important;
78
- background-color: #111;
79
- color: white;
80
- resize: none !important;
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
- gr.LoginButton()
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()