Spaces:
Sleeping
Sleeping
import gradio as gr | |
from transformers import pipeline | |
# โ ุชุญู ูู ู ูุฏูู ู ุฌุงูู ู ู Hugging Face | |
chatbot = pipeline("text-generation", model="mistralai/Mistral-7B-Instruct", device=0 if hasattr(__import__('torch'), 'cuda') and __import__('torch').cuda.is_available() else -1) | |
def respond(message): | |
prompt = f"[INST] {message} [/INST]" | |
result = chatbot(prompt, max_new_tokens=100, do_sample=True, temperature=0.7) | |
reply = result[0]["generated_text"].replace(prompt, "").strip() | |
return reply | |
iface = gr.Interface( | |
fn=respond, | |
inputs=gr.Textbox(lines=1, placeholder="ุงุณุฃู ูููู ุฃู ุณุคุงู!"), | |
outputs=gr.Textbox(label="ุฑุฏ ูููู"), | |
title="ูููู ุดุงุช ุจูุช (ูุณุฎุฉ ู ุฌุงููุฉ)", | |
description="ูููู ุจูุฑุฏ ุนููู ุจุงุณุชุฎุฏุงู ู ูุฏูู ู ุฌุงูู ู ู Hugging Face ๐" | |
) | |
if __name__ == "__main__": | |
iface.launch() | |