File size: 725 Bytes
224cd33
953cb80
4372d3f
f68bac7
 
4372d3f
953cb80
4372d3f
953cb80
 
4372d3f
953cb80
 
 
 
 
 
4372d3f
953cb80
 
 
4372d3f
953cb80
4372d3f
953cb80
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

from transformers import pipeline, Conversation
import gradio as gr
huggingface-cli login 


chatbot = pipeline(model="ContactDoctor/Bio-Medical-Llama-3-8B", task="conversational")

message_list = []
response_list = []

def Medical_Bot(message, history):
    global message_list, response_list
    message_list.append(message)
    conversation = Conversation(text=message, past_user_inputs=message_list[:-1], generated_responses=response_list)
    
    conversation = chatbot(conversation)

    reply = conversation.generated_responses[-1]
    response_list.append(reply)
    return reply

demo_chatbot = gr.ChatInterface(Medical_Bot, title="Medical Bot", description="Enter text to start chatting.")

demo_chatbot.launch()