Spaces:
Sleeping
Sleeping
File size: 541 Bytes
816afd2 37641e3 816afd2 5c1cc75 816afd2 37641e3 a760657 37641e3 816afd2 37641e3 816afd2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | import gradio as gr
from transformers import pipeline
# We switched to a 'community' version that doesn't have a locked door
pipe = pipeline("text-generation", model="unsloth/gemma-2-2b-it-bnb-4bit")
def chat_with_ai(prompt):
messages = [{"role": "user", "content": prompt}]
output = pipe(messages, max_new_tokens=150)
return output[0]["generated_text"][-1]["content"]
demo = gr.Interface(
fn=chat_with_ai,
inputs=gr.Textbox(label="Ask Gemma anything!"),
outputs="text",
title="My Gemma Bot"
)
demo.launch() |