broadfield commited on
Commit
fd4bcdc
·
verified ·
1 Parent(s): f084bd4

Adding file test: 7b7a1841-f6c5-495e-8d8b-47ac7a9f1c2b

Browse files
Files changed (1) hide show
  1. main_chatbot.py +20 -0
main_chatbot.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+
3
+ # Load a pre-trained conversational model
4
+ chatbot = pipeline('conversational', model='microsoft/DialoGPT-medium')
5
+
6
+ def chat(user_input):
7
+ # Convert user input to the format expected by the chatbot
8
+ # For simplicity, we'll assume the model handles this internally
9
+ response = chatbot(user_input)[0]['generated_text']
10
+ return response
11
+
12
+ if __name__ == '__main__':
13
+ print('Welcome to the Chatbot! Type 'exit' to end the conversation.')
14
+ while True:
15
+ user_input = input('You: ')
16
+ if user_input.lower() == 'exit':
17
+ print('Chatbot: Goodbye!')
18
+ break
19
+ response = chat(user_input)
20
+ print(f'Chatbot: {response}')}