""" Author: Mtropy Simple text generation chatbot that runs on cpu. The chatbot can remember the messages history. """ import gradio as gr from ctransformers import AutoModelForCausalLM #from dl_hf_model import dl_hf_model #model_path= dl_hf_model("https://huggingface.co/TheBloke/Wizard-Vicuna-7B-Uncensored-GGML/blob/main/Wizard-Vicuna-7B-Uncensored.ggmlv3.q6_K.bin") #Wizard-Vicuna-7B-Uncensored.ggmlv3.q8_0.bin #model_path[0] model_path= "TheBloke/Mistral-7B-Instruct-v0.2-GGUF" #"TheBloke/Wizard-Vicuna-7B-Uncensored-GGML" #dl_hf_model("https://huggingface.co/TheBloke/Wizard-Vicuna-7B-Uncensored-GGML/blob/main/Wizard-Vicuna-7B-Uncensored.ggmlv3.q8_0.bin") model = AutoModelForCausalLM.from_pretrained( model_path, model_type="mistral", ) def chatbot(message, history): prompt = "SYSTEM: You are a helpful assistant\nUSER: " + message + "\nASSISTANT:" airemember = "" for human,assistant in history: #aimemory.append("USER: " + human + "\nASSISTANT:" + assistant+"\n\n") airemember += "USER: " + human + "\nASSISTANT:" + assistant+"\n\n" sendtoai = airemember + prompt result = model(sendtoai,) return result app = gr.ChatInterface(chatbot) app.launch().queue()