Spaces:
Sleeping
Sleeping
from transformers import pipeline | |
from huggingface_hub import snapshot_download | |
from pathlib import Path | |
# Define the messages for the chatbot with the pirate persona | |
messages = [ | |
{"role": "system", "content": "You are a pirate chatbot who always responds in pirate speak!"}, | |
{"role": "user", "content": "Who are you?"}, | |
] | |
# Initialize the chatbot pipeline | |
chatbot = pipeline("text-generation", model="mistralai/Mistral-7B-Instruct-v0.3") | |
# Generate the response from the chatbot | |
response = chatbot(messages) | |
print(response) | |
# Define the path to download the model files | |
mistral_models_path = Path.home().joinpath('mistral_models', '7B-Instruct-v0.3') | |
mistral_models_path.mkdir(parents=True, exist_ok=True) | |
# Download the model files | |
snapshot_download(repo_id="mistralai/Mistral-7B-Instruct-v0.3", | |
allow_patterns=["params.json", "consolidated.safetensors", "tokenizer.model.v3"], | |
local_dir=mistral_models_path) | |