CoolFace
Apppublic

SpawnedShoyo/chat

sourceHugging Faceupdated 3y agoView on Hugging Face
1likes
app.py25 linesDownload Raw Back to root
1import gradio as gr2from transformers import pipeline3from accelerate import Accelerator4 5# Initialize the Accelerator6accelerator = Accelerator()7 8# Load the pipeline with the accelerator9generator = accelerator.prepare(pipeline(task="text-generation", model="mistralai/Mixtral-8x7B-Instruct-v0.1"))10 11def chatbot(input_text):12    context = "You said: " + input_text13    generated_text = generator(context, max_length=20)14    return generated_text[0]["generated_text"]15 16chatbot_app = gr.Interface(17    fn=chatbot,18    inputs=gr.Textbox(lines=2, label="You:"),19    outputs="text",20    title="Chatbot UI",21    theme="huggingface"22)23 24if __name__ == "__main__":25    chatbot_app.launch()