Update app.py
Browse files
app.py
CHANGED
|
@@ -3,11 +3,17 @@ import gradio as gr
|
|
| 3 |
from huggingface_hub import InferenceClient
|
| 4 |
|
| 5 |
def respond(message, history: list[dict[str, str]]):
|
| 6 |
-
#
|
| 7 |
client = InferenceClient(token=os.environ["HF_TOKEN"], model="openai/gpt-oss-20b")
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
messages = [{"role": "system", "content": system_message}]
|
| 13 |
messages.extend(history)
|
|
@@ -87,7 +93,7 @@ textarea {
|
|
| 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
|
| 91 |
|
| 92 |
if __name__ == "__main__":
|
| 93 |
demo.launch()
|
|
|
|
| 3 |
from huggingface_hub import InferenceClient
|
| 4 |
|
| 5 |
def respond(message, history: list[dict[str, str]]):
|
| 6 |
+
# token direto do secret HF (não precisa de login)
|
| 7 |
client = InferenceClient(token=os.environ["HF_TOKEN"], model="openai/gpt-oss-20b")
|
| 8 |
|
| 9 |
+
# System prompt melhorada: respostas variadas, educadas e naturais
|
| 10 |
+
system_message = """
|
| 11 |
+
You are BitAI (V1), a friendly and clever chatbot created by the user 'Sal'.
|
| 12 |
+
Always respond in a helpful, natural, and varied way, avoiding repeating the same phrases.
|
| 13 |
+
If a user asks something risky, harmful, or inappropriate, politely refuse.
|
| 14 |
+
Always make your answers clear, concise, and engaging, and adapt your tone to the conversation.
|
| 15 |
+
If someone asks what you are, clarify politely that you are BitAI, an AI chatbot.
|
| 16 |
+
"""
|
| 17 |
|
| 18 |
messages = [{"role": "system", "content": system_message}]
|
| 19 |
messages.extend(history)
|
|
|
|
| 93 |
with gr.Column():
|
| 94 |
gr.HTML("<h2 style='text-align:center; color:white'>BitAI</h2>")
|
| 95 |
chatbot = gr.ChatInterface(respond, type="messages")
|
| 96 |
+
# LoginButton removido
|
| 97 |
|
| 98 |
if __name__ == "__main__":
|
| 99 |
demo.launch()
|