File size: 662 Bytes
195fac6 f4224c3 916592f c7bf96d f4224c3 916592f 62f729b a5b3bdc c89af47 195fac6 f0a68fe c7bf96d 195fac6 f5c871b c7bf96d 1ff540d 195fac6 f5c871b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import gradio as gr
from transformers import pipeline
import torch
import spaces
device = 0 if torch.cuda.is_available() else -1
@spaces.GPU
def generate_response(user_input, history):
pipe = pipeline("text-generation", model="explorewithai/ChatFrame-Uncensored-Instruct-Small", device = device)
messages = [
{"role": "user", "content": user_input},
]
response = pipe(messages, max_length=512)
return response[0]['generated_text'][1]["content"]
iface = gr.ChatInterface(
fn=generate_response,
title="Text Generation Chatbot",
description="Enter your text and get a generated response from the model."
)
iface.launch()
|