Spaces:
Runtime error
Runtime error
Download Bot from DoctorErkin/My_Mistral_7B_Bot: direct link, hf CLI and curl.
- Browser
- Download file 636 Bytes
-
https://huggingface.co/spaces/DoctorErkin/My_Mistral_7B_Bot/resolve/main/Bot
- Command line
-
hf download hf://spaces/DoctorErkin/My_Mistral_7B_Bot/Bot
-
curl -L -o Bot https://huggingface.co/spaces/DoctorErkin/My_Mistral_7B_Bot/resolve/main/Bot
636 Bytes
| import gradio as gr | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| MODEL_NAME = "mistralai/Mistral-7B-Instruct-v0.1" | |
| tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME) | |
| model = AutoModelForCausalLM.from_pretrained(MODEL_NAME) | |
| def chat_with_ai(input_text): | |
| inputs = tokenizer(input_text, return_tensors="pt") | |
| outputs = model.generate(**inputs, max_length=512) | |
| return tokenizer.decode(outputs[0], skip_special_tokens=True) | |
| iface = gr.Interface( | |
| fn=chat_with_ai, | |
| inputs="text", | |
| outputs="text", | |
| title="Mistral 7B Chatbot", | |
| description="AI chatbot based on Mistral 7B.", | |
| ) | |
| iface.launch() | |