File size: 408 Bytes
913ffcb 66ddc8e |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
import gradio as gr
from transformers import pipeline
chat = pipeline("text-generation", model="meta-llama/Meta-Llama-3-8B-Instruct", device_map="auto")
def respond(msg, history):
history = history or []
out = chat(history + [msg], max_new_tokens=256)
reply = out[0]["generated_text"]
history.append((msg, reply))
return history, history
iface = gr.ChatInterface(respond)
iface.launch()
|