Spaces:
Runtime error
Runtime error
import gradio as gr | |
from transformers import AutoModelForCausalLM, AutoTokenizer | |
import torch | |
import spaces | |
model_name = "MBZUAI-Paris/Atlas-Chat-27B" | |
model = AutoModelForCausalLM.from_pretrained( | |
model_name, | |
load_in_4bit=True, | |
device_map="auto" | |
) | |
tokenizer = AutoTokenizer.from_pretrained(model_name) | |
def chat(input_text, history=[]): | |
# Tokenize the input and generate response | |
inputs = tokenizer(input_text, return_tensors="pt").to(model.device) | |
outputs = model.generate(**inputs, max_new_tokens=150) | |
response = tokenizer.decode(outputs[0], skip_special_tokens=True) | |
# Update the conversation history | |
history.append((input_text, response)) | |
return history, history | |
iface = gr.Interface( | |
fn=chat, | |
inputs=[ | |
gr.inputs.Textbox(label="ุฃุฏุฎู ุฑุณุงูุชู ููุง"), | |
"state" | |
], | |
outputs=[ | |
gr.outputs.Chatbot(label="ุงูู ุญุงุฏุซุฉ"), | |
"state" | |
], | |
live=True, | |
title="ุฏุฑุฏุดุฉ ุฃุทูุณ", | |
description="ุชุทุจูู ุฏุฑุฏุดุฉ ูุนู ู ุจูู ูุฐุฌ ุฃุทูุณ-ุดุงุช ูุชูููุฑ ุชูุงุนู ุฐูู ูุณูุณ", | |
theme="huggingface", | |
examples=[ | |
["ู ุฑุญุจุงู! ููู ูู ูููู ู ุณุงุนุฏุชู ุงูููู ุ"], | |
["ู ุง ูู ุฃุฎุจุงุฑ ุงูุชูููููุฌูุง ุงูุญุฏูุซุฉุ"] | |
] | |
) | |
# Launch the application | |
iface.launch() | |