Spaces:
Sleeping
Sleeping
File size: 939 Bytes
bf465b6 2a95793 bf465b6 2a95793 bf465b6 2a95793 50fd2c2 2a95793 50fd2c2 2a95793 bf465b6 2a95793 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
import gradio as gr
from transformers import pipeline
# Carrega modelo StarCoder otimizado para gera莽茫o de c贸digo
generator = pipeline("text-generation", model="bigcode/starcoder", device=-1)
def chat(message, history):
history = history or []
response = generator(message, max_new_tokens=200, do_sample=True, temperature=0.2)[0]["generated_text"]
# Pega apenas a resposta ap贸s a mensagem do usu谩rio
response = response[len(message):].strip()
history.append((message, response))
return history, history
with gr.Blocks(css="style.css") as demo:
gr.Markdown("# 馃挰 StarCoder Chat
Escreva c贸digo, fa莽a perguntas e receba respostas em **Markdown**.")
chatbot = gr.Chatbot(elem_id="chatbot")
msg = gr.Textbox(placeholder="Digite sua mensagem...")
clear = gr.Button("Limpar")
msg.submit(chat, [msg, chatbot], [chatbot, chatbot])
clear.click(lambda: None, None, chatbot)
demo.launch() |