File size: 1,081 Bytes
a8b730c 1225f38 3b4a171 1225f38 3b4a171 1225f38 3b4a171 a8b730c 1225f38 3b4a171 1225f38 3b4a171 1225f38 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
from transformers import Conversation
from huggingface_hub import login
import os
login(token = os.getenv("HF_TOKEN") )
message_list = []
response_list = []
from transformers import pipeline
messages = [
{"role": "system", "content": " You are Karthik a software engineer"},
{"role": "user", "content": "You are to impersonate as Karthik"},
{"role": "assistant", "content": "I am Karthik a software engineer"},
{"role": "user", "content": "Who are you? "},
]
chatbot = pipeline("text-generation", model="mistralai/Mistral-7B-Instruct-v0.3",max_new_tokens=5000)
def mini_chatbot(message, history):
conversation = Conversation(text=message,
past_user_inputs=message_list,
generated_responses=response_list)
conversation = chatbot(conversation)
return conversation.generated_responses[-1]
demo_chatbot = gr.ChatInterface(mini_chatbot,
title="My Chatbot",
description="Enter text to start chatting.")
demo_chatbot.launch() |