Salt40404 commited on
Commit
cf8f347
·
verified ·
1 Parent(s): ac45bcc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -11
app.py CHANGED
@@ -1,6 +1,5 @@
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
- import time
4
 
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")
@@ -19,20 +18,20 @@ Keep a simple, approachable, and friendly tone."""
19
  if chunk.choices and chunk.choices[0].delta.content:
20
  token = chunk.choices[0].delta.content
21
  response += token
22
-
23
- # Yield por partes para dar efeito de digitação
24
- for i in range(len(response)):
25
- yield response[:i+1]
26
- time.sleep(0.01) # velocidade do "typing"
27
 
28
  chatbot = gr.ChatInterface(respond, type="messages")
29
 
30
  with gr.Blocks(css="""
31
- body{background-color:#000;font-family:'Arial',sans-serif;}
32
- .gradio-container{border-radius:20px;padding:15px;max-width:700px;margin:20px auto;background-color:#fff;}
33
- .chat-message{border-radius:15px;padding:10px 15px;margin:5px 0; display:flex; flex-direction:column;}
34
- .chat-message.user{background-color:#dceefc; align-items:flex-end;}
35
- .chat-message.bot{background-color:#f0f0f0; align-items:flex-start;}
 
 
 
 
36
  """) as demo:
37
  with gr.Sidebar():
38
  gr.LoginButton()
 
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")
 
18
  if chunk.choices and chunk.choices[0].delta.content:
19
  token = chunk.choices[0].delta.content
20
  response += token
21
+ yield response
 
 
 
 
22
 
23
  chatbot = gr.ChatInterface(respond, type="messages")
24
 
25
  with gr.Blocks(css="""
26
+ body {background-color:#000; font-family:'Arial',sans-serif;}
27
+ .gradio-container {border-radius:20px; padding:15px; max-width:700px; margin:20px auto; background-color:#fff;}
28
+ .chat-message {border-radius:15px; padding:10px 15px; margin:5px 0; display:flex; flex-direction:column; opacity:0; animation: fadein 0.5s forwards;}
29
+ .chat-message.user {background-color:#dceefc; align-items:flex-end;}
30
+ .chat-message.bot {background-color:#f0f0f0; align-items:flex-start;}
31
+ @keyframes fadein {
32
+ from {opacity:0;}
33
+ to {opacity:1;}
34
+ }
35
  """) as demo:
36
  with gr.Sidebar():
37
  gr.LoginButton()