Spaces:
Sleeping
Sleeping
File size: 627 Bytes
1198a45 bdff1e2 b29c9a1 29bf8cc 1198a45 bdff1e2 1198a45 a16c99a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import gradio as gr
from transformers import pipeline
import torch
device = 0 if torch.cuda.is_available() else -1
def generate_response(user_input, history):
pipe = pipeline("text-generation", model="frameai/ChatFrame-Instruct-Persian-Small", device=device)
messages = [
{"role": "user", "content": user_input},
]
response = pipe(messages, max_length=8000)
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()
|