Salt40404 commited on
Commit
5e71a8a
·
verified ·
1 Parent(s): ece3423

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -14
app.py CHANGED
@@ -5,13 +5,13 @@ from huggingface_hub import InferenceClient
5
  def respond(message, history: list[dict[str, str]], hf_token: gr.OAuthToken):
6
  client = InferenceClient(token=hf_token.token, model="openai/gpt-oss-20b")
7
 
8
- # Descrição melhorada
9
- system_message = """You are BitAI (or simply Bit), a friendly chatbot created by the user "Sal".
10
- - Always answer in a polite and clear way.
11
- - Keep a playful and friendly personality, but never rude.
12
- - Refuse harmful, inappropriate or unsafe requests.
13
- - You are still a work in progress, so if you don’t know something, admit it kindly.
14
- - Never claim to be "Sal". Only identify yourself as BitAI (Bit)."""
15
 
16
  messages = [{"role": "system", "content": system_message}]
17
  messages.extend(history)
@@ -40,7 +40,7 @@ function initTitle() {
40
  titleContainer.innerHTML = `
41
  <div class="title-inner">
42
  <h1 class="chat-title">Talk with BitAI (W.I.P)</h1>
43
- <p class="chat-subtitle">Your friendly AI, still learning — answers might be limited</p>
44
  <button class="close-title-btn">
45
  <svg width="28" height="28" viewBox="0 0 24 24">
46
  <path fill="#fff" d="M12 16l-6-6h12z"/>
@@ -67,19 +67,28 @@ function initTitle() {
67
  }
68
  }
69
 
70
- // esperar carregar
 
 
 
 
 
 
 
 
 
 
 
71
  window.addEventListener("load", () => {
72
  setTimeout(initTitle, 300);
73
 
74
- // deixar botão enviar grande
75
  const observer = new MutationObserver(() => {
76
  const txtArea = document.querySelector("textarea");
77
  const btn = document.querySelector("button.primary");
78
  if(txtArea && btn){
79
- btn.style.height = txtArea.offsetHeight + "px";
80
- btn.style.width = txtArea.offsetHeight + "px";
81
- btn.style.borderRadius = "50%";
82
- btn.style.fontSize = "16px";
83
  observer.disconnect();
84
  }
85
  });
 
5
  def respond(message, history: list[dict[str, str]], hf_token: gr.OAuthToken):
6
  client = InferenceClient(token=hf_token.token, model="openai/gpt-oss-20b")
7
 
8
+ # Prompt melhorado
9
+ system_message = """You are BitAI (Bit), a friendly chatbot created by the user "Sal".
10
+ - Always answer clearly, friendly and playful.
11
+ - Refuse unsafe or harmful requests.
12
+ - If you don’t know something, admit kindly.
13
+ - Never claim to be Sal, only identify as BitAI (Bit).
14
+ """
15
 
16
  messages = [{"role": "system", "content": system_message}]
17
  messages.extend(history)
 
40
  titleContainer.innerHTML = `
41
  <div class="title-inner">
42
  <h1 class="chat-title">Talk with BitAI (W.I.P)</h1>
43
+ <p class="chat-subtitle">Your friendly AI still learning ✨</p>
44
  <button class="close-title-btn">
45
  <svg width="28" height="28" viewBox="0 0 24 24">
46
  <path fill="#fff" d="M12 16l-6-6h12z"/>
 
67
  }
68
  }
69
 
70
+ // deixar botão enviar grande sempre
71
+ function resizeSendBtn() {
72
+ const txtArea = document.querySelector("textarea");
73
+ const btn = document.querySelector("button.primary");
74
+ if(txtArea && btn){
75
+ btn.style.height = txtArea.offsetHeight + "px";
76
+ btn.style.width = txtArea.offsetHeight + "px";
77
+ btn.style.borderRadius = "50%";
78
+ btn.style.fontSize = "16px";
79
+ }
80
+ }
81
+
82
  window.addEventListener("load", () => {
83
  setTimeout(initTitle, 300);
84
 
85
+ // observar textarea
86
  const observer = new MutationObserver(() => {
87
  const txtArea = document.querySelector("textarea");
88
  const btn = document.querySelector("button.primary");
89
  if(txtArea && btn){
90
+ resizeSendBtn();
91
+ new ResizeObserver(resizeSendBtn).observe(txtArea);
 
 
92
  observer.disconnect();
93
  }
94
  });