MEaCHATBOT1 / app.py
Robadeldesouza's picture
Upload 2 files
2ab9a23 verified
raw
history blame contribute delete
731 Bytes
from ctransformers import AutoModelForCausalLM
import gradio as gr
# Carrega CodeLlama 7B Instruct quantizado (GGUF) direto do Hugging Face
llm = AutoModelForCausalLM.from_pretrained(
"TheBloke/CodeLlama-7B-Instruct-GGUF",
model_file="codellama-7b-instruct.Q4_K_M.gguf", # versão leve
model_type="llama"
)
def chat(message, history):
prompt = f"### Instrução:\n{message}\n### Resposta:\n"
response = llm(prompt, max_new_tokens=512)
return response
# Layout igual ao anterior (estilo chat)
iface = gr.ChatInterface(
fn=chat,
title="MEu ChatBot CodeLlama",
description="Assistente de Programação rodando no Hugging Face Spaces (CodeLlama-7B Instruct).",
theme="soft"
)
iface.launch()