Spaces:
Sleeping
Sleeping
File size: 904 Bytes
47e6e94 30caa71 79b8b80 30caa71 b5ac77b 5038547 30caa71 47e6e94 79b8b80 b5ac77b 79b8b80 30caa71 79b8b80 d743ebd 79b8b80 |
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
# โ
ุชุญู
ูู ู
ูุฏูู ู
ุฌุงูู ู
ู 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()
|