mkoot007 commited on
Commit
5baecf1
·
1 Parent(s): d1ce0d7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -4,10 +4,17 @@ from transformers import pipeline
4
  # Load the conversational pipeline with the "facebook/blenderbot-400M-distill" model
5
  pipe = pipeline("conversational", model="facebook/blenderbot-400M-distill")
6
 
7
- def chat_with_model(conversation):
8
- conversation = [{"role": "system", "content": "You are a helpful assistant."}]
 
 
 
9
  response = pipe(conversation)
10
- return response[0]['message']['content']
 
 
 
 
11
 
12
  iface = gr.Interface(
13
  fn=chat_with_model,
 
4
  # Load the conversational pipeline with the "facebook/blenderbot-400M-distill" model
5
  pipe = pipeline("conversational", model="facebook/blenderbot-400M-distill")
6
 
7
+ def chat_with_model(input_text):
8
+ # Start a new conversation with the user's input
9
+ conversation = [{"role": "user", "content": input_text}]
10
+
11
+ # Generate a response from the model
12
  response = pipe(conversation)
13
+
14
+ # Extract the assistant's reply
15
+ reply = response[0]['message']['content']
16
+
17
+ return reply
18
 
19
  iface = gr.Interface(
20
  fn=chat_with_model,