test1 / main_chatbot.py
broadfield's picture
Adding file test: 7b7a1841-f6c5-495e-8d8b-47ac7a9f1c2b
fd4bcdc verified
raw
history blame contribute delete
706 Bytes
from transformers import pipeline
# Load a pre-trained conversational model
chatbot = pipeline('conversational', model='microsoft/DialoGPT-medium')
def chat(user_input):
# Convert user input to the format expected by the chatbot
# For simplicity, we'll assume the model handles this internally
response = chatbot(user_input)[0]['generated_text']
return response
if __name__ == '__main__':
print('Welcome to the Chatbot! Type 'exit' to end the conversation.')
while True:
user_input = input('You: ')
if user_input.lower() == 'exit':
print('Chatbot: Goodbye!')
break
response = chat(user_input)
print(f'Chatbot: {response}')}