File size: 981 Bytes
3b4a171
 
1225f38
 
 
3b4a171
1225f38
 
 
 
 
3b4a171
1225f38
3b4a171
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
import gradio as gr

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()